UNPKG

ngx-pendo

Version:

A simple wrapper to load Pendo by angular way

239 lines (228 loc) 9.17 kB
import * as _angular_core from '@angular/core'; import { InputSignal, WritableSignal, Provider, ModuleWithProviders, InjectionToken } from '@angular/core'; interface IPendoSettings { pendoApiKey: string; pendoScriptOrigin?: string; pendoIdFormatter?: (pendoId: string) => string; pendoInitializerProvider?: Provider; } interface IPendoDirective { inherit: InputSignal<boolean>; parent: WritableSignal<IPendoDirective | undefined>; } interface IVisitor { id: string; [key: string]: string; } interface IAccount { id: string; [key: string]: string; } interface IPendoIdentity { visitor?: IVisitor; account?: IAccount; } interface IPendoOptions extends IPendoIdentity { additionalApiKeys?: string[]; annotateUrl?: Function; apiKey?: string; appAutoOrdering?: string[]; autoFrameInstall?: boolean; contentHost?: string; cookieDomain?: string; dataHost?: string; disableCookies?: boolean; disableFeedback?: boolean; disablePendo?: boolean; disablePersistence?: boolean; frameIdentitySync?: boolean; ignoreHashRouting?: boolean; initializeImmediately?: boolean; observeShadowRoots?: boolean; leaderKey?: string[]; localStorageOnly?: boolean; preferBroadcastChannel?: boolean; preferMutationObserver?: boolean; preventUnloadListener?: boolean; queryStringWhitelist?: string[] | Function; sanitizeUrl?: Function; selfHostedAgentUrl?: string; sendEventsWithPostOnly?: boolean; allowedText?: string[]; analytics?: { excludeEvents?: string[]; }; enableDebugEvents?: boolean; eventPropertyMatchParents?: boolean; excludeAllText?: boolean; excludeNonGuideAnalytics?: boolean; syntheticClicks?: { elementRemoval?: boolean; targetChanged?: boolean; }; disableGlobalCSS?: boolean; disableGuidePseudoStyles?: boolean; disablePrefetch?: boolean; enableDesignerKeyboardShortcut?: boolean; enableGuideTimeout?: boolean; guideSeenTimeoutLength?: number; guideValidation?: boolean; guides?: { attachPoint?: string | Function; delay?: boolean; disabled?: boolean; globalScripts?: any[]; timeout?: number; tooltip?: { arrowSize?: number; }; }; preventCodeInjection?: boolean; } interface IPendo { additionalApiKeys: string[]; apiKey: string; getVersion(): string; initialize(options: IPendoOptions): void; isReady(): boolean; teardown(): void; hideLauncher(): void; removeLauncher(): void; showLauncher(): void; toggleLauncher(): void; addDebuggingFunctions(): void; disableDebugging(): void; disableLogging(): void; enableDebugging(): void; enableLogging(): void; isDebuggingEnabled(): void; logPublic(): void; dom(input: string): HTMLElement; attachEvent(element: HTMLElement, evt: string, fn: (event: Event) => void, useCapture?: boolean): void; detachEvent(element: HTMLElement, evt: string, fn: (event: Event) => void, useCapture?: boolean): void; doNotProcess: string; flushNow(force?: boolean): void; isSendingEvents(): boolean; startSendingEvents(): boolean; stopSendingEvents(): boolean; stopSendingEvents(): boolean; track(trackType: string, metadata?: any): void; clearSession(): void; generate_unique_id(prefix?: string): string; getAccountId(): string | null; get_account_id(): string | null; getSerializedMetadata(): any; getVisitorId(): string; get_visitor_id(): string; identify(options: IPendoIdentity | string, accountId?: string): void; isAnonymousVisitor(visitorId?: string): boolean; set_account_id(newAccountId?: string): void; set_visitor_id(newVisitorId?: string): void; updateOptions(options: IPendoOptions): void; url: { get: () => string; }; normalizedUrl: string; getCurrentUrl: () => string; getNormalizedUrl: () => string; pageLoad: (url: string) => void; } declare class NgxPendoService { private pendo; private pendoIdFormatter; /** * Completely re-initialize the Agent with new options * * @param optionsOrVisitor IPendoOptions | IVisitor * @param account IAccount */ initialize(options: IPendoOptions): void; initialize(visitor: IVisitor, account?: IAccount): void; /** * Send an identify event and a meta event. * * @param visitor IVisitor | string * @param account IAccount | string */ identify(visitor: string, account?: string): void; identify(visitor: IVisitor, account?: IAccount): void; /** * Updates metadata object for the Pendo agent. * * @param options IPendoOptions */ updateOptions(options: IPendoOptions): void; /** * Format Pendo * * @param ids string[] */ formatPendoId(...ids: string[]): string; /** * Shuts down the agent and cleans up all timers and listeners. */ teardown(): void; /** * Checks if a given visitor id string is anonymous. * If no argument is given, calls with pendo.getVisitorId() to check current visitor status. */ isAnonymousVisitor(visitorId?: string): boolean; /** * Removes current visitor id and account id. * Triggers an identify event and reloads with a new anonymous visitor. */ clearSession(): void; /** * Loads Pendo Debugger and extends the global pendo object with additional functionality for debugging purposes. */ enableDebugging(): void; /** * Removes Pendo Debugger extension. */ disableDebugging(): void; /** * Method to manually track events. Requires a non-empty name string to collect event. */ track(trackType: string, metadata?: Record<string, string | number | boolean | string[] | null>): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxPendoService, never>; static ɵprov: _angular_core.ɵɵInjectableDeclaration<NgxPendoService>; } declare class NgxPendoSectionDirective implements IPendoDirective { pendoSection: _angular_core.InputSignal<string>; inherit: _angular_core.InputSignal<boolean>; parent: _angular_core.WritableSignal<NgxPendoSectionDirective | undefined>; idDirectives: _angular_core.Signal<readonly NgxPendoIdDirective[]>; sectionDirectivs: _angular_core.Signal<readonly NgxPendoSectionDirective[]>; disableInherit: _angular_core.Signal<boolean | undefined>; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxPendoSectionDirective, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgxPendoSectionDirective, "[ngx-pendo-section]", never, { "pendoSection": { "alias": "ngx-pendo-section"; "required": false; "isSignal": true; }; "inherit": { "alias": "ngx-pendo-inherit"; "required": false; "isSignal": true; }; }, {}, ["idDirectives", "sectionDirectivs"], never, true, never>; } declare class NgxPendoIdDirective implements IPendoDirective { pendoId: _angular_core.InputSignal<string>; inherit: _angular_core.InputSignal<boolean>; parent: _angular_core.WritableSignal<NgxPendoSectionDirective | undefined>; mergedPendoId: _angular_core.Signal<string>; disableInherit: _angular_core.Signal<boolean | undefined>; service: NgxPendoService; static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxPendoIdDirective, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgxPendoIdDirective, "[ngx-pendo-id]", never, { "pendoId": { "alias": "ngx-pendo-id"; "required": false; "isSignal": true; }; "inherit": { "alias": "ngx-pendo-inherit"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } type PendoWindow = Window & { pendo?: IPendo; }; declare const NGX_PENDO_INITIALIZER_PROVIDER: Provider; declare function pendoInitializer($settings: IPendoSettings, window: PendoWindow): () => Promise<void>; declare class NgxPendoModule { static forRoot(settings: IPendoSettings): ModuleWithProviders<NgxPendoModule>; static forChild(): ModuleWithProviders<NgxPendoModule>; static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgxPendoModule, never>; static ɵmod: _angular_core.ɵɵNgModuleDeclaration<NgxPendoModule, never, [typeof NgxPendoIdDirective, typeof NgxPendoSectionDirective], [typeof NgxPendoIdDirective, typeof NgxPendoSectionDirective]>; static ɵinj: _angular_core.ɵɵInjectorDeclaration<NgxPendoModule>; } declare function provideNgxPendo(settings: IPendoSettings): _angular_core.EnvironmentProviders; declare const NGX_PENDO_SETTINGS_TOKEN: InjectionToken<IPendoSettings>; declare const NGX_PENDO_WINDOW: InjectionToken<PendoWindow>; declare const NGX_PENDO_CONTEXT: InjectionToken<IPendo>; export { NGX_PENDO_CONTEXT, NGX_PENDO_INITIALIZER_PROVIDER, NGX_PENDO_SETTINGS_TOKEN, NGX_PENDO_WINDOW, NgxPendoIdDirective, NgxPendoModule, NgxPendoSectionDirective, NgxPendoService, pendoInitializer, provideNgxPendo }; export type { IAccount, IPendo, IPendoDirective, IPendoIdentity, IPendoOptions, IPendoSettings, IVisitor, PendoWindow };