@jitsu/js 1.1.0-canary.388.20230519133920 → 1.1.0-canary.391.20230523080206
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/.turbo/turbo-build.log +95 -95
- package/.turbo/turbo-clean.log +5 -5
- package/dist/analytics-plugin.d.ts +1 -0
- package/dist/jitsu.cjs.js +27 -14
- package/dist/jitsu.es.js +27 -14
- package/dist/web/p.js.txt +27 -14
- package/package.json +2 -2
- package/src/analytics-plugin.ts +4 -3
- package/src/destination-plugins/gtm.ts +20 -10
- package/src/destination-plugins/index.ts +7 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
@jitsu/js:build: cache hit, replaying output [
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
54
|
-
[
|
|
55
|
-
[
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
1
|
+
@jitsu/js:build: cache hit, replaying output [2m70799201810b0c5a[0m
|
|
2
|
+
[36m@jitsu/js:build: [0m
|
|
3
|
+
[36m@jitsu/js:build: [0m> @jitsu/js@0.0.0 build /Users/ildarnurislamov/Projects/onetag/libs/jitsu-js
|
|
4
|
+
[36m@jitsu/js:build: [0m> tsc -p . && rollup -c && cp compiled/src/*.d.ts dist
|
|
5
|
+
[36m@jitsu/js:build: [0m
|
|
6
|
+
[36m@jitsu/js:build: [0m[36m
|
|
7
|
+
[36m@jitsu/js:build: [0m[1m./compiled/src/browser.js[22m → [1mdist/web/p.js.txt[22m...[39m
|
|
8
|
+
[36m@jitsu/js:build: [0m[1m[33m(!) "this" has been rewritten to "undefined"[39m[22m
|
|
9
|
+
[36m@jitsu/js:build: [0m[90mhttps://rollupjs.org/troubleshooting/#error-this-is-undefined[39m
|
|
10
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/analytics-plugin.js[22m
|
|
11
|
+
[36m@jitsu/js:build: [0m[90m1: /* global analytics */
|
|
12
|
+
[36m@jitsu/js:build: [0m2: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
[36m@jitsu/js:build: [0m ^
|
|
14
|
+
[36m@jitsu/js:build: [0m3: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
[36m@jitsu/js:build: [0m4: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
16
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
17
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/tag.js[22m
|
|
18
|
+
[36m@jitsu/js:build: [0m[90m1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
19
|
+
[36m@jitsu/js:build: [0m ^
|
|
20
|
+
[36m@jitsu/js:build: [0m2: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
+
[36m@jitsu/js:build: [0m3: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
22
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
23
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/gtm.js[22m
|
|
24
|
+
[36m@jitsu/js:build: [0m[90m1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
25
|
+
[36m@jitsu/js:build: [0m ^
|
|
26
|
+
[36m@jitsu/js:build: [0m2: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
[36m@jitsu/js:build: [0m3: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
28
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
29
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/logrocket.js[22m
|
|
30
|
+
[36m@jitsu/js:build: [0m[90m1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
31
|
+
[36m@jitsu/js:build: [0m ^
|
|
32
|
+
[36m@jitsu/js:build: [0m2: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
+
[36m@jitsu/js:build: [0m3: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
34
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
35
|
+
[36m@jitsu/js:build: [0m[1m[33m(!) Circular dependencies[39m[22m
|
|
36
|
+
[36m@jitsu/js:build: [0mcompiled/src/index.js -> compiled/src/analytics-plugin.js -> compiled/src/index.js
|
|
37
|
+
[36m@jitsu/js:build: [0mcompiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/tag.js -> compiled/src/destination-plugins/index.js
|
|
38
|
+
[36m@jitsu/js:build: [0mcompiled/src/analytics-plugin.js -> compiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/tag.js -> compiled/src/analytics-plugin.js
|
|
39
|
+
[36m@jitsu/js:build: [0mcompiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/logrocket.js -> compiled/src/destination-plugins/index.js
|
|
40
|
+
[36m@jitsu/js:build: [0mcompiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/gtm.js -> compiled/src/destination-plugins/index.js
|
|
41
|
+
[36m@jitsu/js:build: [0m[1m[33m(!) Use of eval is strongly discouraged[39m[22m
|
|
42
|
+
[36m@jitsu/js:build: [0m[90mhttps://rollupjs.org/troubleshooting/#avoiding-eval[39m
|
|
43
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/tag.js[22m
|
|
44
|
+
[36m@jitsu/js:build: [0m[90m68: })()`;
|
|
45
|
+
[36m@jitsu/js:build: [0m69: try {
|
|
46
|
+
[36m@jitsu/js:build: [0m70: eval(iif);
|
|
47
|
+
[36m@jitsu/js:build: [0m ^
|
|
48
|
+
[36m@jitsu/js:build: [0m71: }
|
|
49
|
+
[36m@jitsu/js:build: [0m72: catch (e) {[39m
|
|
50
|
+
[36m@jitsu/js:build: [0m[32mcreated [1mdist/web/p.js.txt[22m in [1m512ms[22m[39m
|
|
51
|
+
[36m@jitsu/js:build: [0m[36m
|
|
52
|
+
[36m@jitsu/js:build: [0m[1m./compiled/src/index.js, ./compiled/src/jitsu.js, ./compiled/src/analytics-plugin.js[22m → [1mdist/jitsu.es.js, dist/jitsu.cjs.js[22m...[39m
|
|
53
|
+
[36m@jitsu/js:build: [0m[1m[33m(!) "this" has been rewritten to "undefined"[39m[22m
|
|
54
|
+
[36m@jitsu/js:build: [0m[90mhttps://rollupjs.org/troubleshooting/#error-this-is-undefined[39m
|
|
55
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/analytics-plugin.js[22m
|
|
56
|
+
[36m@jitsu/js:build: [0m[90m1: /* global analytics */
|
|
57
|
+
[36m@jitsu/js:build: [0m2: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
58
|
+
[36m@jitsu/js:build: [0m ^
|
|
59
|
+
[36m@jitsu/js:build: [0m3: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
60
|
+
[36m@jitsu/js:build: [0m4: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
61
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
62
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/tag.js[22m
|
|
63
|
+
[36m@jitsu/js:build: [0m[90m1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
64
|
+
[36m@jitsu/js:build: [0m ^
|
|
65
|
+
[36m@jitsu/js:build: [0m2: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
66
|
+
[36m@jitsu/js:build: [0m3: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
67
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
68
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/logrocket.js[22m
|
|
69
|
+
[36m@jitsu/js:build: [0m[90m1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
70
|
+
[36m@jitsu/js:build: [0m ^
|
|
71
|
+
[36m@jitsu/js:build: [0m2: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
72
|
+
[36m@jitsu/js:build: [0m3: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
73
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
74
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/gtm.js[22m
|
|
75
|
+
[36m@jitsu/js:build: [0m[90m1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
76
|
+
[36m@jitsu/js:build: [0m ^
|
|
77
|
+
[36m@jitsu/js:build: [0m2: function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
78
|
+
[36m@jitsu/js:build: [0m3: return new (P || (P = Promise))(function (resolve, reject) {[39m
|
|
79
|
+
[36m@jitsu/js:build: [0m...and 1 other occurrence
|
|
80
|
+
[36m@jitsu/js:build: [0m[1m[33m(!) Circular dependencies[39m[22m
|
|
81
|
+
[36m@jitsu/js:build: [0mcompiled/src/index.js -> compiled/src/analytics-plugin.js -> compiled/src/index.js
|
|
82
|
+
[36m@jitsu/js:build: [0mcompiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/tag.js -> compiled/src/destination-plugins/index.js
|
|
83
|
+
[36m@jitsu/js:build: [0mcompiled/src/analytics-plugin.js -> compiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/tag.js -> compiled/src/analytics-plugin.js
|
|
84
|
+
[36m@jitsu/js:build: [0mcompiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/logrocket.js -> compiled/src/destination-plugins/index.js
|
|
85
|
+
[36m@jitsu/js:build: [0mcompiled/src/destination-plugins/index.js -> compiled/src/destination-plugins/gtm.js -> compiled/src/destination-plugins/index.js
|
|
86
|
+
[36m@jitsu/js:build: [0m[1m[33m(!) Use of eval is strongly discouraged[39m[22m
|
|
87
|
+
[36m@jitsu/js:build: [0m[90mhttps://rollupjs.org/troubleshooting/#avoiding-eval[39m
|
|
88
|
+
[36m@jitsu/js:build: [0m[1mcompiled/src/destination-plugins/tag.js[22m
|
|
89
|
+
[36m@jitsu/js:build: [0m[90m68: })()`;
|
|
90
|
+
[36m@jitsu/js:build: [0m69: try {
|
|
91
|
+
[36m@jitsu/js:build: [0m70: eval(iif);
|
|
92
|
+
[36m@jitsu/js:build: [0m ^
|
|
93
|
+
[36m@jitsu/js:build: [0m71: }
|
|
94
|
+
[36m@jitsu/js:build: [0m72: catch (e) {[39m
|
|
95
|
+
[36m@jitsu/js:build: [0m[32mcreated [1mdist/jitsu.es.js, dist/jitsu.cjs.js[22m in [1m353ms[22m[39m
|
package/.turbo/turbo-clean.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@jitsu/js:clean: cache hit, replaying output [
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
1
|
+
@jitsu/js:clean: cache hit, replaying output [2m96c25c4b05e1319b[0m
|
|
2
|
+
[36m@jitsu/js:clean: [0m
|
|
3
|
+
[36m@jitsu/js:clean: [0m> @jitsu/js@0.0.0 clean /Users/ildarnurislamov/Projects/onetag/libs/jitsu-js
|
|
4
|
+
[36m@jitsu/js:clean: [0m> rm -rf ./dist
|
|
5
|
+
[36m@jitsu/js:clean: [0m
|
package/dist/jitsu.cjs.js
CHANGED
|
@@ -284,6 +284,7 @@ const defaultScriptSrc = "https://www.googletagmanager.com/gtag/js";
|
|
|
284
284
|
const gtmPlugin = {
|
|
285
285
|
id: "gtm",
|
|
286
286
|
handle(config, payload) {
|
|
287
|
+
var _a, _b;
|
|
287
288
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
288
289
|
if (!applyFilters(payload, config)) {
|
|
289
290
|
return;
|
|
@@ -292,8 +293,13 @@ const gtmPlugin = {
|
|
|
292
293
|
const dataLayer = window[config.dataLayerName || "dataLayer"];
|
|
293
294
|
switch (payload.type) {
|
|
294
295
|
case "page":
|
|
295
|
-
const { properties: pageProperties } = payload;
|
|
296
|
-
const pageEvent =
|
|
296
|
+
const { properties: pageProperties, context } = payload;
|
|
297
|
+
const pageEvent = {
|
|
298
|
+
event: "page_view",
|
|
299
|
+
url: pageProperties.url,
|
|
300
|
+
title: pageProperties.title,
|
|
301
|
+
referer: (_b = (_a = context === null || context === void 0 ? void 0 : context.page) === null || _a === void 0 ? void 0 : _a.referrer) !== null && _b !== void 0 ? _b : "",
|
|
302
|
+
};
|
|
297
303
|
if (config.debug) {
|
|
298
304
|
console.log("gtag push", pageEvent);
|
|
299
305
|
}
|
|
@@ -302,21 +308,26 @@ const gtmPlugin = {
|
|
|
302
308
|
case "track":
|
|
303
309
|
const { properties: trackProperties } = payload;
|
|
304
310
|
const trackEvent = Object.assign({ event: payload.event }, trackProperties);
|
|
311
|
+
if (payload.userId) {
|
|
312
|
+
trackEvent.userId = payload.userId;
|
|
313
|
+
}
|
|
314
|
+
if (payload.anonymousId) {
|
|
315
|
+
trackEvent.anonymousId = payload.anonymousId;
|
|
316
|
+
}
|
|
305
317
|
if (config.debug) {
|
|
306
318
|
console.log("gtag push", trackEvent);
|
|
307
319
|
}
|
|
308
320
|
dataLayer.push(trackEvent);
|
|
309
321
|
break;
|
|
310
322
|
case "identify":
|
|
311
|
-
const {
|
|
312
|
-
const
|
|
313
|
-
if (userId) {
|
|
314
|
-
|
|
323
|
+
const { traits } = payload;
|
|
324
|
+
const identifyEvent = Object.assign({ event: "identify" }, traits);
|
|
325
|
+
if (payload.userId) {
|
|
326
|
+
identifyEvent.userId = payload.userId;
|
|
315
327
|
}
|
|
316
|
-
if (anonymousId) {
|
|
317
|
-
|
|
328
|
+
if (payload.anonymousId) {
|
|
329
|
+
identifyEvent.anonymousId = payload.anonymousId;
|
|
318
330
|
}
|
|
319
|
-
const identifyEvent = { event: "identify", user: user };
|
|
320
331
|
if (config.debug) {
|
|
321
332
|
console.log("gtag push", identifyEvent);
|
|
322
333
|
}
|
|
@@ -367,9 +378,11 @@ function satisfyFilter(filter, subject) {
|
|
|
367
378
|
return filter === "*" || filter.toLowerCase().trim() === (subject || "").trim().toLowerCase();
|
|
368
379
|
}
|
|
369
380
|
function applyFilters(event, creds) {
|
|
370
|
-
const { hosts =
|
|
371
|
-
|
|
372
|
-
|
|
381
|
+
const { hosts = "*", events = "*" } = creds;
|
|
382
|
+
const eventsArray = events.split("\n");
|
|
383
|
+
return (!!hosts.split("\n").find(hostFilter => { var _a; return satisfyFilter(hostFilter, (_a = event.context) === null || _a === void 0 ? void 0 : _a.host); }) &&
|
|
384
|
+
(!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.type)) ||
|
|
385
|
+
!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.event))));
|
|
373
386
|
}
|
|
374
387
|
const internalDestinationPlugins = {
|
|
375
388
|
[tagPlugin.id]: tagPlugin,
|
|
@@ -642,12 +655,12 @@ function processDestinations(destinations, method, event, debug, analyticsInstan
|
|
|
642
655
|
return __awaiter(this, void 0, void 0, function* () {
|
|
643
656
|
const promises = [];
|
|
644
657
|
for (const destination of destinations) {
|
|
658
|
+
const credentials = Object.assign(Object.assign({}, destination.credentials), destination.options);
|
|
645
659
|
if (destination.deviceOptions.type === "internal-plugin") {
|
|
646
660
|
const plugin = internalDestinationPlugins[destination.deviceOptions.name];
|
|
647
661
|
if (plugin) {
|
|
648
662
|
try {
|
|
649
663
|
//to support old versions, where credentials were stored in root
|
|
650
|
-
const credentials = destination.credentials || destination;
|
|
651
664
|
promises.push(plugin.handle(credentials, event));
|
|
652
665
|
}
|
|
653
666
|
catch (e) {
|
|
@@ -667,7 +680,7 @@ function processDestinations(destinations, method, event, debug, analyticsInstan
|
|
|
667
680
|
else {
|
|
668
681
|
let pluginInstance;
|
|
669
682
|
try {
|
|
670
|
-
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(
|
|
683
|
+
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(credentials);
|
|
671
684
|
}
|
|
672
685
|
catch (e) {
|
|
673
686
|
console.warn(`[JITSU] Error creating plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e === null || e === void 0 ? void 0 : e.message}`, e);
|
package/dist/jitsu.es.js
CHANGED
|
@@ -282,6 +282,7 @@ const defaultScriptSrc = "https://www.googletagmanager.com/gtag/js";
|
|
|
282
282
|
const gtmPlugin = {
|
|
283
283
|
id: "gtm",
|
|
284
284
|
handle(config, payload) {
|
|
285
|
+
var _a, _b;
|
|
285
286
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
286
287
|
if (!applyFilters(payload, config)) {
|
|
287
288
|
return;
|
|
@@ -290,8 +291,13 @@ const gtmPlugin = {
|
|
|
290
291
|
const dataLayer = window[config.dataLayerName || "dataLayer"];
|
|
291
292
|
switch (payload.type) {
|
|
292
293
|
case "page":
|
|
293
|
-
const { properties: pageProperties } = payload;
|
|
294
|
-
const pageEvent =
|
|
294
|
+
const { properties: pageProperties, context } = payload;
|
|
295
|
+
const pageEvent = {
|
|
296
|
+
event: "page_view",
|
|
297
|
+
url: pageProperties.url,
|
|
298
|
+
title: pageProperties.title,
|
|
299
|
+
referer: (_b = (_a = context === null || context === void 0 ? void 0 : context.page) === null || _a === void 0 ? void 0 : _a.referrer) !== null && _b !== void 0 ? _b : "",
|
|
300
|
+
};
|
|
295
301
|
if (config.debug) {
|
|
296
302
|
console.log("gtag push", pageEvent);
|
|
297
303
|
}
|
|
@@ -300,21 +306,26 @@ const gtmPlugin = {
|
|
|
300
306
|
case "track":
|
|
301
307
|
const { properties: trackProperties } = payload;
|
|
302
308
|
const trackEvent = Object.assign({ event: payload.event }, trackProperties);
|
|
309
|
+
if (payload.userId) {
|
|
310
|
+
trackEvent.userId = payload.userId;
|
|
311
|
+
}
|
|
312
|
+
if (payload.anonymousId) {
|
|
313
|
+
trackEvent.anonymousId = payload.anonymousId;
|
|
314
|
+
}
|
|
303
315
|
if (config.debug) {
|
|
304
316
|
console.log("gtag push", trackEvent);
|
|
305
317
|
}
|
|
306
318
|
dataLayer.push(trackEvent);
|
|
307
319
|
break;
|
|
308
320
|
case "identify":
|
|
309
|
-
const {
|
|
310
|
-
const
|
|
311
|
-
if (userId) {
|
|
312
|
-
|
|
321
|
+
const { traits } = payload;
|
|
322
|
+
const identifyEvent = Object.assign({ event: "identify" }, traits);
|
|
323
|
+
if (payload.userId) {
|
|
324
|
+
identifyEvent.userId = payload.userId;
|
|
313
325
|
}
|
|
314
|
-
if (anonymousId) {
|
|
315
|
-
|
|
326
|
+
if (payload.anonymousId) {
|
|
327
|
+
identifyEvent.anonymousId = payload.anonymousId;
|
|
316
328
|
}
|
|
317
|
-
const identifyEvent = { event: "identify", user: user };
|
|
318
329
|
if (config.debug) {
|
|
319
330
|
console.log("gtag push", identifyEvent);
|
|
320
331
|
}
|
|
@@ -365,9 +376,11 @@ function satisfyFilter(filter, subject) {
|
|
|
365
376
|
return filter === "*" || filter.toLowerCase().trim() === (subject || "").trim().toLowerCase();
|
|
366
377
|
}
|
|
367
378
|
function applyFilters(event, creds) {
|
|
368
|
-
const { hosts =
|
|
369
|
-
|
|
370
|
-
|
|
379
|
+
const { hosts = "*", events = "*" } = creds;
|
|
380
|
+
const eventsArray = events.split("\n");
|
|
381
|
+
return (!!hosts.split("\n").find(hostFilter => { var _a; return satisfyFilter(hostFilter, (_a = event.context) === null || _a === void 0 ? void 0 : _a.host); }) &&
|
|
382
|
+
(!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.type)) ||
|
|
383
|
+
!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.event))));
|
|
371
384
|
}
|
|
372
385
|
const internalDestinationPlugins = {
|
|
373
386
|
[tagPlugin.id]: tagPlugin,
|
|
@@ -640,12 +653,12 @@ function processDestinations(destinations, method, event, debug, analyticsInstan
|
|
|
640
653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
641
654
|
const promises = [];
|
|
642
655
|
for (const destination of destinations) {
|
|
656
|
+
const credentials = Object.assign(Object.assign({}, destination.credentials), destination.options);
|
|
643
657
|
if (destination.deviceOptions.type === "internal-plugin") {
|
|
644
658
|
const plugin = internalDestinationPlugins[destination.deviceOptions.name];
|
|
645
659
|
if (plugin) {
|
|
646
660
|
try {
|
|
647
661
|
//to support old versions, where credentials were stored in root
|
|
648
|
-
const credentials = destination.credentials || destination;
|
|
649
662
|
promises.push(plugin.handle(credentials, event));
|
|
650
663
|
}
|
|
651
664
|
catch (e) {
|
|
@@ -665,7 +678,7 @@ function processDestinations(destinations, method, event, debug, analyticsInstan
|
|
|
665
678
|
else {
|
|
666
679
|
let pluginInstance;
|
|
667
680
|
try {
|
|
668
|
-
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(
|
|
681
|
+
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(credentials);
|
|
669
682
|
}
|
|
670
683
|
catch (e) {
|
|
671
684
|
console.warn(`[JITSU] Error creating plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e === null || e === void 0 ? void 0 : e.message}`, e);
|
package/dist/web/p.js.txt
CHANGED
|
@@ -285,6 +285,7 @@
|
|
|
285
285
|
const gtmPlugin = {
|
|
286
286
|
id: "gtm",
|
|
287
287
|
handle(config, payload) {
|
|
288
|
+
var _a, _b;
|
|
288
289
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
289
290
|
if (!applyFilters(payload, config)) {
|
|
290
291
|
return;
|
|
@@ -293,8 +294,13 @@
|
|
|
293
294
|
const dataLayer = window[config.dataLayerName || "dataLayer"];
|
|
294
295
|
switch (payload.type) {
|
|
295
296
|
case "page":
|
|
296
|
-
const { properties: pageProperties } = payload;
|
|
297
|
-
const pageEvent =
|
|
297
|
+
const { properties: pageProperties, context } = payload;
|
|
298
|
+
const pageEvent = {
|
|
299
|
+
event: "page_view",
|
|
300
|
+
url: pageProperties.url,
|
|
301
|
+
title: pageProperties.title,
|
|
302
|
+
referer: (_b = (_a = context === null || context === void 0 ? void 0 : context.page) === null || _a === void 0 ? void 0 : _a.referrer) !== null && _b !== void 0 ? _b : "",
|
|
303
|
+
};
|
|
298
304
|
if (config.debug) {
|
|
299
305
|
console.log("gtag push", pageEvent);
|
|
300
306
|
}
|
|
@@ -303,21 +309,26 @@
|
|
|
303
309
|
case "track":
|
|
304
310
|
const { properties: trackProperties } = payload;
|
|
305
311
|
const trackEvent = Object.assign({ event: payload.event }, trackProperties);
|
|
312
|
+
if (payload.userId) {
|
|
313
|
+
trackEvent.userId = payload.userId;
|
|
314
|
+
}
|
|
315
|
+
if (payload.anonymousId) {
|
|
316
|
+
trackEvent.anonymousId = payload.anonymousId;
|
|
317
|
+
}
|
|
306
318
|
if (config.debug) {
|
|
307
319
|
console.log("gtag push", trackEvent);
|
|
308
320
|
}
|
|
309
321
|
dataLayer.push(trackEvent);
|
|
310
322
|
break;
|
|
311
323
|
case "identify":
|
|
312
|
-
const {
|
|
313
|
-
const
|
|
314
|
-
if (userId) {
|
|
315
|
-
|
|
324
|
+
const { traits } = payload;
|
|
325
|
+
const identifyEvent = Object.assign({ event: "identify" }, traits);
|
|
326
|
+
if (payload.userId) {
|
|
327
|
+
identifyEvent.userId = payload.userId;
|
|
316
328
|
}
|
|
317
|
-
if (anonymousId) {
|
|
318
|
-
|
|
329
|
+
if (payload.anonymousId) {
|
|
330
|
+
identifyEvent.anonymousId = payload.anonymousId;
|
|
319
331
|
}
|
|
320
|
-
const identifyEvent = { event: "identify", user: user };
|
|
321
332
|
if (config.debug) {
|
|
322
333
|
console.log("gtag push", identifyEvent);
|
|
323
334
|
}
|
|
@@ -368,9 +379,11 @@
|
|
|
368
379
|
return filter === "*" || filter.toLowerCase().trim() === (subject || "").trim().toLowerCase();
|
|
369
380
|
}
|
|
370
381
|
function applyFilters(event, creds) {
|
|
371
|
-
const { hosts =
|
|
372
|
-
|
|
373
|
-
|
|
382
|
+
const { hosts = "*", events = "*" } = creds;
|
|
383
|
+
const eventsArray = events.split("\n");
|
|
384
|
+
return (!!hosts.split("\n").find(hostFilter => { var _a; return satisfyFilter(hostFilter, (_a = event.context) === null || _a === void 0 ? void 0 : _a.host); }) &&
|
|
385
|
+
(!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.type)) ||
|
|
386
|
+
!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.event))));
|
|
374
387
|
}
|
|
375
388
|
const internalDestinationPlugins = {
|
|
376
389
|
[tagPlugin.id]: tagPlugin,
|
|
@@ -643,12 +656,12 @@
|
|
|
643
656
|
return __awaiter(this, void 0, void 0, function* () {
|
|
644
657
|
const promises = [];
|
|
645
658
|
for (const destination of destinations) {
|
|
659
|
+
const credentials = Object.assign(Object.assign({}, destination.credentials), destination.options);
|
|
646
660
|
if (destination.deviceOptions.type === "internal-plugin") {
|
|
647
661
|
const plugin = internalDestinationPlugins[destination.deviceOptions.name];
|
|
648
662
|
if (plugin) {
|
|
649
663
|
try {
|
|
650
664
|
//to support old versions, where credentials were stored in root
|
|
651
|
-
const credentials = destination.credentials || destination;
|
|
652
665
|
promises.push(plugin.handle(credentials, event));
|
|
653
666
|
}
|
|
654
667
|
catch (e) {
|
|
@@ -668,7 +681,7 @@
|
|
|
668
681
|
else {
|
|
669
682
|
let pluginInstance;
|
|
670
683
|
try {
|
|
671
|
-
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(
|
|
684
|
+
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(credentials);
|
|
672
685
|
}
|
|
673
686
|
catch (e) {
|
|
674
687
|
console.warn(`[JITSU] Error creating plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e === null || e === void 0 ? void 0 : e.message}`, e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jitsu/js",
|
|
3
|
-
"version": "1.1.0-canary.
|
|
3
|
+
"version": "1.1.0-canary.391.20230523080206",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Jitsu Dev Team <dev@jitsu.com>",
|
|
6
6
|
"main": "dist/jitsu.cjs.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"rollup": "^3.2.5",
|
|
35
35
|
"ts-jest": "29.0.5",
|
|
36
36
|
"typescript": "^4.9.5",
|
|
37
|
-
"@jitsu/protocols": "1.1.0-canary.
|
|
37
|
+
"@jitsu/protocols": "1.1.0-canary.391.20230523080206"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"analytics": "^0.8.1"
|
package/src/analytics-plugin.ts
CHANGED
|
@@ -293,6 +293,7 @@ export type DestinationDescriptor = {
|
|
|
293
293
|
id: string;
|
|
294
294
|
destinationType: string;
|
|
295
295
|
credentials: any;
|
|
296
|
+
options: any;
|
|
296
297
|
deviceOptions: DeviceOptions;
|
|
297
298
|
};
|
|
298
299
|
export type AnalyticsPluginDescriptor = {
|
|
@@ -317,12 +318,12 @@ async function processDestinations(
|
|
|
317
318
|
) {
|
|
318
319
|
const promises: Promise<any>[] = [];
|
|
319
320
|
for (const destination of destinations) {
|
|
321
|
+
const credentials = { ...destination.credentials, ...destination.options };
|
|
322
|
+
|
|
320
323
|
if (destination.deviceOptions.type === "internal-plugin") {
|
|
321
324
|
const plugin = internalDestinationPlugins[destination.deviceOptions.name];
|
|
322
325
|
if (plugin) {
|
|
323
326
|
try {
|
|
324
|
-
//to support old versions, where credentials were stored in root
|
|
325
|
-
const credentials = destination.credentials || destination;
|
|
326
327
|
promises.push(plugin.handle(credentials, event));
|
|
327
328
|
} catch (e) {
|
|
328
329
|
console.warn(
|
|
@@ -345,7 +346,7 @@ async function processDestinations(
|
|
|
345
346
|
} else {
|
|
346
347
|
let pluginInstance: any;
|
|
347
348
|
try {
|
|
348
|
-
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(
|
|
349
|
+
pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(credentials);
|
|
349
350
|
} catch (e) {
|
|
350
351
|
console.warn(
|
|
351
352
|
`[JITSU] Error creating plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e?.message}`,
|
|
@@ -25,8 +25,13 @@ export const gtmPlugin: InternalPlugin<GtmDestinationCredentials> = {
|
|
|
25
25
|
|
|
26
26
|
switch (payload.type) {
|
|
27
27
|
case "page":
|
|
28
|
-
const { properties: pageProperties } = payload;
|
|
29
|
-
const pageEvent = {
|
|
28
|
+
const { properties: pageProperties, context } = payload;
|
|
29
|
+
const pageEvent = {
|
|
30
|
+
event: "page_view",
|
|
31
|
+
url: pageProperties.url,
|
|
32
|
+
title: pageProperties.title,
|
|
33
|
+
referer: context?.page?.referrer ?? "",
|
|
34
|
+
};
|
|
30
35
|
if (config.debug) {
|
|
31
36
|
console.log("gtag push", pageEvent);
|
|
32
37
|
}
|
|
@@ -34,22 +39,27 @@ export const gtmPlugin: InternalPlugin<GtmDestinationCredentials> = {
|
|
|
34
39
|
break;
|
|
35
40
|
case "track":
|
|
36
41
|
const { properties: trackProperties } = payload;
|
|
37
|
-
const trackEvent = { event: payload.event, ...trackProperties };
|
|
42
|
+
const trackEvent: any = { event: payload.event, ...trackProperties };
|
|
43
|
+
if (payload.userId) {
|
|
44
|
+
trackEvent.userId = payload.userId;
|
|
45
|
+
}
|
|
46
|
+
if (payload.anonymousId) {
|
|
47
|
+
trackEvent.anonymousId = payload.anonymousId;
|
|
48
|
+
}
|
|
38
49
|
if (config.debug) {
|
|
39
50
|
console.log("gtag push", trackEvent);
|
|
40
51
|
}
|
|
41
52
|
dataLayer.push(trackEvent);
|
|
42
53
|
break;
|
|
43
54
|
case "identify":
|
|
44
|
-
const {
|
|
45
|
-
const
|
|
46
|
-
if (userId) {
|
|
47
|
-
|
|
55
|
+
const { traits } = payload;
|
|
56
|
+
const identifyEvent: any = { event: "identify", ...traits };
|
|
57
|
+
if (payload.userId) {
|
|
58
|
+
identifyEvent.userId = payload.userId;
|
|
48
59
|
}
|
|
49
|
-
if (anonymousId) {
|
|
50
|
-
|
|
60
|
+
if (payload.anonymousId) {
|
|
61
|
+
identifyEvent.anonymousId = payload.anonymousId;
|
|
51
62
|
}
|
|
52
|
-
const identifyEvent = { event: "identify", user: user };
|
|
53
63
|
if (config.debug) {
|
|
54
64
|
console.log("gtag push", identifyEvent);
|
|
55
65
|
}
|
|
@@ -9,8 +9,8 @@ export type InternalPlugin<T> = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export type CommonDestinationCredentials = {
|
|
12
|
-
hosts?: string
|
|
13
|
-
events?: string
|
|
12
|
+
hosts?: string;
|
|
13
|
+
events?: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export function satisfyFilter(filter: string, subject: string | undefined): boolean {
|
|
@@ -18,10 +18,12 @@ export function satisfyFilter(filter: string, subject: string | undefined): bool
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function applyFilters(event: AnalyticsClientEvent, creds: CommonDestinationCredentials): boolean {
|
|
21
|
-
const { hosts =
|
|
21
|
+
const { hosts = "*", events = "*" } = creds;
|
|
22
|
+
const eventsArray = events.split("\n");
|
|
22
23
|
return (
|
|
23
|
-
!!hosts.find(hostFilter => satisfyFilter(hostFilter, event.context?.host)) &&
|
|
24
|
-
!!
|
|
24
|
+
!!hosts.split("\n").find(hostFilter => satisfyFilter(hostFilter, event.context?.host)) &&
|
|
25
|
+
(!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.type)) ||
|
|
26
|
+
!!eventsArray.find(eventFilter => satisfyFilter(eventFilter, event.event)))
|
|
25
27
|
);
|
|
26
28
|
}
|
|
27
29
|
|