UNPKG

@dotcms/analytics

Version:

Official JavaScript library for Content Analytics with DotCMS.

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