@dotcms/analytics
Version:
Official JavaScript library for Content Analytics with DotCMS.
33 lines (32 loc) • 1.54 kB
TypeScript
import { AnalyticsBasePayloadWithContext, AnalyticsTrackPayloadWithContext, EnrichedAnalyticsPayload, EnrichedTrackPayload } from '../../shared/models';
/**
* Plugin that enriches the analytics payload data with page, UTM, and custom data.
* Uses Analytics.js lifecycle events to inject enriched data before the main plugin processes it.
*
* The identity plugin runs FIRST to inject context: { session_id, site_auth, user_id, device }
* This enricher plugin runs SECOND to add page/utm/custom data.
* The main plugin runs THIRD to structure events and send to server.
*
* This plugin is ONLY responsible for data enrichment - NOT for event structuring or business logic.
*/
export declare const dotAnalyticsEnricherPlugin: () => {
name: string;
/**
* PAGE VIEW ENRICHMENT - Runs after identity context injection
* Returns enriched payload with page, utm, and custom data added
* @returns {EnrichedAnalyticsPayload} Enriched payload ready for event creation
*/
'page:dot-analytics': ({ payload }: {
payload: AnalyticsBasePayloadWithContext;
}) => EnrichedAnalyticsPayload;
/**
* TRACK EVENT ENRICHMENT - Runs after identity context injection
* Adds page data and timestamp for predefined content events.
* For custom events, only adds timestamp.
*
* @returns {EnrichedTrackPayload} Enriched payload ready for event structuring
*/
'track:dot-analytics': ({ payload }: {
payload: AnalyticsTrackPayloadWithContext;
}) => EnrichedTrackPayload;
};