unified-analytics
Version:
Unified analytics library for web applications
36 lines (35 loc) • 1.01 kB
JavaScript
import clevertap from 'clevertap-web-sdk';
export class CleverTapService {
constructor() {
this._instance = clevertap;
this._instance.logLevel = "DEBUG";
this._instance.enablePersonalization = true;
this._instance.enableDeviceNetworkInfoReporting = true;
}
/**
* Get the CleverTap instance
*/
getInstance() {
return this._instance;
}
/**
* Handle analytics event
* @param event - The analytics event
* @param debug - Whether to enable debug logging
*/
onEvent(event, debug) {
if (debug) {
console.log("[CleverTapService] Debug Event:", event);
}
this._instance.event.push(event.name, event.attributes || {});
}
/**
* Create a new instance of CleverTapService
* @returns A new CleverTapService instance
*/
clone() {
return new CleverTapService();
}
}
export const cleverTapService = new CleverTapService();
export default cleverTapService;