@causalfoundry/js-sdk
Version:
Causal Foundry WEB SDK (JS/TS)
246 lines (218 loc) • 5.22 kB
text/typescript
import {
CancelCheckoutProperties,
CartProperties,
CheckoutProperties,
DeliveryProperties,
ECommerceTypes,
ItemProperties, ItemReportProperties, ItemRequestProperties, ItemVerificationProperties
} from "../modules/ECommerce/typings";
import {
LoyaltyTypes,
LevelProperties,
MilestoneProperties, PromoProperties, RewardProperties, SurveyProperties,
} from "../modules/Loyalty/typings"
import {
ELearningTypes,
ModuleProperties,
QuestionProperties,
ExamProperties
} from "../modules/ELearning/typings";
import {
BreakProperties,
ContactProperties,
CallCenterEventType, OpsScorecardProperties,
} from "../modules/CallCenter/typings";
import {
AmbulanceProperties,
EmergencyMgmtEventType,
IncidentProperties,
} from "../modules/EmergencyMgmt/typings";
import {
AppProperties,
ContentBlock,
IdentifyProperties,
MediaProperties,
NavigationTypes,
PageProperties, ModuleSelectionProperties,
NudgeResponseProperties,
SearchProperties, RateProperties
} from "../modules/Navigation/typings";
import {
DeferredPaymentProperties, PaymentMethodProperties,
PaymentsTypes,
} from "../modules/Payments/typings";
import {
InteractProperties,
InteractTypes,
ReferenceGuideTypes
} from "../modules/ReferenceGuide/typings";
import {
PatientMgmtEventType,
PatientProperties,
EncounterProperties,
AppointmentProperties,
PatientMgmtCatalogType
} from "../modules/PatientMgmt/typings";
export enum GlobalTypes {
NavigationTypes,
ECommerceTypes
}
export interface CfBrowserOptions {
logScroll: boolean;
logPage: boolean;
logUrlChanges: boolean;
flushOnLeave: boolean;
}
export interface LogIngestorOptions {
flushInterval: number;
flushMaxRetries: number;
ingestPath: string;
cacheEventsInLocalstorage: boolean;
cacheEventsKey: string;
}
export interface CfLogOptions {
cdnUrl: string;
baseUrl: string;
nudgeFetchPath: string;
allowAnonymousUsers: boolean;
catalogPath: string;
activateNudgeMechanism: boolean;
selfManagedNudges: boolean;
defaultBlock: ContentBlock;
debug: boolean;
skipDynamicLoading?: boolean;
isUsingAsInternalWrapper: boolean;
pauseSDK: boolean;
}
export interface BatteryStatus {
charging: boolean;
chargingTime: number;
dischargingTime: number;
level: number;
}
export interface EventContext {
browser?: {
user_agent: string;
languages: string[];
online: boolean;
battery?: BatteryStatus
}
}
export type AnyKnownType =
| NavigationTypes
| ECommerceTypes
| ELearningTypes
| ReferenceGuideTypes
| PaymentsTypes
| LoyaltyTypes
| CallCenterEventType
| EmergencyMgmtEventType
| PatientMgmtEventType
| PatientMgmtCatalogType
export type EventTeaser =
{
name?: string;
type: NavigationTypes;
props: ModuleSelectionProperties | PageProperties |
AppProperties |
IdentifyProperties |
MediaProperties | RateProperties | SearchProperties |
NudgeResponseProperties
} | {
name?: string;
type: ECommerceTypes;
props: CartProperties |
DeliveryProperties | ItemReportProperties | ItemRequestProperties | ItemVerificationProperties |
CheckoutProperties | CancelCheckoutProperties |
ItemProperties
} | {
name?: string;
type: ELearningTypes;
props: ExamProperties | ModuleProperties | QuestionProperties
} | {
name?: string;
type: ReferenceGuideTypes,
props: InteractProperties
} | {
name?: string;
type: PaymentsTypes,
props:
DeferredPaymentProperties | PaymentMethodProperties
} | {
name?: string;
type: LoyaltyTypes,
props:
LevelProperties | MilestoneProperties | PromoProperties | RewardProperties | SurveyProperties
} | {
name?: string;
type: CallCenterEventType,
props:
BreakProperties | ContactProperties | OpsScorecardProperties
} | {
name?: string;
type: EmergencyMgmtEventType,
props:
IncidentProperties | AmbulanceProperties
} | {
name?: string
type: PatientMgmtEventType
props: PatientProperties | EncounterProperties | AppointmentProperties
}
export type EventCommon = {
block: ContentBlock,
ol: boolean,
ts: string
}
export type Event = EventTeaser & EventCommon
export type DeviceInfoObject = {
id: string,
brand: string,
model: string,
os: string,
os_ver: string,
}
export type AppInfoObject = {
id: string,
min_sdk_version: number,
target_sdk_version: number,
version_code: number,
version_name: string,
version: string,
}
export type EventMainObject = {
s_id: string,
u_id: string,
app_info: AppInfoObject,
d_info: DeviceInfoObject,
sdk: string,
up?: number,
dn?: number,
data?: Event[],
}
export interface QueueItem {
uuid: string;
event: Event;
time: number;
retries: number;
lastRetry?: number;
}
export interface TypedRows {
header: string[]
data_type: string[]
rows: any[][]
}
export interface ExceptionObject {
title: string
event_type: string
exception_type: string
exception_source: string
stack_trace: string
ts: string
}
export interface MainExceptionBody {
u_id: string
d_info: DeviceInfoObject
app_info: AppInfoObject
sdk_version: string
data: ExceptionObject[]
}