cdp-edge 2.5.9 → 2.6.1
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 +247 -211
- package/bin/cdp-edge.js +1 -0
- package/contracts/agent-versions.json +2 -2
- package/dist/commands/infra.js +1 -1
- package/dist/commands/server.js +38 -33
- package/dist/commands/setup.js +3 -0
- package/dist/commands/validate.js +251 -236
- package/dist/sdk/cdpTrack.js +6 -4
- package/dist/sdk/cdpTrack.min.js +4 -4
- package/dist/sdk/install-snippet.html +1 -1
- package/extracted-skill/tracking-events-generator/INTEGRACAO-COMPLETA.md +4 -4
- package/extracted-skill/tracking-events-generator/Premium-Tracking-Intelligence-Resumo.md +3 -3
- package/extracted-skill/tracking-events-generator/agents/master-orchestrator.md +78 -33
- package/extracted-skill/tracking-events-generator/agents/whatsapp-agent.md +562 -93
- package/extracted-skill/tracking-events-generator/integration-test.js +3 -3
- package/extracted-skill/tracking-events-generator/knowledge-base.md +12 -12
- package/extracted-skill/tracking-events-generator/models/checkout-proprio.md +1 -1
- package/extracted-skill/tracking-events-generator/models/multi-step-checkout.md +4 -4
- package/extracted-skill/tracking-events-generator/models/reddit/conversions-api-template.js +1 -1
- package/extracted-skill/tracking-events-generator/models/scenarios/behavior-engine.js +1 -1
- package/extracted-skill/tracking-events-generator/models/scenarios/sales-page-logic.md +1 -1
- package/extracted-skill/tracking-events-generator/models/trafego-direto.md +7 -7
- package/package.json +2 -2
- package/server-edge-tracker/.client.env.example +5 -0
- package/server-edge-tracker/deploy-client.cjs +47 -31
- package/server-edge-tracker/index.ts +1267 -1204
- package/server-edge-tracker/modules/db.ts +2 -2
- package/server-edge-tracker/modules/dispatch/meta.ts +3 -0
- package/server-edge-tracker/modules/dispatch/tiktok.ts +1 -0
- package/server-edge-tracker/modules/dispatch/whatsapp.ts +5 -2
- package/server-edge-tracker/modules/utils.ts +1 -1
- package/server-edge-tracker/types.ts +3 -0
- package/server-edge-tracker/wrangler.toml +2 -0
- package/templates/checkout-proprio.md +1 -1
- package/templates/install/CLAUDE.md +1 -1
- package/templates/multi-step-checkout.md +4 -4
- package/templates/reddit/conversions-api-template.js +1 -1
- package/templates/scenarios/behavior-engine.js +1 -1
- package/templates/scenarios/sales-page-logic.md +1 -1
- package/templates/trafego-direto.md +7 -7
- package/templates/vsl-page.md +2 -2
- package/extracted-skill/tracking-events-generator/agents/whatsapp-ctwa-setup-agent.md +0 -707
- package/extracted-skill/tracking-events-generator/agents/zapman-agent.md +0 -189
- package/server-edge-tracker/.client.env +0 -5
- package/server-edge-tracker/dist-check/README.md +0 -1
- package/server-edge-tracker/dist-check/index.js +0 -5164
- package/server-edge-tracker/dist-check/index.js.map +0 -8
|
@@ -1,248 +1,263 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP Edge — validate <url>
|
|
3
|
-
*
|
|
4
|
-
* Diagnóstico pós-deploy. Verifica se o tracking está funcionando de ponta a ponta:
|
|
5
|
-
* 1. Página carrega cdpTrack.min.js e tem Meta Pixel
|
|
6
|
-
* 2. Worker /health responde (D1, KV, AI, secrets)
|
|
7
|
-
* 3. Worker /validate-install passa todos os checks internos
|
|
8
|
-
* 4. POST /track aceita evento sintético e retorna 200
|
|
9
|
-
*
|
|
10
|
-
* Uso:
|
|
11
|
-
* cdp-edge validate https://meusite.com.br
|
|
12
|
-
* cdp-edge validate https://meusite.com.br --worker https://worker.meusite.workers.dev
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import chalk from 'chalk';
|
|
16
|
-
import ora from 'ora';
|
|
17
|
-
|
|
18
|
-
// ── Helpers de output ─────────────────────────────────────────────────────────
|
|
19
|
-
|
|
20
|
-
function ok(label, detail = '') {
|
|
21
|
-
console.log(` ${chalk.green('✓')} ${chalk.bold(label)}${detail ? chalk.gray(' — ' + detail) : ''}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function fail(label, detail = '') {
|
|
25
|
-
console.log(` ${chalk.red('✗')} ${chalk.bold(label)}${detail ? chalk.red(' — ' + detail) : ''}`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function warn(label, detail = '') {
|
|
29
|
-
console.log(` ${chalk.yellow('⚠')} ${chalk.bold(label)}${detail ? chalk.yellow(' — ' + detail) : ''}`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function section(title) {
|
|
33
|
-
console.log('\n' + chalk.cyan.bold(`── ${title} ──────────────────────────────`));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// ── Fetch com timeout ─────────────────────────────────────────────────────────
|
|
37
|
-
|
|
38
|
-
async function fetchWithTimeout(url, options = {}, timeoutMs = 10000) {
|
|
39
|
-
const controller = new AbortController();
|
|
40
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
41
|
-
try {
|
|
42
|
-
return await fetch(url, { ...options, signal: controller.signal });
|
|
43
|
-
} finally {
|
|
44
|
-
clearTimeout(timer);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// ── Check 1: Página HTML ──────────────────────────────────────────────────────
|
|
49
|
-
|
|
50
|
-
async function checkPage(siteUrl) {
|
|
51
|
-
section('Página HTML');
|
|
52
|
-
const results = { ok: true };
|
|
53
|
-
|
|
54
|
-
let html = '';
|
|
55
|
-
try {
|
|
56
|
-
const res = await fetchWithTimeout(siteUrl, {
|
|
57
|
-
headers: { 'User-Agent': 'CDP-Edge-Validator/1.0' },
|
|
58
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* CDP Edge — validate <url>
|
|
3
|
+
*
|
|
4
|
+
* Diagnóstico pós-deploy. Verifica se o tracking está funcionando de ponta a ponta:
|
|
5
|
+
* 1. Página carrega cdpTrack.min.js e tem Meta Pixel
|
|
6
|
+
* 2. Worker /health responde (D1, KV, AI, secrets)
|
|
7
|
+
* 3. Worker /validate-install passa todos os checks internos
|
|
8
|
+
* 4. POST /track aceita evento sintético e retorna 200
|
|
9
|
+
*
|
|
10
|
+
* Uso:
|
|
11
|
+
* cdp-edge validate https://meusite.com.br
|
|
12
|
+
* cdp-edge validate https://meusite.com.br --worker https://worker.meusite.workers.dev
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import chalk from 'chalk';
|
|
16
|
+
import ora from 'ora';
|
|
17
|
+
|
|
18
|
+
// ── Helpers de output ─────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
function ok(label, detail = '') {
|
|
21
|
+
console.log(` ${chalk.green('✓')} ${chalk.bold(label)}${detail ? chalk.gray(' — ' + detail) : ''}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function fail(label, detail = '') {
|
|
25
|
+
console.log(` ${chalk.red('✗')} ${chalk.bold(label)}${detail ? chalk.red(' — ' + detail) : ''}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function warn(label, detail = '') {
|
|
29
|
+
console.log(` ${chalk.yellow('⚠')} ${chalk.bold(label)}${detail ? chalk.yellow(' — ' + detail) : ''}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function section(title) {
|
|
33
|
+
console.log('\n' + chalk.cyan.bold(`── ${title} ──────────────────────────────`));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ── Fetch com timeout ─────────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
async function fetchWithTimeout(url, options = {}, timeoutMs = 10000) {
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
41
|
+
try {
|
|
42
|
+
return await fetch(url, { ...options, signal: controller.signal });
|
|
43
|
+
} finally {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ── Check 1: Página HTML ──────────────────────────────────────────────────────
|
|
49
|
+
|
|
50
|
+
async function checkPage(siteUrl) {
|
|
51
|
+
section('Página HTML');
|
|
52
|
+
const results = { ok: true };
|
|
53
|
+
|
|
54
|
+
let html = '';
|
|
55
|
+
try {
|
|
56
|
+
const res = await fetchWithTimeout(siteUrl, {
|
|
57
|
+
headers: { 'User-Agent': 'CDP-Edge-Validator/1.0' },
|
|
58
|
+
});
|
|
59
|
+
if (!res.ok) {
|
|
60
|
+
fail('Página acessível', `HTTP ${res.status}`);
|
|
61
|
+
results.ok = false;
|
|
62
|
+
return results;
|
|
63
|
+
}
|
|
64
|
+
ok('Página acessível', `HTTP ${res.status}`);
|
|
65
|
+
html = await res.text();
|
|
66
|
+
} catch (err) {
|
|
67
|
+
fail('Página acessível', err.message);
|
|
68
|
+
results.ok = false;
|
|
69
|
+
return results;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// cdpTrack.min.js
|
|
73
|
+
if (html.includes('cdpTrack.min.js') || html.includes('cdpTrack.js')) {
|
|
74
|
+
ok('cdpTrack.min.js referenciado na página');
|
|
75
|
+
} else {
|
|
76
|
+
fail('cdpTrack.min.js NÃO encontrado na página', 'adicionar <script src="/cdpTrack.min.js">');
|
|
77
|
+
results.ok = false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Meta Pixel (fbq)
|
|
81
|
+
if (html.includes('fbq(') || html.includes("fbq('init'") || html.includes('connect.facebook.net')) {
|
|
82
|
+
ok('Meta Pixel (fbq) detectado');
|
|
83
|
+
} else {
|
|
84
|
+
warn('Meta Pixel não detectado no HTML', 'pode estar em script externo — verificar manualmente');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Google tag
|
|
88
|
+
if (html.includes('gtag(') || html.includes('googletagmanager.com') || html.includes('G-')) {
|
|
89
|
+
ok('Google Tag detectado');
|
|
90
|
+
} else {
|
|
91
|
+
warn('Google Tag não detectado no HTML', 'opcional — verificar se GA4 está habilitado');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ── Check 2: Worker /health ───────────────────────────────────────────────────
|
|
98
|
+
|
|
99
|
+
async function checkWorkerHealth(workerUrl, adminToken) {
|
|
100
|
+
section(adminToken ? 'Worker /api/health' : 'Worker /health');
|
|
101
|
+
const results = { ok: true };
|
|
102
|
+
|
|
103
|
+
let data;
|
|
104
|
+
try {
|
|
105
|
+
const endpoint = adminToken ? '/api/health' : '/health';
|
|
106
|
+
const headers = adminToken ? { Authorization: `Bearer ${adminToken}` } : {};
|
|
107
|
+
const res = await fetchWithTimeout(`${workerUrl}${endpoint}`, { headers });
|
|
108
|
+
data = await res.json();
|
|
59
109
|
if (!res.ok) {
|
|
60
|
-
|
|
61
|
-
results.ok = false;
|
|
62
|
-
return results;
|
|
110
|
+
throw new Error(`HTTP ${res.status} — ${data?.error || 'erro desconhecido'}`);
|
|
63
111
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
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
|
-
|
|
112
|
+
} catch (err) {
|
|
113
|
+
fail('Worker acessível', err.message);
|
|
114
|
+
results.ok = false;
|
|
115
|
+
return results;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
ok('Worker acessível', `status: ${data.status}`);
|
|
119
|
+
if (!adminToken) {
|
|
120
|
+
warn('Diagnostico profundo nao executado', 'use --admin-token para consultar /api/health');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Bindings
|
|
124
|
+
for (const [key, val] of Object.entries(data.bindings || {})) {
|
|
125
|
+
if (val === 'ok') ok(`Binding ${key}`);
|
|
126
|
+
else { fail(`Binding ${key}`, val); results.ok = false; }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Vars
|
|
130
|
+
for (const [key, val] of Object.entries(data.vars || {})) {
|
|
131
|
+
if (val === 'set') ok(`Var ${key}`);
|
|
132
|
+
else { fail(`Var ${key}`, 'MISSING — configurar no wrangler.toml'); results.ok = false; }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Secrets críticos
|
|
136
|
+
const criticalSecrets = ['META_ACCESS_TOKEN', 'GA4_API_SECRET'];
|
|
137
|
+
for (const [key, val] of Object.entries(data.secrets || {})) {
|
|
138
|
+
if (criticalSecrets.includes(key)) {
|
|
139
|
+
if (val === 'set') ok(`Secret ${key}`);
|
|
140
|
+
else { fail(`Secret ${key}`, 'MISSING — wrangler secret put ' + key); results.ok = false; }
|
|
141
|
+
} else {
|
|
142
|
+
if (val === 'set') ok(`Secret ${key}`);
|
|
143
|
+
else warn(`Secret ${key}`, val);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return results;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ── Check 3: /validate-install ────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
async function checkValidateInstall(workerUrl, adminToken) {
|
|
153
|
+
section('Worker /validate-install (checks internos)');
|
|
101
154
|
const results = { ok: true };
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
const res = await fetchWithTimeout(`${workerUrl}/health`);
|
|
106
|
-
data = await res.json();
|
|
107
|
-
} catch (err) {
|
|
108
|
-
fail('Worker acessível', err.message);
|
|
109
|
-
results.ok = false;
|
|
155
|
+
if (!adminToken) {
|
|
156
|
+
warn('validate-install pulado', 'use --admin-token para executar checks internos');
|
|
110
157
|
return results;
|
|
111
158
|
}
|
|
112
159
|
|
|
113
|
-
ok('Worker acessível', `status: ${data.status}`);
|
|
114
|
-
|
|
115
|
-
// Bindings
|
|
116
|
-
for (const [key, val] of Object.entries(data.bindings || {})) {
|
|
117
|
-
if (val === 'ok') ok(`Binding ${key}`);
|
|
118
|
-
else { fail(`Binding ${key}`, val); results.ok = false; }
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Vars
|
|
122
|
-
for (const [key, val] of Object.entries(data.vars || {})) {
|
|
123
|
-
if (val === 'set') ok(`Var ${key}`);
|
|
124
|
-
else { fail(`Var ${key}`, 'MISSING — configurar no wrangler.toml'); results.ok = false; }
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Secrets críticos
|
|
128
|
-
const criticalSecrets = ['META_ACCESS_TOKEN', 'GA4_API_SECRET'];
|
|
129
|
-
for (const [key, val] of Object.entries(data.secrets || {})) {
|
|
130
|
-
if (criticalSecrets.includes(key)) {
|
|
131
|
-
if (val === 'set') ok(`Secret ${key}`);
|
|
132
|
-
else { fail(`Secret ${key}`, 'MISSING — wrangler secret put ' + key); results.ok = false; }
|
|
133
|
-
} else {
|
|
134
|
-
if (val === 'set') ok(`Secret ${key}`);
|
|
135
|
-
else warn(`Secret ${key}`, val);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return results;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// ── Check 3: /validate-install ────────────────────────────────────────────────
|
|
143
|
-
|
|
144
|
-
async function checkValidateInstall(workerUrl) {
|
|
145
|
-
section('Worker /validate-install (checks internos)');
|
|
146
|
-
const results = { ok: true };
|
|
147
|
-
|
|
148
160
|
let data;
|
|
149
161
|
try {
|
|
150
162
|
const res = await fetchWithTimeout(`${workerUrl}/validate-install`, {
|
|
151
|
-
headers: {
|
|
163
|
+
headers: { Authorization: `Bearer ${adminToken}` },
|
|
152
164
|
});
|
|
153
165
|
data = await res.json();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
results.ok = false;
|
|
157
|
-
return results;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
for (const [key, check] of Object.entries(data.checks || {})) {
|
|
161
|
-
if (check.ok) ok(key, check.detail);
|
|
162
|
-
else { fail(key, check.detail); results.ok = false; }
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return results;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// ── Check 4: POST /track com evento sintético ─────────────────────────────────
|
|
169
|
-
|
|
170
|
-
async function checkTrackEndpoint(workerUrl) {
|
|
171
|
-
section('POST /track (evento sintético)');
|
|
172
|
-
const results = { ok: true };
|
|
173
|
-
|
|
174
|
-
const testEvent = {
|
|
175
|
-
eventName: 'PageView',
|
|
176
|
-
userId: `__cdp_validate_${Date.now()}__`,
|
|
177
|
-
pageUrl: workerUrl + '/',
|
|
178
|
-
userAgent: 'CDP-Edge-Validator/1.0',
|
|
179
|
-
utmSource: 'cdp_validate',
|
|
180
|
-
utmMedium: 'cli',
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
let res, data;
|
|
184
|
-
try {
|
|
185
|
-
res = await fetchWithTimeout(`${workerUrl}/track`, {
|
|
186
|
-
method: 'POST',
|
|
187
|
-
headers: { 'Content-Type': 'application/json' },
|
|
188
|
-
body: JSON.stringify(testEvent),
|
|
189
|
-
});
|
|
190
|
-
data = await res.json().catch(() => ({}));
|
|
191
|
-
} catch (err) {
|
|
192
|
-
fail('POST /track', err.message);
|
|
193
|
-
results.ok = false;
|
|
194
|
-
return results;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (res.ok) {
|
|
198
|
-
ok('POST /track', `HTTP ${res.status} — evento aceito`);
|
|
199
|
-
if (data.event_id) ok('event_id retornado', data.event_id);
|
|
200
|
-
if (data.ltv) ok('LTV Prediction', `${data.ltv?.class || ''} (score: ${data.ltv?.score ?? '?'})`);
|
|
201
|
-
if (data.fraud_score !== undefined) {
|
|
202
|
-
data.fraud_score < 50
|
|
203
|
-
? ok('Fraud Gate', `score ${data.fraud_score} — passou`)
|
|
204
|
-
: warn('Fraud Gate', `score ${data.fraud_score} — CLI pode ter sido flagrado como bot`);
|
|
166
|
+
if (!res.ok) {
|
|
167
|
+
throw new Error(`HTTP ${res.status} — ${data?.error || 'erro desconhecido'}`);
|
|
205
168
|
}
|
|
206
|
-
}
|
|
207
|
-
fail('
|
|
208
|
-
results.ok = false;
|
|
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
|
-
|
|
169
|
+
} catch (err) {
|
|
170
|
+
fail('validate-install acessível', err.message);
|
|
171
|
+
results.ok = false;
|
|
172
|
+
return results;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
for (const [key, check] of Object.entries(data.checks || {})) {
|
|
176
|
+
if (check.ok) ok(key, check.detail);
|
|
177
|
+
else { fail(key, check.detail); results.ok = false; }
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return results;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ── Check 4: POST /track com evento sintético ─────────────────────────────────
|
|
184
|
+
|
|
185
|
+
async function checkTrackEndpoint(workerUrl) {
|
|
186
|
+
section('POST /track (evento sintético)');
|
|
187
|
+
const results = { ok: true };
|
|
188
|
+
|
|
189
|
+
const testEvent = {
|
|
190
|
+
eventName: 'PageView',
|
|
191
|
+
userId: `__cdp_validate_${Date.now()}__`,
|
|
192
|
+
pageUrl: workerUrl + '/',
|
|
193
|
+
userAgent: 'CDP-Edge-Validator/1.0',
|
|
194
|
+
utmSource: 'cdp_validate',
|
|
195
|
+
utmMedium: 'cli',
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
let res, data;
|
|
199
|
+
try {
|
|
200
|
+
res = await fetchWithTimeout(`${workerUrl}/track`, {
|
|
201
|
+
method: 'POST',
|
|
202
|
+
headers: { 'Content-Type': 'application/json' },
|
|
203
|
+
body: JSON.stringify(testEvent),
|
|
204
|
+
});
|
|
205
|
+
data = await res.json().catch(() => ({}));
|
|
206
|
+
} catch (err) {
|
|
207
|
+
fail('POST /track', err.message);
|
|
208
|
+
results.ok = false;
|
|
209
|
+
return results;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (res.ok) {
|
|
213
|
+
ok('POST /track', `HTTP ${res.status} — evento aceito`);
|
|
214
|
+
if (data.event_id) ok('event_id retornado', data.event_id);
|
|
215
|
+
if (data.ltv) ok('LTV Prediction', `${data.ltv?.class || ''} (score: ${data.ltv?.score ?? '?'})`);
|
|
216
|
+
if (data.fraud_score !== undefined) {
|
|
217
|
+
data.fraud_score < 50
|
|
218
|
+
? ok('Fraud Gate', `score ${data.fraud_score} — passou`)
|
|
219
|
+
: warn('Fraud Gate', `score ${data.fraud_score} — CLI pode ter sido flagrado como bot`);
|
|
220
|
+
}
|
|
221
|
+
} else {
|
|
222
|
+
fail('POST /track', `HTTP ${res.status} — ${data?.error || 'erro desconhecido'}`);
|
|
223
|
+
results.ok = false;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return results;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ── Entry point ───────────────────────────────────────────────────────────────
|
|
230
|
+
|
|
231
|
+
export async function runValidate(urlArg, options = {}) {
|
|
232
|
+
// Normaliza URLs
|
|
233
|
+
const siteUrl = urlArg?.startsWith('http') ? urlArg.replace(/\/$/, '') : `https://${urlArg}`;
|
|
234
|
+
const workerUrl = options.worker
|
|
235
|
+
? options.worker.replace(/\/$/, '')
|
|
236
|
+
: siteUrl; // assume Worker no mesmo domínio (Custom Domain)
|
|
237
|
+
|
|
238
|
+
console.log(chalk.cyan.bold('\n CDP Edge — Diagnóstico Pós-Deploy\n'));
|
|
239
|
+
console.log(` Site: ${chalk.white(siteUrl)}`);
|
|
240
|
+
console.log(` Worker: ${chalk.white(workerUrl)}`);
|
|
241
|
+
|
|
242
|
+
const spinner = ora('Iniciando diagnóstico...').start();
|
|
243
|
+
spinner.stop();
|
|
244
|
+
|
|
245
|
+
let allOk = true;
|
|
246
|
+
const pageResult = await checkPage(siteUrl);
|
|
247
|
+
const healthResult = await checkWorkerHealth(workerUrl, options.adminToken);
|
|
248
|
+
const validateResult = await checkValidateInstall(workerUrl, options.adminToken);
|
|
249
|
+
const trackResult = await checkTrackEndpoint(workerUrl);
|
|
250
|
+
|
|
251
|
+
allOk = pageResult.ok && healthResult.ok && validateResult.ok && trackResult.ok;
|
|
252
|
+
|
|
253
|
+
// ── Resultado final ───────────────────────────────────────────────────────
|
|
254
|
+
console.log('\n' + chalk.cyan.bold('── Resultado ─────────────────────────────'));
|
|
255
|
+
if (allOk) {
|
|
256
|
+
console.log(`\n ${chalk.green.bold('✅ TUDO OK — tracking funcionando de ponta a ponta.')}`);
|
|
257
|
+
console.log(chalk.gray(' Eventos chegando ao Worker, D1 operacional, secrets configurados.\n'));
|
|
258
|
+
} else {
|
|
259
|
+
console.log(`\n ${chalk.red.bold('❌ FALHAS DETECTADAS — resolver antes de ir ao ar.')}`);
|
|
260
|
+
console.log(chalk.gray(' Corrija os itens marcados com ✗ acima e rode novamente.\n'));
|
|
261
|
+
process.exitCode = 1;
|
|
262
|
+
}
|
|
263
|
+
}
|
package/dist/sdk/cdpTrack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* CDP Edge SDK v2.
|
|
2
|
+
* CDP Edge SDK v2.6.1
|
|
3
3
|
* (c) 2026 CDP Edge — Quantum Tracking
|
|
4
|
-
* Gerado em: 2026-
|
|
4
|
+
* Gerado em: 2026-05-12T21:01:47.573Z
|
|
5
5
|
* Endpoint padrão: /track (mesmo domínio — anti-adblock)
|
|
6
6
|
*/
|
|
7
7
|
"use strict";
|
|
@@ -289,7 +289,7 @@ var cdpTrack = (() => {
|
|
|
289
289
|
fields_count: formInteracted.size,
|
|
290
290
|
meta_intensity: "medium"
|
|
291
291
|
});
|
|
292
|
-
navigator.sendBeacon("/
|
|
292
|
+
navigator.sendBeacon("/track", new Blob([data], { type: "application/json" }));
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
});
|
|
@@ -1796,6 +1796,7 @@ var cdpTrack = (() => {
|
|
|
1796
1796
|
var _wbraid = _urlParams.get("wbraid") || "";
|
|
1797
1797
|
var _gbraid = _urlParams.get("gbraid") || "";
|
|
1798
1798
|
var _ttclid = _urlParams.get("ttclid") || "";
|
|
1799
|
+
var _msclkid = _urlParams.get("msclkid") || "";
|
|
1799
1800
|
var _utms = {
|
|
1800
1801
|
utm_source: _urlParams.get("utm_source") || "",
|
|
1801
1802
|
utm_medium: _urlParams.get("utm_medium") || "",
|
|
@@ -1845,7 +1846,8 @@ var cdpTrack = (() => {
|
|
|
1845
1846
|
ttclid: _ttclid || void 0,
|
|
1846
1847
|
ttp: ((_c = document.cookie.match(/_ttp=([^;]+)/)) == null ? void 0 : _c[1]) || void 0,
|
|
1847
1848
|
// TikTok Pixel cookie — EMQ TikTok
|
|
1848
|
-
rclid: _urlParams.get("rclid") || void 0
|
|
1849
|
+
rclid: _urlParams.get("rclid") || void 0,
|
|
1850
|
+
msclkid: _msclkid || void 0
|
|
1849
1851
|
};
|
|
1850
1852
|
};
|
|
1851
1853
|
var passCheckoutParams = (options = {}) => {
|