Skip to content

Commit

Permalink
Move trackStartEvent param out of track properties
Browse files Browse the repository at this point in the history
  • Loading branch information
imx-mikhala committed Feb 6, 2025
1 parent 9656e71 commit 5f95edf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions packages/internal/metrics/src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ const getEventName = (flowName: string, eventName: string) => `${flowName}_${cle
const trackFlowFn = (
moduleName: string,
flowName: string,
properties: AllowedTrackProperties = {
trackStartEvent: true,
},
trackStartEvent: boolean = true,
properties?: AllowedTrackProperties,
): Flow => {
// Track the start of the flow
const flowId = generateFlowId();
Expand Down Expand Up @@ -102,7 +101,7 @@ const trackFlowFn = (
previousStepTime = currentTime;
};

if (properties.trackStartEvent) {
if (trackStartEvent) {
// Trigger a Start Event as a record of creating the flow
addEvent('Start');
}
Expand All @@ -123,11 +122,12 @@ const trackFlowFn = (
* Works similarly to `track`
* @param moduleName Name of the module being tracked (for namespacing purposes), e.g. `passport`
* @param flowName Name of the flow, e.g. `performTransaction`
* @param trackStartEvent Whether to track the start event in the flow
* @param properties Other properties to be sent with the event, other than duration
*
* @example
* ```ts
* const flow = trackFlow("passport", "performTransaction", { transationType: "transfer" });
* const flow = trackFlow("passport", "performTransaction", true, { transationType: "transfer" });
* // Do something...
* flow.addEvent("clickItem");
* // Do something...
Expand Down
2 changes: 0 additions & 2 deletions packages/internal/metrics/src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ string | number | boolean | undefined
// List of properties that are allowed to be sent with the track request
// As these are used by other types of tracking
export type AllowedTrackProperties = TrackProperties & {
// Start event
trackStartEvent?: boolean;
// Performance
duration?: never;
// Flow
Expand Down
2 changes: 1 addition & 1 deletion packages/passport/sdk/src/Passport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export class Passport {
}

public async linkExternalWallet(params: LinkWalletParams): Promise<LinkedWallet> {
const flow = trackFlow('passport', 'linkExternalWallet', { trackStartEvent: false });
const flow = trackFlow('passport', 'linkExternalWallet', false);

const user = await this.authManager.getUser();
if (!user) {
Expand Down
4 changes: 2 additions & 2 deletions packages/passport/sdk/src/utils/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const withMetrics = <T>(
const flow: Flow = trackFlow(
'passport',
flowName,
{ trackStartEvent },
trackStartEvent,
);

try {
Expand Down Expand Up @@ -37,7 +37,7 @@ export const withMetricsAsync = async <T>(
const flow: Flow = trackFlow(
'passport',
flowName,
{ trackStartEvent },
trackStartEvent,
);

try {
Expand Down

0 comments on commit 5f95edf

Please sign in to comment.