Skip to content

Commit d95fb2f

Browse files
committed
refactor(shared): reuse shared CI env-var list in telemetry notice
1 parent 4dd535a commit d95fb2f

2 files changed

Lines changed: 4 additions & 38 deletions

File tree

packages/shared/src/__tests__/telemetry.notice.spec.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,9 @@
44
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
55

66
import { __resetTelemetryNoticeForTests, maybeShowTelemetryNotice } from '../telemetry/notice';
7+
import { automatedEnvironmentVariables } from '../utils/runtimeEnvironment';
78

8-
const CI_VARS = [
9-
'CI',
10-
'CONTINUOUS_INTEGRATION',
11-
'BUILD_NUMBER',
12-
'GITHUB_ACTIONS',
13-
'GITLAB_CI',
14-
'CIRCLECI',
15-
'TRAVIS',
16-
'BUILDKITE',
17-
'JENKINS_URL',
18-
'TF_BUILD',
19-
'DRONE',
20-
'CODEBUILD_BUILD_ID',
21-
];
9+
const CI_VARS = automatedEnvironmentVariables;
2210

2311
function clearCIEnv() {
2412
for (const name of CI_VARS) {

packages/shared/src/telemetry/notice.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* the SDK.
2626
*/
2727

28-
import { isTruthy } from '../underscore';
28+
import { isAutomatedEnvironment } from '../utils/runtimeEnvironment';
2929

3030
const PROCESS_FLAG = Symbol.for('@clerk/shared.telemetryNoticeShown');
3131

@@ -35,21 +35,6 @@ const NOTICE_LINES = [
3535
'To learn more, including how to opt-out from the telemetry program, visit: https://clerk.com/docs/telemetry.',
3636
];
3737

38-
const CI_ENV_VARS = [
39-
'CI',
40-
'CONTINUOUS_INTEGRATION',
41-
'BUILD_NUMBER',
42-
'GITHUB_ACTIONS',
43-
'GITLAB_CI',
44-
'CIRCLECI',
45-
'TRAVIS',
46-
'BUILDKITE',
47-
'JENKINS_URL',
48-
'TF_BUILD',
49-
'DRONE',
50-
'CODEBUILD_BUILD_ID',
51-
];
52-
5338
function isServerRuntime(): boolean {
5439
// Skip in browsers.
5540
if (typeof window !== 'undefined') {
@@ -64,13 +49,6 @@ function isServerRuntime(): boolean {
6449
return true;
6550
}
6651

67-
function isCI(): boolean {
68-
if (typeof process === 'undefined' || !process.env) {
69-
return false;
70-
}
71-
return CI_ENV_VARS.some(name => isTruthy(process.env[name]));
72-
}
73-
7452
function hasSeen(): boolean {
7553
return Boolean((globalThis as Record<symbol, unknown>)[PROCESS_FLAG]);
7654
}
@@ -110,7 +88,7 @@ export function maybeShowTelemetryNotice(options: MaybeShowTelemetryNoticeOption
11088
if (!isServerRuntime()) {
11189
return;
11290
}
113-
if (isCI()) {
91+
if (isAutomatedEnvironment()) {
11492
return;
11593
}
11694
if (hasSeen()) {

0 commit comments

Comments
 (0)