Skip to content

Commit abc8efb

Browse files
committed
feat: add telemetry token replacement for bundle process
1 parent 1cbc5c1 commit abc8efb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/schema/build/bundle.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@ const watch = process.argv.includes('--watch');
22
const minify = process.argv.includes('--minify');
33
const success = watch ? 'Watch build succeeded' : 'Build succeeded';
44
const fs = require('fs');
5+
const path = require('path');
6+
7+
// Replace telemetry token before building
8+
function replaceTelemetryToken() {
9+
const telemetryToken = process.env.TELEMETRY_TRACKING_TOKEN;
10+
if (!telemetryToken) {
11+
console.error('Error: TELEMETRY_TRACKING_TOKEN environment variable is not set');
12+
process.exit(1);
13+
}
14+
15+
const constantsPath = path.join(__dirname, '../src/constants.ts');
16+
let constantsContent = fs.readFileSync(constantsPath, 'utf8');
17+
18+
// Replace the placeholder with the actual token
19+
constantsContent = constantsContent.replace('<TELEMETRY_TRACKING_TOKEN>', telemetryToken);
20+
21+
fs.writeFileSync(constantsPath, constantsContent);
22+
console.log('Telemetry token replaced successfully');
23+
}
24+
25+
// Replace the token before building
26+
replaceTelemetryToken();
527

628
require('esbuild')
729
.build({

0 commit comments

Comments
 (0)