File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @clerk/nextjs ' : patch
3
+ ---
4
+
5
+ Updated implementation of detectKeylessEnvDrift to function when <ClerkProvider /> is implemented in client components. Added canUseKeyless check to detectKeylessEnvDrift to prevent telemetry event from running for production applications.
Original file line number Diff line number Diff line change @@ -44,6 +44,13 @@ const NextClientClerkProvider = (props: NextClerkProviderProps) => {
44
44
const replace = useAwaitableReplace ( ) ;
45
45
const [ isPending , startTransition ] = useTransition ( ) ;
46
46
47
+ // Call drift detection on mount (client-side)
48
+ useSafeLayoutEffect ( ( ) => {
49
+ if ( canUseKeyless ) {
50
+ void detectKeylessEnvDriftAction ( ) ;
51
+ }
52
+ } , [ ] ) ;
53
+
47
54
// Avoid rendering nested ClerkProviders by checking for the existence of the ClerkNextOptions context provider
48
55
const isNested = Boolean ( useClerkNextOptions ( ) ) ;
49
56
if ( isNested ) {
@@ -56,11 +63,6 @@ const NextClientClerkProvider = (props: NextClerkProviderProps) => {
56
63
}
57
64
} , [ isPending ] ) ;
58
65
59
- // Call drift detection on mount (client-side)
60
- useSafeLayoutEffect ( ( ) => {
61
- void detectKeylessEnvDriftAction ( ) ;
62
- } , [ ] ) ;
63
-
64
66
useSafeLayoutEffect ( ( ) => {
65
67
window . __unstable__onBeforeSetActive = intent => {
66
68
/**
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ export async function deleteKeylessAction() {
95
95
}
96
96
97
97
export async function detectKeylessEnvDriftAction ( ) {
98
+ if ( ! canUseKeyless ) {
99
+ return ;
100
+ }
101
+
98
102
try {
99
103
const { detectKeylessEnvDrift } = await import ( '../server/keyless-telemetry.js' ) ;
100
104
await detectKeylessEnvDrift ( ) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type { TelemetryEventRaw } from '@clerk/types';
2
2
import { promises as fs } from 'fs' ;
3
3
import { dirname , join } from 'path' ;
4
4
5
+ import { canUseKeyless } from '../utils/feature-flags' ;
5
6
import { createClerkClientWithOptions } from './createClerkClient' ;
6
7
7
8
const EVENT_KEYLESS_ENV_DRIFT_DETECTED = 'KEYLESS_ENV_DRIFT_DETECTED' ;
@@ -86,6 +87,9 @@ async function tryMarkTelemetryEventAsFired(): Promise<boolean> {
86
87
* @returns Promise<void> - Function completes silently, errors are logged but don't throw
87
88
*/
88
89
export async function detectKeylessEnvDrift ( ) : Promise < void > {
90
+ if ( ! canUseKeyless ) {
91
+ return ;
92
+ }
89
93
// Only run on server side
90
94
if ( typeof window !== 'undefined' ) {
91
95
return ;
You can’t perform that action at this time.
0 commit comments