cdp-edge 1.23.3 → 1.24.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 +39 -2
- package/bin/cdp-edge.js +10 -1
- package/contracts/types.ts +81 -0
- package/dist/commands/install.js +6 -1
- package/docs/whatsapp-ctwa.md +3 -2
- package/package.json +7 -4
- package/server-edge-tracker/{index.js → index.ts} +91 -82
- package/server-edge-tracker/modules/{db.js → db.ts} +116 -76
- package/server-edge-tracker/modules/dispatch/{ga4.js → ga4.ts} +12 -10
- package/server-edge-tracker/modules/dispatch/{meta.js → meta.ts} +35 -28
- package/server-edge-tracker/modules/dispatch/{platforms.js → platforms.ts} +58 -56
- package/server-edge-tracker/modules/dispatch/{tiktok.js → tiktok.ts} +22 -20
- package/server-edge-tracker/modules/dispatch/{whatsapp.js → whatsapp.ts} +59 -25
- package/server-edge-tracker/modules/{intelligence.js → intelligence.ts} +175 -60
- package/server-edge-tracker/modules/ml/{bidding.js → bidding.ts} +37 -35
- package/server-edge-tracker/modules/ml/{fraud.js → fraud.ts} +48 -40
- package/server-edge-tracker/modules/ml/{logistic.js → logistic.ts} +44 -19
- package/server-edge-tracker/modules/ml/{ltv.js → ltv.ts} +135 -90
- package/server-edge-tracker/modules/ml/{matchquality.js → matchquality.ts} +70 -26
- package/server-edge-tracker/modules/ml/{segmentation.js → segmentation.ts} +109 -48
- package/server-edge-tracker/modules/{utils.js → utils.ts} +41 -22
- package/server-edge-tracker/types.ts +251 -0
- package/server-edge-tracker/wrangler.toml +8 -8
- package/docs/PixelBuilder-Documentacao-Completa (2).docx +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
**Padrão Quantum Tracking: 100% Cloudflare Edge.** Sem GTM. Sem Stape. Sem cookies de terceiros.
|
|
4
4
|
|
|
5
|
-
> **v2.2.
|
|
5
|
+
> **v2.2.5** — Versão Dinâmica · Correção de banner e CLI · Cloudflare Workers · Meta CAPI v22.0 · GA4 MP · TikTok Events API v1.3
|
|
6
|
+
|
|
7
|
+
> ⚠️ **REGRA DE OURO (SQUAD):** Todas as atualizações, correções ou novas features devem OBRIGATORIAMENTE ser documentadas de forma sincronizada neste `README.md`, no arquivo de instruções `CLAUDE.md` e no dossiê de diretoria `CDP-EDGE-BUSINESS-BOOK.md`. Nenhuma alteração passa sem esse tripé.
|
|
6
8
|
|
|
7
9
|
---
|
|
8
10
|
|
|
@@ -25,6 +27,41 @@ Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um
|
|
|
25
27
|
|
|
26
28
|
---
|
|
27
29
|
|
|
30
|
+
## 📋 CHANGELOG v2.2.5+ — Migração TypeScript (12 de Abril de 2026)
|
|
31
|
+
|
|
32
|
+
### 🔷 Worker 100% TypeScript — Migração Completa
|
|
33
|
+
|
|
34
|
+
Todo o código server-side (`server-edge-tracker/`) foi migrado de JavaScript para **TypeScript nativo**. O Wrangler compila diretamente o `.ts` sem etapa de build separada.
|
|
35
|
+
|
|
36
|
+
**Arquivos migrados (JS → TS):**
|
|
37
|
+
- `index.ts` — entry point do Worker (era `index.js`)
|
|
38
|
+
- `types.ts` — novo arquivo centralizado com `Env`, `TrackPayload`, tipos de webhook
|
|
39
|
+
- `modules/utils.ts`, `modules/db.ts`, `modules/intelligence.ts`
|
|
40
|
+
- `modules/dispatch/` — `meta.ts`, `ga4.ts`, `tiktok.ts`, `platforms.ts`, `whatsapp.ts`
|
|
41
|
+
- `modules/ml/` — `ltv.ts`, `fraud.ts`, `bidding.ts`, `segmentation.ts`, `logistic.ts`, `matchquality.ts`
|
|
42
|
+
|
|
43
|
+
**Infraestrutura:**
|
|
44
|
+
- `tsconfig.json` adicionado (`target: ESNext`, `moduleResolution: bundler`, `strict: true`)
|
|
45
|
+
- `wrangler.toml` — `main = "index.ts"` (TypeScript nativo, sem transpile manual)
|
|
46
|
+
- `npm run typecheck` — novo script para validação de tipos (`tsc --noEmit`)
|
|
47
|
+
|
|
48
|
+
**Testes de integração:**
|
|
49
|
+
- `tests/integration/setup.js` atualizado para compilar o `.ts` com esbuild em memória antes de passar ao Miniflare (esbuild já é dep transitiva do Miniflare 3)
|
|
50
|
+
|
|
51
|
+
**Breaking change:** nenhuma — API HTTP e comportamento em runtime são idênticos.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 📋 CHANGELOG v2.2.5 (11 de Abril de 2026)
|
|
56
|
+
|
|
57
|
+
### 🔧 Correção de Versão Dinâmica
|
|
58
|
+
|
|
59
|
+
- **Versão Dinâmica**: `bin/cdp-edge.js` e `dist/commands/install.js` agora leem a versão do `package.json` dinamicamente
|
|
60
|
+
- **Banner Corrigido**: O banner de instalação agora mostra sempre a versão correta (`cdp-edge --version`)
|
|
61
|
+
- **Compatibilidade**: Garante que a versão exibida no CLI e banner esteja sempre sincronizada com o `package.json`
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
28
65
|
## 📋 CHANGELOG v2.2.0 (10 de Abril de 2026)
|
|
29
66
|
|
|
30
67
|
### 🤖 AI Engine Upgrade — Novos Modelos
|
|
@@ -55,7 +92,7 @@ Meu ecossistema opera como um Cérebro de Conversão Privado na borda. Quando um
|
|
|
55
92
|
- **YouTube events**: `video_milestone`/`video_progress_25/50/75` → `video_25`/`video_50`/`video_75` (alinhado ao VALID_EVENT_NAMES do worker)
|
|
56
93
|
- **LinkedIn CAPI**: endpoint `/rest/conversionEvents` + header `LinkedIn-Version: 202401` em `contracts/api-versions.json`
|
|
57
94
|
- **Workers AI model**: `llama-3-8b-instruct` → `@cf/meta/llama-3.1-8b-instruct`
|
|
58
|
-
- **
|
|
95
|
+
- **index.ts**: Content-Length guard (413 se > 64KB), payload validation (allowlist 19 events, 512 chars, value range), PII removido dos logs
|
|
59
96
|
- **Testes**: bugs críticos em `deduplication.test.js` corrigidos (template literals escapados, prefixo errado)
|
|
60
97
|
- **npm**: lodash 4.17.23 → 4.18.1, node-fetch removido
|
|
61
98
|
|
package/bin/cdp-edge.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* Sistema multi-agente para tracking digital Quantum Tier
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
8
11
|
import { Command } from 'commander';
|
|
9
12
|
import { runSetupWizard } from '../dist/commands/setup.js';
|
|
10
13
|
import { runAnalyze } from '../dist/commands/analyze.js';
|
|
@@ -13,12 +16,18 @@ import { runValidate } from '../dist/commands/validate.js';
|
|
|
13
16
|
import { runInfra } from '../dist/commands/infra.js';
|
|
14
17
|
import { runInstall } from '../dist/commands/install.js';
|
|
15
18
|
|
|
19
|
+
// Ler versão do package.json
|
|
20
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
22
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
23
|
+
const CDP_VERSION = packageJson.version;
|
|
24
|
+
|
|
16
25
|
const program = new Command();
|
|
17
26
|
|
|
18
27
|
program
|
|
19
28
|
.name('cdp-edge')
|
|
20
29
|
.description('CDP Edge Quantum Tier - Sistema multi-agente para tracking digital Cloudflare Native')
|
|
21
|
-
.version(
|
|
30
|
+
.version(CDP_VERSION);
|
|
22
31
|
|
|
23
32
|
// Comando padrão (wizard interativo)
|
|
24
33
|
program
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// CDP Edge Premium - API Contracts & Typings
|
|
2
|
+
|
|
3
|
+
export interface QuantumEventPayload {
|
|
4
|
+
eventName: string;
|
|
5
|
+
eventId: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
email?: string | null;
|
|
8
|
+
phone?: string | null;
|
|
9
|
+
firstName?: string | null;
|
|
10
|
+
lastName?: string | null;
|
|
11
|
+
city?: string | null;
|
|
12
|
+
state?: string | null;
|
|
13
|
+
zip?: string | null;
|
|
14
|
+
country?: string | null;
|
|
15
|
+
|
|
16
|
+
// Identifiers
|
|
17
|
+
fbp?: string | null;
|
|
18
|
+
fbc?: string | null;
|
|
19
|
+
ttp?: string | null;
|
|
20
|
+
gaClientId?: string | null;
|
|
21
|
+
|
|
22
|
+
// Parameters
|
|
23
|
+
value?: number | null;
|
|
24
|
+
currency?: string;
|
|
25
|
+
contentIds?: string[];
|
|
26
|
+
contentName?: string;
|
|
27
|
+
contentType?: string;
|
|
28
|
+
pageUrl?: string;
|
|
29
|
+
orderId?: string;
|
|
30
|
+
|
|
31
|
+
// Quantum Tracking Details
|
|
32
|
+
intentScoreNum?: number | null;
|
|
33
|
+
metaSignal?: number;
|
|
34
|
+
distanceBucket?: string;
|
|
35
|
+
funnelLevel?: string;
|
|
36
|
+
botScore?: number;
|
|
37
|
+
|
|
38
|
+
// Any extra params
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface AgencyContext {
|
|
43
|
+
// Required Env mappings for specialists
|
|
44
|
+
META_ACCESS_TOKEN?: string;
|
|
45
|
+
META_PIXEL_ID?: string;
|
|
46
|
+
GA4_API_SECRET?: string;
|
|
47
|
+
GA4_MEASUREMENT_ID?: string;
|
|
48
|
+
TIKTOK_ACCESS_TOKEN?: string;
|
|
49
|
+
TIKTOK_PIXEL_ID?: string;
|
|
50
|
+
PINTEREST_ACCESS_TOKEN?: string;
|
|
51
|
+
PINTEREST_AD_ACCOUNT_ID?: string;
|
|
52
|
+
REDDIT_ACCESS_TOKEN?: string;
|
|
53
|
+
REDDIT_AD_ACCOUNT_ID?: string;
|
|
54
|
+
LINKEDIN_ACCESS_TOKEN?: string;
|
|
55
|
+
LINKEDIN_AD_ACCOUNT_ID?: string;
|
|
56
|
+
SPOTIFY_ACCESS_TOKEN?: string;
|
|
57
|
+
SPOTIFY_AD_ACCOUNT_ID?: string;
|
|
58
|
+
|
|
59
|
+
// Databases and Stores
|
|
60
|
+
DB?: any; // D1 Database
|
|
61
|
+
GEO_CACHE?: any; // KV Namespace
|
|
62
|
+
RATE_LIMITER?: any;
|
|
63
|
+
SITE_DOMAIN?: string;
|
|
64
|
+
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ApiVersionsConfig {
|
|
69
|
+
metadata: {
|
|
70
|
+
version: string;
|
|
71
|
+
};
|
|
72
|
+
meta: any;
|
|
73
|
+
google: any;
|
|
74
|
+
tiktok: any;
|
|
75
|
+
pinterest: any;
|
|
76
|
+
reddit: any;
|
|
77
|
+
linkedin: any;
|
|
78
|
+
bing: any;
|
|
79
|
+
youtube: any;
|
|
80
|
+
spotify: any;
|
|
81
|
+
}
|
package/dist/commands/install.js
CHANGED
|
@@ -18,6 +18,11 @@ import chalk from 'chalk';
|
|
|
18
18
|
|
|
19
19
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
20
20
|
|
|
21
|
+
// Ler versão do package.json
|
|
22
|
+
const packageJsonPath = path.join(__dirname, '..', '..', 'package.json');
|
|
23
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
24
|
+
const CDP_VERSION = packageJson.version;
|
|
25
|
+
|
|
21
26
|
// Raiz do pacote CDP Edge (2 níveis acima de dist/commands/)
|
|
22
27
|
const CDP_EDGE_ROOT = path.resolve(__dirname, '..', '..');
|
|
23
28
|
|
|
@@ -32,7 +37,7 @@ function printBanner() {
|
|
|
32
37
|
console.log(chalk.cyan('╚██████╗██████╔╝██║ ███████╗██████╔╝╚██████╔╝███████╗'));
|
|
33
38
|
console.log(chalk.cyan(' ╚═════╝╚═════╝ ╚═╝ ╚══════╝╚═════╝ ╚═════╝╚══════╝'));
|
|
34
39
|
console.log('');
|
|
35
|
-
console.log(chalk.gray(
|
|
40
|
+
console.log(chalk.gray(` Customer Data Platform on the Edge · Global Edge Tracking · v${CDP_VERSION}`));
|
|
36
41
|
console.log('');
|
|
37
42
|
console.log(chalk.gray('═'.repeat(68)));
|
|
38
43
|
console.log('');
|
package/docs/whatsapp-ctwa.md
CHANGED
|
@@ -199,11 +199,12 @@ fetch('https://SEU_WORKER.SEU_USUARIO.workers.dev/track', {
|
|
|
199
199
|
|
|
200
200
|
| Arquivo | Descrição |
|
|
201
201
|
|---------|-----------|
|
|
202
|
-
| `server-edge-tracker/
|
|
202
|
+
| `server-edge-tracker/modules/dispatch/whatsapp.ts` | Funções `processWhatsAppWebhook()`, `sendWhatsApp()`, `verifyHmac()` |
|
|
203
|
+
| `server-edge-tracker/index.ts` | Rotas `/webhook/whatsapp` (GET verify + POST mensagens) |
|
|
203
204
|
| `server-edge-tracker/migrate-v6.sql` | Migration que criou a tabela `whatsapp_contacts` |
|
|
204
205
|
| `server-edge-tracker/wrangler.toml` | Secret `WA_WEBHOOK_VERIFY_TOKEN` documentado |
|
|
205
206
|
| `server-edge-tracker/schema.sql` | Schema completo do D1 (referência) |
|
|
206
207
|
|
|
207
208
|
---
|
|
208
209
|
|
|
209
|
-
*Implementado em: 30 de março de 2026. CDP Edge v1.2 — WhatsApp CTWA Module.*
|
|
210
|
+
*Implementado em: 30 de março de 2026. CDP Edge v1.2 — WhatsApp CTWA Module. Migrado para TypeScript (`whatsapp.ts`) em 12 de abril de 2026 (v2.2.5+).*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdp-edge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.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",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"agents:check": "node scripts/validate-agents.js",
|
|
35
35
|
"agents:sync": "node scripts/sync-agents.js",
|
|
36
36
|
"agents:sync:list": "node scripts/sync-agents.js --list",
|
|
37
|
-
"agents:sync:all": "node scripts/sync-agents.js --apply-all"
|
|
37
|
+
"agents:sync:all": "node scripts/sync-agents.js --apply-all",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
38
39
|
},
|
|
39
40
|
"keywords": [
|
|
40
41
|
"pixel",
|
|
@@ -71,12 +72,14 @@
|
|
|
71
72
|
"ora": "^8.0.0"
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
75
|
+
"@cloudflare/workers-types": "^4.20260412.1",
|
|
74
76
|
"@semantic-release/changelog": "^6.0.3",
|
|
75
77
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
76
78
|
"@semantic-release/github": "^12.0.6",
|
|
77
79
|
"@semantic-release/npm": "^13.1.5",
|
|
78
80
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
79
|
-
"@types/node": "^20.
|
|
80
|
-
"semantic-release": "^25.0.3"
|
|
81
|
+
"@types/node": "^20.19.39",
|
|
82
|
+
"semantic-release": "^25.0.3",
|
|
83
|
+
"typescript": "^6.0.2"
|
|
81
84
|
}
|
|
82
85
|
}
|