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/yellow-worlds-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@knocklabs/client": patch
---

[guides] fix: KnockGuideStep type definition to return a promise from async methods
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nodejs 22.17.0
nodejs 24.12.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated but upgrading the nodejs to v24, similar to what we did in dashboard: https://github.com/knocklabs/control/pull/6801

yarn 1.22.22
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"vitest": "^3.1.1"
},
"engines": {
"node": "22.17.0"
"node": ">=24.10.0"
}
}
5 changes: 0 additions & 5 deletions packages/client/src/clients/guide/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,17 +952,12 @@ export class KnockGuideClient {
...rest,
message: { ...message },
markAsSeen() {
// Send a seen event if it has not been previously seen.
if (this.message.seen_at) return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markAsSeen and markAsArchived class methods already check the same thing and noop if already marked as such. This allows the return value types to be cleaner. i.e.

// This
markAsSeen: () => Promise<KnockGuideStep<TContent> | undefined>;
// Instead of
markAsSeen: () => Promise<KnockGuideStep<TContent> | undefined> | undefined;

return self.markAsSeen(localGuide, this);
},
markAsInteracted({ metadata }: { metadata?: GenericData } = {}) {
// Always send an interaction event through.
return self.markAsInteracted(localGuide, this, metadata);
},
markAsArchived() {
// Send an archived event if it has not been previously archived.
if (this.message.archived_at) return;
return self.markAsArchived(localGuide, this);
},
};
Expand Down
8 changes: 5 additions & 3 deletions packages/client/src/clients/guide/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ export type GuideSocketEvent =

export interface KnockGuideStep<TContent = Any>
extends GuideStepData<TContent> {
markAsSeen: () => void;
markAsInteracted: (params?: { metadata?: GenericData }) => void;
markAsArchived: () => void;
markAsSeen: () => Promise<KnockGuideStep<TContent> | undefined>;
markAsInteracted: (params?: {
metadata?: GenericData;
}) => Promise<KnockGuideStep<TContent> | undefined>;
markAsArchived: () => Promise<KnockGuideStep<TContent> | undefined>;
}

export interface KnockGuideActivationUrlPattern
Expand Down
Loading