rozmova-analytics 1.0.17 → 1.0.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/analytics.d.ts +5 -14
- package/dist/constants.d.ts +0 -1
- package/dist/helpers.d.ts +1 -0
- package/dist/index.d.ts +16 -12
- package/dist/index.esm.js +112 -105
- package/dist/index.js +112 -105
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/analytics.d.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import { AnalyticsCommonParams, EventParams } from "./types.js";
|
|
2
1
|
export declare function insertCustomerIOScript(): void;
|
|
3
|
-
export declare const setUserId: (userId: string) => void;
|
|
4
2
|
export declare const generateUserId: () => string;
|
|
5
3
|
export declare const getUserId: () => string;
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare const init: (locale?: string, platform?: string) => void;
|
|
12
|
-
export declare const trackEvent: (eventName: string, properties?: EventParams) => void;
|
|
13
|
-
export declare const setUser: (userId: string, userParams: {
|
|
14
|
-
email: string;
|
|
15
|
-
name: string;
|
|
16
|
-
}) => void;
|
|
17
|
-
export declare const resetUser: () => void;
|
|
4
|
+
export declare const getCurrentParams: () => {
|
|
5
|
+
referrer: any;
|
|
6
|
+
search_query: any;
|
|
7
|
+
landing_page_url: any;
|
|
8
|
+
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -5,5 +5,4 @@ export declare const GOOGLE_ANALYTICS_ID = "G-9PCTLFE0F6";
|
|
|
5
5
|
export declare const GA_SERVER_CONTAINER_URL = "https://tagging.clearly.help";
|
|
6
6
|
export declare const MIXPANEL_TOKEN = "9d4cb3d213e5aee689ea01dd68ad65ad";
|
|
7
7
|
export declare const CUSTOMER_IO_WRITE_KEY = "e6d009719c77519432c3";
|
|
8
|
-
export declare const IS_CLEARLY: boolean;
|
|
9
8
|
export declare const SUPPORTED_LANGUAGES: string[];
|
package/dist/helpers.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export declare const getReferrer: () => string | null;
|
|
|
10
10
|
export declare function getSearchQueryFromReferrer(): string | null;
|
|
11
11
|
export declare const getGAClientId: () => string;
|
|
12
12
|
export declare function getGASessionId(): string | null;
|
|
13
|
+
export declare const isClearly: () => boolean;
|
|
13
14
|
export declare const getLocaleFromURL: () => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { AnalyticsCommonParams, EventParams } from "./types";
|
|
2
|
+
declare class Analytics {
|
|
3
|
+
private initialized;
|
|
4
|
+
private locale;
|
|
5
|
+
private platform;
|
|
6
|
+
init(locale?: string, platform?: string): void;
|
|
7
|
+
trackEvent(eventName: string, properties?: EventParams): void;
|
|
8
|
+
setUser(userId: string, userParams: {
|
|
8
9
|
email: string;
|
|
9
10
|
name: string;
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
setLocale
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
}): void;
|
|
12
|
+
getCommonParams(): AnalyticsCommonParams;
|
|
13
|
+
setLocale(newLocale: string): void;
|
|
14
|
+
resetUser(): void;
|
|
15
|
+
getUserId: () => string;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: Analytics;
|
|
18
|
+
export default _default;
|
package/dist/index.esm.js
CHANGED
|
@@ -30,7 +30,7 @@ var defaultConverter = {
|
|
|
30
30
|
|
|
31
31
|
/* eslint-disable no-var */
|
|
32
32
|
|
|
33
|
-
function init
|
|
33
|
+
function init (converter, defaultAttributes) {
|
|
34
34
|
function set (name, value, attributes) {
|
|
35
35
|
if (typeof document === 'undefined') {
|
|
36
36
|
return
|
|
@@ -115,10 +115,10 @@ function init$1 (converter, defaultAttributes) {
|
|
|
115
115
|
);
|
|
116
116
|
},
|
|
117
117
|
withAttributes: function (attributes) {
|
|
118
|
-
return init
|
|
118
|
+
return init(this.converter, assign({}, this.attributes, attributes))
|
|
119
119
|
},
|
|
120
120
|
withConverter: function (converter) {
|
|
121
|
-
return init
|
|
121
|
+
return init(assign({}, this.converter, converter), this.attributes)
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
{
|
|
@@ -128,7 +128,7 @@ function init$1 (converter, defaultAttributes) {
|
|
|
128
128
|
)
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
var api = init
|
|
131
|
+
var api = init(defaultConverter, { path: '/' });
|
|
132
132
|
|
|
133
133
|
var NodeType;
|
|
134
134
|
(function (NodeType) {
|
|
@@ -11945,7 +11945,6 @@ const GOOGLE_ANALYTICS_ID = "G-9PCTLFE0F6";
|
|
|
11945
11945
|
const GA_SERVER_CONTAINER_URL = "https://tagging.clearly.help";
|
|
11946
11946
|
const MIXPANEL_TOKEN = "9d4cb3d213e5aee689ea01dd68ad65ad";
|
|
11947
11947
|
const CUSTOMER_IO_WRITE_KEY = "e6d009719c77519432c3";
|
|
11948
|
-
const IS_CLEARLY = window.location.hostname.includes("clearly");
|
|
11949
11948
|
const SUPPORTED_LANGUAGES = ["en", "uk", "pl", "es", "ru"];
|
|
11950
11949
|
|
|
11951
11950
|
const setQueryParam = (name, value) => {
|
|
@@ -12078,13 +12077,14 @@ function getGASessionId() {
|
|
|
12078
12077
|
return parts[0];
|
|
12079
12078
|
return null;
|
|
12080
12079
|
}
|
|
12080
|
+
const isClearly = () => window.location.hostname.includes("clearly");
|
|
12081
12081
|
const getLocaleFromURL = () => {
|
|
12082
12082
|
const pathname = window.location.pathname;
|
|
12083
12083
|
const lng = pathname.split("/")[1];
|
|
12084
12084
|
if (SUPPORTED_LANGUAGES.includes(lng))
|
|
12085
12085
|
return lng;
|
|
12086
12086
|
else
|
|
12087
|
-
return
|
|
12087
|
+
return isClearly() ? "en" : "uk";
|
|
12088
12088
|
};
|
|
12089
12089
|
|
|
12090
12090
|
function insertCustomerIOScript() {
|
|
@@ -12169,108 +12169,115 @@ const getCurrentParams = () => {
|
|
|
12169
12169
|
});
|
|
12170
12170
|
return currentParams;
|
|
12171
12171
|
};
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
};
|
|
12200
|
-
|
|
12201
|
-
insertCustomerIOScript();
|
|
12202
|
-
const userId = getUserId();
|
|
12203
|
-
if (isMetaBrowser()) {
|
|
12204
|
-
setQueryParam(USER_ID_KEY, userId);
|
|
12205
|
-
}
|
|
12206
|
-
mixpanel.init(MIXPANEL_TOKEN, {
|
|
12207
|
-
debug: false,
|
|
12208
|
-
track_pageview: "url-with-path",
|
|
12209
|
-
persistence: "cookie",
|
|
12210
|
-
});
|
|
12211
|
-
if (locale)
|
|
12212
|
-
setLocale(locale);
|
|
12213
|
-
if (platform)
|
|
12214
|
-
setPlatform(platform);
|
|
12215
|
-
const userProperties = getCommonParams();
|
|
12216
|
-
mixpanel.register(userProperties);
|
|
12217
|
-
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12218
|
-
user_properties: userProperties,
|
|
12219
|
-
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12220
|
-
});
|
|
12221
|
-
};
|
|
12222
|
-
const trackEvent = (eventName, properties = {}) => {
|
|
12223
|
-
const commonParams = getCommonParams();
|
|
12224
|
-
const params = { ...commonParams, ...properties };
|
|
12225
|
-
// Mixpanel
|
|
12226
|
-
try {
|
|
12227
|
-
mixpanel.track(eventName, params);
|
|
12228
|
-
}
|
|
12229
|
-
catch (e) {
|
|
12230
|
-
console.log(e);
|
|
12172
|
+
|
|
12173
|
+
class Analytics {
|
|
12174
|
+
initialized = false;
|
|
12175
|
+
locale = getLocaleFromURL();
|
|
12176
|
+
platform = "web";
|
|
12177
|
+
init(locale, platform) {
|
|
12178
|
+
if (this.initialized)
|
|
12179
|
+
return;
|
|
12180
|
+
insertCustomerIOScript();
|
|
12181
|
+
const userId = getUserId();
|
|
12182
|
+
if (isMetaBrowser()) {
|
|
12183
|
+
setQueryParam(USER_ID_KEY, userId);
|
|
12184
|
+
}
|
|
12185
|
+
mixpanel.init(MIXPANEL_TOKEN, {
|
|
12186
|
+
debug: false,
|
|
12187
|
+
track_pageview: "url-with-path",
|
|
12188
|
+
persistence: "cookie",
|
|
12189
|
+
});
|
|
12190
|
+
if (locale)
|
|
12191
|
+
this.locale = locale;
|
|
12192
|
+
if (platform)
|
|
12193
|
+
this.platform = platform;
|
|
12194
|
+
const userProperties = this.getCommonParams();
|
|
12195
|
+
mixpanel.register(userProperties);
|
|
12196
|
+
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12197
|
+
user_properties: userProperties,
|
|
12198
|
+
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12199
|
+
});
|
|
12200
|
+
this.initialized = true;
|
|
12231
12201
|
}
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12202
|
+
trackEvent(eventName, properties) {
|
|
12203
|
+
if (!this.initialized) {
|
|
12204
|
+
console.warn("Analytics is not initialized.");
|
|
12205
|
+
return;
|
|
12206
|
+
}
|
|
12207
|
+
const commonParams = this.getCommonParams();
|
|
12208
|
+
const params = { ...commonParams, ...properties };
|
|
12209
|
+
// Mixpanel
|
|
12210
|
+
try {
|
|
12211
|
+
mixpanel.track(eventName, params);
|
|
12212
|
+
}
|
|
12213
|
+
catch (e) {
|
|
12214
|
+
console.log(e);
|
|
12215
|
+
}
|
|
12216
|
+
// GA
|
|
12217
|
+
try {
|
|
12218
|
+
gtag("event", eventName, params);
|
|
12219
|
+
}
|
|
12220
|
+
catch (e) {
|
|
12221
|
+
console.log(e);
|
|
12222
|
+
}
|
|
12223
|
+
// Customer.io
|
|
12224
|
+
try {
|
|
12225
|
+
window.analytics.track(eventName, params);
|
|
12226
|
+
}
|
|
12227
|
+
catch (e) {
|
|
12228
|
+
console.log(e);
|
|
12229
|
+
}
|
|
12235
12230
|
}
|
|
12236
|
-
|
|
12237
|
-
|
|
12231
|
+
setUser(userId, userParams) {
|
|
12232
|
+
if (!this.initialized) {
|
|
12233
|
+
console.warn("Analytics is not initialized.");
|
|
12234
|
+
return;
|
|
12235
|
+
}
|
|
12236
|
+
const { email, name } = userParams;
|
|
12237
|
+
mixpanel.identify(userId);
|
|
12238
|
+
mixpanel.people.set({ $email: email, name });
|
|
12239
|
+
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12240
|
+
user_properties: this.getCommonParams(),
|
|
12241
|
+
user_id: userId,
|
|
12242
|
+
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12243
|
+
});
|
|
12244
|
+
window.analytics.identify(userId, userParams);
|
|
12245
|
+
}
|
|
12246
|
+
getCommonParams() {
|
|
12247
|
+
const persistedParams = getCurrentParams();
|
|
12248
|
+
return {
|
|
12249
|
+
...persistedParams,
|
|
12250
|
+
fbc: api.get("_fbc"),
|
|
12251
|
+
fbp: api.get("_fbp"),
|
|
12252
|
+
session_id: getGASessionId(),
|
|
12253
|
+
user_pseudo_id: getGAClientId(),
|
|
12254
|
+
rid: getUserId(),
|
|
12255
|
+
funnel_name: api.get("funnel_name"),
|
|
12256
|
+
funnel_type: api.get("funnel_type"),
|
|
12257
|
+
language: getBrowserLanguage(),
|
|
12258
|
+
platform: this.platform,
|
|
12259
|
+
url: window.location.href,
|
|
12260
|
+
device: detectDeviceType(),
|
|
12261
|
+
browser: detectBrowser(),
|
|
12262
|
+
system: detectOS(),
|
|
12263
|
+
locale: this.locale,
|
|
12264
|
+
};
|
|
12238
12265
|
}
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
window.analytics.track(eventName, params);
|
|
12266
|
+
setLocale(newLocale) {
|
|
12267
|
+
this.locale = newLocale;
|
|
12242
12268
|
}
|
|
12243
|
-
|
|
12244
|
-
|
|
12269
|
+
resetUser() {
|
|
12270
|
+
if (!this.initialized) {
|
|
12271
|
+
console.warn("Analytics is not initialized.");
|
|
12272
|
+
return;
|
|
12273
|
+
}
|
|
12274
|
+
mixpanel.reset();
|
|
12275
|
+
window.analytics.reset();
|
|
12276
|
+
generateUserId();
|
|
12277
|
+
this.init();
|
|
12245
12278
|
}
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
mixpanel.identify(userId);
|
|
12250
|
-
mixpanel.people.set({ $email: email, name });
|
|
12251
|
-
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12252
|
-
user_properties: getCommonParams(),
|
|
12253
|
-
user_id: userId,
|
|
12254
|
-
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12255
|
-
});
|
|
12256
|
-
window.analytics.identify(userId, userParams);
|
|
12257
|
-
};
|
|
12258
|
-
const resetUser = () => {
|
|
12259
|
-
mixpanel.reset();
|
|
12260
|
-
window.analytics.reset();
|
|
12261
|
-
generateUserId();
|
|
12262
|
-
init();
|
|
12263
|
-
};
|
|
12264
|
-
|
|
12265
|
-
const Analytics = {
|
|
12266
|
-
getUserId,
|
|
12267
|
-
generateUserId,
|
|
12268
|
-
init,
|
|
12269
|
-
getCommonParams,
|
|
12270
|
-
trackEvent,
|
|
12271
|
-
setUser,
|
|
12272
|
-
resetUser,
|
|
12273
|
-
setLocale,
|
|
12274
|
-
};
|
|
12279
|
+
getUserId = getUserId;
|
|
12280
|
+
}
|
|
12281
|
+
var index = new Analytics();
|
|
12275
12282
|
|
|
12276
|
-
export {
|
|
12283
|
+
export { index as default };
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var defaultConverter = {
|
|
|
32
32
|
|
|
33
33
|
/* eslint-disable no-var */
|
|
34
34
|
|
|
35
|
-
function init
|
|
35
|
+
function init (converter, defaultAttributes) {
|
|
36
36
|
function set (name, value, attributes) {
|
|
37
37
|
if (typeof document === 'undefined') {
|
|
38
38
|
return
|
|
@@ -117,10 +117,10 @@ function init$1 (converter, defaultAttributes) {
|
|
|
117
117
|
);
|
|
118
118
|
},
|
|
119
119
|
withAttributes: function (attributes) {
|
|
120
|
-
return init
|
|
120
|
+
return init(this.converter, assign({}, this.attributes, attributes))
|
|
121
121
|
},
|
|
122
122
|
withConverter: function (converter) {
|
|
123
|
-
return init
|
|
123
|
+
return init(assign({}, this.converter, converter), this.attributes)
|
|
124
124
|
}
|
|
125
125
|
},
|
|
126
126
|
{
|
|
@@ -130,7 +130,7 @@ function init$1 (converter, defaultAttributes) {
|
|
|
130
130
|
)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
var api = init
|
|
133
|
+
var api = init(defaultConverter, { path: '/' });
|
|
134
134
|
|
|
135
135
|
var NodeType;
|
|
136
136
|
(function (NodeType) {
|
|
@@ -11947,7 +11947,6 @@ const GOOGLE_ANALYTICS_ID = "G-9PCTLFE0F6";
|
|
|
11947
11947
|
const GA_SERVER_CONTAINER_URL = "https://tagging.clearly.help";
|
|
11948
11948
|
const MIXPANEL_TOKEN = "9d4cb3d213e5aee689ea01dd68ad65ad";
|
|
11949
11949
|
const CUSTOMER_IO_WRITE_KEY = "e6d009719c77519432c3";
|
|
11950
|
-
const IS_CLEARLY = window.location.hostname.includes("clearly");
|
|
11951
11950
|
const SUPPORTED_LANGUAGES = ["en", "uk", "pl", "es", "ru"];
|
|
11952
11951
|
|
|
11953
11952
|
const setQueryParam = (name, value) => {
|
|
@@ -12080,13 +12079,14 @@ function getGASessionId() {
|
|
|
12080
12079
|
return parts[0];
|
|
12081
12080
|
return null;
|
|
12082
12081
|
}
|
|
12082
|
+
const isClearly = () => window.location.hostname.includes("clearly");
|
|
12083
12083
|
const getLocaleFromURL = () => {
|
|
12084
12084
|
const pathname = window.location.pathname;
|
|
12085
12085
|
const lng = pathname.split("/")[1];
|
|
12086
12086
|
if (SUPPORTED_LANGUAGES.includes(lng))
|
|
12087
12087
|
return lng;
|
|
12088
12088
|
else
|
|
12089
|
-
return
|
|
12089
|
+
return isClearly() ? "en" : "uk";
|
|
12090
12090
|
};
|
|
12091
12091
|
|
|
12092
12092
|
function insertCustomerIOScript() {
|
|
@@ -12171,108 +12171,115 @@ const getCurrentParams = () => {
|
|
|
12171
12171
|
});
|
|
12172
12172
|
return currentParams;
|
|
12173
12173
|
};
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
};
|
|
12202
|
-
|
|
12203
|
-
insertCustomerIOScript();
|
|
12204
|
-
const userId = getUserId();
|
|
12205
|
-
if (isMetaBrowser()) {
|
|
12206
|
-
setQueryParam(USER_ID_KEY, userId);
|
|
12207
|
-
}
|
|
12208
|
-
mixpanel.init(MIXPANEL_TOKEN, {
|
|
12209
|
-
debug: false,
|
|
12210
|
-
track_pageview: "url-with-path",
|
|
12211
|
-
persistence: "cookie",
|
|
12212
|
-
});
|
|
12213
|
-
if (locale)
|
|
12214
|
-
setLocale(locale);
|
|
12215
|
-
if (platform)
|
|
12216
|
-
setPlatform(platform);
|
|
12217
|
-
const userProperties = getCommonParams();
|
|
12218
|
-
mixpanel.register(userProperties);
|
|
12219
|
-
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12220
|
-
user_properties: userProperties,
|
|
12221
|
-
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12222
|
-
});
|
|
12223
|
-
};
|
|
12224
|
-
const trackEvent = (eventName, properties = {}) => {
|
|
12225
|
-
const commonParams = getCommonParams();
|
|
12226
|
-
const params = { ...commonParams, ...properties };
|
|
12227
|
-
// Mixpanel
|
|
12228
|
-
try {
|
|
12229
|
-
mixpanel.track(eventName, params);
|
|
12230
|
-
}
|
|
12231
|
-
catch (e) {
|
|
12232
|
-
console.log(e);
|
|
12174
|
+
|
|
12175
|
+
class Analytics {
|
|
12176
|
+
initialized = false;
|
|
12177
|
+
locale = getLocaleFromURL();
|
|
12178
|
+
platform = "web";
|
|
12179
|
+
init(locale, platform) {
|
|
12180
|
+
if (this.initialized)
|
|
12181
|
+
return;
|
|
12182
|
+
insertCustomerIOScript();
|
|
12183
|
+
const userId = getUserId();
|
|
12184
|
+
if (isMetaBrowser()) {
|
|
12185
|
+
setQueryParam(USER_ID_KEY, userId);
|
|
12186
|
+
}
|
|
12187
|
+
mixpanel.init(MIXPANEL_TOKEN, {
|
|
12188
|
+
debug: false,
|
|
12189
|
+
track_pageview: "url-with-path",
|
|
12190
|
+
persistence: "cookie",
|
|
12191
|
+
});
|
|
12192
|
+
if (locale)
|
|
12193
|
+
this.locale = locale;
|
|
12194
|
+
if (platform)
|
|
12195
|
+
this.platform = platform;
|
|
12196
|
+
const userProperties = this.getCommonParams();
|
|
12197
|
+
mixpanel.register(userProperties);
|
|
12198
|
+
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12199
|
+
user_properties: userProperties,
|
|
12200
|
+
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12201
|
+
});
|
|
12202
|
+
this.initialized = true;
|
|
12233
12203
|
}
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12204
|
+
trackEvent(eventName, properties) {
|
|
12205
|
+
if (!this.initialized) {
|
|
12206
|
+
console.warn("Analytics is not initialized.");
|
|
12207
|
+
return;
|
|
12208
|
+
}
|
|
12209
|
+
const commonParams = this.getCommonParams();
|
|
12210
|
+
const params = { ...commonParams, ...properties };
|
|
12211
|
+
// Mixpanel
|
|
12212
|
+
try {
|
|
12213
|
+
mixpanel.track(eventName, params);
|
|
12214
|
+
}
|
|
12215
|
+
catch (e) {
|
|
12216
|
+
console.log(e);
|
|
12217
|
+
}
|
|
12218
|
+
// GA
|
|
12219
|
+
try {
|
|
12220
|
+
gtag("event", eventName, params);
|
|
12221
|
+
}
|
|
12222
|
+
catch (e) {
|
|
12223
|
+
console.log(e);
|
|
12224
|
+
}
|
|
12225
|
+
// Customer.io
|
|
12226
|
+
try {
|
|
12227
|
+
window.analytics.track(eventName, params);
|
|
12228
|
+
}
|
|
12229
|
+
catch (e) {
|
|
12230
|
+
console.log(e);
|
|
12231
|
+
}
|
|
12237
12232
|
}
|
|
12238
|
-
|
|
12239
|
-
|
|
12233
|
+
setUser(userId, userParams) {
|
|
12234
|
+
if (!this.initialized) {
|
|
12235
|
+
console.warn("Analytics is not initialized.");
|
|
12236
|
+
return;
|
|
12237
|
+
}
|
|
12238
|
+
const { email, name } = userParams;
|
|
12239
|
+
mixpanel.identify(userId);
|
|
12240
|
+
mixpanel.people.set({ $email: email, name });
|
|
12241
|
+
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12242
|
+
user_properties: this.getCommonParams(),
|
|
12243
|
+
user_id: userId,
|
|
12244
|
+
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12245
|
+
});
|
|
12246
|
+
window.analytics.identify(userId, userParams);
|
|
12247
|
+
}
|
|
12248
|
+
getCommonParams() {
|
|
12249
|
+
const persistedParams = getCurrentParams();
|
|
12250
|
+
return {
|
|
12251
|
+
...persistedParams,
|
|
12252
|
+
fbc: api.get("_fbc"),
|
|
12253
|
+
fbp: api.get("_fbp"),
|
|
12254
|
+
session_id: getGASessionId(),
|
|
12255
|
+
user_pseudo_id: getGAClientId(),
|
|
12256
|
+
rid: getUserId(),
|
|
12257
|
+
funnel_name: api.get("funnel_name"),
|
|
12258
|
+
funnel_type: api.get("funnel_type"),
|
|
12259
|
+
language: getBrowserLanguage(),
|
|
12260
|
+
platform: this.platform,
|
|
12261
|
+
url: window.location.href,
|
|
12262
|
+
device: detectDeviceType(),
|
|
12263
|
+
browser: detectBrowser(),
|
|
12264
|
+
system: detectOS(),
|
|
12265
|
+
locale: this.locale,
|
|
12266
|
+
};
|
|
12240
12267
|
}
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
window.analytics.track(eventName, params);
|
|
12268
|
+
setLocale(newLocale) {
|
|
12269
|
+
this.locale = newLocale;
|
|
12244
12270
|
}
|
|
12245
|
-
|
|
12246
|
-
|
|
12271
|
+
resetUser() {
|
|
12272
|
+
if (!this.initialized) {
|
|
12273
|
+
console.warn("Analytics is not initialized.");
|
|
12274
|
+
return;
|
|
12275
|
+
}
|
|
12276
|
+
mixpanel.reset();
|
|
12277
|
+
window.analytics.reset();
|
|
12278
|
+
generateUserId();
|
|
12279
|
+
this.init();
|
|
12247
12280
|
}
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
mixpanel.identify(userId);
|
|
12252
|
-
mixpanel.people.set({ $email: email, name });
|
|
12253
|
-
gtag("config", GOOGLE_ANALYTICS_ID, {
|
|
12254
|
-
user_properties: getCommonParams(),
|
|
12255
|
-
user_id: userId,
|
|
12256
|
-
server_container_url: GA_SERVER_CONTAINER_URL,
|
|
12257
|
-
});
|
|
12258
|
-
window.analytics.identify(userId, userParams);
|
|
12259
|
-
};
|
|
12260
|
-
const resetUser = () => {
|
|
12261
|
-
mixpanel.reset();
|
|
12262
|
-
window.analytics.reset();
|
|
12263
|
-
generateUserId();
|
|
12264
|
-
init();
|
|
12265
|
-
};
|
|
12266
|
-
|
|
12267
|
-
const Analytics = {
|
|
12268
|
-
getUserId,
|
|
12269
|
-
generateUserId,
|
|
12270
|
-
init,
|
|
12271
|
-
getCommonParams,
|
|
12272
|
-
trackEvent,
|
|
12273
|
-
setUser,
|
|
12274
|
-
resetUser,
|
|
12275
|
-
setLocale,
|
|
12276
|
-
};
|
|
12281
|
+
getUserId = getUserId;
|
|
12282
|
+
}
|
|
12283
|
+
var index = new Analytics();
|
|
12277
12284
|
|
|
12278
|
-
module.exports =
|
|
12285
|
+
module.exports = index;
|