@walkeros/web-destination-d8a 4.1.0

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.
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/examples/index.ts
21
+ var examples_exports = {};
22
+ __export(examples_exports, {
23
+ env: () => env_exports,
24
+ step: () => step_exports
25
+ });
26
+ module.exports = __toCommonJS(examples_exports);
27
+
28
+ // src/examples/env.ts
29
+ var env_exports = {};
30
+ __export(env_exports, {
31
+ init: () => init,
32
+ push: () => push,
33
+ simulation: () => simulation
34
+ });
35
+ function createD8a() {
36
+ const d8a = (() => {
37
+ });
38
+ d8a.js = () => {
39
+ };
40
+ d8a.config = () => {
41
+ };
42
+ d8a.event = () => {
43
+ };
44
+ d8a.set = () => {
45
+ };
46
+ d8a.consent = () => {
47
+ };
48
+ return d8a;
49
+ }
50
+ var installD8a = (opts) => {
51
+ const windowRef = opts == null ? void 0 : opts.windowRef;
52
+ const globalName = (opts == null ? void 0 : opts.globalName) || "d8a";
53
+ const dataLayerName = (opts == null ? void 0 : opts.dataLayerName) || "d8aLayer";
54
+ if (windowRef) {
55
+ windowRef[dataLayerName] = windowRef[dataLayerName] || [];
56
+ windowRef[globalName] = windowRef[globalName] || createD8a();
57
+ }
58
+ return {
59
+ dataLayerName,
60
+ globalName,
61
+ consumer: {
62
+ start: () => {
63
+ },
64
+ stop: () => {
65
+ },
66
+ getState: () => ({}),
67
+ setOnEvent: () => {
68
+ },
69
+ setOnConfig: () => {
70
+ }
71
+ },
72
+ dispatcher: {
73
+ enqueueEvent: () => {
74
+ },
75
+ flush: async () => ({ sent: 0 }),
76
+ flushNow: async () => ({ sent: 0 }),
77
+ attachLifecycleFlush: () => {
78
+ }
79
+ }
80
+ };
81
+ };
82
+ var init = {
83
+ installD8a,
84
+ window: {}
85
+ };
86
+ var push = {
87
+ installD8a,
88
+ window: {
89
+ d8a: createD8a(),
90
+ d8aLayer: []
91
+ }
92
+ };
93
+ var simulation = ["call:window.d8a"];
94
+
95
+ // src/examples/step.ts
96
+ var step_exports = {};
97
+ __export(step_exports, {
98
+ addToCart: () => addToCart,
99
+ consentMode: () => consentMode,
100
+ init: () => init2,
101
+ pageView: () => pageView,
102
+ purchase: () => purchase
103
+ });
104
+ var import_core = require("@walkeros/core");
105
+ var INIT_DATE_MS = 17e11;
106
+ var INIT_DATE = new Date(INIT_DATE_MS);
107
+ var PROPERTY_ID = "80e1d6d0-560d-419f-ac2a-fe9281e93386";
108
+ var SERVER_CONTAINER_URL = "https://global.t.d8a.tech/80e1d6d0-560d-419f-ac2a-fe9281e93386/d/c";
109
+ var init2 = {
110
+ title: "Initialization",
111
+ description: "The destination installs d8a and configures a property with its server container URL.",
112
+ in: {
113
+ settings: {
114
+ property_id: PROPERTY_ID,
115
+ server_container_url: SERVER_CONTAINER_URL
116
+ }
117
+ },
118
+ out: [
119
+ ["d8a", "js", INIT_DATE],
120
+ [
121
+ "d8a",
122
+ "config",
123
+ PROPERTY_ID,
124
+ { server_container_url: SERVER_CONTAINER_URL }
125
+ ]
126
+ ]
127
+ };
128
+ var pageView = {
129
+ title: "Page view",
130
+ description: "A page view event is forwarded as a d8a page_view event.",
131
+ in: (0, import_core.getEvent)("page view", { timestamp: 1700000300 }),
132
+ mapping: void 0,
133
+ out: [["d8a", "event", "page_view", { send_to: PROPERTY_ID }]]
134
+ };
135
+ var addToCart = {
136
+ title: "Add to cart",
137
+ description: "A product add event is mapped to the d8a add_to_cart event with item details and value.",
138
+ in: (0, import_core.getEvent)("product add", { timestamp: 1700000301 }),
139
+ mapping: {
140
+ name: "add_to_cart",
141
+ include: ["data"],
142
+ data: {
143
+ map: {
144
+ currency: { value: "EUR", key: "data.currency" },
145
+ value: "data.price",
146
+ items: {
147
+ loop: [
148
+ "this",
149
+ {
150
+ map: {
151
+ item_id: "data.id",
152
+ item_variant: "data.color",
153
+ quantity: { value: 1, key: "data.quantity" }
154
+ }
155
+ }
156
+ ]
157
+ }
158
+ }
159
+ }
160
+ },
161
+ out: [
162
+ [
163
+ "d8a",
164
+ "event",
165
+ "add_to_cart",
166
+ {
167
+ currency: "EUR",
168
+ value: 420,
169
+ items: [{ item_id: "ers", item_variant: "black", quantity: 1 }],
170
+ data_id: "ers",
171
+ data_name: "Everyday Ruck Snack",
172
+ data_color: "black",
173
+ data_size: "l",
174
+ data_price: 420,
175
+ send_to: PROPERTY_ID
176
+ }
177
+ ]
178
+ ]
179
+ };
180
+ var purchase = {
181
+ title: "Purchase",
182
+ description: "An order complete event is mapped to the d8a purchase event with transaction details and nested product items.",
183
+ in: (0, import_core.getEvent)("order complete", { timestamp: 1700000302 }),
184
+ mapping: {
185
+ name: "purchase",
186
+ include: ["data", "context"],
187
+ data: {
188
+ map: {
189
+ transaction_id: "data.id",
190
+ value: "data.total",
191
+ tax: "data.taxes",
192
+ shipping: "data.shipping",
193
+ currency: { key: "data.currency", value: "EUR" },
194
+ items: {
195
+ loop: [
196
+ "nested",
197
+ {
198
+ condition: (entity) => {
199
+ const candidate = entity;
200
+ return (0, import_core.isObject)(entity) && candidate.entity === "product";
201
+ },
202
+ map: {
203
+ item_id: "data.id",
204
+ item_name: "data.name",
205
+ quantity: { key: "data.quantity", value: 1 }
206
+ }
207
+ }
208
+ ]
209
+ }
210
+ }
211
+ }
212
+ },
213
+ out: [
214
+ [
215
+ "d8a",
216
+ "event",
217
+ "purchase",
218
+ {
219
+ transaction_id: "0rd3r1d",
220
+ value: 555,
221
+ tax: 73.76,
222
+ shipping: 5.22,
223
+ currency: "EUR",
224
+ items: [
225
+ { item_id: "ers", item_name: "Everyday Ruck Snack", quantity: 1 },
226
+ { item_id: "cc", item_name: "Cool Cap", quantity: 1 }
227
+ ],
228
+ data_id: "0rd3r1d",
229
+ data_currency: "EUR",
230
+ data_shipping: 5.22,
231
+ data_taxes: 73.76,
232
+ data_total: 555,
233
+ context_shopping: "complete",
234
+ send_to: PROPERTY_ID
235
+ }
236
+ ]
237
+ ]
238
+ };
239
+ var consentMode = {
240
+ title: "Consent mode",
241
+ description: "A walker consent command updates d8a using gtag consent mode parameters.",
242
+ command: "consent",
243
+ in: { marketing: true, functional: true },
244
+ out: [
245
+ [
246
+ "d8a",
247
+ "consent",
248
+ "default",
249
+ {
250
+ ad_storage: "denied",
251
+ ad_user_data: "denied",
252
+ ad_personalization: "denied",
253
+ analytics_storage: "denied"
254
+ }
255
+ ],
256
+ [
257
+ "d8a",
258
+ "consent",
259
+ "update",
260
+ {
261
+ ad_storage: "granted",
262
+ ad_user_data: "granted",
263
+ ad_personalization: "granted",
264
+ analytics_storage: "granted"
265
+ }
266
+ ]
267
+ ]
268
+ };
269
+ // Annotate the CommonJS export names for ESM import in node:
270
+ 0 && (module.exports = {
271
+ env,
272
+ step
273
+ });
@@ -0,0 +1,251 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/examples/env.ts
8
+ var env_exports = {};
9
+ __export(env_exports, {
10
+ init: () => init,
11
+ push: () => push,
12
+ simulation: () => simulation
13
+ });
14
+ function createD8a() {
15
+ const d8a = (() => {
16
+ });
17
+ d8a.js = () => {
18
+ };
19
+ d8a.config = () => {
20
+ };
21
+ d8a.event = () => {
22
+ };
23
+ d8a.set = () => {
24
+ };
25
+ d8a.consent = () => {
26
+ };
27
+ return d8a;
28
+ }
29
+ var installD8a = (opts) => {
30
+ const windowRef = opts == null ? void 0 : opts.windowRef;
31
+ const globalName = (opts == null ? void 0 : opts.globalName) || "d8a";
32
+ const dataLayerName = (opts == null ? void 0 : opts.dataLayerName) || "d8aLayer";
33
+ if (windowRef) {
34
+ windowRef[dataLayerName] = windowRef[dataLayerName] || [];
35
+ windowRef[globalName] = windowRef[globalName] || createD8a();
36
+ }
37
+ return {
38
+ dataLayerName,
39
+ globalName,
40
+ consumer: {
41
+ start: () => {
42
+ },
43
+ stop: () => {
44
+ },
45
+ getState: () => ({}),
46
+ setOnEvent: () => {
47
+ },
48
+ setOnConfig: () => {
49
+ }
50
+ },
51
+ dispatcher: {
52
+ enqueueEvent: () => {
53
+ },
54
+ flush: async () => ({ sent: 0 }),
55
+ flushNow: async () => ({ sent: 0 }),
56
+ attachLifecycleFlush: () => {
57
+ }
58
+ }
59
+ };
60
+ };
61
+ var init = {
62
+ installD8a,
63
+ window: {}
64
+ };
65
+ var push = {
66
+ installD8a,
67
+ window: {
68
+ d8a: createD8a(),
69
+ d8aLayer: []
70
+ }
71
+ };
72
+ var simulation = ["call:window.d8a"];
73
+
74
+ // src/examples/step.ts
75
+ var step_exports = {};
76
+ __export(step_exports, {
77
+ addToCart: () => addToCart,
78
+ consentMode: () => consentMode,
79
+ init: () => init2,
80
+ pageView: () => pageView,
81
+ purchase: () => purchase
82
+ });
83
+ import { getEvent, isObject } from "@walkeros/core";
84
+ var INIT_DATE_MS = 17e11;
85
+ var INIT_DATE = new Date(INIT_DATE_MS);
86
+ var PROPERTY_ID = "80e1d6d0-560d-419f-ac2a-fe9281e93386";
87
+ var SERVER_CONTAINER_URL = "https://global.t.d8a.tech/80e1d6d0-560d-419f-ac2a-fe9281e93386/d/c";
88
+ var init2 = {
89
+ title: "Initialization",
90
+ description: "The destination installs d8a and configures a property with its server container URL.",
91
+ in: {
92
+ settings: {
93
+ property_id: PROPERTY_ID,
94
+ server_container_url: SERVER_CONTAINER_URL
95
+ }
96
+ },
97
+ out: [
98
+ ["d8a", "js", INIT_DATE],
99
+ [
100
+ "d8a",
101
+ "config",
102
+ PROPERTY_ID,
103
+ { server_container_url: SERVER_CONTAINER_URL }
104
+ ]
105
+ ]
106
+ };
107
+ var pageView = {
108
+ title: "Page view",
109
+ description: "A page view event is forwarded as a d8a page_view event.",
110
+ in: getEvent("page view", { timestamp: 1700000300 }),
111
+ mapping: void 0,
112
+ out: [["d8a", "event", "page_view", { send_to: PROPERTY_ID }]]
113
+ };
114
+ var addToCart = {
115
+ title: "Add to cart",
116
+ description: "A product add event is mapped to the d8a add_to_cart event with item details and value.",
117
+ in: getEvent("product add", { timestamp: 1700000301 }),
118
+ mapping: {
119
+ name: "add_to_cart",
120
+ include: ["data"],
121
+ data: {
122
+ map: {
123
+ currency: { value: "EUR", key: "data.currency" },
124
+ value: "data.price",
125
+ items: {
126
+ loop: [
127
+ "this",
128
+ {
129
+ map: {
130
+ item_id: "data.id",
131
+ item_variant: "data.color",
132
+ quantity: { value: 1, key: "data.quantity" }
133
+ }
134
+ }
135
+ ]
136
+ }
137
+ }
138
+ }
139
+ },
140
+ out: [
141
+ [
142
+ "d8a",
143
+ "event",
144
+ "add_to_cart",
145
+ {
146
+ currency: "EUR",
147
+ value: 420,
148
+ items: [{ item_id: "ers", item_variant: "black", quantity: 1 }],
149
+ data_id: "ers",
150
+ data_name: "Everyday Ruck Snack",
151
+ data_color: "black",
152
+ data_size: "l",
153
+ data_price: 420,
154
+ send_to: PROPERTY_ID
155
+ }
156
+ ]
157
+ ]
158
+ };
159
+ var purchase = {
160
+ title: "Purchase",
161
+ description: "An order complete event is mapped to the d8a purchase event with transaction details and nested product items.",
162
+ in: getEvent("order complete", { timestamp: 1700000302 }),
163
+ mapping: {
164
+ name: "purchase",
165
+ include: ["data", "context"],
166
+ data: {
167
+ map: {
168
+ transaction_id: "data.id",
169
+ value: "data.total",
170
+ tax: "data.taxes",
171
+ shipping: "data.shipping",
172
+ currency: { key: "data.currency", value: "EUR" },
173
+ items: {
174
+ loop: [
175
+ "nested",
176
+ {
177
+ condition: (entity) => {
178
+ const candidate = entity;
179
+ return isObject(entity) && candidate.entity === "product";
180
+ },
181
+ map: {
182
+ item_id: "data.id",
183
+ item_name: "data.name",
184
+ quantity: { key: "data.quantity", value: 1 }
185
+ }
186
+ }
187
+ ]
188
+ }
189
+ }
190
+ }
191
+ },
192
+ out: [
193
+ [
194
+ "d8a",
195
+ "event",
196
+ "purchase",
197
+ {
198
+ transaction_id: "0rd3r1d",
199
+ value: 555,
200
+ tax: 73.76,
201
+ shipping: 5.22,
202
+ currency: "EUR",
203
+ items: [
204
+ { item_id: "ers", item_name: "Everyday Ruck Snack", quantity: 1 },
205
+ { item_id: "cc", item_name: "Cool Cap", quantity: 1 }
206
+ ],
207
+ data_id: "0rd3r1d",
208
+ data_currency: "EUR",
209
+ data_shipping: 5.22,
210
+ data_taxes: 73.76,
211
+ data_total: 555,
212
+ context_shopping: "complete",
213
+ send_to: PROPERTY_ID
214
+ }
215
+ ]
216
+ ]
217
+ };
218
+ var consentMode = {
219
+ title: "Consent mode",
220
+ description: "A walker consent command updates d8a using gtag consent mode parameters.",
221
+ command: "consent",
222
+ in: { marketing: true, functional: true },
223
+ out: [
224
+ [
225
+ "d8a",
226
+ "consent",
227
+ "default",
228
+ {
229
+ ad_storage: "denied",
230
+ ad_user_data: "denied",
231
+ ad_personalization: "denied",
232
+ analytics_storage: "denied"
233
+ }
234
+ ],
235
+ [
236
+ "d8a",
237
+ "consent",
238
+ "update",
239
+ {
240
+ ad_storage: "granted",
241
+ ad_user_data: "granted",
242
+ ad_personalization: "granted",
243
+ analytics_storage: "granted"
244
+ }
245
+ ]
246
+ ]
247
+ };
248
+ export {
249
+ env_exports as env,
250
+ step_exports as step
251
+ };