@ima/plugin-analytic
Version:
Seznam IMA.js abstract analytic plugin
79 lines • 2.48 kB
TypeScript
import type { Dependencies, Dispatcher, Window } from '@ima/core';
import { ScriptLoaderPlugin } from '@ima/plugin-script-loader';
import { Events as AnalyticEvents } from './Events';
export type InitConfig = Record<string, any> & {
purposeConsents?: Record<string, unknown>;
};
/**
* Abstract analytic class
*/
export declare abstract class AbstractAnalytic {
#private;
_window: Window;
_analyticScriptName: string | null;
_analyticScriptUrl: string | null;
_enable: boolean;
static get $dependencies(): Dependencies;
constructor(scriptLoader: ScriptLoaderPlugin, window: Window, dispatcher: Dispatcher);
/**
* Initialization analytic.
*
* @function init
* @param initConfig
* @param initConfig.purposeConsents Purpose Consents of TCModel, see: https://www.npmjs.com/package/@iabtcf/core#tcmodel
*/
init(initConfig?: InitConfig): void;
/**
* Load analytic script, configure analytic and execute deferred hits.
*/
load(): Promise<boolean | void>;
/**
* Applies Purpose Consents to respect GDPR, see https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework
*
* @abstract
* @param purposeConsents Purpose Consents of TCModel, see: https://www.npmjs.com/package/@iabtcf/core#tcmodel
*/
abstract _applyPurposeConsents(purposeConsents: Record<string, any>): void;
/**
* Returns true if analytic is enabled.
*/
isEnabled(): boolean;
/**
* Returns true if analytic is loaded.
* @protected
*/
isLoaded(): boolean;
/**
* Hit event to analytic with defined data. If analytic is not configured then
* defer hit to storage.
*
* @abstract
*/
abstract hit(...args: unknown[]): void;
/**
* Hit page view event to analytic for defined page data.
*
* @abstract
*/
abstract hitPageView(...args: unknown[]): void;
/**
* Configuration analytic. The analytic must be enabled after configuration.
*
* @abstract
* @protected
*/
abstract _configuration(): void;
/**
* Creates global definition for analytics script.
*
* @abstract
* @protected
*/
abstract _createGlobalDefinition(window: globalThis.Window): void;
/**
* @protected
* @param eventType
*/
_fireLifecycleEvent(eventType: AnalyticEvents): void;
}
//# sourceMappingURL=AbstractAnalytic.d.ts.map