rozmova-analytics 1.1.14 → 1.1.15

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/index.d.ts CHANGED
@@ -1,14 +1,20 @@
1
1
  import { AnalyticsCommonParams, EventParams } from "./types";
2
+ type GConfig = {
3
+ userId?: string;
4
+ email?: string;
5
+ locale?: string;
6
+ };
2
7
  declare class Analytics {
3
8
  private initialized;
4
9
  private locale;
5
10
  private platform;
6
11
  private dataLayer;
12
+ private lastGConfig;
7
13
  init({ locale, platform, isClearly, }?: {
8
14
  locale?: string;
9
15
  platform?: string;
10
16
  isClearly?: boolean;
11
- }): void;
17
+ }): Promise<void>;
12
18
  private processDataLayer;
13
19
  setUserTag(key: string, value: string): void;
14
20
  trackEvent(eventName: string, properties?: EventParams, services?: {
@@ -16,11 +22,8 @@ declare class Analytics {
16
22
  mixpanel?: boolean;
17
23
  customerIO?: boolean;
18
24
  }): Promise<void>;
19
- setConfig({ userId, email, locale, }?: {
20
- userId?: string;
21
- email?: string;
22
- locale?: string;
23
- }): void;
25
+ setConfig(params?: GConfig): void;
26
+ getLastGConfig(): GConfig;
24
27
  trackPageView(): void;
25
28
  setUser(userId: string, userParams: {
26
29
  email: string;
package/dist/index.esm.js CHANGED
@@ -12003,7 +12003,7 @@ const GA_ECOMMERCE_EVENTS = [
12003
12003
  "begin_checkout",
12004
12004
  "add_payment_info",
12005
12005
  ];
12006
- const INTERNAL_USER_EMAILS = ["rozmova.me", "uptech.team"];
12006
+ const INTERNAL_USER_EMAILS = ["rozmova.me", "clearly.help"];
12007
12007
 
12008
12008
  const setQueryParam = (name, value) => {
12009
12009
  const url = new URL(window.location.href);
@@ -12544,7 +12544,8 @@ class Analytics {
12544
12544
  locale = "uk";
12545
12545
  platform = "web";
12546
12546
  dataLayer = [];
12547
- init({ locale, platform, isClearly, } = {}) {
12547
+ lastGConfig = {};
12548
+ async init({ locale, platform, isClearly, } = {}) {
12548
12549
  if (this.initialized)
12549
12550
  return;
12550
12551
  insertCustomerIOScript();
@@ -12568,7 +12569,7 @@ class Analytics {
12568
12569
  });
12569
12570
  // init microsoft clarity
12570
12571
  Clarity.init(CLARITY_ID);
12571
- const userProperties = this.getCommonParams();
12572
+ const userProperties = await this.getCommonParams();
12572
12573
  mixpanel.register(userProperties);
12573
12574
  this.setConfig();
12574
12575
  this.trackPageView();
@@ -12650,22 +12651,39 @@ class Analytics {
12650
12651
  }
12651
12652
  }
12652
12653
  }
12653
- setConfig({ userId, email, locale, } = {}) {
12654
- const user_id = userId || getProfileId();
12655
- const user_email = email || getProfileEmail();
12656
- this.trackEvent("g_config", {
12657
- user_id,
12658
- is_logged: user_id ? "yes" : "no",
12659
- locale: locale || this.locale,
12654
+ setConfig(params = {
12655
+ userId: getProfileId(),
12656
+ email: getProfileEmail(),
12657
+ locale: this.locale,
12658
+ }) {
12659
+ this.lastGConfig = params;
12660
+ const { userId, email, locale } = params;
12661
+ const eventParams = {
12662
+ user_id: userId,
12663
+ is_logged: userId ? "yes" : "no",
12664
+ locale: locale,
12660
12665
  platform: this.platform,
12661
- user_type: getUserType(user_email),
12666
+ user_type: getUserType(email),
12667
+ };
12668
+ mixpanel.track("g_config", eventParams);
12669
+ window.dataLayer.push({
12670
+ event: "g_config",
12671
+ ...eventParams,
12662
12672
  });
12663
12673
  }
12674
+ getLastGConfig() {
12675
+ return this.lastGConfig;
12676
+ }
12664
12677
  trackPageView() {
12665
- this.trackEvent("page_view", {
12678
+ const eventParams = {
12666
12679
  page_title: document.title,
12667
12680
  page_location: window.location.href,
12668
- page_referrer: document.referrer,
12681
+ page_referrer: getReferrer(),
12682
+ };
12683
+ mixpanel.track("page_view", eventParams);
12684
+ window.dataLayer.push({
12685
+ event: "page_view",
12686
+ ...eventParams,
12669
12687
  });
12670
12688
  }
12671
12689
  setUser(userId, userParams) {
package/dist/index.js CHANGED
@@ -12005,7 +12005,7 @@ const GA_ECOMMERCE_EVENTS = [
12005
12005
  "begin_checkout",
12006
12006
  "add_payment_info",
12007
12007
  ];
12008
- const INTERNAL_USER_EMAILS = ["rozmova.me", "uptech.team"];
12008
+ const INTERNAL_USER_EMAILS = ["rozmova.me", "clearly.help"];
12009
12009
 
12010
12010
  const setQueryParam = (name, value) => {
12011
12011
  const url = new URL(window.location.href);
@@ -12546,7 +12546,8 @@ class Analytics {
12546
12546
  locale = "uk";
12547
12547
  platform = "web";
12548
12548
  dataLayer = [];
12549
- init({ locale, platform, isClearly, } = {}) {
12549
+ lastGConfig = {};
12550
+ async init({ locale, platform, isClearly, } = {}) {
12550
12551
  if (this.initialized)
12551
12552
  return;
12552
12553
  insertCustomerIOScript();
@@ -12570,7 +12571,7 @@ class Analytics {
12570
12571
  });
12571
12572
  // init microsoft clarity
12572
12573
  Clarity.init(CLARITY_ID);
12573
- const userProperties = this.getCommonParams();
12574
+ const userProperties = await this.getCommonParams();
12574
12575
  mixpanel.register(userProperties);
12575
12576
  this.setConfig();
12576
12577
  this.trackPageView();
@@ -12652,22 +12653,39 @@ class Analytics {
12652
12653
  }
12653
12654
  }
12654
12655
  }
12655
- setConfig({ userId, email, locale, } = {}) {
12656
- const user_id = userId || getProfileId();
12657
- const user_email = email || getProfileEmail();
12658
- this.trackEvent("g_config", {
12659
- user_id,
12660
- is_logged: user_id ? "yes" : "no",
12661
- locale: locale || this.locale,
12656
+ setConfig(params = {
12657
+ userId: getProfileId(),
12658
+ email: getProfileEmail(),
12659
+ locale: this.locale,
12660
+ }) {
12661
+ this.lastGConfig = params;
12662
+ const { userId, email, locale } = params;
12663
+ const eventParams = {
12664
+ user_id: userId,
12665
+ is_logged: userId ? "yes" : "no",
12666
+ locale: locale,
12662
12667
  platform: this.platform,
12663
- user_type: getUserType(user_email),
12668
+ user_type: getUserType(email),
12669
+ };
12670
+ mixpanel.track("g_config", eventParams);
12671
+ window.dataLayer.push({
12672
+ event: "g_config",
12673
+ ...eventParams,
12664
12674
  });
12665
12675
  }
12676
+ getLastGConfig() {
12677
+ return this.lastGConfig;
12678
+ }
12666
12679
  trackPageView() {
12667
- this.trackEvent("page_view", {
12680
+ const eventParams = {
12668
12681
  page_title: document.title,
12669
12682
  page_location: window.location.href,
12670
- page_referrer: document.referrer,
12683
+ page_referrer: getReferrer(),
12684
+ };
12685
+ mixpanel.track("page_view", eventParams);
12686
+ window.dataLayer.push({
12687
+ event: "page_view",
12688
+ ...eventParams,
12671
12689
  });
12672
12690
  }
12673
12691
  setUser(userId, userParams) {