export interface DeviceInfo { browser?: string; browserVersion?: string; os: string; language: string; timezone: string; resolution?: string; model?: string; userAgent?: string; } export type DevicePropertyKey = keyof DeviceInfo; export interface NetworkManager { postRequest(url: string, data: Partial>, headers?: Headers | [string, string][]): Promise>>; } export interface PushManager { isPushBlocked(): boolean | undefined; isPushPermissionGranted(): boolean | undefined; isPushSupported(): boolean | undefined; registerPush(successCallback?: (endpoint: string, publicKey: string, userAuth: string) => void, deniedCallback?: (temporaryDenial: boolean) => void): void; unregisterPush(successCallback?: () => void, errorCallback?: () => void): void; } export type InitializationOptions = { /** * The SDK version of the consuming SDK */ sdkVersion: string; /** * If you provide a value for this option, user events sent to Braze will be associated with the given version, which can be * used for user segmentation. */ appVersion?: string; /** * A numerical app version value which can be used for user segmentation. This value must be sent with four fields, such as * "1.2.3.4", otherwise it will be ignored. * * Note: `appVersion` must also be set, either with the same value or a unique name for this version. */ appVersionNumber?: string; /** * By default, Braze will assign a random guid as the device ID. Provide a value for this configuration option to override that * default with a value of your own. */ deviceId?: string; /** * By default, the Braze SDK automatically detects and collects all device properties in [[`DeviceInfo`]]. To override * this behavior, provide an array of [[`DevicePropertyKey`]]. To disable all properties being sent to Braze servers, provide * an empty array. Note that without some properties, not all features will function properly. For instance, without the time * zone, local timezone delivery will not function. */ devicePropertyAllowlist?: DevicePropertyKey[]; /** * By default, the Braze SDK will flush data in the cache every 10 seconds. Providing this option will override the interval. * The minimum flush interval is 3 seconds. */ flushIntervalInSeconds?: number; /** * Set to true to enable logging by default. Note that this will cause Braze to log to the javascript console, which is visible * to all users! You should probably remove this or provide an alternate logger with [[`setLogger`]] before you release * your page to production. */ enableLogging?: boolean; /** * By default, sessions time out after 30 minutes of inactivity. Provide a value for this configuration option to override that * default with a value of your own. */ sessionTimeoutInSeconds?: number; /** * By default, a trigger action will only fire if at least 30 seconds have elapsed since the last trigger action. Provide a * value for this configuration option to override that default with a value of your own. We do not recommend making this * value any smaller than 10 to avoid spamming the user with notifications. */ minimumIntervalBetweenTriggerActionsInSeconds?: number; /** * A function called when handling links within in-app messages. * @param uri - The URI to open * @param openLinkInNewTab - Whether the link should be opened in a new tab * @param event - The event that triggered the redirect */ openUriCallback?: (uri: string, openLinkInNewTab: boolean, event: Event | undefined) => void; /** * Set to true to enable the SDK Authentication feature. For more information about SDK Authentication, see our * [Product Documentation](https://www.braze.com/docs/developer_guide/platform_wide/sdk_authentication/). */ enableSdkAuthentication?: boolean; }; export type SdkMetadata = string[]; export interface StorageManager { store(key: string, value: string, isId?: boolean): Promise; remove(key: string, isId?: boolean): Promise; retrieve(key: string, isId?: boolean): Promise; clearData(storageKeys: string[]): Promise; } export interface InitializeProps { apiKey: string; baseUrl: string; options: InitializationOptions; sdkMetadata: SdkMetadata; deviceInfo: DeviceInfo; storageManager: StorageManager; networkManager?: NetworkManager; pushManager?: PushManager; }