cdp-edge 2.6.0 → 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 +41 -41
- package/contracts/agent-versions.json +2 -2
- package/dist/sdk/cdpTrack.js +2 -2
- package/dist/sdk/cdpTrack.min.js +2 -2
- package/dist/sdk/install-snippet.html +1 -1
- package/extracted-skill/tracking-events-generator/agents/master-orchestrator.md +7 -11
- package/extracted-skill/tracking-events-generator/agents/whatsapp-agent.md +562 -93
- package/package.json +1 -1
- package/server-edge-tracker/.client.env.example +5 -0
- package/server-edge-tracker/deploy-client.cjs +47 -31
- 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/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* CDP Edge
|
|
3
|
+
* CDP Edge - deploy-client.js
|
|
4
4
|
*
|
|
5
|
-
* Deploy
|
|
6
|
-
*
|
|
5
|
+
* Deploy the Worker with client-specific values without committing credentials.
|
|
6
|
+
* Reads .client.env (gitignored) and writes a temporary wrangler.deploy.toml.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* node deploy-client.
|
|
10
|
-
* node deploy-client.
|
|
8
|
+
* Usage:
|
|
9
|
+
* node deploy-client.cjs -> full deploy
|
|
10
|
+
* node deploy-client.cjs --dry-run -> validate without deploying
|
|
11
11
|
*
|
|
12
12
|
* Setup:
|
|
13
13
|
* cp .client.env.example .client.env
|
|
14
|
-
* #
|
|
15
|
-
* node deploy-client.
|
|
14
|
+
* # edit .client.env with the client values
|
|
15
|
+
* node deploy-client.cjs --dry-run
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
const fs
|
|
18
|
+
const fs = require('fs');
|
|
19
19
|
const path = require('path');
|
|
20
20
|
const { execSync } = require('child_process');
|
|
21
21
|
|
|
22
|
-
const ROOT
|
|
23
|
-
const TOML
|
|
24
|
-
const DEPLOY
|
|
25
|
-
const ENV
|
|
22
|
+
const ROOT = __dirname;
|
|
23
|
+
const TOML = path.join(ROOT, 'wrangler.toml');
|
|
24
|
+
const DEPLOY = path.join(ROOT, 'wrangler.deploy.toml');
|
|
25
|
+
const ENV = path.join(ROOT, '.client.env');
|
|
26
26
|
const DRY_RUN = process.argv.includes('--dry-run');
|
|
27
27
|
|
|
28
|
-
// ── Carregar .client.env ──────────────────────────────────────────────────────
|
|
29
28
|
if (!fs.existsSync(ENV)) {
|
|
30
|
-
console.error('\
|
|
31
|
-
console.error('
|
|
29
|
+
console.error('\nERROR: .client.env not found.');
|
|
30
|
+
console.error('Run: cp .client.env.example .client.env');
|
|
31
|
+
console.error('Then fill in the client values.\n');
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const env = {};
|
|
36
|
-
fs.readFileSync(ENV, 'utf8').split('\n').forEach(line => {
|
|
36
|
+
fs.readFileSync(ENV, 'utf8').split('\n').forEach((line) => {
|
|
37
37
|
const trimmed = line.trim();
|
|
38
38
|
if (!trimmed || trimmed.startsWith('#')) return;
|
|
39
39
|
const [key, ...rest] = trimmed.split('=');
|
|
@@ -41,36 +41,52 @@ fs.readFileSync(ENV, 'utf8').split('\n').forEach(line => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
const required = ['DATABASE_ID', 'SITE_DOMAIN'];
|
|
44
|
-
const missing
|
|
44
|
+
const missing = required.filter((key) => !env[key]);
|
|
45
45
|
if (missing.length > 0) {
|
|
46
|
-
console.error(`\
|
|
46
|
+
console.error(`\nERROR: missing required .client.env values: ${missing.join(', ')}\n`);
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
const invalid = [];
|
|
51
|
+
if (env.DATABASE_ID === 'SEU_DATABASE_ID') invalid.push('DATABASE_ID');
|
|
52
|
+
if (env.SITE_DOMAIN === 'SEU_DOMINIO' || env.SITE_DOMAIN === 'seudominio.com.br') {
|
|
53
|
+
invalid.push('SITE_DOMAIN');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (invalid.length > 0) {
|
|
57
|
+
console.error(`\nERROR: placeholder values remain in .client.env: ${invalid.join(', ')}\n`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function tomlString(value) {
|
|
62
|
+
return String(value || '').replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
63
|
+
}
|
|
64
|
+
|
|
51
65
|
let toml = fs.readFileSync(TOML, 'utf8');
|
|
52
66
|
|
|
53
67
|
toml = toml
|
|
54
|
-
.replace(/
|
|
55
|
-
.replace(/
|
|
56
|
-
.replace(/
|
|
57
|
-
.replace(/
|
|
58
|
-
.replace(/
|
|
68
|
+
.replace(/database_id\s*=\s*"[^"]*"/, `database_id = "${tomlString(env.DATABASE_ID)}"`)
|
|
69
|
+
.replace(/SEU_DATABASE_ID/g, tomlString(env.DATABASE_ID))
|
|
70
|
+
.replace(/SEU_DOMINIO/g, tomlString(env.SITE_DOMAIN))
|
|
71
|
+
.replace(/META_PIXEL_ID\s*=\s*"[^"]*"/, `META_PIXEL_ID = "${tomlString(env.META_PIXEL_ID)}"`)
|
|
72
|
+
.replace(/GA4_MEASUREMENT_ID\s*=\s*"[^"]*"/, `GA4_MEASUREMENT_ID = "${tomlString(env.GA4_MEASUREMENT_ID)}"`)
|
|
73
|
+
.replace(/TIKTOK_PIXEL_ID\s*=\s*"[^"]*"/, `TIKTOK_PIXEL_ID = "${tomlString(env.TIKTOK_PIXEL_ID)}"`)
|
|
74
|
+
.replace(/ZAPMAN_API_URL\s*=\s*"[^"]*"/, `ZAPMAN_API_URL = "${tomlString(env.ZAPMAN_API_URL)}"`)
|
|
75
|
+
.replace(/ZAPMAN_CRM_INSTANCE\s*=\s*"[^"]*"/, `ZAPMAN_CRM_INSTANCE = "${tomlString(env.ZAPMAN_CRM_INSTANCE)}"`)
|
|
76
|
+
.replace(/ZAPMAN_WEBHOOK_URL\s*=\s*"[^"]*"/, `ZAPMAN_WEBHOOK_URL = "${tomlString(env.ZAPMAN_WEBHOOK_URL)}"`);
|
|
59
77
|
|
|
60
78
|
fs.writeFileSync(DEPLOY, toml);
|
|
61
79
|
|
|
62
|
-
// ── Executar wrangler deploy ──────────────────────────────────────────────────
|
|
63
80
|
const cmd = `wrangler deploy --config wrangler.deploy.toml${DRY_RUN ? ' --dry-run' : ''}`;
|
|
64
|
-
console.log(`\n
|
|
81
|
+
console.log(`\n${DRY_RUN ? '[DRY-RUN] ' : ''}Deploying with client config...\n`);
|
|
65
82
|
|
|
66
83
|
try {
|
|
67
84
|
execSync(cmd, { stdio: 'inherit', cwd: ROOT });
|
|
68
|
-
console.log(`\
|
|
85
|
+
console.log(`\nDeploy ${DRY_RUN ? '(dry-run) ' : ''}completed.\n`);
|
|
69
86
|
} catch (err) {
|
|
70
|
-
console.error('\
|
|
87
|
+
console.error('\nDeploy failed.\n');
|
|
71
88
|
process.exit(1);
|
|
72
89
|
} finally {
|
|
73
|
-
// sempre remove o arquivo temporário
|
|
74
90
|
if (fs.existsSync(DEPLOY)) fs.unlinkSync(DEPLOY);
|
|
75
|
-
console.log('
|
|
91
|
+
console.log('Removed temporary wrangler.deploy.toml.\n');
|
|
76
92
|
}
|