@walkeros/server-destination-criteo 3.4.0-next-1776749829492

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,295 @@
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
+ push: () => push,
32
+ simulation: () => simulation
33
+ });
34
+ var mockSendServer = async () => ({
35
+ ok: true,
36
+ data: "OK"
37
+ });
38
+ var push = {
39
+ sendServer: mockSendServer
40
+ };
41
+ var simulation = ["sendServer"];
42
+
43
+ // src/examples/step.ts
44
+ var step_exports = {};
45
+ __export(step_exports, {
46
+ addToCart: () => addToCart,
47
+ pageView: () => pageView,
48
+ purchase: () => purchase,
49
+ viewItem: () => viewItem
50
+ });
51
+ var import_core = require("@walkeros/core");
52
+ var ENDPOINT = "https://widget.criteo.com/m/event?version=s2s_v0";
53
+ var purchase = {
54
+ in: (0, import_core.getEvent)("order complete", {
55
+ timestamp: 17000009e5,
56
+ data: { id: "ORD-300", total: 249.99, currency: "EUR" },
57
+ nested: [
58
+ {
59
+ entity: "product",
60
+ data: { id: "SKU-A1", name: "Widget Pro", price: 124.99, quantity: 2 }
61
+ }
62
+ ],
63
+ user: { id: "user-123", device: "device-456" },
64
+ source: {
65
+ type: "server",
66
+ id: "https://shop.example.com/checkout/complete",
67
+ previous_id: "https://shop.example.com/cart"
68
+ }
69
+ }),
70
+ mapping: {
71
+ name: "trackTransaction",
72
+ data: {
73
+ map: {
74
+ id: "data.id",
75
+ item: {
76
+ loop: [
77
+ "nested",
78
+ {
79
+ condition: (entity) => (0, import_core.isObject)(entity) && entity.entity === "product",
80
+ map: {
81
+ id: "data.id",
82
+ price: "data.price",
83
+ quantity: { key: "data.quantity", value: 1 }
84
+ }
85
+ }
86
+ ]
87
+ }
88
+ }
89
+ }
90
+ },
91
+ out: [
92
+ [
93
+ "sendServer",
94
+ ENDPOINT,
95
+ JSON.stringify({
96
+ version: "walkeros_criteo_1.0.0",
97
+ site_type: "d",
98
+ account: "PARTNER_ID",
99
+ id: {
100
+ mapping_key: "CALLER_ID"
101
+ },
102
+ events: [
103
+ {
104
+ event: "trackTransaction",
105
+ timestamp: "2023-11-14T22:28:20.000Z",
106
+ id: "ORD-300",
107
+ item: [
108
+ {
109
+ id: "SKU-A1",
110
+ price: 124.99,
111
+ quantity: 2
112
+ }
113
+ ]
114
+ }
115
+ ],
116
+ full_url: "https://shop.example.com/checkout/complete",
117
+ previous_url: "https://shop.example.com/cart"
118
+ })
119
+ ]
120
+ ]
121
+ };
122
+ var addToCart = {
123
+ in: (0, import_core.getEvent)("product add", {
124
+ timestamp: 1700000901e3,
125
+ data: {
126
+ id: "SKU-B2",
127
+ name: "Running Shoes",
128
+ price: 89.99
129
+ },
130
+ nested: [
131
+ {
132
+ entity: "product",
133
+ data: {
134
+ id: "SKU-B2",
135
+ name: "Running Shoes",
136
+ price: 89.99,
137
+ quantity: 1
138
+ }
139
+ }
140
+ ],
141
+ source: {
142
+ type: "server",
143
+ id: "https://shop.example.com/products/running-shoes",
144
+ previous_id: ""
145
+ }
146
+ }),
147
+ mapping: {
148
+ name: "addToCart",
149
+ data: {
150
+ map: {
151
+ item: {
152
+ loop: [
153
+ "nested",
154
+ {
155
+ condition: (entity) => (0, import_core.isObject)(entity) && entity.entity === "product",
156
+ map: {
157
+ id: "data.id",
158
+ price: "data.price",
159
+ quantity: { key: "data.quantity", value: 1 }
160
+ }
161
+ }
162
+ ]
163
+ }
164
+ }
165
+ }
166
+ },
167
+ out: [
168
+ [
169
+ "sendServer",
170
+ ENDPOINT,
171
+ JSON.stringify({
172
+ version: "walkeros_criteo_1.0.0",
173
+ site_type: "d",
174
+ account: "PARTNER_ID",
175
+ id: {
176
+ mapping_key: "CALLER_ID"
177
+ },
178
+ events: [
179
+ {
180
+ event: "addToCart",
181
+ timestamp: "2023-11-14T22:28:21.000Z",
182
+ item: [
183
+ {
184
+ id: "SKU-B2",
185
+ price: 89.99,
186
+ quantity: 1
187
+ }
188
+ ]
189
+ }
190
+ ],
191
+ full_url: "https://shop.example.com/products/running-shoes"
192
+ })
193
+ ]
194
+ ]
195
+ };
196
+ var viewItem = {
197
+ in: (0, import_core.getEvent)("product view", {
198
+ timestamp: 1700000902e3,
199
+ data: { id: "SKU-C3", name: "Coffee Maker" },
200
+ nested: [
201
+ {
202
+ entity: "product",
203
+ data: { id: "SKU-C3" }
204
+ }
205
+ ],
206
+ source: {
207
+ type: "server",
208
+ id: "https://shop.example.com/products/coffee-maker",
209
+ previous_id: ""
210
+ }
211
+ }),
212
+ mapping: {
213
+ name: "viewItem",
214
+ data: {
215
+ map: {
216
+ item: {
217
+ loop: [
218
+ "nested",
219
+ {
220
+ condition: (entity) => (0, import_core.isObject)(entity) && entity.entity === "product",
221
+ map: {
222
+ id: "data.id"
223
+ }
224
+ }
225
+ ]
226
+ }
227
+ }
228
+ }
229
+ },
230
+ out: [
231
+ [
232
+ "sendServer",
233
+ ENDPOINT,
234
+ JSON.stringify({
235
+ version: "walkeros_criteo_1.0.0",
236
+ site_type: "d",
237
+ account: "PARTNER_ID",
238
+ id: {
239
+ mapping_key: "CALLER_ID"
240
+ },
241
+ events: [
242
+ {
243
+ event: "viewItem",
244
+ timestamp: "2023-11-14T22:28:22.000Z",
245
+ item: [
246
+ {
247
+ id: "SKU-C3"
248
+ }
249
+ ]
250
+ }
251
+ ],
252
+ full_url: "https://shop.example.com/products/coffee-maker"
253
+ })
254
+ ]
255
+ ]
256
+ };
257
+ var pageView = {
258
+ in: (0, import_core.getEvent)("page view", {
259
+ timestamp: 1700000903e3,
260
+ source: {
261
+ type: "server",
262
+ id: "https://example.com/",
263
+ previous_id: ""
264
+ }
265
+ }),
266
+ mapping: {
267
+ name: "viewHome"
268
+ },
269
+ out: [
270
+ [
271
+ "sendServer",
272
+ ENDPOINT,
273
+ JSON.stringify({
274
+ version: "walkeros_criteo_1.0.0",
275
+ site_type: "d",
276
+ account: "PARTNER_ID",
277
+ id: {
278
+ mapping_key: "CALLER_ID"
279
+ },
280
+ events: [
281
+ {
282
+ event: "viewHome",
283
+ timestamp: "2023-11-14T22:28:23.000Z"
284
+ }
285
+ ],
286
+ full_url: "https://example.com/"
287
+ })
288
+ ]
289
+ ]
290
+ };
291
+ // Annotate the CommonJS export names for ESM import in node:
292
+ 0 && (module.exports = {
293
+ env,
294
+ step
295
+ });
@@ -0,0 +1,273 @@
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
+ push: () => push,
11
+ simulation: () => simulation
12
+ });
13
+ var mockSendServer = async () => ({
14
+ ok: true,
15
+ data: "OK"
16
+ });
17
+ var push = {
18
+ sendServer: mockSendServer
19
+ };
20
+ var simulation = ["sendServer"];
21
+
22
+ // src/examples/step.ts
23
+ var step_exports = {};
24
+ __export(step_exports, {
25
+ addToCart: () => addToCart,
26
+ pageView: () => pageView,
27
+ purchase: () => purchase,
28
+ viewItem: () => viewItem
29
+ });
30
+ import { getEvent, isObject } from "@walkeros/core";
31
+ var ENDPOINT = "https://widget.criteo.com/m/event?version=s2s_v0";
32
+ var purchase = {
33
+ in: getEvent("order complete", {
34
+ timestamp: 17000009e5,
35
+ data: { id: "ORD-300", total: 249.99, currency: "EUR" },
36
+ nested: [
37
+ {
38
+ entity: "product",
39
+ data: { id: "SKU-A1", name: "Widget Pro", price: 124.99, quantity: 2 }
40
+ }
41
+ ],
42
+ user: { id: "user-123", device: "device-456" },
43
+ source: {
44
+ type: "server",
45
+ id: "https://shop.example.com/checkout/complete",
46
+ previous_id: "https://shop.example.com/cart"
47
+ }
48
+ }),
49
+ mapping: {
50
+ name: "trackTransaction",
51
+ data: {
52
+ map: {
53
+ id: "data.id",
54
+ item: {
55
+ loop: [
56
+ "nested",
57
+ {
58
+ condition: (entity) => isObject(entity) && entity.entity === "product",
59
+ map: {
60
+ id: "data.id",
61
+ price: "data.price",
62
+ quantity: { key: "data.quantity", value: 1 }
63
+ }
64
+ }
65
+ ]
66
+ }
67
+ }
68
+ }
69
+ },
70
+ out: [
71
+ [
72
+ "sendServer",
73
+ ENDPOINT,
74
+ JSON.stringify({
75
+ version: "walkeros_criteo_1.0.0",
76
+ site_type: "d",
77
+ account: "PARTNER_ID",
78
+ id: {
79
+ mapping_key: "CALLER_ID"
80
+ },
81
+ events: [
82
+ {
83
+ event: "trackTransaction",
84
+ timestamp: "2023-11-14T22:28:20.000Z",
85
+ id: "ORD-300",
86
+ item: [
87
+ {
88
+ id: "SKU-A1",
89
+ price: 124.99,
90
+ quantity: 2
91
+ }
92
+ ]
93
+ }
94
+ ],
95
+ full_url: "https://shop.example.com/checkout/complete",
96
+ previous_url: "https://shop.example.com/cart"
97
+ })
98
+ ]
99
+ ]
100
+ };
101
+ var addToCart = {
102
+ in: getEvent("product add", {
103
+ timestamp: 1700000901e3,
104
+ data: {
105
+ id: "SKU-B2",
106
+ name: "Running Shoes",
107
+ price: 89.99
108
+ },
109
+ nested: [
110
+ {
111
+ entity: "product",
112
+ data: {
113
+ id: "SKU-B2",
114
+ name: "Running Shoes",
115
+ price: 89.99,
116
+ quantity: 1
117
+ }
118
+ }
119
+ ],
120
+ source: {
121
+ type: "server",
122
+ id: "https://shop.example.com/products/running-shoes",
123
+ previous_id: ""
124
+ }
125
+ }),
126
+ mapping: {
127
+ name: "addToCart",
128
+ data: {
129
+ map: {
130
+ item: {
131
+ loop: [
132
+ "nested",
133
+ {
134
+ condition: (entity) => isObject(entity) && entity.entity === "product",
135
+ map: {
136
+ id: "data.id",
137
+ price: "data.price",
138
+ quantity: { key: "data.quantity", value: 1 }
139
+ }
140
+ }
141
+ ]
142
+ }
143
+ }
144
+ }
145
+ },
146
+ out: [
147
+ [
148
+ "sendServer",
149
+ ENDPOINT,
150
+ JSON.stringify({
151
+ version: "walkeros_criteo_1.0.0",
152
+ site_type: "d",
153
+ account: "PARTNER_ID",
154
+ id: {
155
+ mapping_key: "CALLER_ID"
156
+ },
157
+ events: [
158
+ {
159
+ event: "addToCart",
160
+ timestamp: "2023-11-14T22:28:21.000Z",
161
+ item: [
162
+ {
163
+ id: "SKU-B2",
164
+ price: 89.99,
165
+ quantity: 1
166
+ }
167
+ ]
168
+ }
169
+ ],
170
+ full_url: "https://shop.example.com/products/running-shoes"
171
+ })
172
+ ]
173
+ ]
174
+ };
175
+ var viewItem = {
176
+ in: getEvent("product view", {
177
+ timestamp: 1700000902e3,
178
+ data: { id: "SKU-C3", name: "Coffee Maker" },
179
+ nested: [
180
+ {
181
+ entity: "product",
182
+ data: { id: "SKU-C3" }
183
+ }
184
+ ],
185
+ source: {
186
+ type: "server",
187
+ id: "https://shop.example.com/products/coffee-maker",
188
+ previous_id: ""
189
+ }
190
+ }),
191
+ mapping: {
192
+ name: "viewItem",
193
+ data: {
194
+ map: {
195
+ item: {
196
+ loop: [
197
+ "nested",
198
+ {
199
+ condition: (entity) => isObject(entity) && entity.entity === "product",
200
+ map: {
201
+ id: "data.id"
202
+ }
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ }
208
+ },
209
+ out: [
210
+ [
211
+ "sendServer",
212
+ ENDPOINT,
213
+ JSON.stringify({
214
+ version: "walkeros_criteo_1.0.0",
215
+ site_type: "d",
216
+ account: "PARTNER_ID",
217
+ id: {
218
+ mapping_key: "CALLER_ID"
219
+ },
220
+ events: [
221
+ {
222
+ event: "viewItem",
223
+ timestamp: "2023-11-14T22:28:22.000Z",
224
+ item: [
225
+ {
226
+ id: "SKU-C3"
227
+ }
228
+ ]
229
+ }
230
+ ],
231
+ full_url: "https://shop.example.com/products/coffee-maker"
232
+ })
233
+ ]
234
+ ]
235
+ };
236
+ var pageView = {
237
+ in: getEvent("page view", {
238
+ timestamp: 1700000903e3,
239
+ source: {
240
+ type: "server",
241
+ id: "https://example.com/",
242
+ previous_id: ""
243
+ }
244
+ }),
245
+ mapping: {
246
+ name: "viewHome"
247
+ },
248
+ out: [
249
+ [
250
+ "sendServer",
251
+ ENDPOINT,
252
+ JSON.stringify({
253
+ version: "walkeros_criteo_1.0.0",
254
+ site_type: "d",
255
+ account: "PARTNER_ID",
256
+ id: {
257
+ mapping_key: "CALLER_ID"
258
+ },
259
+ events: [
260
+ {
261
+ event: "viewHome",
262
+ timestamp: "2023-11-14T22:28:23.000Z"
263
+ }
264
+ ],
265
+ full_url: "https://example.com/"
266
+ })
267
+ ]
268
+ ]
269
+ };
270
+ export {
271
+ env_exports as env,
272
+ step_exports as step
273
+ };
@@ -0,0 +1,120 @@
1
+ import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
2
+ import { DestinationServer, sendServer } from '@walkeros/server-core';
3
+
4
+ interface Settings {
5
+ /** Criteo Partner ID (numeric string, provided by Criteo) */
6
+ partnerId: string;
7
+ /** Caller ID for user mapping (provided by Criteo) */
8
+ callerId: string;
9
+ /** Site type: `d` (desktop), `m` (mobile web), `t` (tablet). Default `d`. */
10
+ siteType?: SiteType;
11
+ /** ISO 3166-1 alpha-2 country code */
12
+ country?: string;
13
+ /** 2-letter language code */
14
+ language?: string;
15
+ /** API endpoint override (default: https://widget.criteo.com/m/event?version=s2s_v0) */
16
+ url?: string;
17
+ /** Mapping for identity fields (mapped_user_id, email, retailer_visitor_id) */
18
+ user_data?: Mapping$1.Map;
19
+ }
20
+ type InitSettings = Partial<Settings>;
21
+ interface Mapping {
22
+ }
23
+ interface Env extends DestinationServer.Env {
24
+ sendServer?: typeof sendServer;
25
+ }
26
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
27
+ interface Destination extends DestinationServer.Destination<Types> {
28
+ init: DestinationServer.InitFn<Types>;
29
+ }
30
+ type Config = {
31
+ settings: Settings;
32
+ } & DestinationServer.Config<Types>;
33
+ type InitFn = DestinationServer.InitFn<Types>;
34
+ type PushFn = DestinationServer.PushFn<Types>;
35
+ type PartialConfig = DestinationServer.PartialConfig<Types>;
36
+ type PushEvents = DestinationServer.PushEvents<Mapping>;
37
+ type Rule = Mapping$1.Rule<Mapping>;
38
+ type Rules = Mapping$1.Rules<Rule>;
39
+ /** Site type: desktop / mobile web / tablet */
40
+ type SiteType = 'd' | 'm' | 't';
41
+ /**
42
+ * Criteo Events API (S2S v0)
43
+ * https://guides.criteotilt.com/events-api/
44
+ */
45
+ interface CriteoRequestBody {
46
+ /** Integration version identifier (e.g. `walkeros_criteo_1.0.0`) */
47
+ version: string;
48
+ site_type?: SiteType;
49
+ /** Criteo Partner ID */
50
+ account: string;
51
+ id: CriteoIdentity;
52
+ ip?: string;
53
+ full_url?: string;
54
+ previous_url?: string;
55
+ useragent?: string;
56
+ retailer_visitor_id?: string;
57
+ country?: string;
58
+ language?: string;
59
+ events: CriteoEvent[];
60
+ }
61
+ interface CriteoIdentity {
62
+ /** GUM ID */
63
+ mapped_user_id?: string;
64
+ /** Caller ID (provided by Criteo) */
65
+ mapping_key: string;
66
+ email?: CriteoEmailHashes;
67
+ }
68
+ interface CriteoEmailHashes {
69
+ raw?: string;
70
+ md5?: string;
71
+ sha256?: string;
72
+ sha256_md5?: string;
73
+ }
74
+ interface CriteoEvent {
75
+ event: CriteoEventName;
76
+ /** ISO 8601 timestamp */
77
+ timestamp?: string;
78
+ /** Transaction ID or event-level ID */
79
+ id?: string;
80
+ item?: CriteoItem[];
81
+ deduplication_page_view_id?: string;
82
+ }
83
+ interface CriteoItem {
84
+ id: string;
85
+ price?: number;
86
+ quantity?: number;
87
+ }
88
+ /**
89
+ * Standard Criteo Events API event names.
90
+ * Custom event names are also accepted as plain strings.
91
+ */
92
+ type CriteoEventName = 'viewHome' | 'viewPage' | 'viewItem' | 'viewList' | 'addToCart' | 'viewBasket' | 'beginCheckout' | 'trackTransaction' | 'addPaymentInfo' | 'login' | (string & {});
93
+
94
+ type index_Config = Config;
95
+ type index_CriteoEmailHashes = CriteoEmailHashes;
96
+ type index_CriteoEvent = CriteoEvent;
97
+ type index_CriteoEventName = CriteoEventName;
98
+ type index_CriteoIdentity = CriteoIdentity;
99
+ type index_CriteoItem = CriteoItem;
100
+ type index_CriteoRequestBody = CriteoRequestBody;
101
+ type index_Destination = Destination;
102
+ type index_Env = Env;
103
+ type index_InitFn = InitFn;
104
+ type index_InitSettings = InitSettings;
105
+ type index_Mapping = Mapping;
106
+ type index_PartialConfig = PartialConfig;
107
+ type index_PushEvents = PushEvents;
108
+ type index_PushFn = PushFn;
109
+ type index_Rule = Rule;
110
+ type index_Rules = Rules;
111
+ type index_Settings = Settings;
112
+ type index_SiteType = SiteType;
113
+ type index_Types = Types;
114
+ declare namespace index {
115
+ export type { index_Config as Config, index_CriteoEmailHashes as CriteoEmailHashes, index_CriteoEvent as CriteoEvent, index_CriteoEventName as CriteoEventName, index_CriteoIdentity as CriteoIdentity, index_CriteoItem as CriteoItem, index_CriteoRequestBody as CriteoRequestBody, index_Destination as Destination, index_Env as Env, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_SiteType as SiteType, index_Types as Types };
116
+ }
117
+
118
+ declare const destinationCriteo: Destination;
119
+
120
+ export { index as DestinationCriteo, destinationCriteo as default, destinationCriteo };