Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
import type { ApiClient } from '../client';
export interface Credentials {
username: string;
password: string;
}
export async function login(api: ApiClient, { username, password }: Credentials) {
const response = await api.post('/api/auth/login', { username, password });
if (response.status !== 200 || !response.body?.token) {
throw new Error(`Login failed for ${username} (${response.status}): ${response.text}`);
}
return response.body.token as string;
}