@dotcms/analytics
Version:
Official JavaScript library for Content Analytics with DotCMS.
47 lines (46 loc) • 1.91 kB
TypeScript
import { DotCMSAnalyticsConfig, EnrichedAnalyticsPayload, EnrichedTrackPayload } from '../../shared/models';
/**
* Analytics plugin for tracking page views and custom events in DotCMS applications.
* This plugin handles:
* 1. Event structuring (deciding between predefined and custom events)
* 2. Building complete request bodies
* 3. Sending analytics data to the DotCMS server
* 4. Managing initialization and queue management
*
* The enricher plugin runs BEFORE this plugin and adds page/utm/custom data.
* This plugin receives enriched payloads and structures them into proper events.
*
* @param {DotCMSAnalyticsConfig} config - Configuration object containing API key, server URL,
* debug mode, auto page view settings, and queue config
* @returns {Object} Plugin object with methods for initialization and event tracking
*/
export declare const dotAnalytics: (config: DotCMSAnalyticsConfig) => {
name: string;
config: DotCMSAnalyticsConfig;
/**
* Initialize the plugin with optional queue management
*/
initialize: () => Promise<void>;
/**
* Track a page view event
* Receives enriched payload from the enricher plugin and structures it into a pageview event
*/
page: ({ payload }: {
payload: EnrichedAnalyticsPayload;
}) => void;
/**
* Track a custom or predefined event
* Receives enriched payload from enricher plugin and structures it into proper event format.
*
* - content_impression → extracts from properties, combines with enriched page data
* - content_click → extracts from properties, combines with enriched page data
* - custom events → wraps properties in custom object
*/
track: ({ payload }: {
payload: EnrichedTrackPayload;
}) => void;
/**
* Check if the plugin is loaded
*/
loaded: () => boolean;
};