Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtime/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export {
} from './interface';
export { default as MockAnalyticsService } from './MockAnalyticsService';
export { default as SegmentAnalyticsService } from './SegmentAnalyticsService';
export type * from './types';
7 changes: 7 additions & 0 deletions runtime/analytics/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface AnalyticsService {
sendTrackingLogEvent(eventName: string, properties: object): Promise<unknown>,
identifyAuthenticatedUser(userId: string | number, traits?: Record<string, unknown>): void,
identifyAnonymousUser(traits?: Record<string, unknown>): void,
sendTrackEvent(eventName?: string, properties?: Record<string, unknown>): void,
sendPageEvent(category: string, name: string, properties?: Record<string, unknown>): void,
}
1 change: 1 addition & 0 deletions runtime/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export {
setAuthenticatedUser
} from './interface';
export { default as MockAuthService } from './MockAuthService';
export type * from './types';
15 changes: 15 additions & 0 deletions runtime/auth/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { User } from '../../types';

export interface AuthService {
getAuthenticatedHttpClient(options?: Record<string, unknown>): unknown,
getHttpClient(options?: Record<string, unknown>): unknown,
getLoginRedirectUrl(redirectUrl?: string): string,
redirectToLogin(redirectUrl?: string): void,
getLogoutRedirectUrl(redirectUrl?: string): string,
redirectToLogout(redirectUrl?: string): void,
getAuthenticatedUser(): User | null,
setAuthenticatedUser(authUser: User): void,
fetchAuthenticatedUser(options?: Record<string, unknown>): Promise<User | null>,
ensureAuthenticatedUser(redirectUrl?: string): Promise<User>,
hydrateAuthenticatedUser(): Promise<void>,
}
1 change: 1 addition & 0 deletions runtime/logging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export {
} from './interface';
export { default as MockLoggingService } from './MockLoggingService';
export { default as NewRelicLoggingService } from './NewRelicLoggingService';
export type * from './types';
28 changes: 26 additions & 2 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { FC, ReactElement, ReactNode } from 'react';
import { MessageDescriptor } from 'react-intl';
import { RouteObject } from 'react-router';
import { SlotOperation } from './runtime/slots/types';
import { LoggingService } from './runtime/logging';
import { AnalyticsService } from './runtime/analytics';
import { AuthService } from './runtime/auth';

// Apps

Expand Down Expand Up @@ -60,6 +63,22 @@ export interface RequiredSiteConfig {
export type LocalizedMessages = Record<string, Record<string, string>>;
export type SiteMessages = LocalizedMessages[];

export type LoggingServiceClass = new (options: {
config: SiteConfig,
}) => LoggingService;

export type AnalyticsServiceClass = new (options: {
config: SiteConfig,
loggingService: LoggingService,
httpClient: unknown,
}) => AnalyticsService;

export type AuthServiceClass = new (options: {
config: SiteConfig,
loggingService: LoggingService,
middleware: unknown[],
}) => AuthService;

export interface OptionalSiteConfig {
// Site environment
environment: EnvironmentTypes;
Expand Down Expand Up @@ -96,7 +115,12 @@ export interface OptionalSiteConfig {
ignoredErrorRegex: RegExp | null;

// Analytics
segmentKey: string | null;
segmentKey: string | null,

// Services
loggingService: LoggingServiceClass,
analyticsService: AnalyticsServiceClass,
authService: AuthServiceClass,
}

export type SiteConfig = RequiredSiteConfig & Partial<OptionalSiteConfig>;
Expand Down Expand Up @@ -125,7 +149,7 @@ export interface User {
roles: string[];
userId: number;
username: string;
avatar: string;
avatar?: string;
}

export enum EnvironmentTypes {
Expand Down