rozmova-analytics 1.1.13 → 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 +10 -6
- package/dist/index.esm.js +42 -13
- package/dist/index.js +42 -13
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
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>;
|
|
18
|
+
private processDataLayer;
|
|
12
19
|
setUserTag(key: string, value: string): void;
|
|
13
20
|
trackEvent(eventName: string, properties?: EventParams, services?: {
|
|
14
21
|
ga?: boolean;
|
|
15
22
|
mixpanel?: boolean;
|
|
16
23
|
customerIO?: boolean;
|
|
17
24
|
}): Promise<void>;
|
|
18
|
-
setConfig(
|
|
19
|
-
|
|
20
|
-
email?: string;
|
|
21
|
-
locale?: string;
|
|
22
|
-
}): void;
|
|
25
|
+
setConfig(params?: GConfig): void;
|
|
26
|
+
getLastGConfig(): GConfig;
|
|
23
27
|
trackPageView(): void;
|
|
24
28
|
setUser(userId: string, userParams: {
|
|
25
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", "
|
|
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
|
-
|
|
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();
|
|
@@ -12578,6 +12579,17 @@ class Analytics {
|
|
|
12578
12579
|
});
|
|
12579
12580
|
initialLoginEvent(this.trackEvent.bind(this));
|
|
12580
12581
|
this.initialized = true;
|
|
12582
|
+
this.processDataLayer();
|
|
12583
|
+
}
|
|
12584
|
+
processDataLayer() {
|
|
12585
|
+
const priorityEvents = ["g_config", "page_view"];
|
|
12586
|
+
for (const priorityEvent of priorityEvents) {
|
|
12587
|
+
const eventIndex = this.dataLayer.findIndex((event) => event.eventName === priorityEvent);
|
|
12588
|
+
if (eventIndex !== -1) {
|
|
12589
|
+
const event = this.dataLayer.splice(eventIndex, 1)[0];
|
|
12590
|
+
this.trackEvent(event.eventName, event.eventParams);
|
|
12591
|
+
}
|
|
12592
|
+
}
|
|
12581
12593
|
while (this.dataLayer.length > 0) {
|
|
12582
12594
|
const event = this.dataLayer.shift();
|
|
12583
12595
|
this.trackEvent(event?.eventName, event?.eventParams);
|
|
@@ -12639,22 +12651,39 @@ class Analytics {
|
|
|
12639
12651
|
}
|
|
12640
12652
|
}
|
|
12641
12653
|
}
|
|
12642
|
-
setConfig(
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
this.
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
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,
|
|
12649
12665
|
platform: this.platform,
|
|
12650
|
-
user_type: getUserType(
|
|
12666
|
+
user_type: getUserType(email),
|
|
12667
|
+
};
|
|
12668
|
+
mixpanel.track("g_config", eventParams);
|
|
12669
|
+
window.dataLayer.push({
|
|
12670
|
+
event: "g_config",
|
|
12671
|
+
...eventParams,
|
|
12651
12672
|
});
|
|
12652
12673
|
}
|
|
12674
|
+
getLastGConfig() {
|
|
12675
|
+
return this.lastGConfig;
|
|
12676
|
+
}
|
|
12653
12677
|
trackPageView() {
|
|
12654
|
-
|
|
12678
|
+
const eventParams = {
|
|
12655
12679
|
page_title: document.title,
|
|
12656
12680
|
page_location: window.location.href,
|
|
12657
|
-
page_referrer:
|
|
12681
|
+
page_referrer: getReferrer(),
|
|
12682
|
+
};
|
|
12683
|
+
mixpanel.track("page_view", eventParams);
|
|
12684
|
+
window.dataLayer.push({
|
|
12685
|
+
event: "page_view",
|
|
12686
|
+
...eventParams,
|
|
12658
12687
|
});
|
|
12659
12688
|
}
|
|
12660
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", "
|
|
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
|
-
|
|
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();
|
|
@@ -12580,6 +12581,17 @@ class Analytics {
|
|
|
12580
12581
|
});
|
|
12581
12582
|
initialLoginEvent(this.trackEvent.bind(this));
|
|
12582
12583
|
this.initialized = true;
|
|
12584
|
+
this.processDataLayer();
|
|
12585
|
+
}
|
|
12586
|
+
processDataLayer() {
|
|
12587
|
+
const priorityEvents = ["g_config", "page_view"];
|
|
12588
|
+
for (const priorityEvent of priorityEvents) {
|
|
12589
|
+
const eventIndex = this.dataLayer.findIndex((event) => event.eventName === priorityEvent);
|
|
12590
|
+
if (eventIndex !== -1) {
|
|
12591
|
+
const event = this.dataLayer.splice(eventIndex, 1)[0];
|
|
12592
|
+
this.trackEvent(event.eventName, event.eventParams);
|
|
12593
|
+
}
|
|
12594
|
+
}
|
|
12583
12595
|
while (this.dataLayer.length > 0) {
|
|
12584
12596
|
const event = this.dataLayer.shift();
|
|
12585
12597
|
this.trackEvent(event?.eventName, event?.eventParams);
|
|
@@ -12641,22 +12653,39 @@ class Analytics {
|
|
|
12641
12653
|
}
|
|
12642
12654
|
}
|
|
12643
12655
|
}
|
|
12644
|
-
setConfig(
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
this.
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
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,
|
|
12651
12667
|
platform: this.platform,
|
|
12652
|
-
user_type: getUserType(
|
|
12668
|
+
user_type: getUserType(email),
|
|
12669
|
+
};
|
|
12670
|
+
mixpanel.track("g_config", eventParams);
|
|
12671
|
+
window.dataLayer.push({
|
|
12672
|
+
event: "g_config",
|
|
12673
|
+
...eventParams,
|
|
12653
12674
|
});
|
|
12654
12675
|
}
|
|
12676
|
+
getLastGConfig() {
|
|
12677
|
+
return this.lastGConfig;
|
|
12678
|
+
}
|
|
12655
12679
|
trackPageView() {
|
|
12656
|
-
|
|
12680
|
+
const eventParams = {
|
|
12657
12681
|
page_title: document.title,
|
|
12658
12682
|
page_location: window.location.href,
|
|
12659
|
-
page_referrer:
|
|
12683
|
+
page_referrer: getReferrer(),
|
|
12684
|
+
};
|
|
12685
|
+
mixpanel.track("page_view", eventParams);
|
|
12686
|
+
window.dataLayer.push({
|
|
12687
|
+
event: "page_view",
|
|
12688
|
+
...eventParams,
|
|
12660
12689
|
});
|
|
12661
12690
|
}
|
|
12662
12691
|
setUser(userId, userParams) {
|