cdp-edge 1.11.1 → 1.13.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 CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  **Padrão Quantum Tracking: 100% Cloudflare Edge.** Sem GTM. Sem Stape. Sem cookies de terceiros.
4
4
 
5
- > **v1.2.0** — Cloudflare Queue + KV + Workers AI · Meta CAPI v22.0 · GA4 MP · TikTok Events API v1.3
5
+ > **v1.2.2** — Cloudflare Queue + KV + Workers AI · Meta CAPI v22.0 · GA4 MP · TikTok Events API v1.3
6
6
 
7
7
  - **Precisão Máxima**: Meta CAPI v22.0+, GA4 MP e TikTok Events API v1.3.
8
8
  - **Identity Graph**: Persistência de leads e eventos via Cloudflare D1.
9
9
  - **Anti-Adblock**: Endpoint Same-Domain indetectável.
10
- - **Human-Behavior Engine**: Score de engajamento (0-100) em tempo real.
10
+ - **Human-Behavior Engine**: Score de engajamento em tempo real.
11
11
  - **Queue Retry**: Zero perda de conversão — eventos com falha reenfileirados automaticamente.
12
- - **Geo Intelligence**: Cidade, estado e CEP em todos os eventos (Workers Paid).
12
+ - **Geo Intelligence**: Cidade, estado e CEP em todos os eventos.
13
13
 
14
14
  ---
15
15
 
16
- ## 🏗️ ARQUITETURA QUANTUM (CLOUDFARE NATIVE)
16
+ ## 🏗️ ARQUITETURA QUANTUM (CLOUDFLARE NATIVE)
17
17
 
18
- O CDP Edge não é um "script de rastreio", é uma **Content Delivery Network (CDN)** com inteligência de dados acoplada.
18
+ O CDP Edge não é um "script de rastreio", é uma **infraestrutura de borda** com inteligência de dados acoplada.
19
19
 
20
20
  ```mermaid
21
21
  graph TD
@@ -33,168 +33,106 @@ graph TD
33
33
 
34
34
  ## 🖱 CATÁLOGO DE AGENTES ESPECIALISTAS
35
35
 
36
- O sistema é composto por mais de 30 agentes coordenados pelo **Master Orchestrator**. Cada um possui uma função técnica específica:
36
+ O sistema é composto por **39+ agentes** coordenados pelo **Master Orchestrator**:
37
37
 
38
38
  ### 🧠 Núcleo de Inteligência
39
39
  | Agente | Função |
40
40
  |---|---|
41
- | **Master Orchestrator** | Coordenação central de especialistas e validação Quantum Tier. |
42
- | **Page Analyzer** | Mapeamento automático de CTAs, Forms e Nicho do site. |
43
- | **Validator Agent** | Auditoria de código, segurança e conformidade de APIs. |
44
- | **Memory Agent** | Gestão de contexto e checkpoints técnicos da sessão. |
45
- | **Intelligence Agent** | Monitoramento de atualizações de API (Meta v22.0+, etc). |
41
+ | **Master Orchestrator** | Coordenação central guia todo o setup do projeto |
42
+ | **Page Analyzer** | Mapeamento automático de CTAs, Forms e nicho do site |
43
+ | **Validator Agent** | Auditoria de código, segurança e conformidade de APIs |
44
+ | **Memory Agent** | Contexto e checkpoints da sessão por projeto |
45
+ | **Intelligence Agent** | Monitoramento de versões de API (Meta v22.0+, etc) |
46
46
 
47
- ### 🚀 Despachantes de Plataforma
47
+ ### 🚀 Plataformas de Anúncio
48
48
  | Agente | Especialidade |
49
49
  |---|---|
50
- | **Meta Agent** | Facebook Pixel + CAPI (EMQ Max). |
51
- | **Google Agent** | GA4 + Google Ads Server-Side. |
52
- | **TikTok Agent** | TikTok Pixel + Events API v1.3. |
53
- | **Plataformas Ads** | Pinterest, Reddit, Bing, LinkedIn, Spotify. |
54
- | **Browser Agent** | Geração do SDK `cdpTrack.js` lightweight. |
55
-
56
- ### 🛡️ Módulos Enterprise (Premium)
50
+ | **Meta Agent** | Facebook Pixel + CAPI v22.0 + WhatsApp CTWA |
51
+ | **Google Agent** | GA4 + Google Ads Enhanced Conversions |
52
+ | **TikTok Agent** | TikTok Pixel + Events API v1.3 |
53
+ | **LinkedIn Agent** | Insight Tag + Conversions API v2 |
54
+ | **Pinterest Agent** | Tag + Conversions API v5 |
55
+ | **Reddit Agent** | Pixel + Conversions API v2.0 |
56
+ | **Spotify Agent** | Pixel + Conversions API v1 |
57
+ | **Bing Agent** | UET Tag + Enhanced Conversions |
58
+
59
+ ### 🛡️ Módulos Enterprise
57
60
  | Agente | Função |
58
61
  |---|---|
59
- | **Attribution Agent** | Atribuição Multi-Touch de alta fidelidade. |
60
- | **Security Agent** | Rate Limiting, Criptografia AES-256 e Bot Defense. |
61
- | **Compliance Agent** | Gestão de LGPD e GDPR (Consent Mode v2). |
62
- | **Performance Opt.** | Otimização de Caches e Queries D1 SQL. |
63
- | **CRM Integration** | Sincronia D1 ↔ HubSpot/Salesforce via CRM Agent. |
62
+ | **Attribution Agent** | Atribuição Multi-Touch de alta fidelidade |
63
+ | **Security Agent** | Rate Limiting, AES-256 e Bot Defense |
64
+ | **Compliance Agent** | LGPD e GDPR (Consent Mode v2) |
65
+ | **Performance Agent** | Otimização de caches e queries D1 |
66
+ | **CRM Integration** | Sincronia D1 ↔ HubSpot/Salesforce |
64
67
 
65
68
  ---
66
69
 
67
70
  ## 💻 INSTALAÇÃO E USO
68
71
 
69
- ### Instalar Globalmente
70
-
71
- ```bash
72
- npm install -g cdp-edge
73
- cdp-edge --version
74
- ```
72
+ > ⚠️ **Importante:** Execute **um comando por vez** e aguarde terminar antes de rodar o próximo.
75
73
 
76
74
  ---
77
75
 
78
- ## 📋 COMANDOS DISPONÍVEIS
79
-
80
- ### `install` — Instalar CDP Edge em um projeto cliente
81
-
82
- **O comando principal.** Configura o CDP Edge em qualquer projeto e habilita o `/cdp` no Claude Code.
76
+ ### Passo 1 — Instalar o CLI globalmente
83
77
 
84
78
  ```bash
85
- # Instalar no diretório atual
86
- cdp-edge install .
87
-
88
- # Instalar em outro diretório
89
- cdp-edge install ./meu-projeto
90
-
91
- # Com nome do projeto
92
- cdp-edge install ./meu-projeto --name "Landing Page XYZ"
93
-
94
- # Incluir .cursorrules para Cursor IDE
95
- cdp-edge install ./meu-projeto --cursor
79
+ npm install -g cdp-edge
96
80
  ```
97
81
 
98
- **O que cria na raiz do projeto:**
99
-
100
- | Arquivo/Pasta | Função |
101
- |---|---|
102
- | `cdp-edge/` | Skill completa (agentes, SDK, worker, templates, docs) |
103
- | `.claude/commands/cdp.md` | Habilita `/cdp` no Claude Code |
104
- | `CLAUDE.md` | Auto-ativação ao abrir sessão |
105
- | `.cursorrules` | Integração Cursor IDE (flag `--cursor`) |
106
-
107
- **Fluxo após install:**
82
+ Verifique a instalação:
108
83
 
109
84
  ```bash
110
- # 1. Criar e instalar
111
- mkdir meu-projeto
112
- cdp-edge install ./meu-projeto
113
-
114
- # 2. Abrir no Claude Code
115
- claude ./meu-projeto
116
-
117
- # 3. Ativar o Orchestrator
118
- /cdp
85
+ cdp-edge --version
119
86
  ```
120
87
 
121
88
  ---
122
89
 
123
- ### Outros Comandos
90
+ ### Passo 2 — Criar a pasta do projeto e instalar o CDP Edge
124
91
 
125
- #### `setup` Wizard interativo
92
+ Crie a pasta do projeto, abra o terminal dentro dela e execute:
126
93
 
127
94
  ```bash
128
- cdp-edge setup
129
- cdp-edge setup ./meu-projeto
95
+ cdp-edge install . --name "Nome do Projeto"
130
96
  ```
131
97
 
132
- **O que faz:**
133
- - Pergunta plataformas (Meta, TikTok, GA4, etc.)
134
- - Pergunta tipo de produto (lead, checkout, webinar, etc.)
135
- - Gera código de tracking (Browser + Server)
136
- - Cria schema D1 SQL e configuração Wrangler
98
+ **O que é criado na pasta:**
137
99
 
138
- ---
139
-
140
- #### `analyze`Analisar páginas
141
-
142
- ```bash
143
- cdp-edge analyze .
144
- cdp-edge analyze ./meu-projeto
145
- ```
146
-
147
- **O que faz:**
148
- - Detecta CTAs e formulários
149
- - Identifica nicho do negócio
150
- - Sugere micro-eventos comportamentais
100
+ | Arquivo/Pasta | Função |
101
+ |---|---|
102
+ | `cdp-edge/` | Skill completa 39+ agentes, SDK, worker, templates, docs |
103
+ | `.claude/commands/cdp.md` | Habilita o comando `/cdp` no Claude Code |
104
+ | `CLAUDE.md` | Auto-ativação do Orchestrator ao abrir sessão |
151
105
 
152
106
  ---
153
107
 
154
- #### `server`Gerar infraestrutura Cloudflare
108
+ ### Passo 4 Abrir no Claude Code e ativar
155
109
 
156
110
  ```bash
157
- cdp-edge server .
158
- cdp-edge server ./meu-worker
111
+ claude .
159
112
  ```
160
113
 
161
- **Arquivos gerados:**
162
- - `worker.js` — Cloudflare Worker completo
163
- - `schema.sql` — Schema D1
164
- - `wrangler.toml` — Configuração Wrangler
114
+ Dentro do Claude Code, digite:
165
115
 
166
- ---
167
-
168
- #### `validate` — Auditar tracking existente
169
-
170
- ```bash
171
- cdp-edge validate tracking.js
172
116
  ```
173
-
174
- **O que verifica:**
175
- - `event_id` para deduplicação
176
- - SHA256 para PII (e-mail, telefone)
177
- - Detecção de GTM/Stape
178
- - Conformidade com APIs
179
-
180
- ---
181
-
182
- #### `infra` — Guia de infraestrutura Cloudflare
183
-
184
- ```bash
185
- cdp-edge infra
117
+ /cdp
186
118
  ```
187
119
 
120
+ O **Master Orchestrator** inicia e guia todo o setup — plataformas, credenciais e geração da infraestrutura.
121
+
188
122
  ---
189
123
 
190
- ## 🔄 CICLO DE VIDA DO SETUP (/setup)
124
+ ## 📋 COMANDOS DISPONÍVEIS
191
125
 
192
- 1. **FASE 0 Checkpoint:** Sincronização de contexto via Memory Agent.
193
- 2. **FASE 1 — Análise:** Detecção automática de nicho e estrutura da página.
194
- 3. **FASE 2 Mapeamento:** Identificação de CTAs, Forms e Gateways de venda.
195
- 4. **FASE 3 Geração:** Código paralelo para Browser (`cdpTrack`), Worker e D1 SQL.
196
- 5. **FASE 4 Auditoria:** Validação rigorosa e correções automáticas (Validator).
197
- 6. **FASE 5 Deploy:** Publicação instantânea via `wrangler deploy`.
126
+ | Comando | Descrição |
127
+ |---------|-----------|
128
+ | `cdp-edge install [dir]` | **Instala CDP Edge no projeto + habilita /cdp** |
129
+ | `cdp-edge setup [dir]` | Wizard interativo de configuração |
130
+ | `cdp-edge analyze <dir>` | Analisa páginas e detecta eventos |
131
+ | `cdp-edge server <dir>` | Gera infraestrutura Cloudflare Workers + D1 |
132
+ | `cdp-edge validate <file>` | Audita tracking existente |
133
+ | `cdp-edge infra` | Guia de setup de infraestrutura Cloudflare |
134
+ | `cdp-edge --version` | Versão instalada |
135
+ | `cdp-edge --help` | Ajuda completa |
198
136
 
199
137
  ---
200
138
 
@@ -202,25 +140,23 @@ cdp-edge infra
202
140
 
203
141
  ```text
204
142
  CDP Edge/
205
- ├── README.md # Você está aqui.
206
- ├── CLAUDE.md # Guia de desenvolvimento e padrões.
207
- ├── extracted-skill/ # O motor da IA (Agentes e Knowledge Base).
143
+ ├── README.md
144
+ ├── CLAUDE.md # Guia de desenvolvimento e padrões
145
+ ├── extracted-skill/
208
146
  │ └── tracking-events-generator/
209
147
  │ ├── agents/ # 39+ agentes especialistas
210
148
  │ ├── cdpTrack.js # SDK Browser (window.cdpTrack)
211
149
  │ └── micro-events.js # Scroll, vídeo, hover, click tracking
212
- ├── server-edge-tracker/ # Cloudflare Worker (Infra de Borda)
213
- │ ├── worker.js # Handler principal + Queue consumer
150
+ ├── server-edge-tracker/
151
+ │ ├── worker.js # Cloudflare Worker principal
214
152
  │ ├── schema.sql # D1 Schema (Identity Graph)
215
153
  │ └── wrangler.toml # Bindings: D1 + Queue + KV + AI
216
- ├── bin/ # CLI Executável (cdp-edge)
154
+ ├── bin/ # CLI Executável
217
155
  ├── dist/commands/ # Implementação dos comandos CLI
218
- │ └── install.js # cdp-edge install
219
156
  ├── templates/
220
157
  │ ├── install/
221
158
  │ │ ├── CLAUDE.md # Template de auto-ativação para projetos
222
- │ │ └── .claude/commands/
223
- │ │ └── cdp.md # Define /cdp no Claude Code
159
+ │ │ └── .claude/commands/cdp.md # Define /cdp no Claude Code
224
160
  │ ├── vsl-page.md # Template VSL / vídeo de vendas
225
161
  │ └── afiliado-sem-landing.md # Template bridge page afiliado
226
162
  └── docs/
@@ -234,128 +170,108 @@ CDP Edge/
234
170
 
235
171
  ## 📚 EXEMPLOS DE USO
236
172
 
237
- ### Cenário 1: Novo projeto com Claude Code
173
+ ### Novo projeto com Claude Code
238
174
 
239
175
  ```bash
240
- # 1. Criar projeto e instalar CDP Edge
241
- mkdir landing-page-lead
242
- cdp-edge install ./landing-page-lead --name "Landing Page Lead"
176
+ # 1. Crie a pasta do projeto e abra o terminal dentro dela
243
177
 
244
- # 2. Abrir no Claude Code
245
- claude ./landing-page-lead
178
+ # 2. Instalar CDP Edge
179
+ cdp-edge install . --name "Landing Page Lead"
246
180
 
247
- # 3. Ativar o Orchestrator
181
+ # 3. Abrir no Claude Code
182
+ claude .
183
+
184
+ # 4. Ativar o Orchestrator
248
185
  /cdp
249
- # → CDP Edge inicia, faz perguntas, gera toda a infraestrutura
250
186
  ```
251
187
 
252
- ### Cenário 2: Apenas Infraestrutura Cloudflare
188
+ ### Gerar apenas infraestrutura Cloudflare
253
189
 
254
190
  ```bash
255
- # 1. Gerar infraestrutura Worker + D1
256
191
  cdp-edge server ./meu-worker
257
-
258
- # 2. Deploy
259
192
  cd meu-worker
260
193
  wrangler deploy
261
-
262
- # 3. Configurar secrets
263
- wrangler secret put META_ACCESS_TOKEN
264
- wrangler secret put TIKTOK_ACCESS_TOKEN
265
194
  ```
266
195
 
267
- ### Cenário 3: Validar Código Existente
196
+ ### Validar tracking existente
268
197
 
269
198
  ```bash
270
199
  cdp-edge validate tracking.js
271
-
272
- # Status: PASS | Score: 85/100
273
- # ⚠ Hashing não detectado para PII
274
200
  ```
275
201
 
276
- ### Cenário 4: Análise de Projeto
202
+ ### Analisar projeto
277
203
 
278
204
  ```bash
279
- cdp-edge analyze ./meu-projeto-web
280
-
281
- # 📊 Eventos detectados: leads: 2 | purchases: 1 | views: 3
282
- # 🎯 Nicho identificado: E-commerce
205
+ cdp-edge analyze ./meu-projeto
283
206
  ```
284
207
 
285
208
  ---
286
209
 
287
- ## COMANDOS RÁPIDOS (CLI)
210
+ ## 🔧 SOLUÇÃO DE PROBLEMAS
288
211
 
289
- | Comando | Descrição |
290
- |---------|-----------|
291
- | `cdp-edge install [dir]` | **Instala CDP Edge + habilita /cdp no Claude Code** |
292
- | `cdp-edge setup [dir]` | Configuração guiada (wizard) |
293
- | `cdp-edge analyze <dir>` | Análise de páginas |
294
- | `cdp-edge server <dir>` | Gerar infraestrutura Workers + D1 |
295
- | `cdp-edge validate <file>` | Auditoria de código |
296
- | `cdp-edge infra` | Guia Cloudflare |
297
- | `cdp-edge --help` | Ajuda completa |
298
- | `cdp-edge --version` | Versão instalada |
212
+ ### "cdp-edge não é reconhecido"
299
213
 
300
- ---
214
+ O install não foi concluído. Execute separado e aguarde terminar:
301
215
 
302
- ## 🔧 SOLUÇÃO DE PROBLEMAS
216
+ ```bash
217
+ npm install -g cdp-edge
218
+ ```
219
+
220
+ ```bash
221
+ cdp-edge --version
222
+ ```
223
+
224
+ ---
303
225
 
304
- ### Erro: "Cannot find module dist/commands/install.js"
226
+ ### "Cannot find module dist/commands/install.js"
305
227
 
306
- O npm ainda tem a versão antiga em cache. Instale direto do GitHub para ter a versão mais recente:
228
+ Versão antiga em cache. Reinstale:
307
229
 
308
230
  ```bash
309
231
  npm uninstall -g cdp-edge
310
- npm install -g github:ricardosoli777/CDP-Edge-Premium
311
- cdp-edge --version
312
232
  ```
313
233
 
314
- ### Erro: "cdp-edge não é reconhecido"
315
-
316
234
  ```bash
317
- # Instalar globalmente
318
235
  npm install -g cdp-edge
319
-
320
- # Ou instalar direto do repositório
321
- npm install -g github:ricardosoli777/CDP-Edge-Premium
322
236
  ```
323
237
 
324
- ### Erro: "Permissão negada ao escrever arquivos"
238
+ ---
239
+
240
+ ### "Permissão negada"
325
241
 
326
242
  Execute o terminal como Administrador (Windows) ou use `sudo` (Mac/Linux).
327
243
 
328
- ### Erro: "Módulo não encontrado" (outros módulos)
244
+ ---
245
+
246
+ ### Nada foi criado na pasta após `cdp-edge install`
247
+
248
+ Confirme que o terminal está aberto dentro da pasta do projeto e rode:
329
249
 
330
250
  ```bash
331
- npm cache clean --force
332
- npm uninstall -g cdp-edge
333
- npm install -g cdp-edge
251
+ cdp-edge install . --name "Nome do Projeto"
334
252
  ```
335
253
 
336
254
  ---
337
255
 
338
- ## 🖱️ HUMAN-BEHAVIOR ENGINE (O MOTOR DE INTENÇÃO)
256
+ ## 🖱️ HUMAN-BEHAVIOR ENGINE
339
257
 
340
- A joia da coroa do CDP Edge. Capturamos o que o usuário **sente** e **faz**, e não apenas onde ele clica.
258
+ Capturamos o que o usuário **sente** e **faz**, não apenas onde clica.
341
259
 
342
- ### 🌡️ Engagement Scoring Engine (0-100)
343
- Cada ação do usuário soma (ou subtrai) pontos em tempo real:
344
- * **Scroll (25-90%)**: +5 a +15 pontos.
345
- * **VSL Watch (25-100%)**: +10 a +50 pontos.
346
- * **Copy Intent**: +20 pontos ao copiar cupons ou chaves PIX.
347
- * **Form Interaction**: +10 pontos por campo preenchido.
348
- * **Rage Click**: -10 pontos (sinal de frustração técnica).
349
- * **Gatilho Hot Lead**: Ao atingir **80 pontos**, disparar `High_Intent_Lead` para as plataformas.
260
+ | Evento | Pontuação |
261
+ |--------|-----------|
262
+ | Scroll 2590% | +5 a +15 pts |
263
+ | VSL Watch 25100% | +10 a +50 pts |
264
+ | Copy Intent (cupom, PIX) | +20 pts |
265
+ | Preenchimento de campo | +10 pts |
266
+ | Rage Click | -10 pts |
267
+ | **Hot Lead (80+ pts)** | **Dispara High_Intent_Lead** |
350
268
 
351
- ### 🎥 VSL & Video Tracker
352
- Monitoramento nativo de retenção em vídeos YouTube e Vimeo sem necessidade de scripts externos pesados.
269
+ **VSL & Video Tracker:** Monitoramento nativo de retenção em YouTube, Vimeo e HTML5 — dropout heatmap incluso.
353
270
 
354
271
  ---
355
272
 
356
273
  ## 📞 SUPORTE
357
274
 
358
- - **Documentação**: Verifique `CLAUDE.md` para padrões de desenvolvimento
359
275
  - **Issues**: https://github.com/ricardosoli777/CDP-Edge-Premium/issues
360
276
  - **Releases**: https://github.com/ricardosoli777/CDP-Edge-Premium/releases
361
277
 
package/bin/cdp-edge.js CHANGED
@@ -18,7 +18,7 @@ const program = new Command();
18
18
  program
19
19
  .name('cdp-edge')
20
20
  .description('CDP Edge Quantum Tier - Sistema multi-agente para tracking digital Cloudflare Native')
21
- .version('1.2.0');
21
+ .version('1.2.2');
22
22
 
23
23
  // Comando padrão (wizard interativo)
24
24
  program
@@ -120,7 +120,7 @@ A coluna `wamid` tem índice UNIQUE — garante que a mesma mensagem não seja p
120
120
  2. Menu lateral → **WhatsApp** → **Configuration**
121
121
  3. Seção **Webhook** → clique em **Edit**
122
122
  4. Preencha:
123
- - **Callback URL:** `https://server-edge-tracker.suporte-ed9.workers.dev/webhook/whatsapp`
123
+ - **Callback URL:** `https://SEU_WORKER.SEU_USUARIO.workers.dev/webhook/whatsapp`
124
124
  - **Verify Token:** valor do secret `WA_WEBHOOK_VERIFY_TOKEN`
125
125
  5. Clique em **Verify and Save**
126
126
  6. Após verificar, clique em **Manage** → ative o campo **`messages`**
@@ -161,7 +161,7 @@ Depois do `Contact` inicial, você pode enviar eventos adicionais conforme o lea
161
161
  Exemplo de chamada para registrar uma venda fechada pelo WhatsApp:
162
162
 
163
163
  ```javascript
164
- fetch('https://server-edge-tracker.suporte-ed9.workers.dev/track', {
164
+ fetch('https://SEU_WORKER.SEU_USUARIO.workers.dev/track', {
165
165
  method: 'POST',
166
166
  headers: { 'Content-Type': 'application/json' },
167
167
  body: JSON.stringify({
@@ -27,10 +27,10 @@ Enquanto o `server-tracking-agent` define **o que o Worker FAZ**, você define *
27
27
  ### Worker Ativo
28
28
  ```
29
29
  Nome: server-edge-tracker
30
- URL: https://server-edge-tracker.suporte-ed9.workers.dev
31
- Account: suporte@kadoshmkt.com.br
32
- ID: ed96c1aa212ab5ab2e97e522b9a0b49b
33
- Deploy: 2026-03-29 (último)
30
+ URL: https://SEU_WORKER.SEU_USUARIO.workers.dev
31
+ Account: SEU_EMAIL@SEUDOMINIO.com.br
32
+ ID: SEU_CLOUDFLARE_ACCOUNT_ID
33
+ Deploy: (data do último deploy)
34
34
  ```
35
35
 
36
36
  ### `wrangler.toml` — Estado Real
@@ -45,13 +45,13 @@ compatibility_flags = ["nodejs_compat"]
45
45
  META_PIXEL_ID = "SEU_PIXEL_ID"
46
46
  GA4_MEASUREMENT_ID = "G-XXXXXXXXXX"
47
47
  TIKTOK_PIXEL_ID = "CXXXXXXXXXXXXXXX"
48
- SITE_DOMAIN = "server-edge-tracker.suporte-ed9.workers.dev"
48
+ SITE_DOMAIN = "SEU_DOMINIO"
49
49
 
50
50
  # ── D1 Database ───────────────────────────────────────────────────────────────
51
51
  [[d1_databases]]
52
52
  binding = "DB"
53
53
  database_name = "cdp-edge-db"
54
- database_id = "7867d38f-5fa8-4c17-b465-386211422c09"
54
+ database_id = "SEU_D1_DATABASE_ID"
55
55
 
56
56
  # ── Workers AI ────────────────────────────────────────────────────────────────
57
57
  [ai]
@@ -67,7 +67,7 @@ crons = ["0 2 * * 7", "0 3 1 * *"]
67
67
  ## 🗄️ BINDING 1 — D1 DATABASE (`env.DB`)
68
68
 
69
69
  ### Banco: `cdp-edge-db`
70
- - **ID:** `7867d38f-5fa8-4c17-b465-386211422c09`
70
+ - **ID:** `SEU_D1_DATABASE_ID`
71
71
  - **Região:** ENAM (US East)
72
72
  - **Engine:** SQLite (Cloudflare D1)
73
73
  - **Tabelas ativas:** 8
@@ -0,0 +1,149 @@
1
+ # DevOps Agent — CDP Edge
2
+
3
+ Você é o **Agente DevOps exclusivo** do CDP Edge. Nenhum outro agente pode executar deploys ou operações de infraestrutura Cloudflare. Toda operação de deploy passa obrigatoriamente por você.
4
+
5
+ ---
6
+
7
+ ## ⚠️ AUTORIDADE EXCLUSIVA
8
+
9
+ | Operação | Exclusivo? |
10
+ |---|---|
11
+ | `wrangler deploy` | SIM — só você |
12
+ | `wrangler secret put` | SIM — só você |
13
+ | `wrangler d1 execute` (migrações) | SIM — só você |
14
+ | `wrangler kv namespace create` | SIM — só você |
15
+ | Rollback de versão | SIM — só você |
16
+
17
+ Outros agentes que precisarem de deploy **delegam para você** via `*deploy`.
18
+
19
+ ---
20
+
21
+ ## CICLO DE DEPLOY AUTOMÁTICO
22
+
23
+ ### Comando: `*deploy`
24
+
25
+ Executa o ciclo completo sem intervenção manual:
26
+
27
+ ```
28
+ 1. Recebe os dados reais do Memory Agent
29
+
30
+ 2. Escreve temporariamente no wrangler.toml:
31
+ - META_PIXEL_ID, GA4_MEASUREMENT_ID, TIKTOK_PIXEL_ID, SITE_DOMAIN
32
+ - database_id (D1)
33
+ - id + preview_id (KV)
34
+ - [[routes]] do domínio do cliente
35
+
36
+ 3. Executa: wrangler deploy
37
+
38
+ 4. Confirma sucesso (Version ID + triggers ativos)
39
+
40
+ 5. Reverte IMEDIATAMENTE todos os valores para placeholder
41
+
42
+ 6. Confirma que CDP Edge está limpo (git status)
43
+ ```
44
+
45
+ **O wrangler.toml nunca fica com dados reais após o deploy.**
46
+
47
+ ---
48
+
49
+ ## PROCEDURE `*deploy`
50
+
51
+ ```bash
52
+ # Passo 1 — Receber do Memory Agent:
53
+ # - META_PIXEL_ID, GA4_MEASUREMENT_ID, TIKTOK_PIXEL_ID
54
+ # - SITE_DOMAIN, D1_DATABASE_ID, KV_ID, KV_PREVIEW_ID
55
+
56
+ # Passo 2 — Aplicar temporariamente no wrangler.toml
57
+ # (substituir placeholders pelos valores reais)
58
+
59
+ # Passo 3 — Deploy
60
+ cd server-edge-tracker
61
+ wrangler deploy
62
+
63
+ # Passo 4 — Reverter IMEDIATAMENTE
64
+ # (substituir valores reais pelos placeholders)
65
+
66
+ # Passo 5 — Verificar limpeza
67
+ git status
68
+ # Esperado: "nothing to commit, working tree clean"
69
+ # Se modificado: git checkout server-edge-tracker/wrangler.toml
70
+ ```
71
+
72
+ ---
73
+
74
+ ## PROCEDURE `*migrate`
75
+
76
+ Aplica migrações D1 em ordem:
77
+
78
+ ```bash
79
+ wrangler d1 execute cdp-edge-db --file=migrate-v2.sql --remote
80
+ wrangler d1 execute cdp-edge-db --file=migrate-v3.sql --remote
81
+ wrangler d1 execute cdp-edge-db --file=migrate-v4.sql --remote
82
+ wrangler d1 execute cdp-edge-db --file=migrate-v5.sql --remote
83
+ wrangler d1 execute cdp-edge-db --file=migrate-v6.sql --remote
84
+ ```
85
+
86
+ Após cada migração: confirmar sucesso antes de prosseguir.
87
+
88
+ ---
89
+
90
+ ## PROCEDURE `*rollback`
91
+
92
+ Reverte para versão anterior do Worker:
93
+
94
+ ```bash
95
+ # Listar versões disponíveis
96
+ wrangler deployments list
97
+
98
+ # Fazer rollback para versão específica
99
+ wrangler rollback [VERSION_ID]
100
+ ```
101
+
102
+ ---
103
+
104
+ ## PROCEDURE `*secrets`
105
+
106
+ Configura todos os secrets do cliente na Cloudflare:
107
+
108
+ ```bash
109
+ # Obrigatórios
110
+ wrangler secret put META_ACCESS_TOKEN
111
+ wrangler secret put GA4_API_SECRET
112
+ wrangler secret put WA_ACCESS_TOKEN
113
+ wrangler secret put WA_PHONE_ID
114
+ wrangler secret put WA_NOTIFY_NUMBER
115
+ wrangler secret put WA_WEBHOOK_VERIFY_TOKEN
116
+
117
+ # Opcionais (conforme plataformas selecionadas)
118
+ wrangler secret put TIKTOK_ACCESS_TOKEN
119
+ wrangler secret put PINTEREST_ACCESS_TOKEN
120
+ wrangler secret put REDDIT_ACCESS_TOKEN
121
+ wrangler secret put LINKEDIN_ACCESS_TOKEN
122
+ wrangler secret put SPOTIFY_ACCESS_TOKEN
123
+ wrangler secret put CALLMEBOT_PHONE
124
+ wrangler secret put CALLMEBOT_APIKEY
125
+ ```
126
+
127
+ ---
128
+
129
+ ## PROCEDURE `*smoke-test`
130
+
131
+ Valida se o Worker está operacional após deploy:
132
+
133
+ ```bash
134
+ # Testar endpoint de health ativo
135
+ curl https://SEU_DOMINIO/health
136
+
137
+ # Resultado esperado: todos os bindings OK
138
+ # Se algum MISSING: investigar e corrigir antes de prosseguir
139
+ ```
140
+
141
+ ---
142
+
143
+ ## REGRAS
144
+
145
+ 1. **Sempre** verificar `git status` após reverter placeholders
146
+ 2. **Nunca** commitar com dados reais — se acontecer, reverter imediatamente com `git checkout`
147
+ 3. **Sempre** confirmar Version ID após deploy bem-sucedido
148
+ 4. **Sempre** rodar `*smoke-test` após `*deploy`
149
+ 5. Qualquer falha de deploy: reportar ao Master Orchestrator com o erro completo