@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.06 kB
JavaScript
import{a as s,b as r}from"./chunk-PHHQI4QF.js";import{getDeviceDetails as w}from"@groww-tech/ella";var c=w(),o=1,d=1;function E(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<=r&&(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<=r&&(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(s.FirstName,n),g(s.UserEmail,e),g(s.PhoneNumber,i)):o<=r&&(o++,setTimeout(()=>b(n,e,t,i),1e3))}function v(n,e){g(n,e)}function g(n,e){a()?window.webengage.user&&window.webengage.user.setAttribute(n,e):o<=r&&(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"}export{b as identifyLoggedInUser,E as trackEvent,v as updateUserAttribute};