rozmova-analytics 1.1.17 → 1.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/helpers.d.ts CHANGED
@@ -13,3 +13,4 @@ export declare const getGAClientId: () => Promise<string>;
13
13
  export declare function getGASessionId(): string | null;
14
14
  export declare const getLocaleFromURL: (isClearly?: boolean) => string;
15
15
  export declare const getUserType: (email?: string) => "external" | "internal";
16
+ export declare function shallowEqual(obj1: Record<string, unknown>, obj2: Record<string, unknown>): boolean;
package/dist/index.d.ts CHANGED
@@ -10,7 +10,6 @@ declare class Analytics {
10
10
  private platform;
11
11
  private dataLayer;
12
12
  private lastGConfig;
13
- isInitialized(): boolean;
14
13
  init({ locale, platform, isClearly, }?: {
15
14
  locale?: string;
16
15
  platform?: string;
@@ -24,7 +23,6 @@ declare class Analytics {
24
23
  customerIO?: boolean;
25
24
  }): Promise<void>;
26
25
  setConfig(params?: GConfig): void;
27
- getLastGConfig(): GConfig;
28
26
  trackPageView({ referrer }?: {
29
27
  referrer?: string;
30
28
  }): void;
package/dist/index.esm.js CHANGED
@@ -11991,7 +11991,6 @@ const UTM_KEYS = [
11991
11991
  "utm_keyword",
11992
11992
  ];
11993
11993
  const GOOGLE_ANALYTICS_ID = "G-GYQLL028VQ";
11994
- const GA_SERVER_CONTAINER_URL = "https://tagging.clearly.help";
11995
11994
  const MIXPANEL_TOKEN = "9d4cb3d213e5aee689ea01dd68ad65ad";
11996
11995
  const CUSTOMER_IO_WRITE_KEY = "e6d009719c77519432c3";
11997
11996
  const CLARITY_ID = "irbqmnlbwz";
@@ -12190,6 +12189,13 @@ const getUserType = (email) => {
12190
12189
  const isInternal = INTERNAL_USER_EMAILS.some((internalEmail) => email.includes(internalEmail));
12191
12190
  return isInternal ? "internal" : "external";
12192
12191
  };
12192
+ function shallowEqual(obj1, obj2) {
12193
+ const keys1 = Object.keys(obj1);
12194
+ const keys2 = Object.keys(obj2);
12195
+ if (keys1.length !== keys2.length)
12196
+ return false;
12197
+ return keys1.every((key) => obj1[key] === obj2[key]);
12198
+ }
12193
12199
 
12194
12200
  function insertCustomerIOScript() {
12195
12201
  const scriptContent = `
@@ -12545,12 +12551,7 @@ class Analytics {
12545
12551
  platform = "web";
12546
12552
  dataLayer = [];
12547
12553
  lastGConfig = {};
12548
- isInitialized() {
12549
- return this.initialized;
12550
- }
12551
12554
  async init({ locale, platform, isClearly, } = {}) {
12552
- if (this.initialized)
12553
- return;
12554
12555
  insertCustomerIOScript();
12555
12556
  storeGeoParam();
12556
12557
  const userId = getUserId();
@@ -12572,14 +12573,14 @@ class Analytics {
12572
12573
  });
12573
12574
  // init microsoft clarity
12574
12575
  Clarity.init(CLARITY_ID);
12575
- const userProperties = await this.getCommonParams();
12576
- mixpanel.register(userProperties);
12577
12576
  this.setConfig();
12578
12577
  this.trackPageView();
12579
- gtag("config", GOOGLE_ANALYTICS_ID, {
12580
- user_properties: userProperties,
12581
- server_container_url: GA_SERVER_CONTAINER_URL,
12582
- });
12578
+ const userProperties = await this.getCommonParams();
12579
+ mixpanel.register(userProperties);
12580
+ // gtag("config", GOOGLE_ANALYTICS_ID, {
12581
+ // user_properties: userProperties,
12582
+ // server_container_url: GA_SERVER_CONTAINER_URL,
12583
+ // });
12583
12584
  initialLoginEvent(this.trackEvent.bind(this));
12584
12585
  this.initialized = true;
12585
12586
  this.processDataLayer();
@@ -12659,6 +12660,8 @@ class Analytics {
12659
12660
  email: getProfileEmail(),
12660
12661
  locale: this.locale,
12661
12662
  }) {
12663
+ if (shallowEqual(params, this.lastGConfig))
12664
+ return;
12662
12665
  this.lastGConfig = params;
12663
12666
  const { userId, email, locale } = params;
12664
12667
  const eventParams = {
@@ -12674,9 +12677,6 @@ class Analytics {
12674
12677
  ...eventParams,
12675
12678
  });
12676
12679
  }
12677
- getLastGConfig() {
12678
- return this.lastGConfig;
12679
- }
12680
12680
  trackPageView({ referrer } = {}) {
12681
12681
  const eventParams = {
12682
12682
  page_title: document.title,
@@ -12690,20 +12690,16 @@ class Analytics {
12690
12690
  });
12691
12691
  }
12692
12692
  setUser(userId, userParams) {
12693
- if (!this.initialized) {
12694
- console.warn("Analytics is not initialized.");
12695
- return;
12696
- }
12697
12693
  const { email, name, phone, isB2B } = userParams;
12698
12694
  // Mixpanel user
12699
12695
  mixpanel.identify(userId);
12700
12696
  mixpanel.people.set({ $email: email, name, phone, isB2B });
12701
12697
  // GA user
12702
- gtag("config", GOOGLE_ANALYTICS_ID, {
12703
- user_properties: this.getCommonParams(),
12704
- user_id: userId,
12705
- server_container_url: GA_SERVER_CONTAINER_URL,
12706
- });
12698
+ // gtag("config", GOOGLE_ANALYTICS_ID, {
12699
+ // user_properties: this.getCommonParams(),
12700
+ // user_id: userId,
12701
+ // server_container_url: GA_SERVER_CONTAINER_URL,
12702
+ // });
12707
12703
  // Customer IO user
12708
12704
  window.analytics.identify(userId, userParams);
12709
12705
  // store user id in cookies
@@ -12739,10 +12735,6 @@ class Analytics {
12739
12735
  this.locale = newLocale;
12740
12736
  }
12741
12737
  resetUser() {
12742
- if (!this.initialized) {
12743
- console.warn("Analytics is not initialized.");
12744
- return;
12745
- }
12746
12738
  mixpanel.reset();
12747
12739
  window.analytics.reset();
12748
12740
  resetProfileId();
package/dist/index.js CHANGED
@@ -11993,7 +11993,6 @@ const UTM_KEYS = [
11993
11993
  "utm_keyword",
11994
11994
  ];
11995
11995
  const GOOGLE_ANALYTICS_ID = "G-GYQLL028VQ";
11996
- const GA_SERVER_CONTAINER_URL = "https://tagging.clearly.help";
11997
11996
  const MIXPANEL_TOKEN = "9d4cb3d213e5aee689ea01dd68ad65ad";
11998
11997
  const CUSTOMER_IO_WRITE_KEY = "e6d009719c77519432c3";
11999
11998
  const CLARITY_ID = "irbqmnlbwz";
@@ -12192,6 +12191,13 @@ const getUserType = (email) => {
12192
12191
  const isInternal = INTERNAL_USER_EMAILS.some((internalEmail) => email.includes(internalEmail));
12193
12192
  return isInternal ? "internal" : "external";
12194
12193
  };
12194
+ function shallowEqual(obj1, obj2) {
12195
+ const keys1 = Object.keys(obj1);
12196
+ const keys2 = Object.keys(obj2);
12197
+ if (keys1.length !== keys2.length)
12198
+ return false;
12199
+ return keys1.every((key) => obj1[key] === obj2[key]);
12200
+ }
12195
12201
 
12196
12202
  function insertCustomerIOScript() {
12197
12203
  const scriptContent = `
@@ -12547,12 +12553,7 @@ class Analytics {
12547
12553
  platform = "web";
12548
12554
  dataLayer = [];
12549
12555
  lastGConfig = {};
12550
- isInitialized() {
12551
- return this.initialized;
12552
- }
12553
12556
  async init({ locale, platform, isClearly, } = {}) {
12554
- if (this.initialized)
12555
- return;
12556
12557
  insertCustomerIOScript();
12557
12558
  storeGeoParam();
12558
12559
  const userId = getUserId();
@@ -12574,14 +12575,14 @@ class Analytics {
12574
12575
  });
12575
12576
  // init microsoft clarity
12576
12577
  Clarity.init(CLARITY_ID);
12577
- const userProperties = await this.getCommonParams();
12578
- mixpanel.register(userProperties);
12579
12578
  this.setConfig();
12580
12579
  this.trackPageView();
12581
- gtag("config", GOOGLE_ANALYTICS_ID, {
12582
- user_properties: userProperties,
12583
- server_container_url: GA_SERVER_CONTAINER_URL,
12584
- });
12580
+ const userProperties = await this.getCommonParams();
12581
+ mixpanel.register(userProperties);
12582
+ // gtag("config", GOOGLE_ANALYTICS_ID, {
12583
+ // user_properties: userProperties,
12584
+ // server_container_url: GA_SERVER_CONTAINER_URL,
12585
+ // });
12585
12586
  initialLoginEvent(this.trackEvent.bind(this));
12586
12587
  this.initialized = true;
12587
12588
  this.processDataLayer();
@@ -12661,6 +12662,8 @@ class Analytics {
12661
12662
  email: getProfileEmail(),
12662
12663
  locale: this.locale,
12663
12664
  }) {
12665
+ if (shallowEqual(params, this.lastGConfig))
12666
+ return;
12664
12667
  this.lastGConfig = params;
12665
12668
  const { userId, email, locale } = params;
12666
12669
  const eventParams = {
@@ -12676,9 +12679,6 @@ class Analytics {
12676
12679
  ...eventParams,
12677
12680
  });
12678
12681
  }
12679
- getLastGConfig() {
12680
- return this.lastGConfig;
12681
- }
12682
12682
  trackPageView({ referrer } = {}) {
12683
12683
  const eventParams = {
12684
12684
  page_title: document.title,
@@ -12692,20 +12692,16 @@ class Analytics {
12692
12692
  });
12693
12693
  }
12694
12694
  setUser(userId, userParams) {
12695
- if (!this.initialized) {
12696
- console.warn("Analytics is not initialized.");
12697
- return;
12698
- }
12699
12695
  const { email, name, phone, isB2B } = userParams;
12700
12696
  // Mixpanel user
12701
12697
  mixpanel.identify(userId);
12702
12698
  mixpanel.people.set({ $email: email, name, phone, isB2B });
12703
12699
  // GA user
12704
- gtag("config", GOOGLE_ANALYTICS_ID, {
12705
- user_properties: this.getCommonParams(),
12706
- user_id: userId,
12707
- server_container_url: GA_SERVER_CONTAINER_URL,
12708
- });
12700
+ // gtag("config", GOOGLE_ANALYTICS_ID, {
12701
+ // user_properties: this.getCommonParams(),
12702
+ // user_id: userId,
12703
+ // server_container_url: GA_SERVER_CONTAINER_URL,
12704
+ // });
12709
12705
  // Customer IO user
12710
12706
  window.analytics.identify(userId, userParams);
12711
12707
  // store user id in cookies
@@ -12741,10 +12737,6 @@ class Analytics {
12741
12737
  this.locale = newLocale;
12742
12738
  }
12743
12739
  resetUser() {
12744
- if (!this.initialized) {
12745
- console.warn("Analytics is not initialized.");
12746
- return;
12747
- }
12748
12740
  mixpanel.reset();
12749
12741
  window.analytics.reset();
12750
12742
  resetProfileId();