Skip to content

Commit 64acfdd

Browse files
committed
Add support for telemetry debugging via VERCEL_TELEMETRY_DEBUG
1 parent a8287f5 commit 64acfdd

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vercel': patch
3+
---
4+
5+
Add support for telemetry debugging via VERCEL_TELEMETRY_DEBUG. Telemetry collection is not currently enabled and when it is, will be a major version bump for the CLI.

packages/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const main = async () => {
114114
});
115115

116116
const telemetryEventStore = new TelemetryEventStore({
117-
isDebug: isDebugging,
117+
isDebug: process.env.VERCEL_TELEMETRY_DEBUG === '1',
118118
output,
119119
});
120120

packages/cli/src/util/telemetry/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export class TelemetryClient {
102102
export class TelemetryEventStore {
103103
private events: Event[];
104104
private output: Output;
105+
// Whether to log telemetry events to the console, this behavior is independent of the `--debug` flag
106+
// which is used to enable debug logging for the CLI as a whole.
105107
private isDebug: boolean;
106108
private sessionId: string;
107109

@@ -127,9 +129,11 @@ export class TelemetryEventStore {
127129

128130
save() {
129131
if (this.isDebug) {
130-
this.output.debug(`${LogLabel} Flushing Events`);
132+
// Intentionally not using `this.output.debug` as it will
133+
// not write to stderr unless the is run with `--debug`
134+
this.output.log(`${LogLabel} Flushing Events`);
131135
this.events.forEach(event => {
132-
this.output.debug(JSON.stringify(event));
136+
this.output.log(JSON.stringify(event));
133137
});
134138
}
135139
}

0 commit comments

Comments
 (0)