UNPKG

@swrve/smarttv-sdk

Version:

Swrve marketing engagement platform SDK for SmartTV OTT devices

72 lines (65 loc) 2.7 kB
import {ISwrveInternalConfig, SwrveStack} from "./ISwrveInternalConfig"; import { ISwrveEmbeddedMessage } from "../Campaigns/ISwrveCampaign"; import IDictionary from "../utils/IDictionary"; import { IPlatform, IPlatformName } from "../utils/platforms/IPlatform"; import { IKeyMapping } from "../utils/platforms/IKeymapping"; export declare type OnEmbeddedMessageListener = (msg: ISwrveEmbeddedMessage, personalizationProperties?: IDictionary<string>) => void; export declare type OnPersonalizationProvider = (eventPayload: IDictionary<string>) => IDictionary<string>; export declare type OnUserDisabledListener = (swrveUserId: string, externalId: string) => void; export default interface ISwrveConfig { appId: number; apiKey: string; appVersion?: string; stack?: SwrveStack; newSessionInterval?: number; httpsTimeoutSeconds?: number; language?: string; contentUrl?: string; apiUrl?: string; identityUrl?: string; abTestDetailsEnabled?: boolean; autoShowMessagesMaxDelay?: number; inAppMessageButtonStyle?: ICSSStyle | string; inAppMessageButtonFocusStyle?: ICSSStyle | string; inAppMessageStyleOverride?: string; managedMode?: boolean; autoStartLastUser?: boolean; embeddedMessageConfig?: ISwrveEmbeddedMessageConfig; personalizationProvider?: OnPersonalizationProvider; //userDisabledListener?: OnUserDisabledListener; customKeyMappingTizen?: IKeyMapping; customKeyMappingWebOS?: IKeyMapping; customKeyMappingBase?: IKeyMapping; customPlatform?: IPlatform; customOSVersion?: string; customOS?: string; customDeviceName?: IPlatformName; customAppStore?: string; } export interface ICSSStyle { [key: string]: string; } export function configWithDefaults(config: ISwrveConfig, lastUserId: string): ISwrveInternalConfig { return Object.freeze<ISwrveInternalConfig>({ ...config, stack: config.stack || "us", httpsTimeoutSeconds: config.httpsTimeoutSeconds == null ? 60 : config.httpsTimeoutSeconds, userId: lastUserId, language: config.language || "English", autoShowMessagesMaxDelay: config.autoShowMessagesMaxDelay == null ? 5000 : config.autoShowMessagesMaxDelay, newSessionInterval: config.newSessionInterval == null ? 1800 /** 30 minutes in seconds */ : config.newSessionInterval, autoStartLastUser: config.autoStartLastUser == null ? true : config.autoStartLastUser, }); } export interface IPreviousConfig { userId?: string; } export interface ISwrveEmbeddedMessageConfig { embeddedCallback?: OnEmbeddedMessageListener; }