Skip to content

Commit 1fc24e3

Browse files
authored
fix(nextjs): Resolve path module import error in keyless-telemetry (#6694)
1 parent ea65f20 commit 1fc24e3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.changeset/angry-cobras-confess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/nextjs": patch
3+
---
4+
5+
Resolve path module import error in keyless telemetry

packages/nextjs/src/server/keyless-telemetry.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { TelemetryEventRaw } from '@clerk/types';
2-
import { dirname, join } from 'path';
32

43
import { canUseKeyless } from '../utils/feature-flags';
54
import { createClerkClientWithOptions } from './createClerkClient';
6-
import { nodeFsOrThrow } from './fs/utils';
5+
import { nodeFsOrThrow, nodePathOrThrow } from './fs/utils';
76

87
const EVENT_KEYLESS_ENV_DRIFT_DETECTED = 'KEYLESS_ENV_DRIFT_DETECTED';
98
const EVENT_SAMPLING_RATE = 1; // 100% sampling rate
@@ -27,7 +26,8 @@ type EventKeylessEnvDriftPayload = {
2726
* @returns The absolute path to the telemetry flag file in the project's .clerk/.tmp directory
2827
*/
2928
function getTelemetryFlagFilePath(): string {
30-
return join(process.cwd(), TELEMETRY_FLAG_FILE);
29+
const path = nodePathOrThrow();
30+
return path.join(process.cwd(), TELEMETRY_FLAG_FILE);
3131
}
3232

3333
/**
@@ -45,8 +45,9 @@ function tryMarkTelemetryEventAsFired(): boolean {
4545
try {
4646
if (canUseKeyless) {
4747
const { mkdirSync, writeFileSync } = nodeFsOrThrow();
48+
const path = nodePathOrThrow();
4849
const flagFilePath = getTelemetryFlagFilePath();
49-
const flagDirectory = dirname(flagFilePath);
50+
const flagDirectory = path.dirname(flagFilePath);
5051

5152
// Ensure the directory exists before attempting to write the file
5253
mkdirSync(flagDirectory, { recursive: true });

0 commit comments

Comments
 (0)