diff --git a/types.ts b/types.ts index 62113472..303de828 100644 --- a/types.ts +++ b/types.ts @@ -59,6 +59,31 @@ export interface RequiredSiteConfig { export type LocalizedMessages = Record>; export type SiteMessages = LocalizedMessages[]; +// Generic logger contract +export interface LoggingService { + debug?(message: string, meta?: Record): void, + info?(message: string, meta?: Record): void, + warn?(message: string, meta?: Record): void, + error?(message: string | Error, meta?: Record): void, +} + +// Generic analytics contract +export interface AnalyticsService { + identify?(userId: string | number, traits?: Record): void, + track(event: string, properties?: Record): void, + page?(name?: string, properties?: Record): void, + reset?(): void, +} + +// Generic auth contract +export interface AuthService { + isAuthenticated(): boolean | Promise, + getAccessToken?(): string | null | Promise, + login?(redirectUrl?: string): void | Promise, + logout?(redirectUrl?: string): void | Promise, + getCurrentUser?(): User | null | Promise, +} + export interface OptionalSiteConfig { // Site environment environment: EnvironmentTypes, @@ -92,6 +117,11 @@ export interface OptionalSiteConfig { // Analytics segmentKey: string | null, + + // Services + loggingService: LoggingService, + analyticsService: AnalyticsService, + authService: AuthService, } export type SiteConfig = RequiredSiteConfig & Partial;