🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Better typing
Edward Cui1f10230ac14c
diff --git a/server/src/types/import.ts b/server/src/types/import.tsindex 020b60683..babc79e91 100644--- a/server/src/types/import.ts+++ b/server/src/types/import.ts@@ -9,6 +9,36 @@ export interface ImportInitiationJob {source: "umami";}-export interface ImportMapping {- transform(row: any, headers: string[]): any;+export interface ImportMapping<T> {+ transform(row: T, headers: string[]): RybbitEvent;+}++interface RybbitEvent {+ site_id: number; // UInt16+ timestamp: string; // ISO 8601 format (DateTime)+ session_id: string;+ user_id: string;+ hostname: string;+ pathname: string;+ querystring: string; // Raw URL parameters+ url_parameters: Record<string, string>; // Map(String, String)+ page_title: string;+ referrer: string;+ channel: string;+ browser: string;+ browser_version: string;+ operating_system: string;+ operating_system_version: string;+ language: string;+ country: string; // ISO 3166-1 alpha-2 (FixedString(2))+ region: string;+ city: string;+ lat: number;+ lon: number;+ screen_width: number; // UInt16+ screen_height: number; // UInt16+ device_type: string;+ type: string; // Defaults to 'pageview'+ event_name: string;+ props: Record<string, unknown>; // JSON}diff --git a/server/src/workers/mappings/umami.ts b/server/src/workers/mappings/umami.tsindex e38703214..d55d4a0c9 100644--- a/server/src/workers/mappings/umami.ts+++ b/server/src/workers/mappings/umami.ts@@ -43,7 +43,7 @@ interface UmamiEvent {job_id: string | null; // Ignore}-export class UmamiImportMapping implements ImportMapping {+export class UmamiImportMapping implements ImportMapping<UmamiEvent> {transform(row: UmamiEvent, headers: string[]): any {const [screenWidth, screenHeight] = row.screen?.split("x") || [null, null];