rozmova-analytics 1.1.32 → 1.1.34

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.
@@ -15,3 +15,7 @@ export declare const resetProfileId: () => void;
15
15
  export declare const setProfileEmail: (email: string) => void;
16
16
  export declare const getProfileEmail: () => string | undefined;
17
17
  export declare const resetProfileEmail: () => void;
18
+ export declare const getLastListNameAndIndex: () => {
19
+ listName: string | null;
20
+ index: string | null;
21
+ };
@@ -9,3 +9,4 @@ export declare const CLARITY_ID = "irbqmnlbwz";
9
9
  export declare const SUPPORTED_LANGUAGES: string[];
10
10
  export declare const GA_ECOMMERCE_EVENTS: string[];
11
11
  export declare const INTERNAL_USER_EMAILS: string[];
12
+ export declare const CREATE_THERAPY_PAGE_PLACEMENT_KEY = "createTherapyPlacementPage";
package/dist/helpers.d.ts CHANGED
@@ -15,3 +15,6 @@ export declare const setGAClientId: (clientId: string) => void;
15
15
  export declare const getLocaleFromURL: (isClearly?: boolean) => string;
16
16
  export declare const getUserType: (email?: string) => "external" | "internal";
17
17
  export declare function shallowEqual(obj1: Record<string, unknown>, obj2: Record<string, unknown>): boolean;
18
+ export declare function toNumberValue(value: number | string | null): number | null;
19
+ export declare function b64EncodeUnicode(str: string): string;
20
+ export declare const getAPIEndpoint: (isProd: boolean, endpoint: string) => string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnalyticsCommonParams, EventParams } from "./types";
1
+ import { AnalyticsCommonParams, EventParams, ForcedAttributionProperties, UserAttributionProperties } from "./types";
2
2
  type GConfig = {
3
3
  userId?: string;
4
4
  email?: string;
@@ -7,9 +7,11 @@ declare class Analytics {
7
7
  private initialized;
8
8
  private locale;
9
9
  private platform;
10
+ private isProd;
10
11
  private dataLayer;
11
12
  private lastGConfig;
12
- init({ locale, platform, isClearly, config, }?: {
13
+ init({ isProd, locale, platform, isClearly, config, }?: {
14
+ isProd?: boolean;
13
15
  locale?: string;
14
16
  platform?: string;
15
17
  isClearly?: boolean;
@@ -40,6 +42,8 @@ declare class Analytics {
40
42
  setLocale(newLocale: string): void;
41
43
  resetUser(): void;
42
44
  getUserId: () => string;
45
+ getAttributionProperties(forcedAttributionProperties?: ForcedAttributionProperties): Promise<UserAttributionProperties>;
46
+ trackFirstPartyEvent(eventName: string, properties?: EventParams, forcedAttributionProperties?: ForcedAttributionProperties): Promise<Response>;
43
47
  }
44
48
  declare const _default: Analytics;
45
49
  export default _default;
package/dist/index.esm.js CHANGED
@@ -12007,6 +12007,7 @@ const INTERNAL_USER_EMAILS = [
12007
12007
  "clearly.help",
12008
12008
  "uptech.team",
12009
12009
  ];
12010
+ const CREATE_THERAPY_PAGE_PLACEMENT_KEY = "createTherapyPlacementPage";
12010
12011
 
12011
12012
  const setQueryParam = (name, value) => {
12012
12013
  const url = new URL(window.location.href);
@@ -12212,6 +12213,21 @@ function shallowEqual(obj1, obj2) {
12212
12213
  return false;
12213
12214
  return keys1.every((key) => obj1[key] === obj2[key]);
12214
12215
  }
12216
+ function toNumberValue(value) {
12217
+ const num = Number(value);
12218
+ return isNaN(num) ? null : num;
12219
+ }
12220
+ function b64EncodeUnicode(str) {
12221
+ return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
12222
+ return String.fromCharCode(parseInt(p1, 16));
12223
+ }));
12224
+ }
12225
+ const getAPIEndpoint = (isProd, endpoint) => {
12226
+ const baseURL = isProd
12227
+ ? "https://trp.rozmova.me"
12228
+ : "https://stage.trp.rozmova.me";
12229
+ return baseURL + endpoint;
12230
+ };
12215
12231
 
12216
12232
  function insertCustomerIOScript() {
12217
12233
  const scriptContent = `
@@ -12411,6 +12427,12 @@ const resetProfileEmail = () => {
12411
12427
  const domain = getDomain();
12412
12428
  api.remove(PROFILE_EMAIL_KEY, { domain });
12413
12429
  };
12430
+ const getLastListNameAndIndex = () => {
12431
+ return {
12432
+ listName: localStorage.getItem("listName"),
12433
+ index: localStorage.getItem("index"),
12434
+ };
12435
+ };
12414
12436
 
12415
12437
  /*!
12416
12438
  * CookieConsent 3.0.1
@@ -12637,15 +12659,18 @@ class Analytics {
12637
12659
  initialized = false;
12638
12660
  locale = "uk";
12639
12661
  platform = "web";
12662
+ isProd = true;
12640
12663
  dataLayer = [];
12641
12664
  lastGConfig = {};
12642
- async init({ locale, platform, isClearly, config, } = {}) {
12665
+ async init({ isProd, locale, platform, isClearly, config, } = {}) {
12643
12666
  insertCustomerIOScript();
12644
12667
  storeGeoParam();
12645
12668
  const userId = getUserId();
12646
12669
  if (isMetaBrowser()) {
12647
12670
  setQueryParam(USER_ID_KEY, userId);
12648
12671
  }
12672
+ if (typeof isProd === "boolean")
12673
+ this.isProd = isProd;
12649
12674
  if (locale)
12650
12675
  this.locale = locale;
12651
12676
  else
@@ -12838,6 +12863,59 @@ class Analytics {
12838
12863
  this.init();
12839
12864
  }
12840
12865
  getUserId = getUserId;
12866
+ async getAttributionProperties(forcedAttributionProperties) {
12867
+ const paramsFromCookie = this.getCommonParams();
12868
+ const { listName, index } = getLastListNameAndIndex();
12869
+ const placement = localStorage.getItem(CREATE_THERAPY_PAGE_PLACEMENT_KEY);
12870
+ const gaClientId = await this.getGAClientId();
12871
+ return {
12872
+ funnelInfo: {
12873
+ funnelName: forcedAttributionProperties?.funnelName ||
12874
+ paramsFromCookie.funnel_name,
12875
+ funnelType: null,
12876
+ listName,
12877
+ platform: this.platform,
12878
+ index: toNumberValue(index),
12879
+ placement,
12880
+ },
12881
+ trackingParams: {
12882
+ source: paramsFromCookie.utm_source,
12883
+ medium: paramsFromCookie.utm_medium,
12884
+ advertiserId: paramsFromCookie.utm_advertiser_id,
12885
+ campaignId: paramsFromCookie.utm_campaign_id,
12886
+ campaignName: paramsFromCookie.utm_campaign,
12887
+ adsetId: paramsFromCookie.utm_adset_id,
12888
+ adId: paramsFromCookie.utm_ad_id,
12889
+ adName: paramsFromCookie.utm_ad_name,
12890
+ keyword: paramsFromCookie.utm_keyword,
12891
+ searchQuery: paramsFromCookie.search_query,
12892
+ referrer: paramsFromCookie.referrer,
12893
+ landingPageUrl: paramsFromCookie.landing_page_url,
12894
+ },
12895
+ externalAnalyticsUserInfo: {
12896
+ gaClientId,
12897
+ gaSessionId: paramsFromCookie.session_id,
12898
+ rid: getUserId(),
12899
+ fbp: paramsFromCookie.fbp,
12900
+ fbc: paramsFromCookie.fbc,
12901
+ },
12902
+ };
12903
+ }
12904
+ async trackFirstPartyEvent(eventName, properties, forcedAttributionProperties) {
12905
+ const attributionProperties = await this.getAttributionProperties(forcedAttributionProperties);
12906
+ const attributionJSON = JSON.stringify(attributionProperties);
12907
+ const attributionJSONbase64 = b64EncodeUnicode(attributionJSON);
12908
+ const headers = new Headers({
12909
+ "X-Attribution": attributionJSONbase64,
12910
+ "Content-Type": "application/json",
12911
+ });
12912
+ const endpoint = getAPIEndpoint(this.isProd, "/api/analytics/track");
12913
+ return await fetch(endpoint, {
12914
+ body: JSON.stringify({ eventName, eventParams: properties }),
12915
+ method: "POST",
12916
+ headers,
12917
+ });
12918
+ }
12841
12919
  }
12842
12920
  var index = new Analytics();
12843
12921
 
package/dist/index.js CHANGED
@@ -12009,6 +12009,7 @@ const INTERNAL_USER_EMAILS = [
12009
12009
  "clearly.help",
12010
12010
  "uptech.team",
12011
12011
  ];
12012
+ const CREATE_THERAPY_PAGE_PLACEMENT_KEY = "createTherapyPlacementPage";
12012
12013
 
12013
12014
  const setQueryParam = (name, value) => {
12014
12015
  const url = new URL(window.location.href);
@@ -12214,6 +12215,21 @@ function shallowEqual(obj1, obj2) {
12214
12215
  return false;
12215
12216
  return keys1.every((key) => obj1[key] === obj2[key]);
12216
12217
  }
12218
+ function toNumberValue(value) {
12219
+ const num = Number(value);
12220
+ return isNaN(num) ? null : num;
12221
+ }
12222
+ function b64EncodeUnicode(str) {
12223
+ return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
12224
+ return String.fromCharCode(parseInt(p1, 16));
12225
+ }));
12226
+ }
12227
+ const getAPIEndpoint = (isProd, endpoint) => {
12228
+ const baseURL = isProd
12229
+ ? "https://trp.rozmova.me"
12230
+ : "https://stage.trp.rozmova.me";
12231
+ return baseURL + endpoint;
12232
+ };
12217
12233
 
12218
12234
  function insertCustomerIOScript() {
12219
12235
  const scriptContent = `
@@ -12413,6 +12429,12 @@ const resetProfileEmail = () => {
12413
12429
  const domain = getDomain();
12414
12430
  api.remove(PROFILE_EMAIL_KEY, { domain });
12415
12431
  };
12432
+ const getLastListNameAndIndex = () => {
12433
+ return {
12434
+ listName: localStorage.getItem("listName"),
12435
+ index: localStorage.getItem("index"),
12436
+ };
12437
+ };
12416
12438
 
12417
12439
  /*!
12418
12440
  * CookieConsent 3.0.1
@@ -12639,15 +12661,18 @@ class Analytics {
12639
12661
  initialized = false;
12640
12662
  locale = "uk";
12641
12663
  platform = "web";
12664
+ isProd = true;
12642
12665
  dataLayer = [];
12643
12666
  lastGConfig = {};
12644
- async init({ locale, platform, isClearly, config, } = {}) {
12667
+ async init({ isProd, locale, platform, isClearly, config, } = {}) {
12645
12668
  insertCustomerIOScript();
12646
12669
  storeGeoParam();
12647
12670
  const userId = getUserId();
12648
12671
  if (isMetaBrowser()) {
12649
12672
  setQueryParam(USER_ID_KEY, userId);
12650
12673
  }
12674
+ if (typeof isProd === "boolean")
12675
+ this.isProd = isProd;
12651
12676
  if (locale)
12652
12677
  this.locale = locale;
12653
12678
  else
@@ -12840,6 +12865,59 @@ class Analytics {
12840
12865
  this.init();
12841
12866
  }
12842
12867
  getUserId = getUserId;
12868
+ async getAttributionProperties(forcedAttributionProperties) {
12869
+ const paramsFromCookie = this.getCommonParams();
12870
+ const { listName, index } = getLastListNameAndIndex();
12871
+ const placement = localStorage.getItem(CREATE_THERAPY_PAGE_PLACEMENT_KEY);
12872
+ const gaClientId = await this.getGAClientId();
12873
+ return {
12874
+ funnelInfo: {
12875
+ funnelName: forcedAttributionProperties?.funnelName ||
12876
+ paramsFromCookie.funnel_name,
12877
+ funnelType: null,
12878
+ listName,
12879
+ platform: this.platform,
12880
+ index: toNumberValue(index),
12881
+ placement,
12882
+ },
12883
+ trackingParams: {
12884
+ source: paramsFromCookie.utm_source,
12885
+ medium: paramsFromCookie.utm_medium,
12886
+ advertiserId: paramsFromCookie.utm_advertiser_id,
12887
+ campaignId: paramsFromCookie.utm_campaign_id,
12888
+ campaignName: paramsFromCookie.utm_campaign,
12889
+ adsetId: paramsFromCookie.utm_adset_id,
12890
+ adId: paramsFromCookie.utm_ad_id,
12891
+ adName: paramsFromCookie.utm_ad_name,
12892
+ keyword: paramsFromCookie.utm_keyword,
12893
+ searchQuery: paramsFromCookie.search_query,
12894
+ referrer: paramsFromCookie.referrer,
12895
+ landingPageUrl: paramsFromCookie.landing_page_url,
12896
+ },
12897
+ externalAnalyticsUserInfo: {
12898
+ gaClientId,
12899
+ gaSessionId: paramsFromCookie.session_id,
12900
+ rid: getUserId(),
12901
+ fbp: paramsFromCookie.fbp,
12902
+ fbc: paramsFromCookie.fbc,
12903
+ },
12904
+ };
12905
+ }
12906
+ async trackFirstPartyEvent(eventName, properties, forcedAttributionProperties) {
12907
+ const attributionProperties = await this.getAttributionProperties(forcedAttributionProperties);
12908
+ const attributionJSON = JSON.stringify(attributionProperties);
12909
+ const attributionJSONbase64 = b64EncodeUnicode(attributionJSON);
12910
+ const headers = new Headers({
12911
+ "X-Attribution": attributionJSONbase64,
12912
+ "Content-Type": "application/json",
12913
+ });
12914
+ const endpoint = getAPIEndpoint(this.isProd, "/api/analytics/track");
12915
+ return await fetch(endpoint, {
12916
+ body: JSON.stringify({ eventName, eventParams: properties }),
12917
+ method: "POST",
12918
+ headers,
12919
+ });
12920
+ }
12843
12921
  }
12844
12922
  var index = new Analytics();
12845
12923