UNPKG

@dotcms/analytics

Version:

Official JavaScript library for Content Analytics with DotCMS.

41 lines (40 loc) 1.12 kB
import { getAnalyticsContext as i } from "../../shared/dot-content-analytics.utils.js"; import { cleanupActivityTracking as r, initializeActivityTracking as o } from "../../shared/dot-content-analytics.activity-tracker.js"; const c = (t) => ({ name: "dot-analytics-identity", /** * Initialize the identity plugin * Sets up activity tracking for session management */ initialize: () => (o(t), Promise.resolve()), /** * Inject identity context into page events * This runs BEFORE the enricher plugin */ pageStart: ({ payload: e }) => { const n = i(t); return { ...e, context: n }; }, /** * Inject identity context into track events * This runs BEFORE the enricher plugin */ trackStart: ({ payload: e }) => { const n = i(t); return { ...e, context: n }; }, /** * Clean up on plugin unload * Sets up cleanup handlers for activity tracking */ loaded: () => (typeof window < "u" && (window.addEventListener("beforeunload", r), window.addEventListener("pagehide", r)), !0) }); export { c as dotAnalyticsIdentityPlugin };