@dotcms/analytics
Version:
Official JavaScript library for Content Analytics with DotCMS.
133 lines (132 loc) • 4.56 kB
TypeScript
export declare const ANALYTICS_WINDOWS_KEY = "dotAnalytics";
export declare const ANALYTICS_SOURCE_TYPE = "dotAnalytics";
export declare const ANALYTICS_ENDPOINT = "/api/v1/analytics/content/event";
/**
* Structured event types - events with predefined data shapes
* These events have specific data structures and validation
*/
export declare const DotCMSPredefinedEventType: {
readonly PAGEVIEW: "pageview";
readonly CONTENT_IMPRESSION: "content_impression";
readonly CONTENT_CLICK: "content_click";
readonly CONVERSION: "conversion";
};
/**
* Type for structured events
*/
export type DotCMSPredefinedEventType = (typeof DotCMSPredefinedEventType)[keyof typeof DotCMSPredefinedEventType];
/**
* Custom event type - any string except predefined event types
* These events have flexible data structures defined by the user
*/
export type DotCMSCustomEventType = Exclude<string, DotCMSPredefinedEventType>;
/**
* Union type for all possible event types
*/
export type DotCMSEventType = DotCMSPredefinedEventType | DotCMSCustomEventType;
/**
* Expected UTM parameter keys for campaign tracking
*/
export declare const EXPECTED_UTM_KEYS: readonly ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
/**
* Session configuration constants
*/
export declare const DEFAULT_SESSION_TIMEOUT_MINUTES = 30;
/**
* Session storage key for session ID
*/
export declare const SESSION_STORAGE_KEY = "dot_analytics_session_id";
/**
* Session storage key for session start time
*/
export declare const SESSION_START_KEY = "dot_analytics_session_start";
/**
* Session storage key for session UTM data
*/
export declare const SESSION_UTM_KEY = "dot_analytics_session_utm";
/**
* User ID configuration constants
*/
export declare const USER_ID_KEY = "dot_analytics_user_id";
/**
* Activity tracking configuration
* Events used to detect user activity for session management
* - click: Detects real user interaction with minimal performance impact
* - visibilitychange: Handled separately to detect tab changes
*/
export declare const ACTIVITY_EVENTS: readonly ["click"];
/**
* Default queue configuration for event batching
*/
export declare const DEFAULT_QUEUE_CONFIG: {
readonly eventBatchSize: 15;
readonly flushInterval: 5000;
};
/**
* The name of the analytics minified script.
*/
export declare const ANALYTICS_MINIFIED_SCRIPT_NAME = "ca.min.js";
/**
* Default properties that Analytics.js adds automatically
* These should be filtered out to only keep user-provided properties
*/
export declare const ANALYTICS_JS_DEFAULT_PROPERTIES: readonly ["title", "url", "path", "hash", "search", "width", "height", "referrer"];
/**
* Impression tracking configuration constants
*/
/**
* Default minimum percentage of element that must be visible (0.0 to 1.0)
*/
export declare const DEFAULT_IMPRESSION_VISIBILITY_THRESHOLD = 0.5;
/**
* Default minimum time in milliseconds element must be visible
*/
export declare const DEFAULT_IMPRESSION_DWELL_MS = 750;
/**
* Default maximum number of elements to track (performance limit)
*/
export declare const DEFAULT_IMPRESSION_MAX_NODES = 100;
/**
* Default throttle time in milliseconds for intersection callbacks
*/
export declare const DEFAULT_IMPRESSION_THROTTLE_MS = 100;
/**
* Default debounce time in milliseconds for MutationObserver
*/
export declare const DEFAULT_IMPRESSION_MUTATION_OBSERVER_DEBOUNCE_MS = 250;
/**
* Default impression tracking configuration
*/
export declare const DEFAULT_IMPRESSION_CONFIG: {
readonly visibilityThreshold: 0.5;
readonly dwellMs: 750;
readonly maxNodes: 100;
readonly throttleMs: 100;
};
/**
* Event type for content impressions
* Must match DotCMSPredefinedEventType.CONTENT_IMPRESSION
*/
export declare const IMPRESSION_EVENT_TYPE = "content_impression";
/**
* Event type for content clicks
* Must match DotCMSPredefinedEventType.CONTENT_CLICK
*/
export declare const CLICK_EVENT_TYPE = "content_click";
/**
* Default debounce time in milliseconds for clicks
*/
export declare const DEFAULT_CLICK_THROTTLE_MS = 300;
/**
* CSS selector for clickable elements to track
* Only clicks on <a> and <button> elements are tracked
*/
export declare const CLICKABLE_ELEMENTS_SELECTOR = "a, button";
/**
* Session storage key for tracked impressions (deduplication)
*/
export declare const IMPRESSION_SESSION_KEY = "dot_analytics_impressions";
/**
* CSS class selector for trackable contentlets
*/
export declare const ANALYTICS_CONTENTLET_CLASS = "dotcms-analytics-contentlet";