@walkeros/web-destination-gtag 0.4.0 → 0.4.2
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/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.js +32 -26
- package/dist/examples/index.mjs +32 -26
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/examples/index.js
CHANGED
|
@@ -86,38 +86,44 @@ __export(events_exports, {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
// ../../../core/dist/index.mjs
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
var e = Object.defineProperty;
|
|
90
|
+
var c = {};
|
|
91
|
+
((t, n) => {
|
|
92
|
+
for (var r in n) e(t, r, { get: n[r], enumerable: true });
|
|
93
|
+
})(c, { Level: () => a });
|
|
94
|
+
var a = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.INFO = 1] = "INFO", e2[e2.DEBUG = 2] = "DEBUG", e2))(a || {});
|
|
95
|
+
var k = { merge: true, shallow: true, extend: true };
|
|
96
|
+
function E(e2, t = {}, n = {}) {
|
|
97
|
+
n = { ...k, ...n };
|
|
98
|
+
const r = Object.entries(t).reduce((t2, [r2, o]) => {
|
|
99
|
+
const i = e2[r2];
|
|
100
|
+
return n.merge && Array.isArray(i) && Array.isArray(o) ? t2[r2] = o.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...i]) : (n.extend || r2 in e2) && (t2[r2] = o), t2;
|
|
95
101
|
}, {});
|
|
96
|
-
return n.shallow ? { ...
|
|
102
|
+
return n.shallow ? { ...e2, ...r } : (Object.assign(e2, r), e2);
|
|
97
103
|
}
|
|
98
|
-
function
|
|
99
|
-
return Array.isArray(
|
|
104
|
+
function $(e2) {
|
|
105
|
+
return Array.isArray(e2);
|
|
100
106
|
}
|
|
101
|
-
function
|
|
102
|
-
return "object" == typeof
|
|
107
|
+
function T(e2) {
|
|
108
|
+
return "object" == typeof e2 && null !== e2 && !$(e2) && "[object Object]" === Object.prototype.toString.call(e2);
|
|
103
109
|
}
|
|
104
|
-
function
|
|
110
|
+
function z(e2 = {}) {
|
|
105
111
|
var _a;
|
|
106
|
-
const t =
|
|
107
|
-
if (
|
|
108
|
-
const [t2, n2] = (_a =
|
|
109
|
-
t2 && n2 && (
|
|
112
|
+
const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", r = e2.count || 1, o = E({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${r}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: r, version: { source: "0.4.2", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
|
|
113
|
+
if (e2.name) {
|
|
114
|
+
const [t2, n2] = (_a = e2.name.split(" ")) != null ? _a : [];
|
|
115
|
+
t2 && n2 && (o.entity = t2, o.action = n2);
|
|
110
116
|
}
|
|
111
|
-
return
|
|
117
|
+
return o;
|
|
112
118
|
}
|
|
113
|
-
function
|
|
114
|
-
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0),
|
|
115
|
-
return
|
|
119
|
+
function B(e2 = "entity action", t = {}) {
|
|
120
|
+
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, o = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
|
|
121
|
+
return z({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...r.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r.data.price + o.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.elbwalker.com/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t, name: e2 });
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
// src/examples/events.ts
|
|
119
125
|
function ga4Purchase() {
|
|
120
|
-
const event =
|
|
126
|
+
const event = B("order complete");
|
|
121
127
|
return [
|
|
122
128
|
"event",
|
|
123
129
|
"purchase",
|
|
@@ -137,7 +143,7 @@ function ga4Purchase() {
|
|
|
137
143
|
];
|
|
138
144
|
}
|
|
139
145
|
function ga4AddToCart() {
|
|
140
|
-
const event =
|
|
146
|
+
const event = B("product add");
|
|
141
147
|
return [
|
|
142
148
|
"event",
|
|
143
149
|
"add_to_cart",
|
|
@@ -156,7 +162,7 @@ function ga4AddToCart() {
|
|
|
156
162
|
];
|
|
157
163
|
}
|
|
158
164
|
function adsConversion() {
|
|
159
|
-
const event =
|
|
165
|
+
const event = B("order complete");
|
|
160
166
|
return [
|
|
161
167
|
"event",
|
|
162
168
|
"conversion",
|
|
@@ -169,7 +175,7 @@ function adsConversion() {
|
|
|
169
175
|
];
|
|
170
176
|
}
|
|
171
177
|
function gtmEvent() {
|
|
172
|
-
const event =
|
|
178
|
+
const event = B("product view");
|
|
173
179
|
return {
|
|
174
180
|
event: "product_view",
|
|
175
181
|
product_id: event.data.id,
|
|
@@ -208,7 +214,7 @@ var ga4Purchase2 = {
|
|
|
208
214
|
loop: [
|
|
209
215
|
"nested",
|
|
210
216
|
{
|
|
211
|
-
condition: (entity) =>
|
|
217
|
+
condition: (entity) => T(entity) && entity.entity === "product",
|
|
212
218
|
map: {
|
|
213
219
|
item_id: "data.id",
|
|
214
220
|
item_name: "data.name",
|
|
@@ -295,7 +301,7 @@ var combinedPurchase = {
|
|
|
295
301
|
loop: [
|
|
296
302
|
"nested",
|
|
297
303
|
{
|
|
298
|
-
condition: (entity) =>
|
|
304
|
+
condition: (entity) => T(entity) && entity.entity === "product",
|
|
299
305
|
map: {
|
|
300
306
|
item_id: "data.id",
|
|
301
307
|
item_name: "data.name",
|
package/dist/examples/index.mjs
CHANGED
|
@@ -64,38 +64,44 @@ __export(events_exports, {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
// ../../../core/dist/index.mjs
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
var e = Object.defineProperty;
|
|
68
|
+
var c = {};
|
|
69
|
+
((t, n) => {
|
|
70
|
+
for (var r in n) e(t, r, { get: n[r], enumerable: true });
|
|
71
|
+
})(c, { Level: () => a });
|
|
72
|
+
var a = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.INFO = 1] = "INFO", e2[e2.DEBUG = 2] = "DEBUG", e2))(a || {});
|
|
73
|
+
var k = { merge: true, shallow: true, extend: true };
|
|
74
|
+
function E(e2, t = {}, n = {}) {
|
|
75
|
+
n = { ...k, ...n };
|
|
76
|
+
const r = Object.entries(t).reduce((t2, [r2, o]) => {
|
|
77
|
+
const i = e2[r2];
|
|
78
|
+
return n.merge && Array.isArray(i) && Array.isArray(o) ? t2[r2] = o.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...i]) : (n.extend || r2 in e2) && (t2[r2] = o), t2;
|
|
73
79
|
}, {});
|
|
74
|
-
return n.shallow ? { ...
|
|
80
|
+
return n.shallow ? { ...e2, ...r } : (Object.assign(e2, r), e2);
|
|
75
81
|
}
|
|
76
|
-
function
|
|
77
|
-
return Array.isArray(
|
|
82
|
+
function $(e2) {
|
|
83
|
+
return Array.isArray(e2);
|
|
78
84
|
}
|
|
79
|
-
function
|
|
80
|
-
return "object" == typeof
|
|
85
|
+
function T(e2) {
|
|
86
|
+
return "object" == typeof e2 && null !== e2 && !$(e2) && "[object Object]" === Object.prototype.toString.call(e2);
|
|
81
87
|
}
|
|
82
|
-
function
|
|
88
|
+
function z(e2 = {}) {
|
|
83
89
|
var _a;
|
|
84
|
-
const t =
|
|
85
|
-
if (
|
|
86
|
-
const [t2, n2] = (_a =
|
|
87
|
-
t2 && n2 && (
|
|
90
|
+
const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", r = e2.count || 1, o = E({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${r}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: r, version: { source: "0.4.2", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
|
|
91
|
+
if (e2.name) {
|
|
92
|
+
const [t2, n2] = (_a = e2.name.split(" ")) != null ? _a : [];
|
|
93
|
+
t2 && n2 && (o.entity = t2, o.action = n2);
|
|
88
94
|
}
|
|
89
|
-
return
|
|
95
|
+
return o;
|
|
90
96
|
}
|
|
91
|
-
function
|
|
92
|
-
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0),
|
|
93
|
-
return
|
|
97
|
+
function B(e2 = "entity action", t = {}) {
|
|
98
|
+
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, o = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
|
|
99
|
+
return z({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...r.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r.data.price + o.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.elbwalker.com/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t, name: e2 });
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
// src/examples/events.ts
|
|
97
103
|
function ga4Purchase() {
|
|
98
|
-
const event =
|
|
104
|
+
const event = B("order complete");
|
|
99
105
|
return [
|
|
100
106
|
"event",
|
|
101
107
|
"purchase",
|
|
@@ -115,7 +121,7 @@ function ga4Purchase() {
|
|
|
115
121
|
];
|
|
116
122
|
}
|
|
117
123
|
function ga4AddToCart() {
|
|
118
|
-
const event =
|
|
124
|
+
const event = B("product add");
|
|
119
125
|
return [
|
|
120
126
|
"event",
|
|
121
127
|
"add_to_cart",
|
|
@@ -134,7 +140,7 @@ function ga4AddToCart() {
|
|
|
134
140
|
];
|
|
135
141
|
}
|
|
136
142
|
function adsConversion() {
|
|
137
|
-
const event =
|
|
143
|
+
const event = B("order complete");
|
|
138
144
|
return [
|
|
139
145
|
"event",
|
|
140
146
|
"conversion",
|
|
@@ -147,7 +153,7 @@ function adsConversion() {
|
|
|
147
153
|
];
|
|
148
154
|
}
|
|
149
155
|
function gtmEvent() {
|
|
150
|
-
const event =
|
|
156
|
+
const event = B("product view");
|
|
151
157
|
return {
|
|
152
158
|
event: "product_view",
|
|
153
159
|
product_id: event.data.id,
|
|
@@ -186,7 +192,7 @@ var ga4Purchase2 = {
|
|
|
186
192
|
loop: [
|
|
187
193
|
"nested",
|
|
188
194
|
{
|
|
189
|
-
condition: (entity) =>
|
|
195
|
+
condition: (entity) => T(entity) && entity.entity === "product",
|
|
190
196
|
map: {
|
|
191
197
|
item_id: "data.id",
|
|
192
198
|
item_name: "data.name",
|
|
@@ -273,7 +279,7 @@ var combinedPurchase = {
|
|
|
273
279
|
loop: [
|
|
274
280
|
"nested",
|
|
275
281
|
{
|
|
276
|
-
condition: (entity) =>
|
|
282
|
+
condition: (entity) => T(entity) && entity.entity === "product",
|
|
277
283
|
map: {
|
|
278
284
|
item_id: "data.id",
|
|
279
285
|
item_name: "data.name",
|
package/dist/index.browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Destination=(()=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r={};((n,e)=>{for(var o in e)t(n,o,{get:e[o],enumerable:!0})})(r,{DestinationGtag:()=>
|
|
1
|
+
"use strict";var Destination=(()=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r={};((n,e)=>{for(var o in e)t(n,o,{get:e[o],enumerable:!0})})(r,{DestinationGtag:()=>L,default:()=>S,destinationGtag:()=>N,resetConsentState:()=>k});var a=new Set;function i(t,n="https://www.googletagmanager.com/gtag/js?id=",e=globalThis.document){if(a.has(t))return;const o=e.createElement("script");o.src=n+t,e.head.appendChild(o),a.add(t)}function c(t){const n=t;return n.dataLayer=n.dataLayer||[],n.gtag||(n.gtag=function(){n.dataLayer.push(arguments)}),n.gtag}var s=Object.defineProperty;((t,n)=>{for(var e in n)s(t,e,{get:n[e],enumerable:!0})})({},{Level:()=>d});var u,d=((u=d||{})[u.ERROR=0]="ERROR",u[u.INFO=1]="INFO",u[u.DEBUG=2]="DEBUG",u),l={merge:!0,shallow:!0,extend:!0};function g(t,n={},e={}){e={...l,...e};const o=Object.entries(n).reduce((n,[o,r])=>{const a=t[o];return e.merge&&Array.isArray(a)&&Array.isArray(r)?n[o]=r.reduce((t,n)=>t.includes(n)?t:[...t,n],[...a]):(e.extend||o in t)&&(n[o]=r),n},{});return e.shallow?{...t,...o}:(Object.assign(t,o),t)}function f(t){return Array.isArray(t)}function m(t){return void 0!==t}function v(t){return"object"==typeof t&&null!==t&&!f(t)&&"[object Object]"===Object.prototype.toString.call(t)}function w(t){return"string"==typeof t}function y(t,n="",e){const o=n.split(".");let r=t;for(let t=0;t<o.length;t++){const n=o[t];if("*"===n&&f(r)){const n=o.slice(t+1).join("."),a=[];for(const t of r){const o=y(t,n,e);a.push(o)}return a}if(r=r instanceof Object?r[n]:void 0,!r)break}return m(r)?r:e}function p(t){return function(t){return"boolean"==typeof t}(t)||w(t)||function(t){return"number"==typeof t&&!Number.isNaN(t)}(t)||!m(t)||f(t)&&t.every(p)||v(t)&&Object.values(t).every(p)}function h(t){return p(t)?t:void 0}function b(t,n,e){return async function(...o){try{return await t(...o)}catch(t){if(!n)return;return await n(t)}finally{await(null==e?void 0:e())}}}async function j(t,n={},e={}){var o;if(!m(t))return;const r=v(t)&&t.consent||e.consent||(null==(o=e.collector)?void 0:o.consent),a=f(n)?n:[n];for(const n of a){const o=await b(O)(t,n,{...e,consent:r});if(m(o))return o}}async function O(t,n,e={}){const{collector:o,consent:r}=e;return(f(n)?n:[n]).reduce(async(n,a)=>{const i=await n;if(i)return i;const c=w(a)?{key:a}:a;if(!Object.keys(c).length)return;const{condition:s,consent:u,fn:d,key:l,loop:g,map:v,set:p,validate:I,value:_}=c;if(s&&!await b(s)(t,a,o))return;if(u&&!function(t,n={},e={}){const o={...n,...e},r={};let a=void 0===t;return Object.keys(o).forEach(n=>{o[n]&&(r[n]=!0,t&&t[n]&&(a=!0))}),!!a&&r}(u,r))return _;let E=m(_)?_:t;if(d&&(E=await b(d)(t,a,e)),l&&(E=y(t,l,_)),g){const[n,o]=g,r="this"===n?[t]:await j(t,n,e);f(r)&&(E=(await Promise.all(r.map(t=>j(t,o,e)))).filter(m))}else v?E=await Object.entries(v).reduce(async(n,[o,r])=>{const a=await n,i=await j(t,r,e);return m(i)&&(a[o]=i),a},Promise.resolve({})):p&&(E=await Promise.all(p.map(n=>O(t,n,e))));I&&!await b(I)(E)&&(E=void 0);const A=h(E);return m(A)?A:h(_)},Promise.resolve(void 0))}function I(t){return{window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...t}}async function _(t,n,e,o,r){const a=v(n)?n:{},i=e.data?await j(t,e.data,{collector:r}):{},c=(null==o?void 0:o.data)?await j(t,o.data,{collector:r}):{},s=v(i)?i:{},u=v(c)?c:{};return g(g(a,s),u)}function E(t,n,e={},o,r,a){const{window:i}=I(r);n.measurementId||a.throw("Config settings ga4.measurementId missing");const c=v(o)?o:{},s=function(t,n){const e={};return n.includes("all")&&(n=["context","data","event","globals","source","user","version"]),n.forEach(n=>{let o=t[n]||{};"event"==n&&(o={id:t.id,timing:t.timing,trigger:t.trigger,entity:t.entity,action:t.action,group:t.group,count:t.count}),Object.entries(o).forEach(([t,o])=>{"context"==n&&(o=o[0]),e[`${n}_${t}`]=o})}),e}(t,e.include||n.include||["data"]),u={...s,...c};let d=t.name;!1!==n.snakeCase&&(d=function(t,n=!0){return n?t.replace(/\s+/g,"_").toLowerCase():t}(d)),u.send_to=n.measurementId,n.debug&&(u.debug_mode=!0);(0,i.gtag)("event",d,u)}var A="dataLayer";function C(t,n,e,o){const{window:r,document:a}=I(e),{containerId:i,dataLayer:c,domain:s}=t,u=c||A;u===A?r.dataLayer=r.dataLayer||[]:r[u]=r[u]||[];r[u].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),n&&i&&function(t,n,e,o=globalThis.document){const r=e!=A?"&l="+e:"",a=o.createElement("script");a.src=n+t+r,o.head.appendChild(a)}(i,s||"https://www.googletagmanager.com/gtm.js?id=",u,a)}var L={},P=!1;function k(){P=!1}var D,R={marketing:["ad_storage","ad_user_data","ad_personalization"],functional:["analytics_storage"]},N={type:"google-gtag",config:{settings:{}},init({config:t,env:n,logger:e}){const{settings:o={},loadScript:r}=t,{ga4:a,ads:s,gtm:u}=o;return(null==a?void 0:a.measurementId)||(null==s?void 0:s.conversionId)||(null==u?void 0:u.containerId)||e.throw("Config settings missing. Set ga4.measurementId, ads.conversionId, or gtm.containerId"),(null==a?void 0:a.measurementId)&&function(t,n,e,o){const{window:r,document:a}=I(e),{measurementId:s,transport_url:u,server_container_url:d,pageview:l}=t;s||o.throw("Config settings ga4.measurementId missing"),n&&i(s,void 0,a),c(r);const g={};u&&(g.transport_url=u),d&&(g.server_container_url=d),!1===l&&(g.send_page_view=!1);const f=r.gtag;f("js",new Date),f("config",s,g)}(a,r,n,e),(null==s?void 0:s.conversionId)&&function(t,n,e,o){const{window:r,document:a}=I(e),{conversionId:s}=t;s||o.throw("Config settings ads.conversionId missing"),t.currency||(t.currency="EUR"),n&&i(s,void 0,a),c(r);const u=r.gtag;u("js",new Date),u("config",s)}(s,r,n,e),(null==u?void 0:u.containerId)&&C(u,r,n),t},async push(t,{config:n,mapping:e={},data:o,env:r,collector:a,logger:i}){const{settings:c={}}=n,{ga4:s,ads:u,gtm:d}=c,l=e.settings||{},g=await _(t,o,n,s,a),f=await _(t,o,n,u,a),m=await _(t,o,n,d,a);(null==s?void 0:s.measurementId)&&E(t,s,l.ga4,g,r,i),(null==u?void 0:u.conversionId)&&e.name&&function(t,n,e={},o,r,a,i){const{conversionId:c,currency:s}=n,u=v(o)?o:{},d=e.label||r;d||i.throw("Config mapping ads.label missing");const l={send_to:`${c}/${d}`,currency:s||"EUR",...u},{window:g}=I(a);(0,g.gtag)("event","conversion",l)}(0,u,l.ads,f,e.name,r,i),(null==d?void 0:d.containerId)&&function(t,n,e={},o,r){const{window:a}=I(r),i={event:t.name};a.dataLayer.push({...i,...v(o)?o:t})}(t,0,l.gtm,m,r)},on(t,n){var e;if("consent"!==t||!n)return;const o=n,r=(null==(e=this.config)?void 0:e.settings)||{},{como:a=!0}=r;if(!a)return;const{window:i}=I(this.env),s=c(i);if(!s)return;const u=!0===a?R:a;if(!P){const t=new Set;if(Object.values(u).forEach(n=>{(Array.isArray(n)?n:[n]).forEach(n=>t.add(n))}),t.size>0){const n={};t.forEach(t=>{n[t]="denied"}),s("consent","default",n)}P=!0}const d={};Object.entries(o).forEach(([t,n])=>{const e=u[t];if(!e)return;const o=Array.isArray(e)?e:[e],r=n?"granted":"denied";o.forEach(t=>{d[t]=r})}),0!==Object.keys(d).length&&s("consent","update",d)}},S=N;return D=r,((r,a,i,c)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let s of e(a))o.call(r,s)||s===i||t(r,s,{get:()=>a[s],enumerable:!(c=n(a,s))||c.enumerable});return r})(t({},"__esModule",{value:!0}),D)})();
|
package/dist/index.d.mts
CHANGED
|
@@ -28,7 +28,7 @@ type ConsentMode = false | true | ConsentMapping;
|
|
|
28
28
|
interface ConsentMapping {
|
|
29
29
|
[walkerOSConsentGroup: string]: string | string[];
|
|
30
30
|
}
|
|
31
|
-
type Types = Destination$1.Types<Settings, Mapping, Env>;
|
|
31
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
32
32
|
type Destination = DestinationWeb.Destination<Types>;
|
|
33
33
|
type Config = DestinationWeb.Config<Types>;
|
|
34
34
|
interface BaseSettings {
|
|
@@ -40,6 +40,7 @@ interface Settings {
|
|
|
40
40
|
ads?: AdsSettings;
|
|
41
41
|
gtm?: GTMSettings;
|
|
42
42
|
}
|
|
43
|
+
type InitSettings = Partial<Settings>;
|
|
43
44
|
interface GA4Settings extends BaseSettings {
|
|
44
45
|
measurementId: string;
|
|
45
46
|
debug?: boolean;
|
|
@@ -90,6 +91,7 @@ type index_GA4Settings = GA4Settings;
|
|
|
90
91
|
type index_GTMMapping = GTMMapping;
|
|
91
92
|
type index_GTMSettings = GTMSettings;
|
|
92
93
|
type index_Include = Include;
|
|
94
|
+
type index_InitSettings = InitSettings;
|
|
93
95
|
type index_Mapping = Mapping;
|
|
94
96
|
type index_Param = Param;
|
|
95
97
|
type index_Parameters = Parameters;
|
|
@@ -98,7 +100,7 @@ type index_Rules = Rules;
|
|
|
98
100
|
type index_Settings = Settings;
|
|
99
101
|
type index_Types = Types;
|
|
100
102
|
declare namespace index {
|
|
101
|
-
export type { index_AdsMapping as AdsMapping, index_AdsSettings as AdsSettings, index_BaseSettings as BaseSettings, index_Config as Config, index_ConsentMapping as ConsentMapping, index_ConsentMode as ConsentMode, index_Destination as Destination, index_Env as Env, index_GA4Mapping as GA4Mapping, index_GA4Settings as GA4Settings, index_GTMMapping as GTMMapping, index_GTMSettings as GTMSettings, index_Include as Include, index_Mapping as Mapping, index_Param as Param, index_Parameters as Parameters, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
|
|
103
|
+
export type { index_AdsMapping as AdsMapping, index_AdsSettings as AdsSettings, index_BaseSettings as BaseSettings, index_Config as Config, index_ConsentMapping as ConsentMapping, index_ConsentMode as ConsentMode, index_Destination as Destination, index_Env as Env, index_GA4Mapping as GA4Mapping, index_GA4Settings as GA4Settings, index_GTMMapping as GTMMapping, index_GTMSettings as GTMSettings, index_Include as Include, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Param as Param, index_Parameters as Parameters, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
declare function resetConsentState(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ type ConsentMode = false | true | ConsentMapping;
|
|
|
28
28
|
interface ConsentMapping {
|
|
29
29
|
[walkerOSConsentGroup: string]: string | string[];
|
|
30
30
|
}
|
|
31
|
-
type Types = Destination$1.Types<Settings, Mapping, Env>;
|
|
31
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
32
32
|
type Destination = DestinationWeb.Destination<Types>;
|
|
33
33
|
type Config = DestinationWeb.Config<Types>;
|
|
34
34
|
interface BaseSettings {
|
|
@@ -40,6 +40,7 @@ interface Settings {
|
|
|
40
40
|
ads?: AdsSettings;
|
|
41
41
|
gtm?: GTMSettings;
|
|
42
42
|
}
|
|
43
|
+
type InitSettings = Partial<Settings>;
|
|
43
44
|
interface GA4Settings extends BaseSettings {
|
|
44
45
|
measurementId: string;
|
|
45
46
|
debug?: boolean;
|
|
@@ -90,6 +91,7 @@ type index_GA4Settings = GA4Settings;
|
|
|
90
91
|
type index_GTMMapping = GTMMapping;
|
|
91
92
|
type index_GTMSettings = GTMSettings;
|
|
92
93
|
type index_Include = Include;
|
|
94
|
+
type index_InitSettings = InitSettings;
|
|
93
95
|
type index_Mapping = Mapping;
|
|
94
96
|
type index_Param = Param;
|
|
95
97
|
type index_Parameters = Parameters;
|
|
@@ -98,7 +100,7 @@ type index_Rules = Rules;
|
|
|
98
100
|
type index_Settings = Settings;
|
|
99
101
|
type index_Types = Types;
|
|
100
102
|
declare namespace index {
|
|
101
|
-
export type { index_AdsMapping as AdsMapping, index_AdsSettings as AdsSettings, index_BaseSettings as BaseSettings, index_Config as Config, index_ConsentMapping as ConsentMapping, index_ConsentMode as ConsentMode, index_Destination as Destination, index_Env as Env, index_GA4Mapping as GA4Mapping, index_GA4Settings as GA4Settings, index_GTMMapping as GTMMapping, index_GTMSettings as GTMSettings, index_Include as Include, index_Mapping as Mapping, index_Param as Param, index_Parameters as Parameters, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
|
|
103
|
+
export type { index_AdsMapping as AdsMapping, index_AdsSettings as AdsSettings, index_BaseSettings as BaseSettings, index_Config as Config, index_ConsentMapping as ConsentMapping, index_ConsentMode as ConsentMode, index_Destination as Destination, index_Env as Env, index_GA4Mapping as GA4Mapping, index_GA4Settings as GA4Settings, index_GTMMapping as GTMMapping, index_GTMSettings as GTMSettings, index_Include as Include, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Param as Param, index_Parameters as Parameters, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
declare function resetConsentState(): void;
|
package/dist/index.es5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)})}}function _define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_define_property(e,t,r[t])})}return e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var Destination=function(){var e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://www.googletagmanager.com/gtag/js?id=",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:globalThis.document;if(!m.has(e)){var n=r.createElement("script");n.src=t+e,r.head.appendChild(n),m.add(e)}},t=function(e){var t=e;return t.dataLayer=t.dataLayer||[],t.gtag||(t.gtag=function(){t.dataLayer.push(arguments)}),t.gtag},r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r=_object_spread({},w,r);var n=Object.entries(t).reduce(function(t,n){var o=_sliced_to_array(n,2),a=o[0],i=o[1],c=e[a];return r.merge&&Array.isArray(c)&&Array.isArray(i)?t[a]=i.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(r.extend||a in e)&&(t[a]=i),t},{});return r.shallow?_object_spread({},e,n):(Object.assign(e,n),e)},n=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},a=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!n(e)&&"[object Object]"===Object.prototype.toString.call(e)},i=function(e){return"string"==typeof e},c=function(e){return O(e)?e:void 0},u=function(e,t,r){return function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return _async_to_generator(function(){var n;return _ts_generator(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,4,6]),[4,e.apply(void 0,_to_consumable_array(o))];case 1:case 3:return[2,a.sent()];case 2:return n=a.sent(),t?[4,t(n)]:[2];case 4:return[4,null==r?void 0:r()];case 5:return a.sent(),[7];case 6:return[2]}})})()}},s=function(e){return _async_to_generator(function(e){var t,r,i,c,s,l,d,f,_,y,v,p,b,g=arguments;return _ts_generator(this,function(h){switch(h.label){case 0:if(t=g.length>1&&void 0!==g[1]?g[1]:{},r=g.length>2&&void 0!==g[2]?g[2]:{},!o(e))return[2];c=a(e)&&e.consent||r.consent||(null===(i=r.collector)||void 0===i?void 0:i.consent),s=n(t)?t:[t],l=!0,d=!1,f=void 0,h.label=1;case 1:h.trys.push([1,6,7,8]),_=s[Symbol.iterator](),h.label=2;case 2:return(l=(y=_.next()).done)?[3,5]:(v=y.value,[4,u(S)(e,v,_object_spread_props(_object_spread({},r),{consent:c}))]);case 3:if(p=h.sent(),o(p))return[2,p];h.label=4;case 4:return l=!0,[3,2];case 5:return[3,8];case 6:return b=h.sent(),d=!0,f=b,[3,8];case 7:try{l||null==_.return||_.return()}finally{if(d)throw f}return[7];case 8:return[2]}})}).apply(this,arguments)},l=function(e){return _object_spread({window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document},e)},d=function(e,t,n,o,i){return _async_to_generator(function(){var c,u,l,d,f,_,y;return _ts_generator(this,function(v){switch(v.label){case 0:return c=a(t)?t:{},n.data?[4,s(e,n.data,{collector:i})]:[3,2];case 1:return l=v.sent(),[3,3];case 2:l={},v.label=3;case 3:return u=l,(null==o?void 0:o.data)?[4,s(e,o.data,{collector:i})]:[3,5];case 4:return f=v.sent(),[3,6];case 5:f={},v.label=6;case 6:return d=f,_=a(u)?u:{},y=a(d)?d:{},[2,r(r(c,_),y)]}})})()},f=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0,o=l(arguments.length>4?arguments[4]:void 0).window;if(t.measurementId){var i=a(n)?n:{},c=function(e,t){var r={};return t.includes("all")&&(t=["context","data","event","globals","source","user","version"]),t.forEach(function(t){var n=e[t]||{};"event"==t&&(n={id:e.id,timing:e.timing,trigger:e.trigger,entity:e.entity,action:e.action,group:e.group,count:e.count}),Object.entries(n).forEach(function(e){var n=_sliced_to_array(e,2),o=n[0],a=n[1];"context"==t&&(a=a[0]),r["".concat(t,"_").concat(o)]=a})}),r}(e,r.include||t.include||["data"]),u=_object_spread({},c,i),s=e.name;!1!==t.snakeCase&&(s=function(e){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?e:e.replace(/\s+/g,"_").toLowerCase()}(s)),u.send_to=t.measurementId,t.debug&&(u.debug_mode=!0),(0,o.gtag)("event",s,u)}},_=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:globalThis.document,o=r!=P?"&l="+r:"",a=n.createElement("script");a.src=t+e+o,n.head.appendChild(a)},y=function(){E=!1},v=Object.defineProperty,p=Object.getOwnPropertyDescriptor,b=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,h={};!function(e,t){for(var r in t)v(e,r,{get:t[r],enumerable:!0})}(h,{DestinationGtag:function(){return k},default:function(){return L},destinationGtag:function(){return D},resetConsentState:function(){return y}});var m=new Set,w={merge:!0,shallow:!0,extend:!0};function j(e){for(var t=arguments.length>2?arguments[2]:void 0,r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"").split("."),a=e,i=0;i<r.length;i++){var c=r[i];if("*"===c&&n(a)){var u=r.slice(i+1).join("."),s=[],l=!0,d=!1,f=void 0;try{for(var _,y=a[Symbol.iterator]();!(l=(_=y.next()).done);l=!0){var v=j(_.value,u,t);s.push(v)}}catch(e){d=!0,f=e}finally{try{l||null==y.return||y.return()}finally{if(d)throw f}}return s}if(!(a=_instanceof(a,Object)?a[c]:void 0))break}return o(a)?a:t}function O(e){return function(e){return"boolean"==typeof e}(e)||i(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!o(e)||n(e)&&e.every(O)||a(e)&&Object.values(e).every(O)}function S(e,t){return _async_to_generator(function(e,t){var r,a,l,d=arguments;return _ts_generator(this,function(f){return a=(r=d.length>2&&void 0!==d[2]?d[2]:{}).collector,l=r.consent,[2,(n(t)?t:[t]).reduce(function(t,d){return _async_to_generator(function(){var f,_,y,v,p,b,g,h,m,w,O,I,P,A,k,E,x,D,L,T,C;return _ts_generator(this,function(G){switch(G.label){case 0:return[4,t];case 1:return(f=G.sent())?[2,f]:(_=i(d)?{key:d}:d,Object.keys(_).length?(y=_.condition,v=_.consent,p=_.fn,b=_.key,g=_.loop,h=_.map,m=_.set,w=_.validate,O=_.value,(I=y)?[4,u(y)(e,d,a)]:[3,3]):[2]);case 2:I=!G.sent(),G.label=3;case 3:return I?[2]:v&&!function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),r={},n=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(r[o]=!0,e&&e[o]&&(n=!0))}),!!n&&r}(v,l)?[2,O]:(P=o(O)?O:e,p?[4,u(p)(e,d,r)]:[3,5]);case 4:P=G.sent(),G.label=5;case 5:return b&&(P=j(e,b,O)),g?(A=_sliced_to_array(g,2),k=A[0],E=A[1],"this"!==k?[3,6]:(D=[e],[3,8])):[3,11];case 6:return[4,s(e,k,r)];case 7:D=G.sent(),G.label=8;case 8:return n(x=D)?[4,Promise.all(x.map(function(e){return s(e,E,r)}))]:[3,10];case 9:P=G.sent().filter(o),G.label=10;case 10:return[3,17];case 11:return h?[4,Object.entries(h).reduce(function(t,n){var a=_sliced_to_array(n,2),i=a[0],c=a[1];return _async_to_generator(function(){var n,a;return _ts_generator(this,function(u){switch(u.label){case 0:return[4,t];case 1:return n=u.sent(),[4,s(e,c,r)];case 2:return a=u.sent(),[2,(o(a)&&(n[i]=a),n)]}})})()},Promise.resolve({}))]:[3,13];case 12:return P=G.sent(),[3,16];case 13:return(L=m)?[4,Promise.all(m.map(function(t){return S(e,t,r)}))]:[3,15];case 14:L=P=G.sent(),G.label=15;case 15:G.label=16;case 16:G.label=17;case 17:return(T=w)?[4,u(w)(P)]:[3,19];case 18:T=!G.sent(),G.label=19;case 19:return T&&(P=void 0),C=c(P),[2,o(C)?C:c(O)]}})})()},Promise.resolve(void 0))]})}).apply(this,arguments)}var I,P="dataLayer",A="https://www.googletagmanager.com/gtm.js?id=",k={},E=!1,x={marketing:["ad_storage","ad_user_data","ad_personalization"],functional:["analytics_storage"]},D={type:"google-gtag",config:{settings:{}},init:function(r){var n=r.config,o=r.env,a=n.settings,i=void 0===a?{}:a,c=n.loadScript,u=i.ga4,s=i.ads,d=i.gtm;return(null==u?void 0:u.measurementId)&&function(r,n,o){var a=l(o),i=a.window,c=a.document,u=r.measurementId,s=r.transport_url,d=r.server_container_url,f=r.pageview;if(u){n&&e(u,void 0,c),t(i);var _={};s&&(_.transport_url=s),d&&(_.server_container_url=d),!1===f&&(_.send_page_view=!1);var y=i.gtag;y("js",new Date),y("config",u,_)}}(u,c,o),(null==s?void 0:s.conversionId)&&function(r,n,o){var a=l(o),i=a.window,c=a.document,u=r.conversionId;if(u){r.currency||(r.currency="EUR"),n&&e(u,void 0,c),t(i);var s=i.gtag;s("js",new Date),s("config",u)}}(s,c,o),(null==d?void 0:d.containerId)&&function(e,t,r){var n=l(r),o=n.window,a=n.document,i=e.containerId,c=e.dataLayer,u=e.domain,s=c||P;s===P?o.dataLayer=o.dataLayer||[]:o[s]=o[s]||[],o[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),t&&i&&_(i,u||A,s,a)}(d,c,o),!!((null==u?void 0:u.measurementId)||(null==s?void 0:s.conversionId)||(null==d?void 0:d.containerId))&&n},push:function(e,t){return _async_to_generator(function(e,t){var r,n,o,i,c,u,s,_,y,v,p,b,g,h,m;return _ts_generator(this,function(w){switch(w.label){case 0:return r=t.config,n=t.mapping,o=void 0===n?{}:n,i=t.data,c=t.env,u=t.collector,s=r.settings,y=(_=void 0===s?{}:s).ga4,v=_.ads,p=_.gtm,b=o.settings||{},[4,d(e,i,r,y,u)];case 1:return g=w.sent(),[4,d(e,i,r,v,u)];case 2:return h=w.sent(),[4,d(e,i,r,p,u)];case 3:return m=w.sent(),(null==y?void 0:y.measurementId)&&f(e,y,b.ga4,g,c),(null==v?void 0:v.conversionId)&&o.name&&function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i=arguments.length>5?arguments[5]:void 0,c=t.conversionId,u=t.currency,s=a(n)?n:{},d=r.label||o;if(d){var f=_object_spread({send_to:"".concat(c,"/").concat(d),currency:u||"EUR"},s);(0,l(i).window.gtag)("event","conversion",f)}}(e,v,b.ads,h,o.name,c),(null==p?void 0:p.containerId)&&function(e,t){var r=arguments.length>3?arguments[3]:void 0,n=l(arguments.length>4?arguments[4]:void 0).window,o={event:e.name};n.dataLayer.push(_object_spread({},o,a(r)?r:e))}(e,p,b.gtm,m,c),[2]}})}).apply(this,arguments)},on:function(e,r){var n;if("consent"===e&&r){var o=r,a=((null===(n=this.config)||void 0===n?void 0:n.settings)||{}).como,i=void 0===a||a;if(i){var c=l(this.env).window,u=t(c);if(u){var s=!0===i?x:i;if(!E){var d=new Set;if(Object.values(s).forEach(function(e){(Array.isArray(e)?e:[e]).forEach(function(e){return d.add(e)})}),d.size>0){var f={};d.forEach(function(e){f[e]="denied"}),u("consent","default",f)}E=!0}var _={};Object.entries(o).forEach(function(e){var t=_sliced_to_array(e,2),r=t[0],n=t[1],o=s[r];if(o){var a=Array.isArray(o)?o:[o],i=n?"granted":"denied";a.forEach(function(e){_[e]=i})}}),0!==Object.keys(_).length&&u("consent","update",_)}}}}},L=D;return I=h,function(e,t,r,n){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,a=!1,i=void 0;try{for(var c,u=function(){var o=c.value;g.call(e,o)||o===r||v(e,o,{get:function(){return t[o]},enumerable:!(n=p(t,o))||n.enumerable})},s=b(t)[Symbol.iterator]();!(o=(c=s.next()).done);o=!0)u()}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}return e}(v({},"__esModule",{value:!0}),I)}();
|
|
1
|
+
"use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,n,r,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function _async_to_generator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){asyncGeneratorStep(a,r,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,r,o,i,c,"throw",e)}i(void 0)})}}function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_define_property(e,t,n[t])})}return e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var Destination=function(){var e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://www.googletagmanager.com/gtag/js?id=",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:globalThis.document;if(!m.has(e)){var r=n.createElement("script");r.src=t+e,n.head.appendChild(r),m.add(e)}},t=function(e){var t=e;return t.dataLayer=t.dataLayer||[],t.gtag||(t.gtag=function(){t.dataLayer.push(arguments)}),t.gtag},n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n=_object_spread({},I,n);var r=Object.entries(t).reduce(function(t,r){var o=_sliced_to_array(r,2),a=o[0],i=o[1],c=e[a];return n.merge&&Array.isArray(c)&&Array.isArray(i)?t[a]=i.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(n.extend||a in e)&&(t[a]=i),t},{});return n.shallow?_object_spread({},e,r):(Object.assign(e,r),e)},r=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},a=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)},i=function(e){return"string"==typeof e},c=function(e){return P(e)?e:void 0},u=function(e,t,n){return function(){for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return _async_to_generator(function(){var r;return _ts_generator(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,4,6]),[4,e.apply(void 0,_to_consumable_array(o))];case 1:case 3:return[2,a.sent()];case 2:return r=a.sent(),t?[4,t(r)]:[2];case 4:return[4,null==n?void 0:n()];case 5:return a.sent(),[7];case 6:return[2]}})})()}},s=function(e){return _async_to_generator(function(e){var t,n,i,c,s,l,d,f,_,y,v,g,p,b=arguments;return _ts_generator(this,function(h){switch(h.label){case 0:if(t=b.length>1&&void 0!==b[1]?b[1]:{},n=b.length>2&&void 0!==b[2]?b[2]:{},!o(e))return[2];c=a(e)&&e.consent||n.consent||(null===(i=n.collector)||void 0===i?void 0:i.consent),s=r(t)?t:[t],l=!0,d=!1,f=void 0,h.label=1;case 1:h.trys.push([1,6,7,8]),_=s[Symbol.iterator](),h.label=2;case 2:return(l=(y=_.next()).done)?[3,5]:(v=y.value,[4,u(E)(e,v,_object_spread_props(_object_spread({},n),{consent:c}))]);case 3:if(g=h.sent(),o(g))return[2,g];h.label=4;case 4:return l=!0,[3,2];case 5:return[3,8];case 6:return p=h.sent(),d=!0,f=p,[3,8];case 7:try{l||null==_.return||_.return()}finally{if(d)throw f}return[7];case 8:return[2]}})}).apply(this,arguments)},l=function(e){return _object_spread({window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document},e)},d=function(e,t,r,o,i){return _async_to_generator(function(){var c,u,l,d,f,_,y;return _ts_generator(this,function(v){switch(v.label){case 0:return c=a(t)?t:{},r.data?[4,s(e,r.data,{collector:i})]:[3,2];case 1:return l=v.sent(),[3,3];case 2:l={},v.label=3;case 3:return u=l,(null==o?void 0:o.data)?[4,s(e,o.data,{collector:i})]:[3,5];case 4:return f=v.sent(),[3,6];case 5:f={},v.label=6;case 6:return d=f,_=a(u)?u:{},y=a(d)?d:{},[2,n(n(c,_),y)]}})})()},f=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,o=arguments.length>5?arguments[5]:void 0,i=l(arguments.length>4?arguments[4]:void 0).window;t.measurementId||o.throw("Config settings ga4.measurementId missing");var c=a(r)?r:{},u=function(e,t){var n={};return t.includes("all")&&(t=["context","data","event","globals","source","user","version"]),t.forEach(function(t){var r=e[t]||{};"event"==t&&(r={id:e.id,timing:e.timing,trigger:e.trigger,entity:e.entity,action:e.action,group:e.group,count:e.count}),Object.entries(r).forEach(function(e){var r=_sliced_to_array(e,2),o=r[0],a=r[1];"context"==t&&(a=a[0]),n["".concat(t,"_").concat(o)]=a})}),n}(e,n.include||t.include||["data"]),s=_object_spread({},u,c),d=e.name;!1!==t.snakeCase&&(d=function(e){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?e:e.replace(/\s+/g,"_").toLowerCase()}(d)),s.send_to=t.measurementId,t.debug&&(s.debug_mode=!0),(0,i.gtag)("event",d,s)},_=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:globalThis.document,o=n!=k?"&l="+n:"",a=r.createElement("script");a.src=t+e+o,r.head.appendChild(a)},y=function(){C=!1},v=Object.defineProperty,g=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,b=Object.prototype.hasOwnProperty,h={};!function(e,t){for(var n in t)v(e,n,{get:t[n],enumerable:!0})}(h,{DestinationGtag:function(){return x},default:function(){return R},destinationGtag:function(){return G},resetConsentState:function(){return y}});var m=new Set,w=Object.defineProperty;!function(e,t){for(var n in t)w(e,n,{get:t[n],enumerable:!0})}({},{Level:function(){return O}});var j,O=((j=O||{})[j.ERROR=0]="ERROR",j[j.INFO=1]="INFO",j[j.DEBUG=2]="DEBUG",j),I={merge:!0,shallow:!0,extend:!0};function S(e){for(var t=arguments.length>2?arguments[2]:void 0,n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"").split("."),a=e,i=0;i<n.length;i++){var c=n[i];if("*"===c&&r(a)){var u=n.slice(i+1).join("."),s=[],l=!0,d=!1,f=void 0;try{for(var _,y=a[Symbol.iterator]();!(l=(_=y.next()).done);l=!0){var v=S(_.value,u,t);s.push(v)}}catch(e){d=!0,f=e}finally{try{l||null==y.return||y.return()}finally{if(d)throw f}}return s}if(!(a=_instanceof(a,Object)?a[c]:void 0))break}return o(a)?a:t}function P(e){return function(e){return"boolean"==typeof e}(e)||i(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!o(e)||r(e)&&e.every(P)||a(e)&&Object.values(e).every(P)}function E(e,t){return _async_to_generator(function(e,t){var n,a,l,d=arguments;return _ts_generator(this,function(f){return a=(n=d.length>2&&void 0!==d[2]?d[2]:{}).collector,l=n.consent,[2,(r(t)?t:[t]).reduce(function(t,d){return _async_to_generator(function(){var f,_,y,v,g,p,b,h,m,w,j,O,I,P,A,k,D,x,C,L,G;return _ts_generator(this,function(R){switch(R.label){case 0:return[4,t];case 1:return(f=R.sent())?[2,f]:(_=i(d)?{key:d}:d,Object.keys(_).length?(y=_.condition,v=_.consent,g=_.fn,p=_.key,b=_.loop,h=_.map,m=_.set,w=_.validate,j=_.value,(O=y)?[4,u(y)(e,d,a)]:[3,3]):[2]);case 2:O=!R.sent(),R.label=3;case 3:return O?[2]:v&&!function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),n={},r=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(n[o]=!0,e&&e[o]&&(r=!0))}),!!r&&n}(v,l)?[2,j]:(I=o(j)?j:e,g?[4,u(g)(e,d,n)]:[3,5]);case 4:I=R.sent(),R.label=5;case 5:return p&&(I=S(e,p,j)),b?(P=_sliced_to_array(b,2),A=P[0],k=P[1],"this"!==A?[3,6]:(x=[e],[3,8])):[3,11];case 6:return[4,s(e,A,n)];case 7:x=R.sent(),R.label=8;case 8:return r(D=x)?[4,Promise.all(D.map(function(e){return s(e,k,n)}))]:[3,10];case 9:I=R.sent().filter(o),R.label=10;case 10:return[3,17];case 11:return h?[4,Object.entries(h).reduce(function(t,r){var a=_sliced_to_array(r,2),i=a[0],c=a[1];return _async_to_generator(function(){var r,a;return _ts_generator(this,function(u){switch(u.label){case 0:return[4,t];case 1:return r=u.sent(),[4,s(e,c,n)];case 2:return a=u.sent(),[2,(o(a)&&(r[i]=a),r)]}})})()},Promise.resolve({}))]:[3,13];case 12:return I=R.sent(),[3,16];case 13:return(C=m)?[4,Promise.all(m.map(function(t){return E(e,t,n)}))]:[3,15];case 14:C=I=R.sent(),R.label=15;case 15:R.label=16;case 16:R.label=17;case 17:return(L=w)?[4,u(w)(I)]:[3,19];case 18:L=!R.sent(),R.label=19;case 19:return L&&(I=void 0),G=c(I),[2,o(G)?G:c(j)]}})})()},Promise.resolve(void 0))]})}).apply(this,arguments)}var A,k="dataLayer",D="https://www.googletagmanager.com/gtm.js?id=",x={},C=!1,L={marketing:["ad_storage","ad_user_data","ad_personalization"],functional:["analytics_storage"]},G={type:"google-gtag",config:{settings:{}},init:function(n){var r=n.config,o=n.env,a=n.logger,i=r.settings,c=void 0===i?{}:i,u=r.loadScript,s=c.ga4,d=c.ads,f=c.gtm;return(null==s?void 0:s.measurementId)||(null==d?void 0:d.conversionId)||(null==f?void 0:f.containerId)||a.throw("Config settings missing. Set ga4.measurementId, ads.conversionId, or gtm.containerId"),(null==s?void 0:s.measurementId)&&function(n,r,o,a){var i=l(o),c=i.window,u=i.document,s=n.measurementId,d=n.transport_url,f=n.server_container_url,_=n.pageview;s||a.throw("Config settings ga4.measurementId missing"),r&&e(s,void 0,u),t(c);var y={};d&&(y.transport_url=d),f&&(y.server_container_url=f),!1===_&&(y.send_page_view=!1);var v=c.gtag;v("js",new Date),v("config",s,y)}(s,u,o,a),(null==d?void 0:d.conversionId)&&function(n,r,o,a){var i=l(o),c=i.window,u=i.document,s=n.conversionId;s||a.throw("Config settings ads.conversionId missing"),n.currency||(n.currency="EUR"),r&&e(s,void 0,u),t(c);var d=c.gtag;d("js",new Date),d("config",s)}(d,u,o,a),(null==f?void 0:f.containerId)&&function(e,t,n){var r=l(n),o=r.window,a=r.document,i=e.containerId,c=e.dataLayer,u=e.domain,s=c||k;s===k?o.dataLayer=o.dataLayer||[]:o[s]=o[s]||[],o[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),t&&i&&_(i,u||D,s,a)}(f,u,o),r},push:function(e,t){return _async_to_generator(function(e,t){var n,r,o,i,c,u,s,_,y,v,g,p,b,h,m,w;return _ts_generator(this,function(j){switch(j.label){case 0:return n=t.config,r=t.mapping,o=void 0===r?{}:r,i=t.data,c=t.env,u=t.collector,s=t.logger,_=n.settings,v=(y=void 0===_?{}:_).ga4,g=y.ads,p=y.gtm,b=o.settings||{},[4,d(e,i,n,v,u)];case 1:return h=j.sent(),[4,d(e,i,n,g,u)];case 2:return m=j.sent(),[4,d(e,i,n,p,u)];case 3:return w=j.sent(),(null==v?void 0:v.measurementId)&&f(e,v,b.ga4,h,c,s),(null==g?void 0:g.conversionId)&&o.name&&function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i=arguments.length>5?arguments[5]:void 0,c=arguments.length>6?arguments[6]:void 0,u=t.conversionId,s=t.currency,d=a(r)?r:{},f=n.label||o;f||c.throw("Config mapping ads.label missing");var _=_object_spread({send_to:"".concat(u,"/").concat(f),currency:s||"EUR"},d);(0,l(i).window.gtag)("event","conversion",_)}(e,g,b.ads,m,o.name,c,s),(null==p?void 0:p.containerId)&&function(e,t){var n=arguments.length>3?arguments[3]:void 0,r=l(arguments.length>4?arguments[4]:void 0).window,o={event:e.name};r.dataLayer.push(_object_spread({},o,a(n)?n:e))}(e,p,b.gtm,w,c,s),[2]}})}).apply(this,arguments)},on:function(e,n){var r;if("consent"===e&&n){var o=n,a=((null===(r=this.config)||void 0===r?void 0:r.settings)||{}).como,i=void 0===a||a;if(i){var c=l(this.env).window,u=t(c);if(u){var s=!0===i?L:i;if(!C){var d=new Set;if(Object.values(s).forEach(function(e){(Array.isArray(e)?e:[e]).forEach(function(e){return d.add(e)})}),d.size>0){var f={};d.forEach(function(e){f[e]="denied"}),u("consent","default",f)}C=!0}var _={};Object.entries(o).forEach(function(e){var t=_sliced_to_array(e,2),n=t[0],r=t[1],o=s[n];if(o){var a=Array.isArray(o)?o:[o],i=r?"granted":"denied";a.forEach(function(e){_[e]=i})}}),0!==Object.keys(_).length&&u("consent","update",_)}}}}},R=G;return A=h,function(e,t,n,r){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,a=!1,i=void 0;try{for(var c,u=function(){var o=c.value;b.call(e,o)||o===n||v(e,o,{get:function(){return t[o]},enumerable:!(r=g(t,o))||r.enumerable})},s=p(t)[Symbol.iterator]();!(o=(c=s.next()).done);o=!0)u()}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}return e}(v({},"__esModule",{value:!0}),A)}();
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(a,{DestinationGtag:()=>
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(a,{DestinationGtag:()=>S,default:()=>T,destinationGtag:()=>$,resetConsentState:()=>G}),module.exports=(e=a,((e,a,i,c)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let s of r(a))o.call(e,s)||s===i||t(e,s,{get:()=>a[s],enumerable:!(c=n(a,s))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i=new Set;function c(e,t="https://www.googletagmanager.com/gtag/js?id=",n=globalThis.document){if(i.has(e))return;const r=n.createElement("script");r.src=t+e,n.head.appendChild(r),i.add(e)}function s(e){const t=e;return t.dataLayer=t.dataLayer||[],t.gtag||(t.gtag=function(){t.dataLayer.push(arguments)}),t.gtag}var u=require("@walkeros/web-core");var d=Object.defineProperty;((e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>g});var l,g=((l=g||{})[l.ERROR=0]="ERROR",l[l.INFO=1]="INFO",l[l.DEBUG=2]="DEBUG",l),f={merge:!0,shallow:!0,extend:!0};function v(e,t={},n={}){n={...f,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const a=e[r];return n.merge&&Array.isArray(a)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...a]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function m(e){return Array.isArray(e)}function w(e){return void 0!==e}function y(e){return"object"==typeof e&&null!==e&&!m(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(e){return"string"==typeof e}function b(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&m(o)){const t=r.slice(e+1).join("."),a=[];for(const e of o){const r=b(e,t,n);a.push(r)}return a}if(o=o instanceof Object?o[t]:void 0,!o)break}return w(o)?o:n}function h(e){return function(e){return"boolean"==typeof e}(e)||p(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!w(e)||m(e)&&e.every(h)||y(e)&&Object.values(e).every(h)}function j(e){return h(e)?e:void 0}function O(e,t,n){return async function(...r){try{return await e(...r)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function E(e,t={},n={}){var r;if(!w(e))return;const o=y(e)&&e.consent||n.consent||(null==(r=n.collector)?void 0:r.consent),a=m(t)?t:[t];for(const t of a){const r=await O(I)(e,t,{...n,consent:o});if(w(r))return r}}async function I(e,t,n={}){const{collector:r,consent:o}=n;return(m(t)?t:[t]).reduce(async(t,a)=>{const i=await t;if(i)return i;const c=p(a)?{key:a}:a;if(!Object.keys(c).length)return;const{condition:s,consent:u,fn:d,key:l,loop:g,map:f,set:v,validate:y,value:h}=c;if(s&&!await O(s)(e,a,r))return;if(u&&!function(e,t={},n={}){const r={...t,...n},o={};let a=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(a=!0))}),!!a&&o}(u,o))return h;let _=w(h)?h:e;if(d&&(_=await O(d)(e,a,n)),l&&(_=b(e,l,h)),g){const[t,r]=g,o="this"===t?[e]:await E(e,t,n);m(o)&&(_=(await Promise.all(o.map(e=>E(e,r,n)))).filter(w))}else f?_=await Object.entries(f).reduce(async(t,[r,o])=>{const a=await t,i=await E(e,o,n);return w(i)&&(a[r]=i),a},Promise.resolve({})):v&&(_=await Promise.all(v.map(t=>I(e,t,n))));y&&!await O(y)(_)&&(_=void 0);const k=j(_);return w(k)?k:j(h)},Promise.resolve(void 0))}async function _(e,t,n,r,o){const a=y(t)?t:{},i=n.data?await E(e,n.data,{collector:o}):{},c=(null==r?void 0:r.data)?await E(e,r.data,{collector:o}):{},s=y(i)?i:{},u=y(c)?c:{};return v(v(a,s),u)}var k=require("@walkeros/web-core");function A(e,t,n={},r,o,a){const{window:i}=(0,k.getEnv)(o);t.measurementId||a.throw("Config settings ga4.measurementId missing");const c=y(r)?r:{},s=function(e,t){const n={};return t.includes("all")&&(t=["context","data","event","globals","source","user","version"]),t.forEach(t=>{let r=e[t]||{};"event"==t&&(r={id:e.id,timing:e.timing,trigger:e.trigger,entity:e.entity,action:e.action,group:e.group,count:e.count}),Object.entries(r).forEach(([e,r])=>{"context"==t&&(r=r[0]),n[`${t}_${e}`]=r})}),n}(e,n.include||t.include||["data"]),u={...s,...c};let d=e.name;!1!==t.snakeCase&&(d=function(e,t=!0){return t?e.replace(/\s+/g,"_").toLowerCase():e}(d)),u.send_to=t.measurementId,t.debug&&(u.debug_mode=!0);(0,i.gtag)("event",d,u)}var C=require("@walkeros/web-core");var L=require("@walkeros/web-core");var P=require("@walkeros/web-core"),R="dataLayer";function q(e,t,n,r){const{window:o,document:a}=(0,P.getEnv)(n),{containerId:i,dataLayer:c,domain:s}=e,u=c||R;u===R?o.dataLayer=o.dataLayer||[]:o[u]=o[u]||[];o[u].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),t&&i&&function(e,t,n,r=globalThis.document){const o=n!=R?"&l="+n:"",a=r.createElement("script");a.src=t+e+o,r.head.appendChild(a)}(i,s||"https://www.googletagmanager.com/gtm.js?id=",u,a)}var D=require("@walkeros/web-core");var N=require("@walkeros/web-core"),S={},x=!1;function G(){x=!1}var U={marketing:["ad_storage","ad_user_data","ad_personalization"],functional:["analytics_storage"]},$={type:"google-gtag",config:{settings:{}},init({config:e,env:t,logger:n}){const{settings:r={},loadScript:o}=e,{ga4:a,ads:i,gtm:d}=r;return(null==a?void 0:a.measurementId)||(null==i?void 0:i.conversionId)||(null==d?void 0:d.containerId)||n.throw("Config settings missing. Set ga4.measurementId, ads.conversionId, or gtm.containerId"),(null==a?void 0:a.measurementId)&&function(e,t,n,r){const{window:o,document:a}=(0,u.getEnv)(n),{measurementId:i,transport_url:d,server_container_url:l,pageview:g}=e;i||r.throw("Config settings ga4.measurementId missing"),t&&c(i,void 0,a),s(o);const f={};d&&(f.transport_url=d),l&&(f.server_container_url=l),!1===g&&(f.send_page_view=!1);const v=o.gtag;v("js",new Date),v("config",i,f)}(a,o,t,n),(null==i?void 0:i.conversionId)&&function(e,t,n,r){const{window:o,document:a}=(0,C.getEnv)(n),{conversionId:i}=e;i||r.throw("Config settings ads.conversionId missing"),e.currency||(e.currency="EUR"),t&&c(i,void 0,a),s(o);const u=o.gtag;u("js",new Date),u("config",i)}(i,o,t,n),(null==d?void 0:d.containerId)&&q(d,o,t),e},async push(e,{config:t,mapping:n={},data:r,env:o,collector:a,logger:i}){const{settings:c={}}=t,{ga4:s,ads:u,gtm:d}=c,l=n.settings||{},g=await _(e,r,t,s,a),f=await _(e,r,t,u,a),v=await _(e,r,t,d,a);(null==s?void 0:s.measurementId)&&A(e,s,l.ga4,g,o,i),(null==u?void 0:u.conversionId)&&n.name&&function(e,t,n={},r,o,a,i){const{conversionId:c,currency:s}=t,u=y(r)?r:{},d=n.label||o;d||i.throw("Config mapping ads.label missing");const l={send_to:`${c}/${d}`,currency:s||"EUR",...u},{window:g}=(0,L.getEnv)(a);(0,g.gtag)("event","conversion",l)}(0,u,l.ads,f,n.name,o,i),(null==d?void 0:d.containerId)&&function(e,t,n={},r,o){const{window:a}=(0,D.getEnv)(o),i={event:e.name};a.dataLayer.push({...i,...y(r)?r:e})}(e,0,l.gtm,v,o)},on(e,t){var n;if("consent"!==e||!t)return;const r=t,o=(null==(n=this.config)?void 0:n.settings)||{},{como:a=!0}=o;if(!a)return;const{window:i}=(0,N.getEnv)(this.env),c=s(i);if(!c)return;const u=!0===a?U:a;if(!x){const e=new Set;if(Object.values(u).forEach(t=>{(Array.isArray(t)?t:[t]).forEach(t=>e.add(t))}),e.size>0){const t={};e.forEach(e=>{t[e]="denied"}),c("consent","default",t)}x=!0}const d={};Object.entries(r).forEach(([e,t])=>{const n=u[e];if(!n)return;const r=Array.isArray(n)?n:[n],o=t?"granted":"denied";r.forEach(e=>{d[e]=o})}),0!==Object.keys(d).length&&c("consent","update",d)}},T=$;//# sourceMappingURL=index.js.map
|