import type { Analytics, AnalyticsSettings, InitOptions } from '.' import type { Plugin } from '../plugin' import type { EventParams, DispatchedEvent, PageParams, IdentifyParams, AliasParams, GroupParams, } from '../arguments-resolver' import type { Context } from '../context' import type { CustomerioEvent } from '../events' import type { Group, User } from '../user' import type { LegacyIntegration } from '../../plugins/ajs-destination/types' import type { InboxAPI } from '../../plugins/in-app-plugin' import { CoreAnalytics } from '@customerio/cdp-analytics-core' // we can define a contract because: // - it gives us a neat place to put all our typedocs (they end up being inherited by the class that implements them). // - it makes it easy to reason about what's being shared between browser and node /** * All of these methods are a no-op. */ /** @deprecated */ interface AnalyticsClassicStubs { /** @deprecated */ log(this: never): void /** @deprecated */ addIntegrationMiddleware(this: never): void /** @deprecated */ listeners(this: never): void /** @deprecated */ addEventListener(this: never): void /** @deprecated */ removeAllListeners(this: never): void /** @deprecated */ removeListener(this: never): void /** @deprecated */ removeEventListener(this: never): void /** @deprecated */ hasListeners(this: never): void /** @deprecated */ // This function is only used to add GA and Appcue, but these are already being added to Integrations by AJSN addIntegration(this: never): void /** @deprecated */ add(this: never): void } /** @deprecated */ export interface AnalyticsClassic extends AnalyticsClassicStubs { /** @deprecated */ initialize( settings?: AnalyticsSettings, options?: InitOptions ): Promise /** @deprecated */ noConflict(): Analytics /** @deprecated */ normalize(msg: CustomerioEvent): CustomerioEvent /** @deprecated */ readonly failedInitializations: string[] /** @deprecated */ pageview(url: string): Promise /** @deprecated*/ readonly plugins: any /** @deprecated */ readonly Integrations: Record } /** * Interface implemented by concrete Analytics class (commonly accessible if you use "await" on AnalyticsBrowser.load()) */ export interface AnalyticsCore extends CoreAnalytics { track(...args: EventParams): Promise page(...args: PageParams): Promise identify(...args: IdentifyParams): Promise group(): Group group(...args: GroupParams): Promise alias(...args: AliasParams): Promise screen(...args: PageParams): Promise register(...plugins: Plugin[]): Promise deregister(...plugins: string[]): Promise user(): User readonly VERSION: string /** * Access inbox functionality provided by the Customer.io In-App Plugin. * Only available when the In-App Plugin is loaded. * @param topics - Optional topics to filter inbox messages * @returns InboxAPI interface for managing inbox messages */ inbox?(...topics: string[]): InboxAPI } /** * Interface implemented by AnalyticsBrowser (buffered version of analytics) (commonly accessible through AnalyticsBrowser.load()) */ export type AnalyticsBrowserCore = Omit & { group(): Promise group(...args: GroupParams): Promise user(): Promise }