Skip to content

Commit abd8446

Browse files
authored
chore(shared): Check for process.env presence in telemetry collector (#6245)
1 parent ed54bd8 commit abd8446

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.changeset/four-countries-share.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/shared": patch
3+
---
4+
5+
Fixes an issue accessing the `CLERK_TELEMETRY_DEBUG` environment variable during telemetry collection

packages/shared/src/telemetry/collector.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ export class TelemetryCollector implements TelemetryCollectorInterface {
9898

9999
// In browser or client environments, we most likely pass the disabled option to the collector, but in environments
100100
// where environment variables are available we also check for `CLERK_TELEMETRY_DISABLED`.
101-
if (this.#config.disabled || (typeof process !== 'undefined' && isTruthy(process.env.CLERK_TELEMETRY_DISABLED))) {
101+
if (
102+
this.#config.disabled ||
103+
(typeof process !== 'undefined' && process.env && isTruthy(process.env.CLERK_TELEMETRY_DISABLED))
104+
) {
102105
return false;
103106
}
104107

@@ -113,7 +116,10 @@ export class TelemetryCollector implements TelemetryCollectorInterface {
113116
}
114117

115118
get isDebug(): boolean {
116-
return this.#config.debug || (typeof process !== 'undefined' && isTruthy(process.env.CLERK_TELEMETRY_DEBUG));
119+
return (
120+
this.#config.debug ||
121+
(typeof process !== 'undefined' && process.env && isTruthy(process.env.CLERK_TELEMETRY_DEBUG))
122+
);
117123
}
118124

119125
record(event: TelemetryEventRaw): void {

0 commit comments

Comments
 (0)