cdp-edge 2.0.2 → 2.0.4
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/README.md +325 -308
- package/contracts/agent-versions.json +364 -0
- package/dist/commands/install.js +1 -1
- package/dist/commands/setup.js +1 -1
- package/extracted-skill/tracking-events-generator/agents/browser-tracking.md +2 -2
- package/extracted-skill/tracking-events-generator/agents/master-orchestrator.md +14 -20
- package/extracted-skill/tracking-events-generator/agents/premium-tracking-intelligence-agent.md +4 -4
- package/extracted-skill/tracking-events-generator/agents/server-tracking.md +13 -13
- package/extracted-skill/tracking-events-generator/agents/spotify-agent.md +1 -1
- package/extracted-skill/tracking-events-generator/agents/webhook-agent.md +4 -4
- package/extracted-skill/tracking-events-generator/agents/youtube-agent.md +3 -3
- package/package.json +81 -76
- package/server-edge-tracker/index.js +780 -0
- package/server-edge-tracker/modules/db.js +531 -0
- package/server-edge-tracker/modules/dispatch/ga4.js +65 -0
- package/server-edge-tracker/modules/dispatch/meta.js +103 -0
- package/server-edge-tracker/modules/dispatch/platforms.js +237 -0
- package/server-edge-tracker/modules/dispatch/tiktok.js +100 -0
- package/server-edge-tracker/modules/dispatch/whatsapp.js +233 -0
- package/server-edge-tracker/modules/intelligence.js +204 -0
- package/server-edge-tracker/modules/ml/bidding.js +245 -0
- package/server-edge-tracker/modules/ml/fraud.js +301 -0
- package/server-edge-tracker/modules/ml/ltv.js +320 -0
- package/server-edge-tracker/modules/ml/segmentation.js +316 -0
- package/server-edge-tracker/modules/utils.js +89 -0
- package/server-edge-tracker/schema-indexes.sql +67 -0
- package/server-edge-tracker/wrangler.toml +2 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Fonte de verdade para versões dos agent files. Atualizar manualmente quando worker.js mudar. Use scripts/validate-agents.js para detectar drifts.",
|
|
3
|
+
"worker_version": "2.0.3",
|
|
4
|
+
"worker_hash_date": "2026-04-10",
|
|
5
|
+
"agents": {
|
|
6
|
+
"master-orchestrator": {
|
|
7
|
+
"version": "2.0.3",
|
|
8
|
+
"last_synced": "2026-04-10",
|
|
9
|
+
"depends_on": [
|
|
10
|
+
"worker.js:fetch",
|
|
11
|
+
"worker.js:endpoints",
|
|
12
|
+
"worker.js:events"
|
|
13
|
+
],
|
|
14
|
+
"critical_sections": [
|
|
15
|
+
"endpoints",
|
|
16
|
+
"event_names",
|
|
17
|
+
"secret_names",
|
|
18
|
+
"phases"
|
|
19
|
+
],
|
|
20
|
+
"status": "synced"
|
|
21
|
+
},
|
|
22
|
+
"server-tracking": {
|
|
23
|
+
"version": "2.0.3",
|
|
24
|
+
"last_synced": "2026-04-10",
|
|
25
|
+
"depends_on": [
|
|
26
|
+
"worker.js:fetch",
|
|
27
|
+
"worker.js:saveLead",
|
|
28
|
+
"worker.js:upsertProfile",
|
|
29
|
+
"worker.js:secrets"
|
|
30
|
+
],
|
|
31
|
+
"critical_sections": [
|
|
32
|
+
"endpoint /track",
|
|
33
|
+
"secret names",
|
|
34
|
+
"D1 binding",
|
|
35
|
+
"identity graph"
|
|
36
|
+
],
|
|
37
|
+
"status": "synced"
|
|
38
|
+
},
|
|
39
|
+
"meta-agent": {
|
|
40
|
+
"version": "2.0.3",
|
|
41
|
+
"last_synced": "2026-04-10",
|
|
42
|
+
"depends_on": [
|
|
43
|
+
"worker.js:sendMetaCapi",
|
|
44
|
+
"contracts/api-versions.json:meta"
|
|
45
|
+
],
|
|
46
|
+
"critical_sections": [
|
|
47
|
+
"Meta CAPI version",
|
|
48
|
+
"endpoint pattern",
|
|
49
|
+
"event names"
|
|
50
|
+
],
|
|
51
|
+
"status": "synced"
|
|
52
|
+
},
|
|
53
|
+
"google-agent": {
|
|
54
|
+
"version": "2.0.3",
|
|
55
|
+
"last_synced": "2026-04-10",
|
|
56
|
+
"depends_on": [
|
|
57
|
+
"worker.js:sendGA4Mp",
|
|
58
|
+
"contracts/api-versions.json:google"
|
|
59
|
+
],
|
|
60
|
+
"critical_sections": [
|
|
61
|
+
"GA4 Measurement Protocol endpoint",
|
|
62
|
+
"event names"
|
|
63
|
+
],
|
|
64
|
+
"status": "synced"
|
|
65
|
+
},
|
|
66
|
+
"tiktok-agent": {
|
|
67
|
+
"version": "2.0.3",
|
|
68
|
+
"last_synced": "2026-04-10",
|
|
69
|
+
"depends_on": [
|
|
70
|
+
"worker.js:sendTikTokApi",
|
|
71
|
+
"contracts/api-versions.json:tiktok"
|
|
72
|
+
],
|
|
73
|
+
"critical_sections": [
|
|
74
|
+
"TikTok Events API v1.3",
|
|
75
|
+
"endpoint pattern",
|
|
76
|
+
"event names"
|
|
77
|
+
],
|
|
78
|
+
"status": "synced"
|
|
79
|
+
},
|
|
80
|
+
"youtube-agent": {
|
|
81
|
+
"version": "2.0.3",
|
|
82
|
+
"last_synced": "2026-04-10",
|
|
83
|
+
"depends_on": [
|
|
84
|
+
"contracts/api-versions.json:youtube"
|
|
85
|
+
],
|
|
86
|
+
"critical_sections": [
|
|
87
|
+
"video milestone events: video_25/50/75/video_complete",
|
|
88
|
+
"YT IFrame API"
|
|
89
|
+
],
|
|
90
|
+
"status": "synced"
|
|
91
|
+
},
|
|
92
|
+
"whatsapp-ctwa-setup-agent": {
|
|
93
|
+
"version": "2.0.3",
|
|
94
|
+
"last_synced": "2026-04-10",
|
|
95
|
+
"depends_on": [
|
|
96
|
+
"worker.js:sendWhatsApp",
|
|
97
|
+
"worker.js:processWhatsAppWebhook"
|
|
98
|
+
],
|
|
99
|
+
"critical_sections": [
|
|
100
|
+
"WHATSAPP_ACCESS_TOKEN",
|
|
101
|
+
"WHATSAPP_PHONE_NUMBER_ID",
|
|
102
|
+
"WA_WEBHOOK_VERIFY_TOKEN"
|
|
103
|
+
],
|
|
104
|
+
"status": "synced"
|
|
105
|
+
},
|
|
106
|
+
"intelligence-agent": {
|
|
107
|
+
"version": "2.0.3",
|
|
108
|
+
"last_synced": "2026-04-10",
|
|
109
|
+
"depends_on": [
|
|
110
|
+
"worker.js:runIntelligenceAgent",
|
|
111
|
+
"worker.js:checkApiVersionsIntelligence"
|
|
112
|
+
],
|
|
113
|
+
"critical_sections": [
|
|
114
|
+
"cron schedule",
|
|
115
|
+
"endpoint /track",
|
|
116
|
+
"secret names"
|
|
117
|
+
],
|
|
118
|
+
"status": "synced"
|
|
119
|
+
},
|
|
120
|
+
"fraud-detection-agent": {
|
|
121
|
+
"version": "2.0.3",
|
|
122
|
+
"last_synced": "2026-04-10",
|
|
123
|
+
"depends_on": [
|
|
124
|
+
"worker.js:checkFraudGate",
|
|
125
|
+
"worker.js:handleFraudAlerts",
|
|
126
|
+
"schema-fraud.sql"
|
|
127
|
+
],
|
|
128
|
+
"critical_sections": [
|
|
129
|
+
"fraud score threshold",
|
|
130
|
+
"KV blocklist",
|
|
131
|
+
"endpoints /api/fraud/"
|
|
132
|
+
],
|
|
133
|
+
"status": "synced"
|
|
134
|
+
},
|
|
135
|
+
"ml-clustering-agent": {
|
|
136
|
+
"version": "2.0.3",
|
|
137
|
+
"last_synced": "2026-04-10",
|
|
138
|
+
"depends_on": [
|
|
139
|
+
"worker.js:handleSegmentationCluster",
|
|
140
|
+
"schema-segmentation.sql"
|
|
141
|
+
],
|
|
142
|
+
"critical_sections": [
|
|
143
|
+
"Workers AI model",
|
|
144
|
+
"endpoints /api/segmentation/",
|
|
145
|
+
"D1 binding"
|
|
146
|
+
],
|
|
147
|
+
"status": "synced"
|
|
148
|
+
},
|
|
149
|
+
"bidding-agent": {
|
|
150
|
+
"version": "2.0.3",
|
|
151
|
+
"last_synced": "2026-04-10",
|
|
152
|
+
"depends_on": [
|
|
153
|
+
"worker.js:handleBiddingRecommend",
|
|
154
|
+
"schema-bidding.sql"
|
|
155
|
+
],
|
|
156
|
+
"critical_sections": [
|
|
157
|
+
"endpoints /api/bidding/",
|
|
158
|
+
"segment multipliers"
|
|
159
|
+
],
|
|
160
|
+
"status": "synced"
|
|
161
|
+
},
|
|
162
|
+
"ab-ltv-agent": {
|
|
163
|
+
"version": "2.0.3",
|
|
164
|
+
"last_synced": "2026-04-10",
|
|
165
|
+
"depends_on": [
|
|
166
|
+
"worker.js:predictLtv",
|
|
167
|
+
"worker.js:getLtvAbVariation",
|
|
168
|
+
"schema-ab-ltv.sql"
|
|
169
|
+
],
|
|
170
|
+
"critical_sections": [
|
|
171
|
+
"Workers AI model @cf/meta/llama-3.1-8b-instruct",
|
|
172
|
+
"endpoints /api/ltv/"
|
|
173
|
+
],
|
|
174
|
+
"status": "synced"
|
|
175
|
+
},
|
|
176
|
+
"security-enterprise-agent": {
|
|
177
|
+
"version": "2.0.3",
|
|
178
|
+
"last_synced": "2026-04-10",
|
|
179
|
+
"depends_on": [
|
|
180
|
+
"worker.js:checkFraudGate",
|
|
181
|
+
"worker.js:verifyHmac"
|
|
182
|
+
],
|
|
183
|
+
"critical_sections": [
|
|
184
|
+
"env.DB.prepare",
|
|
185
|
+
"env.GEO_CACHE",
|
|
186
|
+
"HMAC validation"
|
|
187
|
+
],
|
|
188
|
+
"status": "synced"
|
|
189
|
+
},
|
|
190
|
+
"attribution-agent": {
|
|
191
|
+
"version": "2.0.3",
|
|
192
|
+
"last_synced": "2026-04-10",
|
|
193
|
+
"depends_on": [
|
|
194
|
+
"worker.js:saveLead",
|
|
195
|
+
"worker.js:sendMetaCapi",
|
|
196
|
+
"worker.js:sendTikTokApi"
|
|
197
|
+
],
|
|
198
|
+
"critical_sections": [
|
|
199
|
+
"env.DB.prepare",
|
|
200
|
+
"env.META_ACCESS_TOKEN",
|
|
201
|
+
"env.TIKTOK_ACCESS_TOKEN"
|
|
202
|
+
],
|
|
203
|
+
"status": "synced"
|
|
204
|
+
},
|
|
205
|
+
"devops-agent": {
|
|
206
|
+
"version": "2.0.3",
|
|
207
|
+
"last_synced": "2026-04-10",
|
|
208
|
+
"depends_on": [
|
|
209
|
+
"wrangler.toml",
|
|
210
|
+
"schema.sql",
|
|
211
|
+
"schema-segmentation.sql",
|
|
212
|
+
"schema-bidding.sql",
|
|
213
|
+
"schema-ab-ltv.sql",
|
|
214
|
+
"schema-fraud.sql"
|
|
215
|
+
],
|
|
216
|
+
"critical_sections": [
|
|
217
|
+
"D1 binding names",
|
|
218
|
+
"secret names",
|
|
219
|
+
"schema execution order",
|
|
220
|
+
"Workers AI binding"
|
|
221
|
+
],
|
|
222
|
+
"status": "synced"
|
|
223
|
+
},
|
|
224
|
+
"validator-agent": {
|
|
225
|
+
"version": "2.0.3",
|
|
226
|
+
"last_synced": "2026-04-10",
|
|
227
|
+
"depends_on": [
|
|
228
|
+
"worker.js",
|
|
229
|
+
"all agents"
|
|
230
|
+
],
|
|
231
|
+
"critical_sections": [
|
|
232
|
+
"canonical event names 19",
|
|
233
|
+
"canonical secret names",
|
|
234
|
+
"canonical endpoints"
|
|
235
|
+
],
|
|
236
|
+
"status": "synced"
|
|
237
|
+
},
|
|
238
|
+
"ltv-predictor-agent": {
|
|
239
|
+
"version": "2.0.3",
|
|
240
|
+
"last_synced": "2026-04-10",
|
|
241
|
+
"depends_on": [
|
|
242
|
+
"worker.js:predictLtv"
|
|
243
|
+
],
|
|
244
|
+
"critical_sections": [
|
|
245
|
+
"@cf/meta/llama-3.1-8b-instruct model name"
|
|
246
|
+
],
|
|
247
|
+
"status": "synced"
|
|
248
|
+
},
|
|
249
|
+
"database-agent": {
|
|
250
|
+
"version": "2.0.3",
|
|
251
|
+
"last_synced": "2026-04-10",
|
|
252
|
+
"depends_on": [
|
|
253
|
+
"schema.sql",
|
|
254
|
+
"schema-segmentation.sql",
|
|
255
|
+
"schema-bidding.sql",
|
|
256
|
+
"schema-ab-ltv.sql",
|
|
257
|
+
"schema-fraud.sql",
|
|
258
|
+
"schema-indexes.sql"
|
|
259
|
+
],
|
|
260
|
+
"critical_sections": [
|
|
261
|
+
"table count (24 tables)",
|
|
262
|
+
"binding: DB",
|
|
263
|
+
"KV: GEO_CACHE"
|
|
264
|
+
],
|
|
265
|
+
"status": "synced"
|
|
266
|
+
},
|
|
267
|
+
"performance-agent": {
|
|
268
|
+
"version": "2.0.3",
|
|
269
|
+
"last_synced": "2026-04-10",
|
|
270
|
+
"depends_on": [
|
|
271
|
+
"worker.js:getHealthMetrics"
|
|
272
|
+
],
|
|
273
|
+
"critical_sections": [
|
|
274
|
+
"env.DB.prepare",
|
|
275
|
+
"env.GEO_CACHE"
|
|
276
|
+
],
|
|
277
|
+
"status": "synced"
|
|
278
|
+
},
|
|
279
|
+
"dashboard-agent": {
|
|
280
|
+
"version": "2.0.3",
|
|
281
|
+
"last_synced": "2026-04-10",
|
|
282
|
+
"depends_on": [
|
|
283
|
+
"worker.js:generateDailyReport"
|
|
284
|
+
],
|
|
285
|
+
"critical_sections": [
|
|
286
|
+
"env.DB.prepare",
|
|
287
|
+
"env.GEO_CACHE"
|
|
288
|
+
],
|
|
289
|
+
"status": "synced"
|
|
290
|
+
},
|
|
291
|
+
"browser-tracking": {
|
|
292
|
+
"version": "2.0.3",
|
|
293
|
+
"last_synced": "2026-04-10",
|
|
294
|
+
"depends_on": [
|
|
295
|
+
"extracted-skill/tracking-events-generator/cdpTrack.js"
|
|
296
|
+
],
|
|
297
|
+
"critical_sections": [
|
|
298
|
+
"endpoint /track",
|
|
299
|
+
"event_id deduplication",
|
|
300
|
+
"cdp_uid cookie"
|
|
301
|
+
],
|
|
302
|
+
"status": "synced"
|
|
303
|
+
},
|
|
304
|
+
"debug-agent": {
|
|
305
|
+
"version": "2.0.3",
|
|
306
|
+
"last_synced": "2026-04-10",
|
|
307
|
+
"depends_on": [
|
|
308
|
+
"worker.js",
|
|
309
|
+
"all endpoints"
|
|
310
|
+
],
|
|
311
|
+
"critical_sections": [
|
|
312
|
+
"endpoint /track",
|
|
313
|
+
"endpoint /health",
|
|
314
|
+
"D1 binding"
|
|
315
|
+
],
|
|
316
|
+
"status": "synced"
|
|
317
|
+
},
|
|
318
|
+
"crm-integration-agent": {
|
|
319
|
+
"version": "2.0.3",
|
|
320
|
+
"last_synced": "2026-04-10",
|
|
321
|
+
"depends_on": [
|
|
322
|
+
"worker.js:saveLead",
|
|
323
|
+
"worker.js:upsertProfile"
|
|
324
|
+
],
|
|
325
|
+
"critical_sections": [
|
|
326
|
+
"env.DB.prepare",
|
|
327
|
+
"leads table schema"
|
|
328
|
+
],
|
|
329
|
+
"status": "synced"
|
|
330
|
+
},
|
|
331
|
+
"performance-optimization-agent": {
|
|
332
|
+
"version": "2.0.3",
|
|
333
|
+
"last_synced": "2026-04-10",
|
|
334
|
+
"depends_on": [
|
|
335
|
+
"worker.js"
|
|
336
|
+
],
|
|
337
|
+
"critical_sections": [
|
|
338
|
+
"env.GEO_CACHE (not env.CACHE_KV)"
|
|
339
|
+
],
|
|
340
|
+
"status": "synced"
|
|
341
|
+
},
|
|
342
|
+
"master-feedback-loop": {
|
|
343
|
+
"version": "2.0.3",
|
|
344
|
+
"last_synced": "2026-04-10",
|
|
345
|
+
"depends_on": [
|
|
346
|
+
"all agents"
|
|
347
|
+
],
|
|
348
|
+
"critical_sections": [
|
|
349
|
+
"env.DB.prepare",
|
|
350
|
+
"cron schedule"
|
|
351
|
+
],
|
|
352
|
+
"status": "synced"
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
"change_triggers": {
|
|
356
|
+
"worker.js:addNewEndpoint": "Atualizar: master-orchestrator, server-tracking, browser-tracking, debug-agent, intelligence-agent",
|
|
357
|
+
"worker.js:changeSecretName": "Atualizar: devops-agent, server-tracking, intelligence-agent, whatsapp-ctwa-setup-agent, database-agent",
|
|
358
|
+
"worker.js:changeEventName": "Atualizar: master-orchestrator, youtube-agent, validator-agent, browser-tracking",
|
|
359
|
+
"worker.js:changeAIModel": "Atualizar: ml-clustering-agent, ab-ltv-agent, ltv-predictor-agent",
|
|
360
|
+
"schema.sql:addTable": "Atualizar: database-agent (table count), devops-agent (migration order)",
|
|
361
|
+
"wrangler.toml:addBinding": "Atualizar: devops-agent, database-agent, debug-agent",
|
|
362
|
+
"contracts/api-versions.json:bumpVersion": "Atualizar: agent especialista + master-orchestrator"
|
|
363
|
+
}
|
|
364
|
+
}
|
package/dist/commands/install.js
CHANGED
|
@@ -32,7 +32,7 @@ function printBanner() {
|
|
|
32
32
|
console.log(chalk.cyan('╚██████╗██████╔╝██║ ███████╗██████╔╝╚██████╔╝███████╗'));
|
|
33
33
|
console.log(chalk.cyan(' ╚═════╝╚═════╝ ╚═╝ ╚══════╝╚═════╝ ╚═════╝╚══════╝'));
|
|
34
34
|
console.log('');
|
|
35
|
-
console.log(chalk.gray(' Customer Data Platform on the Edge · Global Edge Tracking · v2.0.
|
|
35
|
+
console.log(chalk.gray(' Customer Data Platform on the Edge · Global Edge Tracking · v2.0.4'));
|
|
36
36
|
console.log('');
|
|
37
37
|
console.log(chalk.gray('═'.repeat(68)));
|
|
38
38
|
console.log('');
|
package/dist/commands/setup.js
CHANGED
|
@@ -19,7 +19,7 @@ function printBanner() {
|
|
|
19
19
|
console.log(chalk.cyan('╚██████╗██████╔╝██║ ███████╗██████╔╝╚██████╔╝███████╗'));
|
|
20
20
|
console.log(chalk.cyan(' ╚═════╝╚═════╝ ╚═╝ ╚══════╝╚═════╝ ╚═════╝╚══════╝'));
|
|
21
21
|
console.log('');
|
|
22
|
-
console.log(chalk.gray(' Customer Data Platform on the Edge · Global Edge Tracking · v2.0.
|
|
22
|
+
console.log(chalk.gray(' Customer Data Platform on the Edge · Global Edge Tracking · v2.0.4'));
|
|
23
23
|
console.log('');
|
|
24
24
|
console.log(chalk.gray('═'.repeat(68)));
|
|
25
25
|
console.log('');
|
|
@@ -33,7 +33,7 @@ Database: Cloudflare D1 (Persistência)
|
|
|
33
33
|
## 📊 FUNCIONALIDADES DO SDK
|
|
34
34
|
|
|
35
35
|
### 1. Direct Fetch
|
|
36
|
-
O rastreamento utiliza chamadas diretas via `fetch()` para o endpoint `/
|
|
36
|
+
O rastreamento utiliza chamadas diretas via `fetch()` para o endpoint `/track` no mesmo domínio.
|
|
37
37
|
|
|
38
38
|
### 2. Deduplicação
|
|
39
39
|
Gera um `event_id` único para cada evento disparado no browser para que o Worker possa bater com a CAPI.
|
|
@@ -311,7 +311,7 @@ document.getElementById('buy-btn').addEventListener('click', function() {
|
|
|
311
311
|
| Depende de | Input Esperado | O que faz com isso |
|
|
312
312
|
|-------------|----------------|------------------|
|
|
313
313
|
| **Page Analyzer** | Lista de elementos HTML | Mapeia `content_name` e `content_id` |
|
|
314
|
-
| **Server Tracking Agent** | Lista de plataformas | Adiciona endpoint Spotify `/
|
|
314
|
+
| **Server Tracking Agent** | Lista de plataformas | Adiciona endpoint Spotify `/webhook/spotify` |
|
|
315
315
|
| **Premium Tracking Intelligence** | Estratégia de tracking | Define eventos prioritários para Spotify |
|
|
316
316
|
| **Validator Agent** | Código gerado | Valida conformidade com Spotify API v1 |
|
|
317
317
|
|
|
@@ -359,7 +359,7 @@ Perguntar ao cliente qual opção se aplica:
|
|
|
359
359
|
"reddit": ["Lead", "Purchase", "SignUp", "AddToCart", "PageVisit"],
|
|
360
360
|
"linkedin": ["LEAD", "PURCHASE", "REGISTRATION", "ADD_TO_CART"],
|
|
361
361
|
"spotify": ["LEAD", "PURCHASE", "SIGN_UP", "ADD_TO_CART"],
|
|
362
|
-
"youtube": ["video_start", "
|
|
362
|
+
"youtube": ["video_start", "video_25", "video_50", "video_75", "video_complete"],
|
|
363
363
|
"bing": ["generate_lead", "purchase", "begin_checkout", "view_item"]
|
|
364
364
|
},
|
|
365
365
|
"engagement_scoring": {
|
|
@@ -370,7 +370,7 @@ Perguntar ao cliente qual opção se aplica:
|
|
|
370
370
|
"anti_bloqueio": {
|
|
371
371
|
"adblock_detection": "3 metodos",
|
|
372
372
|
"first_party_cookie": "365 dias",
|
|
373
|
-
"same_domain_endpoint": "/
|
|
373
|
+
"same_domain_endpoint": "/track",
|
|
374
374
|
"fallback_server_side": "POST request"
|
|
375
375
|
}
|
|
376
376
|
}
|
|
@@ -679,7 +679,7 @@ src/tracking/platforms/
|
|
|
679
679
|
- Gerar `wrangler.toml` (configuração completa Cloudflare)
|
|
680
680
|
- Gerar `schema.sql` (D1: events_log, identity_graph, leads)
|
|
681
681
|
- Gerar `worker.js` (Cloudflare Worker principal)
|
|
682
|
-
- Implementar endpoint `/
|
|
682
|
+
- Implementar endpoint `/track` (recebe eventos do browser)
|
|
683
683
|
- Implementar Engagement Scoring (0.0 - 5.0) calculado no servidor
|
|
684
684
|
- Implementar Intention Level (curioso, interessado, comprador) calculado no servidor
|
|
685
685
|
- Implementar SHA256 hashing (WebCrypto) para PII
|
|
@@ -708,7 +708,7 @@ cloudflare/
|
|
|
708
708
|
"cloudflare/DEPLOY.md"
|
|
709
709
|
],
|
|
710
710
|
"recursos_implementados": {
|
|
711
|
-
"worker_endpoint": "/
|
|
711
|
+
"worker_endpoint": "/track",
|
|
712
712
|
"d1_database": "cdp-edge-db",
|
|
713
713
|
"cloudflare_queue": "cdp-edge-retry",
|
|
714
714
|
"kv_namespace": "geo-cache",
|
|
@@ -741,7 +741,7 @@ cloudflare/
|
|
|
741
741
|
- JSON do Premium Tracking Intelligence Agent (estratégia de tracking)
|
|
742
742
|
|
|
743
743
|
**RESPONSABILIDADE:**
|
|
744
|
-
- Gerar endpoint `/
|
|
744
|
+
- Gerar endpoint `/webhook/*` (recebe webhooks de Hotmart, Kiwify, Eduzz, Ticto)
|
|
745
745
|
- Implementar Lead Lock (salvar PII no D1, vincular com fbp/fbc)
|
|
746
746
|
- Implementar despacho de Purchase via Server-Side (CAPI, Events API)
|
|
747
747
|
- Implementar Advanced Matching Máximo (email, phone, city, state) via checkout data
|
|
@@ -751,9 +751,9 @@ cloudflare/
|
|
|
751
751
|
```
|
|
752
752
|
cloudflare/
|
|
753
753
|
└── webhooks/
|
|
754
|
-
├── hotmart-webhook.js ← Rota /
|
|
755
|
-
├── kiwify-webhook.js ← Rota /
|
|
756
|
-
├── eduzz-webhook.js ← Rota /
|
|
754
|
+
├── hotmart-webhook.js ← Rota /webhook/hotmart
|
|
755
|
+
├── kiwify-webhook.js ← Rota /webhook/kiwify
|
|
756
|
+
├── eduzz-webhook.js ← Rota /webhook/eduzz
|
|
757
757
|
└── ticto-webhook.js ← Rota /webhook/ticto (HMAC-SHA256 X-Ticto-Signature)
|
|
758
758
|
```
|
|
759
759
|
|
|
@@ -1092,7 +1092,7 @@ Aguardar resposta. Armazenar em `PROJECT_TYPE`.
|
|
|
1092
1092
|
- Gera / valida worker.js com:
|
|
1093
1093
|
GET /webhook/whatsapp → verifica hub.verify_token
|
|
1094
1094
|
POST /webhook/whatsapp → processWhatsAppWebhook()
|
|
1095
|
-
/
|
|
1095
|
+
/track (manter ativo — pode ser usado no futuro)
|
|
1096
1096
|
- Confirma wrangler.toml com D1 binding
|
|
1097
1097
|
|
|
1098
1098
|
✅ FASE B-3 — Database Agent
|
|
@@ -1143,9 +1143,9 @@ Aguardar resposta. Armazenar em `PROJECT_TYPE`.
|
|
|
1143
1143
|
|
|
1144
1144
|
📋 Próximos passos para qualificar leads do WhatsApp:
|
|
1145
1145
|
• Quando lead qualificado → dispare Lead via:
|
|
1146
|
-
POST /
|
|
1146
|
+
POST /track { event: "Lead", phone: "+5511...", ... }
|
|
1147
1147
|
• Quando venda confirmada → dispare Purchase via:
|
|
1148
|
-
POST /
|
|
1148
|
+
POST /track { event: "Purchase", value: 97, phone: "+5511..." }
|
|
1149
1149
|
```
|
|
1150
1150
|
|
|
1151
1151
|
---
|
|
@@ -1164,7 +1164,7 @@ Aguardar resposta. Armazenar em `PROJECT_TYPE`.
|
|
|
1164
1164
|
com o link de afiliado correto injetado
|
|
1165
1165
|
|
|
1166
1166
|
✅ FASE C-2 — Server Tracking Agent (mínimo)
|
|
1167
|
-
Worker com: /
|
|
1167
|
+
Worker com: /track + /webhook/{plataforma}
|
|
1168
1168
|
|
|
1169
1169
|
✅ FASE C-3 — Database Agent
|
|
1170
1170
|
Schema identity_graph + webhook_events
|
|
@@ -1386,7 +1386,7 @@ Define a estratégia completa de tracking profissional para reduzir 30-50% no cu
|
|
|
1386
1386
|
"reddit": ["Lead", "Purchase", "SignUp", "AddToCart", "PageVisit"],
|
|
1387
1387
|
"linkedin": ["LEAD", "PURCHASE", "REGISTRATION", "ADD_TO_CART"],
|
|
1388
1388
|
"spotify": ["LEAD", "PURCHASE", "SIGN_UP", "ADD_TO_CART"],
|
|
1389
|
-
"youtube": ["video_start", "
|
|
1389
|
+
"youtube": ["video_start", "video_25", "video_50", "video_75", "video_complete"],
|
|
1390
1390
|
"bing": ["generate_lead", "purchase", "begin_checkout", "view_item"]
|
|
1391
1391
|
},
|
|
1392
1392
|
"engagement_scoring": {
|
|
@@ -1397,7 +1397,7 @@ Define a estratégia completa de tracking profissional para reduzir 30-50% no cu
|
|
|
1397
1397
|
"anti_bloqueio": {
|
|
1398
1398
|
"adblock_detection": "3 metodos",
|
|
1399
1399
|
"first_party_cookie": "365 dias",
|
|
1400
|
-
"same_domain_endpoint": "/
|
|
1400
|
+
"same_domain_endpoint": "/track",
|
|
1401
1401
|
"fallback_server_side": "POST request"
|
|
1402
1402
|
}
|
|
1403
1403
|
}
|
|
@@ -1408,12 +1408,6 @@ Define a estratégia completa de tracking profissional para reduzir 30-50% no cu
|
|
|
1408
1408
|
|
|
1409
1409
|
Com base nas plataformas selecionadas, spawnar os agentes em paralelo utilizando os modelos de referência em `models/`.
|
|
1410
1410
|
|
|
1411
|
-
---
|
|
1412
|
-
|
|
1413
|
-
### FASE 3 — Geração em paralelo (agentes especialistas)
|
|
1414
|
-
|
|
1415
|
-
Com base nas plataformas selecionadas, spawnar os agentes em paralelo utilizando os modelos de referência em `models/`.
|
|
1416
|
-
|
|
1417
1411
|
**IMPORTANTE: Ordem de Execução Sequencial:**
|
|
1418
1412
|
|
|
1419
1413
|
Antes de spawnar agentes em paralelo, seguir esta ordem **OBRIGATÓRIA**:
|
package/extracted-skill/tracking-events-generator/agents/premium-tracking-intelligence-agent.md
CHANGED
|
@@ -553,7 +553,7 @@ function detectAdBlock() {
|
|
|
553
553
|
function handleAdBlockFallback(eventData) {
|
|
554
554
|
if (detectAdBlock()) {
|
|
555
555
|
// AdBlock ativo: enviar via servidor (não pode usar scripts de terceiros)
|
|
556
|
-
fetch('/
|
|
556
|
+
fetch('/track', {
|
|
557
557
|
method: 'POST',
|
|
558
558
|
headers: { 'Content-Type': 'application/json' },
|
|
559
559
|
body: JSON.stringify({
|
|
@@ -619,9 +619,9 @@ function getSessionId() {
|
|
|
619
619
|
```javascript
|
|
620
620
|
/**
|
|
621
621
|
* Endpoint de Tracking no Mesmo Domínio
|
|
622
|
-
* URL: https://meusite.com/
|
|
622
|
+
* URL: https://meusite.com/track (NÃO third-party)
|
|
623
623
|
*/
|
|
624
|
-
const TRACKING_ENDPOINT = '/
|
|
624
|
+
const TRACKING_ENDPOINT = '/track'; // Same-Domain Protocol
|
|
625
625
|
|
|
626
626
|
/**
|
|
627
627
|
* Enviar evento via servidor (adblock-proof)
|
|
@@ -804,7 +804,7 @@ const serverTracking = {
|
|
|
804
804
|
|
|
805
805
|
### Server Tracking (O que processar no Worker)
|
|
806
806
|
|
|
807
|
-
- [x] Receber eventos do browser (POST /
|
|
807
|
+
- [x] Receber eventos do browser (POST /track)
|
|
808
808
|
- [x] Capturar IP e geolocalização (Cloudflare headers)
|
|
809
809
|
- [x] Recuperar PII do D1 (Lead Lock)
|
|
810
810
|
- [x] Calcular Engagement Score (0.0 - 5.0)
|
|
@@ -27,7 +27,7 @@ Browser (Visitante)
|
|
|
27
27
|
▼
|
|
28
28
|
Cloudflare Edge (Worker)
|
|
29
29
|
├── Route Principal: /api/* ← Same-Domain Protocol
|
|
30
|
-
├── Route Webhook: /
|
|
30
|
+
├── Route Webhook: /webhook/* ← Rota para Gateways de Pagamento
|
|
31
31
|
├── Edge Routing (A/B) ← Interceptação via A/B Testing Agent
|
|
32
32
|
├── Edge Localization ← Manipulação de Checkout/Moeda
|
|
33
33
|
├── ML LTV Prediction ← Predição de Valor via Workers AI
|
|
@@ -526,7 +526,7 @@ async function syncIdentity(DB, body) {
|
|
|
526
526
|
const fp = body.fingerprint || null;
|
|
527
527
|
if (!fp || !DB) return body;
|
|
528
528
|
|
|
529
|
-
const existing = await DB.prepare(
|
|
529
|
+
const existing = await env.DB.prepare(
|
|
530
530
|
'SELECT * FROM identity_graph WHERE fingerprint = ?'
|
|
531
531
|
).bind(fp).first();
|
|
532
532
|
|
|
@@ -541,7 +541,7 @@ async function syncIdentity(DB, body) {
|
|
|
541
541
|
visit_count: (existing.visit_count || 1) + 1
|
|
542
542
|
};
|
|
543
543
|
} else {
|
|
544
|
-
await DB.prepare(`
|
|
544
|
+
await env.DB.prepare(`
|
|
545
545
|
INSERT OR IGNORE INTO identity_graph (fingerprint, fbp, fbc, ga_client_id, external_id, ttclid, first_utm)
|
|
546
546
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
547
547
|
`).bind(fp, body.fbp, body.fbc, body.ga_client_id, body.external_id, body.ttclid, JSON.stringify(body.utm || {})).run();
|
|
@@ -635,7 +635,7 @@ function buildCookieHeader(visitor, umbrellaDomain) {
|
|
|
635
635
|
async function logBehavioralEvent(DB, body, visitor, engagementScore) {
|
|
636
636
|
if (!DB) return;
|
|
637
637
|
|
|
638
|
-
await DB.prepare(`
|
|
638
|
+
await env.DB.prepare(`
|
|
639
639
|
INSERT OR REPLACE INTO behavioral_events (
|
|
640
640
|
event_id, user_id, session_id,
|
|
641
641
|
engagement_score, time_level, scroll_score, click_score, video_score, hover_score, intention_level,
|
|
@@ -812,7 +812,7 @@ context: {
|
|
|
812
812
|
### Estratégias para Maximizar Resiliência
|
|
813
813
|
|
|
814
814
|
**1. Same-Domain Endpoint:**
|
|
815
|
-
- Worker deve estar no mesmo domínio do site: `site.com/
|
|
815
|
+
- Worker deve estar no mesmo domínio do site: `site.com/track`
|
|
816
816
|
- Evita bloqueios de CORS e ad-blockers que bloqueiam requests cross-origin
|
|
817
817
|
|
|
818
818
|
**2. First-Party Cookies:**
|
|
@@ -843,9 +843,9 @@ const corsHeaders = {
|
|
|
843
843
|
- Ad-blockers podem falsificar user-agent
|
|
844
844
|
- Validação deve ser baseada em token/secret, não UA
|
|
845
845
|
|
|
846
|
-
**6.
|
|
847
|
-
-
|
|
848
|
-
-
|
|
846
|
+
**6. Same-Domain via Worker Route (anti-blocking):**
|
|
847
|
+
- Endpoint de tracking: `/track` (Worker route same-domain — ad-blockers não bloqueiam requests same-domain)
|
|
848
|
+
- A proteção real vem do same-domain, não do nome do path
|
|
849
849
|
|
|
850
850
|
---
|
|
851
851
|
|
|
@@ -972,7 +972,7 @@ CREATE INDEX IF NOT EXISTS idx_retry_scheduled ON retry_queue(scheduled_at, stat
|
|
|
972
972
|
async function logEventSuccess(DB, platform, eventId) {
|
|
973
973
|
if (!DB) return;
|
|
974
974
|
|
|
975
|
-
await DB.prepare(`
|
|
975
|
+
await env.DB.prepare(`
|
|
976
976
|
UPDATE events_log
|
|
977
977
|
SET status = 'success',
|
|
978
978
|
retry_count = 0,
|
|
@@ -988,7 +988,7 @@ async function logEventFailure(DB, platform, eventId, errorMessage, retryCount)
|
|
|
988
988
|
const maxRetries = 3;
|
|
989
989
|
const isFinalFailure = retryCount >= maxRetries;
|
|
990
990
|
|
|
991
|
-
await DB.prepare(`
|
|
991
|
+
await env.DB.prepare(`
|
|
992
992
|
UPDATE events_log
|
|
993
993
|
SET status = ?,
|
|
994
994
|
retry_count = ?,
|
|
@@ -1150,7 +1150,7 @@ export async function queue(batch, env) {
|
|
|
1150
1150
|
|
|
1151
1151
|
- Gerar `wrangler.toml` completo com bindings D1, KV, R2, Queues e Cron Triggers
|
|
1152
1152
|
- Gerar `schema.sql` com todas as tabelas: `events_log`, `identity_graph`, `leads`, `behavioral_events`, `webhook_events`, `user_profiles`
|
|
1153
|
-
- Gerar `worker.js` principal com endpoint `/
|
|
1153
|
+
- Gerar `worker.js` principal com endpoint `/track` (recebe eventos do browser)
|
|
1154
1154
|
- Implementar Identity Graph sync, Engagement Scoring server-side e First-Party Cookie (`_cdp_uid`)
|
|
1155
1155
|
- Implementar Anti-Blocking: CORS same-domain, headers limpos, sem keywords bloqueáveis
|
|
1156
1156
|
- Implementar sistema de retry com Cloudflare Queues (3-Tier: imediato → 5min → 15min → 45min)
|
|
@@ -1167,9 +1167,9 @@ export async function queue(batch, env) {
|
|
|
1167
1167
|
"DEPLOY.md"
|
|
1168
1168
|
],
|
|
1169
1169
|
"endpoints": {
|
|
1170
|
-
"tracking": "POST /
|
|
1170
|
+
"tracking": "POST /track",
|
|
1171
1171
|
"health": "GET /api/health",
|
|
1172
|
-
"webhooks": "POST /
|
|
1172
|
+
"webhooks": "POST /webhook/{gateway}",
|
|
1173
1173
|
"ticto": "POST /webhook/ticto"
|
|
1174
1174
|
},
|
|
1175
1175
|
"bindings_cloudflare": {
|
|
@@ -310,7 +310,7 @@ export async function hashPII(data) {
|
|
|
310
310
|
| Depende de | Input Esperado | O que faz com isso |
|
|
311
311
|
|-------------|----------------|------------------|
|
|
312
312
|
| **Page Analyzer** | Lista de elementos HTML | Mapeia `content_name` e `content_id` |
|
|
313
|
-
| **Server Tracking Agent** | Lista de plataformas | Adiciona endpoint Spotify `/
|
|
313
|
+
| **Server Tracking Agent** | Lista de plataformas | Adiciona endpoint Spotify `/webhook/spotify` |
|
|
314
314
|
| **Premium Tracking Intelligence** | Estratégia de tracking | Define eventos prioritários para Spotify |
|
|
315
315
|
| **Validator Agent** | Código gerado | Valida conformidade com Spotify API v1 |
|
|
316
316
|
|
|
@@ -65,7 +65,7 @@ async function hashWebhookUserData(webhookPayload) {
|
|
|
65
65
|
|
|
66
66
|
## 📦 ENTREGÁVEIS
|
|
67
67
|
|
|
68
|
-
1. **Route Handler**: `/
|
|
68
|
+
1. **Route Handler**: `/webhook/{gateway}` no Worker.
|
|
69
69
|
2. **D1 Query**: Lógica de atualização do perfil do usuário com o status de comprador.
|
|
70
70
|
3. **CAPI Dispatch**: Envio dos dados enriquecidos para as redes de anúncio.
|
|
71
71
|
|
|
@@ -153,10 +153,10 @@ ctx.waitUntil(Promise.allSettled([
|
|
|
153
153
|
```json
|
|
154
154
|
{
|
|
155
155
|
"rotas_geradas": {
|
|
156
|
-
"hotmart": "/
|
|
157
|
-
"kiwify": "/
|
|
156
|
+
"hotmart": "/webhook/hotmart",
|
|
157
|
+
"kiwify": "/webhook/kiwify",
|
|
158
158
|
"ticto": "/webhook/ticto",
|
|
159
|
-
"stripe": "/
|
|
159
|
+
"stripe": "/webhook/stripe"
|
|
160
160
|
},
|
|
161
161
|
"validacao_hmac": {
|
|
162
162
|
"hotmart": "X-Hotmart-Hottok",
|