@walkeros/server-destination-amplitude 3.3.0-next-1776098542393

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,440 @@
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
+ var noop = () => {
36
+ };
37
+ var noopPromise = () => ({ promise: Promise.resolve() });
38
+ var MockIdentify = class {
39
+ set() {
40
+ return this;
41
+ }
42
+ setOnce() {
43
+ return this;
44
+ }
45
+ add() {
46
+ return this;
47
+ }
48
+ append() {
49
+ return this;
50
+ }
51
+ prepend() {
52
+ return this;
53
+ }
54
+ preInsert() {
55
+ return this;
56
+ }
57
+ postInsert() {
58
+ return this;
59
+ }
60
+ remove() {
61
+ return this;
62
+ }
63
+ unset() {
64
+ return this;
65
+ }
66
+ clearAll() {
67
+ return this;
68
+ }
69
+ };
70
+ var MockRevenue = class {
71
+ setProductId() {
72
+ return this;
73
+ }
74
+ setPrice() {
75
+ return this;
76
+ }
77
+ setQuantity() {
78
+ return this;
79
+ }
80
+ setRevenueType() {
81
+ return this;
82
+ }
83
+ setCurrency() {
84
+ return this;
85
+ }
86
+ setRevenue() {
87
+ return this;
88
+ }
89
+ setReceipt() {
90
+ return this;
91
+ }
92
+ setReceiptSig() {
93
+ return this;
94
+ }
95
+ setEventProperties() {
96
+ return this;
97
+ }
98
+ };
99
+ var init = {
100
+ amplitude: {
101
+ init: noopPromise,
102
+ track: noop,
103
+ identify: noop,
104
+ revenue: noop,
105
+ setOptOut: noop,
106
+ setGroup: noop,
107
+ groupIdentify: noop,
108
+ flush: noopPromise,
109
+ Identify: MockIdentify,
110
+ Revenue: MockRevenue
111
+ }
112
+ };
113
+ var push = {
114
+ amplitude: {
115
+ init: noopPromise,
116
+ track: noop,
117
+ identify: noop,
118
+ revenue: noop,
119
+ setOptOut: noop,
120
+ setGroup: noop,
121
+ groupIdentify: noop,
122
+ flush: noopPromise,
123
+ Identify: MockIdentify,
124
+ Revenue: MockRevenue
125
+ }
126
+ };
127
+ var simulation = [
128
+ "call:amplitude.init",
129
+ "call:amplitude.track",
130
+ "call:amplitude.identify",
131
+ "call:amplitude.revenue",
132
+ "call:amplitude.setOptOut",
133
+ "call:amplitude.setGroup",
134
+ "call:amplitude.groupIdentify"
135
+ ];
136
+
137
+ // src/examples/step.ts
138
+ var step_exports = {};
139
+ __export(step_exports, {
140
+ consentGrantOptIn: () => consentGrantOptIn,
141
+ consentRevokeOptOut: () => consentRevokeOptOut,
142
+ defaultEventForwarding: () => defaultEventForwarding,
143
+ destinationLevelIdentify: () => destinationLevelIdentify,
144
+ destinationLevelInclude: () => destinationLevelInclude,
145
+ eventOptionsTimeInsertId: () => eventOptionsTimeInsertId,
146
+ groupAssignmentWithProperties: () => groupAssignmentWithProperties,
147
+ orderCompleteMultiProduct: () => orderCompleteMultiProduct,
148
+ subscriptionRenewRevenue: () => subscriptionRenewRevenue,
149
+ userLoginIdentify: () => userLoginIdentify,
150
+ wildcardIgnored: () => wildcardIgnored
151
+ });
152
+ var import_core = require("@walkeros/core");
153
+ var defaultEventForwarding = {
154
+ in: (0, import_core.getEvent)("product view", { timestamp: 1700000100 }),
155
+ out: ["amplitude.track", "product view", {}]
156
+ };
157
+ var wildcardIgnored = {
158
+ in: (0, import_core.getEvent)("debug noise", { timestamp: 1700000101 }),
159
+ mapping: { ignore: true },
160
+ out: []
161
+ };
162
+ var destinationLevelInclude = {
163
+ in: (0, import_core.getEvent)("product view", { timestamp: 1700000102 }),
164
+ configInclude: ["data"],
165
+ out: [
166
+ "amplitude.track",
167
+ "product view",
168
+ {
169
+ data_id: "ers",
170
+ data_name: "Everyday Ruck Snack",
171
+ data_color: "black",
172
+ data_size: "l",
173
+ data_price: 420
174
+ }
175
+ ]
176
+ };
177
+ var destinationLevelIdentify = {
178
+ in: (0, import_core.getEvent)("page view", { timestamp: 1700000104 }),
179
+ settings: {
180
+ identify: {
181
+ map: {
182
+ user_id: "user.id",
183
+ device_id: "user.device",
184
+ session_id: "user.session"
185
+ }
186
+ }
187
+ },
188
+ out: [
189
+ "amplitude.track",
190
+ "page view",
191
+ {},
192
+ {
193
+ user_id: "us3r",
194
+ device_id: "c00k13",
195
+ session_id: 394324160
196
+ }
197
+ ]
198
+ };
199
+ var userLoginIdentify = {
200
+ in: (0, import_core.getEvent)("user login", {
201
+ timestamp: 1700000105,
202
+ data: {
203
+ user_id: "new-user-123",
204
+ plan: "premium",
205
+ company: "Acme",
206
+ email: "user@acme.com"
207
+ }
208
+ }),
209
+ mapping: {
210
+ skip: true,
211
+ settings: {
212
+ identify: {
213
+ map: {
214
+ user_id: "data.user_id",
215
+ set: {
216
+ map: {
217
+ plan: "data.plan",
218
+ company: "data.company",
219
+ email: "data.email"
220
+ }
221
+ },
222
+ setOnce: {
223
+ map: {
224
+ first_login: "timestamp"
225
+ }
226
+ },
227
+ add: {
228
+ map: {
229
+ login_count: { value: 1 }
230
+ }
231
+ }
232
+ }
233
+ }
234
+ }
235
+ },
236
+ out: [
237
+ "amplitude.identify",
238
+ {
239
+ set: {
240
+ plan: "premium",
241
+ company: "Acme",
242
+ email: "user@acme.com"
243
+ },
244
+ setOnce: {
245
+ first_login: 1700000105
246
+ },
247
+ add: {
248
+ login_count: 1
249
+ }
250
+ },
251
+ {
252
+ user_id: "new-user-123"
253
+ }
254
+ ]
255
+ };
256
+ var subscriptionRenewRevenue = {
257
+ in: (0, import_core.getEvent)("subscription renew", {
258
+ timestamp: 1700000107,
259
+ data: {
260
+ plan_id: "plan-pro",
261
+ amount: 9.99
262
+ }
263
+ }),
264
+ mapping: {
265
+ skip: true,
266
+ settings: {
267
+ revenue: {
268
+ map: {
269
+ productId: "data.plan_id",
270
+ price: "data.amount",
271
+ revenueType: { value: "renewal" },
272
+ currency: { key: "data.currency", value: "EUR" }
273
+ }
274
+ }
275
+ }
276
+ },
277
+ out: [
278
+ "amplitude.revenue",
279
+ {
280
+ productId: "plan-pro",
281
+ price: 9.99,
282
+ revenueType: "renewal",
283
+ currency: "EUR"
284
+ }
285
+ ]
286
+ };
287
+ var orderCompleteMultiProduct = {
288
+ in: (0, import_core.getEvent)("order complete", { timestamp: 1700000108 }),
289
+ mapping: {
290
+ include: ["data", "globals"],
291
+ settings: {
292
+ revenue: {
293
+ loop: [
294
+ "nested",
295
+ {
296
+ condition: (value) => {
297
+ var _a;
298
+ const v = value;
299
+ return typeof ((_a = v == null ? void 0 : v.data) == null ? void 0 : _a.price) === "number";
300
+ },
301
+ map: {
302
+ productId: "data.id",
303
+ price: "data.price",
304
+ quantity: { key: "data.quantity", value: 1 },
305
+ revenueType: { value: "purchase" },
306
+ currency: { key: "data.currency", value: "EUR" }
307
+ }
308
+ }
309
+ ]
310
+ }
311
+ }
312
+ },
313
+ out: [
314
+ [
315
+ "amplitude.revenue",
316
+ {
317
+ productId: "ers",
318
+ price: 420,
319
+ quantity: 1,
320
+ revenueType: "purchase",
321
+ currency: "EUR"
322
+ }
323
+ ],
324
+ [
325
+ "amplitude.revenue",
326
+ {
327
+ productId: "cc",
328
+ price: 42,
329
+ quantity: 1,
330
+ revenueType: "purchase",
331
+ currency: "EUR"
332
+ }
333
+ ],
334
+ [
335
+ "amplitude.track",
336
+ "order complete",
337
+ {
338
+ data_id: "0rd3r1d",
339
+ data_currency: "EUR",
340
+ data_shipping: 5.22,
341
+ data_taxes: 73.76,
342
+ data_total: 555,
343
+ globals_pagegroup: "shop"
344
+ }
345
+ ]
346
+ ]
347
+ };
348
+ var groupAssignmentWithProperties = {
349
+ in: (0, import_core.getEvent)("company update", {
350
+ timestamp: 1700000109,
351
+ data: {
352
+ company: "Acme",
353
+ industry: "tech",
354
+ employee_count: 50,
355
+ founded_year: 2020
356
+ }
357
+ }),
358
+ mapping: {
359
+ skip: true,
360
+ settings: {
361
+ group: {
362
+ map: {
363
+ type: { value: "company" },
364
+ name: "data.company"
365
+ }
366
+ },
367
+ groupIdentify: {
368
+ map: {
369
+ type: { value: "company" },
370
+ name: "data.company",
371
+ set: {
372
+ map: {
373
+ industry: "data.industry",
374
+ size: "data.employee_count"
375
+ }
376
+ },
377
+ setOnce: {
378
+ map: {
379
+ founded: "data.founded_year"
380
+ }
381
+ }
382
+ }
383
+ }
384
+ }
385
+ },
386
+ out: [
387
+ ["amplitude.setGroup", "company", "Acme"],
388
+ [
389
+ "amplitude.groupIdentify",
390
+ "company",
391
+ "Acme",
392
+ {
393
+ set: {
394
+ industry: "tech",
395
+ size: 50
396
+ },
397
+ setOnce: {
398
+ founded: 2020
399
+ }
400
+ }
401
+ ]
402
+ ]
403
+ };
404
+ var eventOptionsTimeInsertId = {
405
+ in: (0, import_core.getEvent)("page view", { timestamp: 1700000110 }),
406
+ settings: {
407
+ eventOptions: {
408
+ map: {
409
+ time: "timestamp",
410
+ insert_id: "id"
411
+ }
412
+ }
413
+ },
414
+ out: [
415
+ "amplitude.track",
416
+ "page view",
417
+ {},
418
+ {
419
+ time: 1700000110,
420
+ insert_id: "1700000110-gr0up-1"
421
+ }
422
+ ]
423
+ };
424
+ var consentRevokeOptOut = {
425
+ command: "consent",
426
+ in: { analytics: false },
427
+ settings: {},
428
+ out: ["amplitude.setOptOut", true]
429
+ };
430
+ var consentGrantOptIn = {
431
+ command: "consent",
432
+ in: { analytics: true },
433
+ settings: {},
434
+ out: ["amplitude.setOptOut", false]
435
+ };
436
+ // Annotate the CommonJS export names for ESM import in node:
437
+ 0 && (module.exports = {
438
+ env,
439
+ step
440
+ });