Skip to content

Commit 84357ad

Browse files
authored
feat: add skipEngagementTracking debug setting to guide toolbar (#877)
1 parent 785251a commit 84357ad

8 files changed

Lines changed: 594 additions & 38 deletions

File tree

packages/client/src/clients/guide/client.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,11 @@ export class KnockGuideClient {
588588

589589
this.store.setState((state) => ({
590590
...state,
591-
debug: { ...debugOpts, debugging: true },
591+
debug: {
592+
skipEngagementTracking: true,
593+
...debugOpts,
594+
debugging: true,
595+
},
592596
}));
593597

594598
if (shouldRefetch) {
@@ -970,6 +974,13 @@ export class KnockGuideClient {
970974
});
971975
if (!updatedStep) return;
972976

977+
if (this.shouldSkipEngagementApi()) {
978+
this.knock.log(
979+
"[Guide] Skipping engagement API call for markAsSeen (debug mode)",
980+
);
981+
return updatedStep;
982+
}
983+
973984
const params = {
974985
...this.buildEngagementEventBaseParams(guide, updatedStep),
975986
content: updatedStep.content,
@@ -1000,6 +1011,13 @@ export class KnockGuideClient {
10001011
});
10011012
if (!updatedStep) return;
10021013

1014+
if (this.shouldSkipEngagementApi()) {
1015+
this.knock.log(
1016+
"[Guide] Skipping engagement API call for markAsInteracted (debug mode)",
1017+
);
1018+
return updatedStep;
1019+
}
1020+
10031021
const params = {
10041022
...this.buildEngagementEventBaseParams(guide, updatedStep),
10051023
metadata,
@@ -1025,6 +1043,13 @@ export class KnockGuideClient {
10251043
});
10261044
if (!updatedStep) return;
10271045

1046+
if (this.shouldSkipEngagementApi()) {
1047+
this.knock.log(
1048+
"[Guide] Skipping engagement API call for markAsArchived (debug mode)",
1049+
);
1050+
return updatedStep;
1051+
}
1052+
10281053
const params = this.buildEngagementEventBaseParams(guide, updatedStep);
10291054

10301055
this.knock.user.markGuideStepAs<MarkAsArchivedParams, MarkGuideAsResponse>(
@@ -1038,6 +1063,10 @@ export class KnockGuideClient {
10381063
return updatedStep;
10391064
}
10401065

1066+
private shouldSkipEngagementApi(): boolean {
1067+
return !!this.store.state.debug?.skipEngagementTracking;
1068+
}
1069+
10411070
//
10421071
// Helpers
10431072
//

packages/client/src/clients/guide/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export type DebugState = {
233233
debugging?: boolean;
234234
forcedGuideKey?: string | null;
235235
previewSessionId?: string | null;
236+
skipEngagementTracking?: boolean;
236237
};
237238

238239
export type StoreState = {

0 commit comments

Comments
 (0)