cdp-edge 2.0.2 → 2.0.3
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/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 +8 -8
- 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 +76 -76
package/README.md
CHANGED
|
@@ -1,308 +1,325 @@
|
|
|
1
|
-
# 🚀 CDP Edge — Quantum Tracking Enterprise
|
|
2
|
-
|
|
3
|
-
**Padrão Quantum Tracking: 100% Cloudflare Edge.** Sem GTM. Sem Stape. Sem cookies de terceiros.
|
|
4
|
-
|
|
5
|
-
> **v2.0.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 🤖 MANIFESTO: EU, CDP EDGE
|
|
10
|
-
|
|
11
|
-
*Eu não sou um simples "script de pixel". Eu sou uma arquitetura **Enterprise Tier 10** nascida e construída 100% nativa na infraestrutura da Cloudflare.*
|
|
12
|
-
|
|
13
|
-
**A Linha de Montagem Sincronizada (A Prova de Latência)**
|
|
14
|
-
Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um evento de Lead bate no endpoint `/track`:
|
|
15
|
-
1. **O Escudo Frontal (Fraud Gate):** Inspeciono IP, ASN e Velocity na borda. Bloqueio bots silenciosamente antes mesmo deles carregarem.
|
|
16
|
-
2. **A Roleta Invisível (A/B LTV):** Faço o sorteio de prompts para testes A/B via KV Cache em ~0ms.
|
|
17
|
-
3. **O Cérebro Financeiro (LTV Predictor):** Rodo Machine Learning (Llama 3.1) para qualificar a intenção e gerar o LTV Preditivo.
|
|
18
|
-
4. **Envio para as Plataformas:** O Facebook/Google/LinkedIn recebem um payload limpo (sem bot) recheado com valor financeiro de intenção extrema.
|
|
19
|
-
5. **Máquina Autônoma (Background):** Meu banco SQLite (D1) retroalimenta os processos de Clustering (Fase 1) e Bidding (Fase 2) de forma autônoma pelas costas do usuário (`ctx.waitUntil`).
|
|
20
|
-
|
|
21
|
-
**Minha Vantagem Absoluta (A "Killer Feature")**
|
|
22
|
-
- **A Extinção da Latência:** Destruo concorrentes como GTM/Stape mitigando a latência do servidor (+150ms) para as antenas da Cloudflare Brasileira (~5ms). Custando absurdamente menos (Tier Free ou $5/mês na infraestrutura).
|
|
23
|
-
- **Cookies Indestrutíveis:** Meus *First-Party Cookies Seguros* originam diretamente da nuvem, imunes hoje às varreduras massivas de 24 horas usadas por AdBlockers e Safari (Apple ITP).
|
|
24
|
-
- **Filas Inquebráveis (Fail-Safe + Queues):** Se a AI Cloudflare cair ocasionalmente, eu recuo pro LTV $0. Se a Meta CAPI espirrar 500 downtime, o sistema guarda religiosamente os seus eventos caros em *Cloudflare Queues* e faz o retry sucessivo. Sou incansável na garantia de Event Match Quality (EMQ).
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## 📋 CHANGELOG v2.0.
|
|
29
|
-
|
|
30
|
-
###
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
- **`
|
|
35
|
-
- **`
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- **`
|
|
51
|
-
- **`
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
- **`GET /api/
|
|
60
|
-
- **`GET /api/
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
- D1: `
|
|
71
|
-
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
|
123
|
-
|
|
124
|
-
| **
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
|
131
|
-
|
|
132
|
-
| **
|
|
133
|
-
| **
|
|
134
|
-
| **
|
|
135
|
-
| **
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
|
265
|
-
|
|
266
|
-
|
|
|
267
|
-
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
|
281
|
-
|
|
282
|
-
| `/
|
|
283
|
-
| `/
|
|
284
|
-
| `/
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
| `/api/
|
|
291
|
-
| `/api/
|
|
292
|
-
| `/api/
|
|
293
|
-
| `/api/
|
|
294
|
-
| `/api/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
1
|
+
# 🚀 CDP Edge — Quantum Tracking Enterprise
|
|
2
|
+
|
|
3
|
+
**Padrão Quantum Tracking: 100% Cloudflare Edge.** Sem GTM. Sem Stape. Sem cookies de terceiros.
|
|
4
|
+
|
|
5
|
+
> **v2.0.3** — Enterprise-Level Intelligence Engine · Cloudflare Workers · Meta CAPI v22.0 · GA4 MP · TikTok Events API v1.3
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🤖 MANIFESTO: EU, CDP EDGE
|
|
10
|
+
|
|
11
|
+
*Eu não sou um simples "script de pixel". Eu sou uma arquitetura **Enterprise Tier 10** nascida e construída 100% nativa na infraestrutura da Cloudflare.*
|
|
12
|
+
|
|
13
|
+
**A Linha de Montagem Sincronizada (A Prova de Latência)**
|
|
14
|
+
Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um evento de Lead bate no endpoint `/track`:
|
|
15
|
+
1. **O Escudo Frontal (Fraud Gate):** Inspeciono IP, ASN e Velocity na borda. Bloqueio bots silenciosamente antes mesmo deles carregarem.
|
|
16
|
+
2. **A Roleta Invisível (A/B LTV):** Faço o sorteio de prompts para testes A/B via KV Cache em ~0ms.
|
|
17
|
+
3. **O Cérebro Financeiro (LTV Predictor):** Rodo Machine Learning (Llama 3.1) para qualificar a intenção e gerar o LTV Preditivo.
|
|
18
|
+
4. **Envio para as Plataformas:** O Facebook/Google/LinkedIn recebem um payload limpo (sem bot) recheado com valor financeiro de intenção extrema.
|
|
19
|
+
5. **Máquina Autônoma (Background):** Meu banco SQLite (D1) retroalimenta os processos de Clustering (Fase 1) e Bidding (Fase 2) de forma autônoma pelas costas do usuário (`ctx.waitUntil`).
|
|
20
|
+
|
|
21
|
+
**Minha Vantagem Absoluta (A "Killer Feature")**
|
|
22
|
+
- **A Extinção da Latência:** Destruo concorrentes como GTM/Stape mitigando a latência do servidor (+150ms) para as antenas da Cloudflare Brasileira (~5ms). Custando absurdamente menos (Tier Free ou $5/mês na infraestrutura).
|
|
23
|
+
- **Cookies Indestrutíveis:** Meus *First-Party Cookies Seguros* originam diretamente da nuvem, imunes hoje às varreduras massivas de 24 horas usadas por AdBlockers e Safari (Apple ITP).
|
|
24
|
+
- **Filas Inquebráveis (Fail-Safe + Queues):** Se a AI Cloudflare cair ocasionalmente, eu recuo pro LTV $0. Se a Meta CAPI espirrar 500 downtime, o sistema guarda religiosamente os seus eventos caros em *Cloudflare Queues* e faz o retry sucessivo. Sou incansável na garantia de Event Match Quality (EMQ).
|
|
25
|
+
|
|
26
|
+
---
|
|
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
|
+
|
|
45
|
+
## 📋 CHANGELOG v2.0.0 (9 de Abril de 2026)
|
|
46
|
+
|
|
47
|
+
### 🆕 Sprint Enterprise — Fases 1 a 4
|
|
48
|
+
|
|
49
|
+
#### ✅ Fase 1 — ML Clustering (Segmentação Dinâmica)
|
|
50
|
+
- **`POST /api/segmentation/cluster`** — K-means / DBSCAN / Hierarchical via Workers AI
|
|
51
|
+
- **`GET /api/segmentation/list`** — Segmentos ativos com métricas
|
|
52
|
+
- **`GET /api/segmentation/outliers`** — Detecção de outliers comportamentais
|
|
53
|
+
- **`PUT /api/segmentation/update`** — Atualização de metadados de segmento
|
|
54
|
+
- Schema D1: `ml_segments`, `ml_segment_members` + VIEWs otimizadas
|
|
55
|
+
- Agente: `ml-clustering-agent.md`
|
|
56
|
+
|
|
57
|
+
#### ✅ Fase 2 — Bidding Recommendations (Otimização de Bids ML)
|
|
58
|
+
- **`POST /api/bidding/recommend`** — Bid otimizado por segmento × plataforma (Meta/Google/TikTok), calculado com fórmula `LTV × ROI target / CPA base`
|
|
59
|
+
- **`GET /api/bidding/history`** — Histórico completo de recomendações
|
|
60
|
+
- **`GET /api/bidding/status`** — Snapshot atual das recomendações ativas por vertical
|
|
61
|
+
- Schema D1: `bid_recommendations` + VIEW `v_active_bid_recommendations`
|
|
62
|
+
- Agente: `bidding-agent.md`
|
|
63
|
+
|
|
64
|
+
#### ✅ Fase 3 — A/B Testing de Prompts LTV
|
|
65
|
+
- **`POST /api/ltv/ab-test/create`** — Cria experimento com múltiplas variações de system prompt
|
|
66
|
+
- **`GET /api/ltv/ab-test/list`** — Lista experimentos com status e progresso
|
|
67
|
+
- **`GET /api/ltv/ab-test/results`** — Accuracy score por variação + recomendação automática de winner
|
|
68
|
+
- **`POST /api/ltv/ab-test/winner`** — Declara vencedor e retorna o prompt ganador
|
|
69
|
+
- Integração automática: cada evento Lead sorteia a variação ativa e registra o assignment via KV cache
|
|
70
|
+
- Schema D1: `ltv_ab_tests`, `ltv_ab_variations`, `ltv_ab_assignments` + VIEW `v_ab_test_performance`
|
|
71
|
+
- Agente: `ab-ltv-agent.md`
|
|
72
|
+
|
|
73
|
+
#### ✅ Fase 4 — Fraud Detection Engine
|
|
74
|
+
- **Fraud Gate automático em `/track`** — roda ANTES de qualquer processamento (heurístico puro, ~2ms)
|
|
75
|
+
- Silent drop (retorna 200 falso) — bots não detectam a defesa
|
|
76
|
+
- **`GET /api/fraud/stats`** — Dashboard de fraude (últimas 24h)
|
|
77
|
+
- **`GET /api/fraud/alerts`** — Log de sinais detectados com filtros
|
|
78
|
+
- **`GET /api/fraud/blocklist`** — IPs/fingerprints atualmente bloqueados
|
|
79
|
+
- **`POST /api/fraud/blocklist/add`** — Bloquear IP ou fingerprint (via KV, efeito imediato)
|
|
80
|
+
- **`DELETE /api/fraud/blocklist/remove`** — Remover do blocklist
|
|
81
|
+
- Sinais detectados: bot_score, datacenter IP, velocity attack, email descartável, headless UA, sem Accept-Language
|
|
82
|
+
- Schema D1: `fraud_signals`, `fraud_alerts` + VIEW `v_fraud_dashboard`
|
|
83
|
+
- Agente: `fraud-detection-agent.md`
|
|
84
|
+
|
|
85
|
+
### 🔧 Fix: `wrangler.toml` atualizado
|
|
86
|
+
- Todos os placeholders (`SEU_D1_DATABASE_ID`, `SEU_KV_NAMESPACE_ID`) substituídos pelos IDs reais da conta Cloudflare
|
|
87
|
+
- D1: `7867d38f-5fa8-4c17-b465-386211422c09`
|
|
88
|
+
- KV: `821b6c1ccb4b475985439b801c1fdbe0`
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🏗️ ARQUITETURA QUANTUM ENTERPRISE (CLOUDFLARE NATIVE)
|
|
93
|
+
|
|
94
|
+
```mermaid
|
|
95
|
+
graph TD
|
|
96
|
+
User((Usuário)) -->|Interação| SDK[cdpTrack SDK + Behavior Engine]
|
|
97
|
+
SDK -->|Edge Fetch 1ª via KV blocklist| FraudGate{🛡️ Fraud Gate}
|
|
98
|
+
FraudGate -->|score ≥ 80: Silent Drop 200| Void[/dev/null]
|
|
99
|
+
FraudGate -->|score < 80: Permitido| Worker[Cloudflare Worker Agent]
|
|
100
|
+
Worker -->|Identity Graph + _cdp_uid| D1[(D1 SQL — 21 tabelas)]
|
|
101
|
+
Worker -->|LTV + A/B Prompt| AI[Workers AI Llama 3.1 8B]
|
|
102
|
+
Worker -->|Segmento ML| Cluster[ML Clustering Engine]
|
|
103
|
+
Cluster -->|Bid otimizado| Bidding[Bidding Recommendations]
|
|
104
|
+
Worker -->|Background| Queue[Cloudflare Queues]
|
|
105
|
+
Queue -->|Server Dispatch| Meta[Meta CAPI v22.0]
|
|
106
|
+
Queue -->|Server Dispatch| Google[GA4 / Google Ads]
|
|
107
|
+
Queue -->|Server Dispatch| TikTok[TikTok API v1.3]
|
|
108
|
+
D1 -->|Reports| Dash[Dashboard Agent]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 🧠 CATÁLOGO DE AGENTES ESPECIALISTAS
|
|
114
|
+
|
|
115
|
+
O sistema é composto por **43+ agentes** coordenados pelo **Master Orchestrator**:
|
|
116
|
+
|
|
117
|
+
### 🧠 Núcleo de Inteligência
|
|
118
|
+
| Agente | Função |
|
|
119
|
+
|---|---|
|
|
120
|
+
| **Master Orchestrator** | Coordenação central — guia todo o setup do projeto |
|
|
121
|
+
| **Page Analyzer** | Mapeamento automático de CTAs, Forms e nicho do site |
|
|
122
|
+
| **Validator Agent** | Auditoria de código, segurança e conformidade de APIs |
|
|
123
|
+
| **Memory Agent** | Contexto e checkpoints da sessão por projeto |
|
|
124
|
+
| **Intelligence Agent** | Monitoramento de versões de API (Meta v22.0+, etc) |
|
|
125
|
+
|
|
126
|
+
### 🚀 Plataformas de Anúncio
|
|
127
|
+
| Agente | Especialidade |
|
|
128
|
+
|---|---|
|
|
129
|
+
| **Meta Agent** | Facebook Pixel + CAPI v22.0 + WhatsApp CTWA |
|
|
130
|
+
| **Google Agent** | GA4 + Google Ads Enhanced Conversions |
|
|
131
|
+
| **TikTok Agent** | TikTok Pixel + Events API v1.3 |
|
|
132
|
+
| **LinkedIn Agent** | Insight Tag + Conversions API v2 |
|
|
133
|
+
| **Pinterest Agent** | Tag + Conversions API v5 |
|
|
134
|
+
| **Reddit Agent** | Pixel + Conversions API v2.0 |
|
|
135
|
+
| **Spotify Agent** | Pixel + Conversions API v1 |
|
|
136
|
+
| **Bing Agent** | UET Tag + Enhanced Conversions |
|
|
137
|
+
|
|
138
|
+
### 🤖 Enterprise Intelligence (Fase 1–4)
|
|
139
|
+
| Agente | Endpoint Principal | Impacto |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| **ML Clustering Agent** | `POST /api/segmentation/cluster` | Segmentação K-means/DBSCAN/Hierarchical |
|
|
142
|
+
| **Bidding Agent** | `POST /api/bidding/recommend` | -20% CPA via bid por segmento de LTV |
|
|
143
|
+
| **A/B LTV Agent** | `POST /api/ltv/ab-test/create` | +25% precisão LTV via test de prompts |
|
|
144
|
+
| **Fraud Detection Agent** | Auto em `/track` | Bloqueia click fraud, bots, velocity attacks |
|
|
145
|
+
|
|
146
|
+
### 🛡️ Módulos Enterprise
|
|
147
|
+
| Agente | Função |
|
|
148
|
+
|---|---|
|
|
149
|
+
| **Attribution Agent** | Atribuição Multi-Touch de alta fidelidade |
|
|
150
|
+
| **Security Agent** | Rate Limiting, AES-256 e Bot Defense |
|
|
151
|
+
| **Compliance Agent** | LGPD e GDPR (Consent Mode v2) |
|
|
152
|
+
| **Performance Agent** | Otimização de caches e queries D1 |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 📊 BANCO DE DADOS D1 — 21 Tabelas
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
CORE TRACKING ML & INTELLIGENCE ENTERPRISE SECURITY
|
|
160
|
+
───────────────── ───────────────────── ─────────────────────
|
|
161
|
+
leads ml_segments fraud_signals
|
|
162
|
+
events ml_segment_members fraud_alerts
|
|
163
|
+
sessions bid_recommendations ltv_ab_tests
|
|
164
|
+
webhook_events ltv_ab_tests ltv_ab_variations
|
|
165
|
+
api_failures ltv_ab_variations ltv_ab_assignments
|
|
166
|
+
|
|
167
|
+
VIEWS
|
|
168
|
+
─────────────────────────────────────────────────
|
|
169
|
+
v_active_segments → Segmentos ML ativos com contagem de membros
|
|
170
|
+
v_active_bid_recs → Bids ativos por plataforma/vertical
|
|
171
|
+
v_ab_test_performance → Accuracy por variação de prompt
|
|
172
|
+
v_fraud_dashboard → Dashboard fraude 24h
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 🔄 FLUXO ENTERPRISE COMPLETO
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
POST /track (evento Lead)
|
|
181
|
+
│
|
|
182
|
+
├─ [1] 🛡️ Fraud Gate (KV blocklist + velocity + heurísticas) ~2ms
|
|
183
|
+
│ ├─ score < 40 → processa normalmente
|
|
184
|
+
│ ├─ score 40-79 → processa + loga suspeito (background)
|
|
185
|
+
│ └─ score ≥ 80 → silent drop 200 + loga (background)
|
|
186
|
+
│
|
|
187
|
+
├─ [2] 🔮 A/B LTV Testing — sorteia variação ativa (KV cache ~0ms)
|
|
188
|
+
│ └─ passa customSystemPrompt para predictLtv()
|
|
189
|
+
│
|
|
190
|
+
├─ [3] 🧮 LTV Prediction — Workers AI Llama 3.1 8B
|
|
191
|
+
│ └─ Score 0-100 → class High/Medium/Low → valor em BRL
|
|
192
|
+
│
|
|
193
|
+
├─ [4] 💾 D1 Writes (background via ctx.waitUntil)
|
|
194
|
+
│ ├─ upsertLtvProfile() → tabela leads
|
|
195
|
+
│ ├─ recordAbAssignment() → ltv_ab_assignments
|
|
196
|
+
│ └─ resolveDeviceGraph() → cross-device linking
|
|
197
|
+
│
|
|
198
|
+
└─ [5] 📡 CAPI dispatch (Meta + GA4 + TikTok em paralelo)
|
|
199
|
+
└─ com LTV injetado no value field
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 💻 INSTALAÇÃO E USO
|
|
205
|
+
|
|
206
|
+
> ⚠️ **Importante:** Escolha o método de instalação abaixo que melhor se adequa ao seu cenário de implantação.
|
|
207
|
+
|
|
208
|
+
### OPÇÃO 1 — Instalação Rápida e Confiável (Recomendada via Git Clone)
|
|
209
|
+
|
|
210
|
+
A forma mais pura, inquebrável e à prova de bugs para iniciar a base de um novo cliente. Basta criar uma pasta "vazia" para o seu cliente, abrir o terminal dentro dela e rodar:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
git clone https://github.com/ricardosoli777/CDP-Edge-Premium.git .
|
|
214
|
+
```
|
|
215
|
+
*(O ponto no final garante que os arquivos desçam diretamente dentro da pasta atual).*
|
|
216
|
+
|
|
217
|
+
### OPÇÃO 2 — Instalação via CLI Corporativo (Avançado)
|
|
218
|
+
|
|
219
|
+
Se preferir usar a linha de comando instalando o nosso CLI Privado do GitHub em todo o computador:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm install -g git+https://github.com/ricardosoli777/CDP-Edge-Premium.git
|
|
223
|
+
cdp-edge install . --name "Nome do Projeto"
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Passo 3 — Ativar no Claude Code
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
claude .
|
|
230
|
+
```
|
|
231
|
+
Dentro do Claude Code:
|
|
232
|
+
```
|
|
233
|
+
/cdp
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 🚀 DEPLOY COMPLETO (referência)
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
cd server-edge-tracker
|
|
242
|
+
|
|
243
|
+
# 1. Schemas D1 (todos em sequência)
|
|
244
|
+
wrangler d1 execute cdp-edge-db --file=schema.sql --remote
|
|
245
|
+
wrangler d1 execute cdp-edge-db --file=migrate-v6.sql --remote
|
|
246
|
+
wrangler d1 execute cdp-edge-db --file=schema-segmentation.sql --remote # Fase 1
|
|
247
|
+
wrangler d1 execute cdp-edge-db --file=schema-bidding.sql --remote # Fase 2
|
|
248
|
+
wrangler d1 execute cdp-edge-db --file=schema-ab-ltv.sql --remote # Fase 3
|
|
249
|
+
wrangler d1 execute cdp-edge-db --file=schema-fraud.sql --remote # Fase 4
|
|
250
|
+
|
|
251
|
+
# 2. Secrets
|
|
252
|
+
wrangler secret put META_ACCESS_TOKEN
|
|
253
|
+
wrangler secret put GA4_API_SECRET
|
|
254
|
+
wrangler secret put TIKTOK_ACCESS_TOKEN
|
|
255
|
+
|
|
256
|
+
# 3. Deploy
|
|
257
|
+
wrangler deploy
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 🖱️ HUMAN-BEHAVIOR ENGINE
|
|
263
|
+
|
|
264
|
+
| Evento | Pontuação |
|
|
265
|
+
|--------|-----------|
|
|
266
|
+
| Scroll 25–90% | +5 a +15 pts |
|
|
267
|
+
| VSL Watch 25–100% | +10 a +50 pts |
|
|
268
|
+
| Copy Intent (cupom, PIX) | +20 pts |
|
|
269
|
+
| Preenchimento de campo | +10 pts |
|
|
270
|
+
| Rage Click | -10 pts |
|
|
271
|
+
| **Hot Lead (80+ pts)** | **Dispara High_Intent_Lead** |
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 📋 TODOS OS ENDPOINTS (referência rápida)
|
|
276
|
+
|
|
277
|
+
### Core Tracking
|
|
278
|
+
| Rota | Método | Função |
|
|
279
|
+
|---|---|---|
|
|
280
|
+
| `/track` | POST | Evento principal (browser → CAPI) |
|
|
281
|
+
| `/health` | GET | Smoke test completo |
|
|
282
|
+
| `/webhook/hotmart` | POST | Webhook Hotmart Purchase |
|
|
283
|
+
| `/webhook/kiwify` | POST | Webhook Kiwify Purchase |
|
|
284
|
+
| `/webhook/ticto` | POST | Webhook Ticto Purchase |
|
|
285
|
+
|
|
286
|
+
### Intelligence ML
|
|
287
|
+
| Rota | Método | Função |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| `/api/segmentation/cluster` | POST | Clustering K-means/DBSCAN |
|
|
290
|
+
| `/api/segmentation/list` | GET | Segmentos ativos |
|
|
291
|
+
| `/api/segmentation/outliers` | GET | Outliers comportamentais |
|
|
292
|
+
| `/api/bidding/recommend` | POST | Bid otimizado por segmento |
|
|
293
|
+
| `/api/bidding/history` | GET | Histórico de bids |
|
|
294
|
+
| `/api/bidding/status` | GET | Status por plataforma |
|
|
295
|
+
|
|
296
|
+
### A/B Testing LTV
|
|
297
|
+
| Rota | Método | Função |
|
|
298
|
+
|---|---|---|
|
|
299
|
+
| `/api/ltv/ab-test/create` | POST | Criar experimento |
|
|
300
|
+
| `/api/ltv/ab-test/list` | GET | Listar experimentos |
|
|
301
|
+
| `/api/ltv/ab-test/results` | GET | Accuracy por variação |
|
|
302
|
+
| `/api/ltv/ab-test/winner` | POST | Declarar vencedor |
|
|
303
|
+
|
|
304
|
+
### Fraud Detection
|
|
305
|
+
| Rota | Método | Função |
|
|
306
|
+
|---|---|---|
|
|
307
|
+
| `/api/fraud/stats` | GET | Dashboard 24h |
|
|
308
|
+
| `/api/fraud/alerts` | GET | Log de alertas |
|
|
309
|
+
| `/api/fraud/blocklist` | GET | Lista bloqueada |
|
|
310
|
+
| `/api/fraud/blocklist/add` | POST | Bloquear IP/fingerprint |
|
|
311
|
+
| `/api/fraud/blocklist/remove` | DELETE | Desbloquear |
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## 📞 SUPORTE
|
|
316
|
+
|
|
317
|
+
- **Issues**: https://github.com/ricardosoli777/CDP-Edge-Premium/issues
|
|
318
|
+
- **Releases**: https://github.com/ricardosoli777/CDP-Edge-Premium/releases
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
### **CDP Edge — By Rica Soares**
|
|
323
|
+
> "Dados sem inteligência são apenas ruído. No Quantum Tier Enterprise, transformamos dados em ROAS."
|
|
324
|
+
|
|
325
|
+
© 2026 CDP Edge Premium. Todos os direitos reservados.
|
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
|
|
|
@@ -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
|
|
@@ -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
|
|
|
@@ -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,76 +1,76 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cdp-edge",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "CDP Edge - Quantum Tracking - Sistema multi-agente para tracking digital Cloudflare Native (Workers + D1)",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
"cdp-edge": "./bin/cdp-edge.js",
|
|
9
|
-
"pb": "./bin/cdp-edge.js"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"bin",
|
|
13
|
-
"dist",
|
|
14
|
-
"templates",
|
|
15
|
-
"contracts",
|
|
16
|
-
"extracted-skill",
|
|
17
|
-
"server-edge-tracker",
|
|
18
|
-
"docs",
|
|
19
|
-
"README.md"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"prepare": "node build.js",
|
|
23
|
-
"build": "node build.js",
|
|
24
|
-
"dev": "node build.js --watch",
|
|
25
|
-
"test": "node test.js",
|
|
26
|
-
"test:unit": "node tests/unit/normalization.test.js && node tests/unit/hashing.test.js && node tests/unit/deduplication.test.js && node tests/unit/payload-validation.test.js && node tests/unit/new-features.test.js",
|
|
27
|
-
"test:unit:normalize": "node tests/unit/normalization.test.js",
|
|
28
|
-
"test:unit:hash": "node tests/unit/hashing.test.js",
|
|
29
|
-
"test:unit:dedup": "node tests/unit/deduplication.test.js",
|
|
30
|
-
"test:unit:payload": "node tests/unit/payload-validation.test.js",
|
|
31
|
-
"test:all": "npm run test:unit"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [
|
|
34
|
-
"pixel",
|
|
35
|
-
"tracking",
|
|
36
|
-
"meta",
|
|
37
|
-
"caut",
|
|
38
|
-
"capi",
|
|
39
|
-
"tiktok",
|
|
40
|
-
"ga4",
|
|
41
|
-
"cloudflare",
|
|
42
|
-
"workers",
|
|
43
|
-
"d1",
|
|
44
|
-
"analytics",
|
|
45
|
-
"conversion",
|
|
46
|
-
"server-side"
|
|
47
|
-
],
|
|
48
|
-
"author": "CDP Edge",
|
|
49
|
-
"license": "MIT",
|
|
50
|
-
"repository": {
|
|
51
|
-
"type": "git",
|
|
52
|
-
"url": "https://github.com/ricardosoli777/CDP-Edge-Premium"
|
|
53
|
-
},
|
|
54
|
-
"bugs": {
|
|
55
|
-
"url": "https://github.com/ricardosoli777/CDP-Edge-Premium/issues"
|
|
56
|
-
},
|
|
57
|
-
"homepage": "https://github.com/ricardosoli777/CDP-Edge-Premium#readme",
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=18.0.0"
|
|
60
|
-
},
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"chalk": "^5.3.0",
|
|
63
|
-
"commander": "^12.0.0",
|
|
64
|
-
"inquirer": "^9.2.0",
|
|
65
|
-
"ora": "^8.0.0"
|
|
66
|
-
},
|
|
67
|
-
"devDependencies": {
|
|
68
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
69
|
-
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
70
|
-
"@semantic-release/github": "^12.0.6",
|
|
71
|
-
"@semantic-release/npm": "^13.1.5",
|
|
72
|
-
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
73
|
-
"@types/node": "^20.0.0",
|
|
74
|
-
"semantic-release": "^25.0.3"
|
|
75
|
-
}
|
|
76
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cdp-edge",
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "CDP Edge - Quantum Tracking - Sistema multi-agente para tracking digital Cloudflare Native (Workers + D1)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cdp-edge": "./bin/cdp-edge.js",
|
|
9
|
+
"pb": "./bin/cdp-edge.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"dist",
|
|
14
|
+
"templates",
|
|
15
|
+
"contracts",
|
|
16
|
+
"extracted-skill",
|
|
17
|
+
"server-edge-tracker",
|
|
18
|
+
"docs",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"prepare": "node build.js",
|
|
23
|
+
"build": "node build.js",
|
|
24
|
+
"dev": "node build.js --watch",
|
|
25
|
+
"test": "node test.js",
|
|
26
|
+
"test:unit": "node tests/unit/normalization.test.js && node tests/unit/hashing.test.js && node tests/unit/deduplication.test.js && node tests/unit/payload-validation.test.js && node tests/unit/new-features.test.js",
|
|
27
|
+
"test:unit:normalize": "node tests/unit/normalization.test.js",
|
|
28
|
+
"test:unit:hash": "node tests/unit/hashing.test.js",
|
|
29
|
+
"test:unit:dedup": "node tests/unit/deduplication.test.js",
|
|
30
|
+
"test:unit:payload": "node tests/unit/payload-validation.test.js",
|
|
31
|
+
"test:all": "npm run test:unit"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"pixel",
|
|
35
|
+
"tracking",
|
|
36
|
+
"meta",
|
|
37
|
+
"caut",
|
|
38
|
+
"capi",
|
|
39
|
+
"tiktok",
|
|
40
|
+
"ga4",
|
|
41
|
+
"cloudflare",
|
|
42
|
+
"workers",
|
|
43
|
+
"d1",
|
|
44
|
+
"analytics",
|
|
45
|
+
"conversion",
|
|
46
|
+
"server-side"
|
|
47
|
+
],
|
|
48
|
+
"author": "CDP Edge",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/ricardosoli777/CDP-Edge-Premium"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/ricardosoli777/CDP-Edge-Premium/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/ricardosoli777/CDP-Edge-Premium#readme",
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18.0.0"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"chalk": "^5.3.0",
|
|
63
|
+
"commander": "^12.0.0",
|
|
64
|
+
"inquirer": "^9.2.0",
|
|
65
|
+
"ora": "^8.0.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
69
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
70
|
+
"@semantic-release/github": "^12.0.6",
|
|
71
|
+
"@semantic-release/npm": "^13.1.5",
|
|
72
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
73
|
+
"@types/node": "^20.0.0",
|
|
74
|
+
"semantic-release": "^25.0.3"
|
|
75
|
+
}
|
|
76
|
+
}
|