cdp-edge 1.18.2 → 1.19.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.
- package/README.md +18 -1
- 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 +4 -4
- 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 +7 -2
- 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
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Padrão Quantum Tracking: 100% Cloudflare Edge.** Sem GTM. Sem Stape. Sem cookies de terceiros.
|
|
4
4
|
|
|
5
|
-
> **v2.0.
|
|
5
|
+
> **v2.0.3** — Enterprise-Level Intelligence Engine · Cloudflare Workers · Meta CAPI v22.0 · GA4 MP · TikTok Events API v1.3
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -25,6 +25,23 @@ Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um
|
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
+
## 📋 CHANGELOG v2.0.3 (10 de Abril de 2026)
|
|
29
|
+
|
|
30
|
+
### 🔧 Audit Completo — 45 Agentes
|
|
31
|
+
|
|
32
|
+
- **Endpoints corrigidos**: `/api/tracking` → `/track`, `/api/wh/` → `/webhook/` em todos os agentes
|
|
33
|
+
- **Secrets WhatsApp**: `WA_PHONE_ID`/`WA_ACCESS_TOKEN`/`WHATSAPP_TOKEN` → `WHATSAPP_PHONE_NUMBER_ID`/`WHATSAPP_ACCESS_TOKEN`
|
|
34
|
+
- **`env.DB.prepare`**: corrigido em 8 agentes (attribution, crm, dashboard, debug, performance, security, master-feedback-loop)
|
|
35
|
+
- **`env.GEO_CACHE`**: substituiu `KV.` bare em dashboard-agent, performance-agent, performance-optimization-agent
|
|
36
|
+
- **YouTube events**: `video_milestone`/`video_progress_25/50/75` → `video_25`/`video_50`/`video_75` (alinhado ao VALID_EVENT_NAMES do worker)
|
|
37
|
+
- **LinkedIn CAPI**: endpoint `/rest/conversionEvents` + header `LinkedIn-Version: 202401` em `contracts/api-versions.json`
|
|
38
|
+
- **Workers AI model**: `llama-3-8b-instruct` → `@cf/meta/llama-3.1-8b-instruct`
|
|
39
|
+
- **worker.js**: Content-Length guard (413 se > 64KB), payload validation (allowlist 19 events, 512 chars, value range), PII removido dos logs
|
|
40
|
+
- **Testes**: bugs críticos em `deduplication.test.js` corrigidos (template literals escapados, prefixo errado)
|
|
41
|
+
- **npm**: lodash 4.17.23 → 4.18.1, node-fetch removido
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
28
45
|
## 📋 CHANGELOG v2.0.0 (9 de Abril de 2026)
|
|
29
46
|
|
|
30
47
|
### 🆕 Sprint Enterprise — Fases 1 a 4
|
|
@@ -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.3'));
|
|
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.3'));
|
|
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
|
|
|
@@ -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
|
|
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",
|
|
@@ -53,7 +53,7 @@ if (consentModeVersion !== 'v2') {
|
|
|
53
53
|
|
|
54
54
|
### TrueView In-Stream (pulável após 5s)
|
|
55
55
|
- **Evento de billing**: view confirmada após 30s ou clique
|
|
56
|
-
- **Rastrear**: `video_start`, `
|
|
56
|
+
- **Rastrear**: `video_start`, `video_complete`, clique no CTA
|
|
57
57
|
- **Conversão Google Ads**: `engaged_view` (30s assistidos = 1 conversão de vídeo)
|
|
58
58
|
|
|
59
59
|
### Bumper Ads (6s não-puláveis)
|
|
@@ -505,7 +505,7 @@ if (youtubeMobileLeads.count === 0) {
|
|
|
505
505
|
|
|
506
506
|
## RESPONSABILIDADE
|
|
507
507
|
|
|
508
|
-
- Gerar eventos de progresso de vídeo (`video_start`, `
|
|
508
|
+
- Gerar eventos de progresso de vídeo (`video_start`, `video_25`, `video_50`, `video_75`, `video_complete`) via GA4
|
|
509
509
|
- Implementar YouTube IFrame API listener para rastreamento de VSL no browser
|
|
510
510
|
- Garantir `gclid`, `wbraid`, `gbraid` chegando ao Worker (nunca hashear estes campos)
|
|
511
511
|
- Persistir `ga_client_id` no D1 para cruzamento com conversões YouTube Ads
|
|
@@ -522,7 +522,7 @@ if (youtubeMobileLeads.count === 0) {
|
|
|
522
522
|
},
|
|
523
523
|
"eventos_implementados": [
|
|
524
524
|
"video_start",
|
|
525
|
-
"
|
|
525
|
+
"video_25", "video_50", "video_75",
|
|
526
526
|
"video_complete",
|
|
527
527
|
"generate_lead",
|
|
528
528
|
"purchase"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdp-edge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "CDP Edge - Quantum Tracking - Sistema multi-agente para tracking digital Cloudflare Native (Workers + D1)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,12 @@
|
|
|
28
28
|
"test:unit:hash": "node tests/unit/hashing.test.js",
|
|
29
29
|
"test:unit:dedup": "node tests/unit/deduplication.test.js",
|
|
30
30
|
"test:unit:payload": "node tests/unit/payload-validation.test.js",
|
|
31
|
-
"test:all": "npm run test:unit"
|
|
31
|
+
"test:all": "npm run test:unit",
|
|
32
|
+
"test:integration": "cd tests/integration && npx vitest run",
|
|
33
|
+
"agents:check": "node scripts/validate-agents.js",
|
|
34
|
+
"agents:sync": "node scripts/sync-agents.js",
|
|
35
|
+
"agents:sync:list": "node scripts/sync-agents.js --list",
|
|
36
|
+
"agents:sync:all": "node scripts/sync-agents.js --apply-all"
|
|
32
37
|
},
|
|
33
38
|
"keywords": [
|
|
34
39
|
"pixel",
|