UNPKG

@groww-tech/analytics

Version:

Analytics service exposes methods to send events to 3rd party analytics tools like Webengage and Gtm.

2 lines (1 loc) 1.29 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQCQVJWISjs = require('./chunk-QCQVJWIS.js');var _ella = require('@groww-tech/ella');var c=_ella.getDeviceDetails.call(void 0, ),o=1,d=1;function D(n,e,t={}){try{let i={...t,origin:c.origin};f(e,i),u(e,i,n)}catch(i){console.error("Exception trackEvent",i)}}function f(n,e){a()?window.webengage.track(n,e):o<=_chunkQCQVJWISjs.b&&(o++,setTimeout(()=>f(n,e),1e3))}function u(n,e,t){y()?window.dataLayer.push({event:"event",eventCategory:t,eventAction:n,eventLabel:JSON.stringify(e)}):d<=_chunkQCQVJWISjs.b&&(d++,setTimeout(()=>u(n,e,t),1e3))}function b(n,e,t="",i=""){l(n,e,t,i)}function l(n,e,t="",i=""){a()?window.webengage.user&&(window.webengage.user.login(t),g(_chunkQCQVJWISjs.a.FirstName,n),g(_chunkQCQVJWISjs.a.UserEmail,e),g(_chunkQCQVJWISjs.a.PhoneNumber,i)):o<=_chunkQCQVJWISjs.b&&(o++,setTimeout(()=>b(n,e,t,i),1e3))}function E(n,e){g(n,e)}function g(n,e){a()?window.webengage.user&&window.webengage.user.setAttribute(n,e):o<=_chunkQCQVJWISjs.b&&(o++,setTimeout(()=>g(n,e),1e3))}function a(){return typeof window<"u"&&typeof window.webengage<"u"}function y(){return typeof window<"u"&&typeof window.dataLayer<"u"}exports.identifyLoggedInUser = b; exports.trackEvent = D; exports.updateUserAttribute = E;