Skip to content

Commit a9b0087

Browse files
authoredFeb 14, 2025··
fix(clerk-js): Ensure withSignUp is collected in telemetry (#5150)
1 parent 14fd729 commit a9b0087

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed
 

‎.changeset/good-olives-unite.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/shared': minor
3+
'@clerk/clerk-js': patch
4+
'@clerk/types': patch
5+
---
6+
7+
Support passing additional properties to `eventPrebuiltComponentMounted()`, and ensure `withSignUp` is collected on `SignIn` mount.

‎packages/clerk-js/src/core/clerk.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,15 @@ export class Clerk implements ClerkInterface {
581581
}),
582582
);
583583
this.telemetry?.record(
584-
eventPrebuiltComponentMounted('SignIn', {
585-
...props,
586-
withSignUp: props?.withSignUp ?? this.#isCombinedSignInOrUpFlow(),
587-
}),
584+
eventPrebuiltComponentMounted(
585+
'SignIn',
586+
{
587+
...props,
588+
},
589+
{
590+
withSignUp: props?.withSignUp ?? this.#isCombinedSignInOrUpFlow(),
591+
},
592+
),
588593
);
589594
};
590595

‎packages/shared/src/telemetry/events/component-mounted.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ type EventPrebuiltComponentMounted = ComponentMountedBase & {
1414
baseTheme: boolean;
1515
};
1616

17-
type EventComponentMounted = ComponentMountedBase & {
18-
[key: string]: boolean | string;
19-
};
17+
type EventComponentMounted = ComponentMountedBase & TelemetryEventRaw['payload'];
2018

2119
/**
2220
* Helper function for `telemetry.record()`. Create a consistent event object for when a prebuilt (AIO) component is mounted.
2321
*
2422
* @param component - The name of the component.
2523
* @param props - The props passed to the component. Will be filtered to a known list of props.
24+
* @param additionalPayload - Additional data to send with the event.
2625
*
2726
* @example
2827
* telemetry.record(eventPrebuiltComponentMounted('SignUp', props));
2928
*/
3029
export function eventPrebuiltComponentMounted(
3130
component: string,
3231
props?: Record<string, any>,
32+
additionalPayload?: TelemetryEventRaw['payload'],
3333
): TelemetryEventRaw<EventPrebuiltComponentMounted> {
3434
return {
3535
event: EVENT_COMPONENT_MOUNTED,
@@ -40,6 +40,7 @@ export function eventPrebuiltComponentMounted(
4040
baseTheme: Boolean(props?.appearance?.baseTheme),
4141
elements: Boolean(props?.appearance?.elements),
4242
variables: Boolean(props?.appearance?.variables),
43+
...additionalPayload,
4344
},
4445
};
4546
}
@@ -57,7 +58,7 @@ export function eventPrebuiltComponentMounted(
5758
*/
5859
export function eventComponentMounted(
5960
component: string,
60-
props: Record<string, string | boolean> = {},
61+
props: TelemetryEventRaw['payload'] = {},
6162
): TelemetryEventRaw<EventComponentMounted> {
6263
return {
6364
event: EVENT_COMPONENT_MOUNTED,

‎packages/types/src/telemetry.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { InstanceType } from 'instance';
22

3+
type JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue };
4+
35
/**
46
* @internal
57
*/
@@ -29,7 +31,7 @@ export type TelemetryEvent = {
2931
* SDK Version
3032
*/
3133
sdkv?: string;
32-
payload: Record<string, string | number | boolean>;
34+
payload: Record<string, JSONValue>;
3335
};
3436

3537
/**

0 commit comments

Comments
 (0)
Please sign in to comment.