@knocklabs/client 0.19.2 → 0.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/clients/guide/client.js +1 -1
- package/dist/cjs/clients/guide/client.js.map +1 -1
- package/dist/cjs/knock.js +2 -2
- package/dist/cjs/knock.js.map +1 -1
- package/dist/esm/api.mjs +20 -17
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/clients/guide/client.mjs +4 -3
- package/dist/esm/clients/guide/client.mjs.map +1 -1
- package/dist/esm/knock.mjs +20 -18
- package/dist/esm/knock.mjs.map +1 -1
- package/dist/types/api.d.ts +2 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/clients/guide/client.d.ts.map +1 -1
- package/dist/types/interfaces.d.ts +1 -0
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/types/knock.d.ts +1 -0
- package/dist/types/knock.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +5 -0
- package/src/clients/guide/client.ts +2 -1
- package/src/interfaces.ts +1 -0
- package/src/knock.ts +3 -0
package/src/api.ts
CHANGED
|
@@ -6,6 +6,7 @@ type ApiClientOptions = {
|
|
|
6
6
|
host: string;
|
|
7
7
|
apiKey: string;
|
|
8
8
|
userToken: string | undefined;
|
|
9
|
+
branch?: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export interface ApiResponse {
|
|
@@ -21,6 +22,7 @@ class ApiClient {
|
|
|
21
22
|
private host: string;
|
|
22
23
|
private apiKey: string;
|
|
23
24
|
private userToken: string | null;
|
|
25
|
+
private branch: string | null;
|
|
24
26
|
private axiosClient: AxiosInstance;
|
|
25
27
|
|
|
26
28
|
public socket: Socket | undefined;
|
|
@@ -29,6 +31,7 @@ class ApiClient {
|
|
|
29
31
|
this.host = options.host;
|
|
30
32
|
this.apiKey = options.apiKey;
|
|
31
33
|
this.userToken = options.userToken || null;
|
|
34
|
+
this.branch = options.branch || null;
|
|
32
35
|
|
|
33
36
|
// Create a retryable axios client
|
|
34
37
|
this.axiosClient = axios.create({
|
|
@@ -39,6 +42,7 @@ class ApiClient {
|
|
|
39
42
|
Authorization: `Bearer ${this.apiKey}`,
|
|
40
43
|
"X-Knock-User-Token": this.userToken,
|
|
41
44
|
"X-Knock-Client": this.getKnockClientHeader(),
|
|
45
|
+
"X-Knock-Branch": this.branch,
|
|
42
46
|
},
|
|
43
47
|
});
|
|
44
48
|
|
|
@@ -47,6 +51,7 @@ class ApiClient {
|
|
|
47
51
|
params: {
|
|
48
52
|
user_token: this.userToken,
|
|
49
53
|
api_key: this.apiKey,
|
|
54
|
+
branch_slug: this.branch,
|
|
50
55
|
},
|
|
51
56
|
});
|
|
52
57
|
}
|
|
@@ -848,7 +848,6 @@ export class KnockGuideClient {
|
|
|
848
848
|
...this.buildEngagementEventBaseParams(guide, updatedStep),
|
|
849
849
|
content: updatedStep.content,
|
|
850
850
|
data: this.targetParams.data,
|
|
851
|
-
tenant: this.targetParams.tenant,
|
|
852
851
|
};
|
|
853
852
|
|
|
854
853
|
this.knock.user.markGuideStepAs<MarkAsSeenParams, MarkGuideAsResponse>(
|
|
@@ -1076,6 +1075,8 @@ export class KnockGuideClient {
|
|
|
1076
1075
|
guide_key: guide.key,
|
|
1077
1076
|
guide_id: guide.id,
|
|
1078
1077
|
guide_step_ref: step.ref,
|
|
1078
|
+
// Can be used for scoping guide messages.
|
|
1079
|
+
tenant: this.targetParams.tenant,
|
|
1079
1080
|
};
|
|
1080
1081
|
}
|
|
1081
1082
|
|
package/src/interfaces.ts
CHANGED
package/src/knock.ts
CHANGED
|
@@ -25,6 +25,7 @@ class Knock {
|
|
|
25
25
|
public userId: string | undefined | null;
|
|
26
26
|
public userToken?: string;
|
|
27
27
|
public logLevel?: LogLevel;
|
|
28
|
+
public readonly branch?: string;
|
|
28
29
|
private tokenExpirationTimer: ReturnType<typeof setTimeout> | null = null;
|
|
29
30
|
readonly feeds = new FeedClient(this);
|
|
30
31
|
readonly objects = new ObjectClient(this);
|
|
@@ -40,6 +41,7 @@ class Knock {
|
|
|
40
41
|
) {
|
|
41
42
|
this.host = options.host || DEFAULT_HOST;
|
|
42
43
|
this.logLevel = options.logLevel;
|
|
44
|
+
this.branch = options.branch || undefined;
|
|
43
45
|
|
|
44
46
|
this.log("Initialized Knock instance");
|
|
45
47
|
|
|
@@ -187,6 +189,7 @@ class Knock {
|
|
|
187
189
|
apiKey: this.apiKey,
|
|
188
190
|
host: this.host,
|
|
189
191
|
userToken: this.userToken,
|
|
192
|
+
branch: this.branch,
|
|
190
193
|
});
|
|
191
194
|
}
|
|
192
195
|
|