Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-cobras-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/nextjs": patch
---

Resolve path module import error in keyless telemetry
9 changes: 5 additions & 4 deletions packages/nextjs/src/server/keyless-telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { TelemetryEventRaw } from '@clerk/types';
import { dirname, join } from 'path';

import { canUseKeyless } from '../utils/feature-flags';
import { createClerkClientWithOptions } from './createClerkClient';
import { nodeFsOrThrow } from './fs/utils';
import { nodeFsOrThrow, nodePathOrThrow } from './fs/utils';

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

/**
Expand All @@ -45,8 +45,9 @@ function tryMarkTelemetryEventAsFired(): boolean {
try {
if (canUseKeyless) {
const { mkdirSync, writeFileSync } = nodeFsOrThrow();
const path = nodePathOrThrow();
const flagFilePath = getTelemetryFlagFilePath();
const flagDirectory = dirname(flagFilePath);
const flagDirectory = path.dirname(flagFilePath);

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