@getuserfeedback/sdk 0.18.0 → 0.19.1
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/README.md +17 -416
- package/dist/index.d.ts +19 -7
- package/dist/index.js +2 -2
- package/dist/index.js.map +7 -6
- package/dist/internal/action-registry.d.ts +7 -6
- package/dist/internal/action-registry.js +2 -2
- package/dist/internal/action-registry.js.map +3 -3
- package/dist/internal/inline-flow.d.ts +18 -6
- package/dist/internal/inline-flow.js +2 -2
- package/dist/internal/inline-flow.js.map +3 -3
- package/dist/internal/link-router.d.ts +6 -0
- package/dist/internal/link-router.js +4 -0
- package/dist/internal/link-router.js.map +10 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,435 +1,36 @@
|
|
|
1
1
|
# @getuserfeedback/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Add in-product surveys, forms, and messages to browser applications with
|
|
4
|
+
[getuserfeedback.com](https://getuserfeedback.com).
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
> Building a browser React app? Use [@getuserfeedback/react](https://www.npmjs.com/package/@getuserfeedback/react).
|
|
6
|
+
> Building a React app? Use
|
|
7
|
+
> [@getuserfeedback/react](https://www.npmjs.com/package/@getuserfeedback/react).
|
|
8
8
|
>
|
|
9
|
-
> Building a React Native app? Use
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install @getuserfeedback/sdk
|
|
15
|
-
```
|
|
9
|
+
> Building a React Native app? Use
|
|
10
|
+
> [@getuserfeedback/react-native](https://www.npmjs.com/package/@getuserfeedback/react-native).
|
|
16
11
|
|
|
17
12
|
## Get started
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
Sign up on [getuserfeedback.com](https://getuserfeedback.com) and grab your key in Settings.
|
|
21
|
-
|
|
22
|
-
### 2. Add the client
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
// client.ts
|
|
26
|
-
import { createClient } from "@getuserfeedback/sdk";
|
|
27
|
-
|
|
28
|
-
export const client = createClient({
|
|
29
|
-
apiKey: "YOUR_API_KEY",
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// identify user (e.g., on login)
|
|
33
|
-
client.identify(user.id, {
|
|
34
|
-
email: user.email,
|
|
35
|
-
firstName: user.firstName,
|
|
36
|
-
lastName: user.lastName,
|
|
37
|
-
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### 3. Start collecting responses
|
|
41
|
-
|
|
42
|
-
Pick one of our curated templates on [getuserfeedback.com/templates](https://getuserfeedback.com/templates) — from a post-signup welcome message to customer satisfaction surveys, feedback forms, and more. You can also customize everything or start from scratch.
|
|
43
|
-
|
|
44
|
-
### 4. Get feedback — improve product — repeat
|
|
45
|
-
Our widgets are optimized to get you *more* responses. Polished UI, crafted copy, templates, and a million subtle tricks. Result — you get more responses, make better roadmap calls, and find product-market fit faster.
|
|
46
|
-
|
|
47
|
-
### Bonus
|
|
48
|
-
Our AI-powered theme editor allows a complete overhaul of the widget look and feel with a single prompt. Demo: [getuserfeedback.com/themes](https://getuserfeedback.com/themes).
|
|
49
|
-
|
|
50
|
-
## Advanced use cases
|
|
51
|
-
### Feedback form
|
|
52
|
-
You can open flows on demand, e.g., show a support form when the user clicks a help menu item.
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
// contact support flow you created on getuserfeedback.com
|
|
56
|
-
const CONTACT_SUPPORT_FLOW_ID = "YOUR_FLOW_ID";
|
|
57
|
-
|
|
58
|
-
const supportMenuItem = document.querySelector<HTMLButtonElement>("#help-menu-contact-support");
|
|
59
|
-
|
|
60
|
-
supportMenuItem?.addEventListener("click", () => {
|
|
61
|
-
client.open(CONTACT_SUPPORT_FLOW_ID);
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Bring your own UI
|
|
66
|
-
By default, flows are displayed in a floating container and [themed](https://getuserfeedback.com/themes) accordingly. Beyond that, you can replace the default floating container with your own. This gives you unprecedented customization options for a seamless user experience.
|
|
67
|
-
|
|
68
|
-
For example, if you're using custom dialogs throughout your product, our widgets can be seamlessly rendered into your dialogs and appear just like any other part of your app.
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
const flow = await client.flow("YOUR_FLOW_ID");
|
|
72
|
-
|
|
73
|
-
// your custom container, e.g. a dialog
|
|
74
|
-
const container = document.querySelector<HTMLDivElement>("#support-dialog-body");
|
|
75
|
-
|
|
76
|
-
if (container) {
|
|
77
|
-
await flow.open({ container });
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## API Overview
|
|
82
|
-
|
|
83
|
-
- `createClient(options)`
|
|
84
|
-
- `client.identify(userId, traits?)` or `client.identify(traits)`
|
|
85
|
-
- `client.reset()`
|
|
86
|
-
- `client.open(flowId, options?)`
|
|
87
|
-
- `client.prefetch(flowId)`
|
|
88
|
-
- `client.prerender(flowId)`
|
|
89
|
-
- `client.flow(flowId)`
|
|
90
|
-
- `client.configure(updates)`
|
|
91
|
-
- `client.close()`
|
|
92
|
-
- `client.setDefaultContainerPolicy(policy)`
|
|
93
|
-
- `client.subscribeFlowState(callback, options?)`
|
|
94
|
-
|
|
95
|
-
## `createClient(options)`
|
|
96
|
-
|
|
97
|
-
Create a single SDK client and reuse it across your app.
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
import { createClient } from "@getuserfeedback/sdk";
|
|
101
|
-
|
|
102
|
-
export const client = createClient({
|
|
103
|
-
apiKey: "YOUR_API_KEY",
|
|
104
|
-
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Options
|
|
108
|
-
|
|
109
|
-
- `apiKey` (`string`, required): your project API key.
|
|
110
|
-
- `colorScheme` (`"light" | "dark" | "system" | { autoDetectColorScheme: string[] }`, optional):
|
|
111
|
-
controls widget theme mode. See [Dark mode](#dark-mode).
|
|
112
|
-
- `disableAutoLoad` (`boolean`, optional): if `true`, call `client.load()` manually.
|
|
113
|
-
- `disableTelemetry` (`boolean`, optional): disables anonymous telemetry used for performance and error monitoring.
|
|
114
|
-
|
|
115
|
-
### Notes
|
|
116
|
-
|
|
117
|
-
- If you call `createClient` again with the same `apiKey`, the SDK will return the same (stable) reference.
|
|
118
|
-
|
|
119
|
-
### Delay widget load
|
|
120
|
-
|
|
121
|
-
If you want to manually control when the widget starts loading:
|
|
122
|
-
|
|
123
|
-
```ts
|
|
124
|
-
import { createClient } from "@getuserfeedback/sdk";
|
|
125
|
-
|
|
126
|
-
export const client = createClient({
|
|
127
|
-
apiKey: "YOUR_API_KEY",
|
|
128
|
-
disableAutoLoad: true,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
type ConsentResolvedDetail = {
|
|
132
|
-
hasResolvedConsent: boolean;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
function isConsentResolvedEvent(
|
|
136
|
-
event: Event,
|
|
137
|
-
): event is CustomEvent<ConsentResolvedDetail> {
|
|
138
|
-
return event instanceof CustomEvent;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
window.addEventListener("cookie-consent-resolved", (event) => {
|
|
142
|
-
if (!isConsentResolvedEvent(event)) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (!event.detail?.hasResolvedConsent) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
client.load();
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Identify users
|
|
155
|
-
|
|
156
|
-
Use identity to unlock cohort targeting and attach responses to user profiles.
|
|
157
|
-
|
|
158
|
-
### `client.identify(userId, traits?)` or `client.identify(traits)`
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
import { client } from "./client";
|
|
162
|
-
|
|
163
|
-
client.identify(user.id, {
|
|
164
|
-
email: user.email,
|
|
165
|
-
firstName: user.firstName,
|
|
166
|
-
lastName: user.lastName,
|
|
167
|
-
});
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Pass a stable `userId` when you have one. If you don't, use traits-only mode:
|
|
171
|
-
|
|
172
|
-
```ts
|
|
173
|
-
import { client } from "./client";
|
|
174
|
-
|
|
175
|
-
client.identify({
|
|
176
|
-
email: user.email,
|
|
177
|
-
plan: user.plan,
|
|
178
|
-
});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### `client.reset()`
|
|
182
|
-
|
|
183
|
-
Call this on logout to clear active identity state and auth (if you use auth):
|
|
184
|
-
|
|
185
|
-
```ts
|
|
186
|
-
import { auth } from "./auth";
|
|
187
|
-
import { client } from "./client";
|
|
188
|
-
|
|
189
|
-
const logoutButton = document.querySelector<HTMLButtonElement>("#logout-button");
|
|
14
|
+
Install the SDK:
|
|
190
15
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
await client.reset();
|
|
194
|
-
});
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Dark mode
|
|
198
|
-
|
|
199
|
-
If you're using industry-standard ways to indicate when dark mode is *on*, the widget will pick it up and automatically keep itself in sync. If you only have light mode, the widget will stay in light mode.
|
|
200
|
-
|
|
201
|
-
Default behavior:
|
|
202
|
-
- The widget observes `class` and `data-theme` attributes on both `html` and `body`.
|
|
203
|
-
- `class="dark"` / `data-theme="dark"` enables dark mode.
|
|
204
|
-
- `class="light"` / `data-theme="light"` enables light mode.
|
|
205
|
-
- `class="system"` / `data-theme="system"` follows the user's system preference (`prefers-color-scheme`).
|
|
206
|
-
- If nothing is detected, it falls back to `"light"`.
|
|
207
|
-
|
|
208
|
-
You can control the behavior using the `colorScheme` option when creating a client, and you can also update it later.
|
|
209
|
-
|
|
210
|
-
### Set a static color scheme at startup
|
|
211
|
-
|
|
212
|
-
```ts
|
|
213
|
-
import { createClient } from "@getuserfeedback/sdk";
|
|
214
|
-
|
|
215
|
-
export const client = createClient({
|
|
216
|
-
apiKey: "YOUR_API_KEY",
|
|
217
|
-
colorScheme: "dark", // set to a static value
|
|
218
|
-
});
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
`colorScheme` supports:
|
|
222
|
-
- `{ autoDetectColorScheme: string[] }`
|
|
223
|
-
- `"light" | "dark" | "system"`
|
|
224
|
-
### Update color scheme at runtime
|
|
225
|
-
|
|
226
|
-
```ts
|
|
227
|
-
type ThemePreference = "light" | "dark" | "system";
|
|
228
|
-
|
|
229
|
-
function onThemePreferenceChanged(themePreference: ThemePreference) {
|
|
230
|
-
client.configure({
|
|
231
|
-
colorScheme: themePreference,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
You can also switch runtime behavior back to host-driven auto-detection:
|
|
237
|
-
|
|
238
|
-
```ts
|
|
239
|
-
function onUseAppThemeChanged(useAppTheme: boolean) {
|
|
240
|
-
if (!useAppTheme) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
client.configure({
|
|
245
|
-
colorScheme: {
|
|
246
|
-
autoDetectColorScheme: ["class", "data-theme"] // default
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
## Auth (optional)
|
|
253
|
-
|
|
254
|
-
You can run the SDK without auth. This is standard industry practice for client-side widgets like ours, so it is not enforced by default. However, we encourage you to implement auth for stricter controls.
|
|
255
|
-
|
|
256
|
-
Enable identity verification in Widget settings and pass a signed token from
|
|
257
|
-
your app. Each token must use the asymmetric signing algorithm selected in
|
|
258
|
-
Widget settings, set the protected `typ` header to `gx-widget+jwt`, and use the
|
|
259
|
-
Audience shown there as its `aud` claim. It must also include a future `exp`
|
|
260
|
-
expiration timestamp. See the
|
|
261
|
-
[identity verification guide](https://getuserfeedback.com/docs/security-and-privacy/jwt-auth)
|
|
262
|
-
for the full issuer, JWKS, claim, and rollout contract.
|
|
263
|
-
|
|
264
|
-
### Example: set, refresh, and clear auth token
|
|
265
|
-
|
|
266
|
-
```ts
|
|
267
|
-
type AuthAdapter = {
|
|
268
|
-
isSignedIn: () => boolean;
|
|
269
|
-
getToken: () => Promise<string | null>;
|
|
270
|
-
onSessionChanged: (callback: () => void) => () => void;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
declare const auth: AuthAdapter;
|
|
274
|
-
|
|
275
|
-
const AUTH_REFRESH_INTERVAL_MS = 5 * 60 * 1000;
|
|
276
|
-
|
|
277
|
-
async function syncAuthToken() {
|
|
278
|
-
if (!auth.isSignedIn()) {
|
|
279
|
-
await client.configure({ auth: { jwt: null } });
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const token = await auth.getToken();
|
|
284
|
-
if (!token) {
|
|
285
|
-
await client.configure({ auth: { jwt: null } });
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
await client.configure({ auth: { jwt: { token } } });
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
syncAuthToken();
|
|
293
|
-
const unsubscribeSessionChanged = auth.onSessionChanged(() => {
|
|
294
|
-
syncAuthToken();
|
|
295
|
-
});
|
|
296
|
-
const refreshTimer = window.setInterval(syncAuthToken, AUTH_REFRESH_INTERVAL_MS);
|
|
297
|
-
|
|
298
|
-
window.addEventListener("beforeunload", () => {
|
|
299
|
-
unsubscribeSessionChanged();
|
|
300
|
-
window.clearInterval(refreshTimer);
|
|
301
|
-
});
|
|
16
|
+
```bash
|
|
17
|
+
npm install @getuserfeedback/sdk
|
|
302
18
|
```
|
|
303
19
|
|
|
304
|
-
|
|
20
|
+
Create one client with the Public API key from
|
|
21
|
+
[Widget settings](https://getuserfeedback.com/app/_/settings/widget):
|
|
305
22
|
|
|
306
|
-
Consent settings control non-essential data scopes: analytics, storage, personalization, ads.
|
|
307
|
-
|
|
308
|
-
By default, the widget starts with `granted` consent. For compliance with privacy regulations like GDPR and CCPA, you may want to choose a different default.
|
|
309
|
-
|
|
310
|
-
### Set default consent to `pending`
|
|
311
23
|
```ts
|
|
312
24
|
import { createClient } from "@getuserfeedback/sdk";
|
|
313
25
|
|
|
314
26
|
export const client = createClient({
|
|
315
|
-
|
|
316
|
-
defaultConsent: "pending", // set to `pending`
|
|
317
|
-
});
|
|
318
|
-
```
|
|
319
|
-
With `pending` consent set by default, all non-essential data scopes are considered effectively denied.
|
|
320
|
-
|
|
321
|
-
### Update consent at runtime
|
|
322
|
-
|
|
323
|
-
For example, sync consent from your cookie banner or CMP state:
|
|
324
|
-
|
|
325
|
-
```ts
|
|
326
|
-
function syncConsent(state: CookieConsentState) {
|
|
327
|
-
if (!state.hasAnswered) {
|
|
328
|
-
client.configure({ consent: "pending" });
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (!state.analyticsEnabled) {
|
|
333
|
-
client.configure({ consent: "denied" });
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
client.configure({
|
|
338
|
-
consent: ["analytics.measurement", "analytics.storage"],
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
window.addEventListener("cookie-consent-changed", (event) => {
|
|
343
|
-
syncConsent(event.detail);
|
|
344
|
-
});
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
Or, when users save privacy settings, pass explicit granted scopes:
|
|
348
|
-
|
|
349
|
-
```ts
|
|
350
|
-
type PrivacySettings = {
|
|
351
|
-
analyticsEnabled: boolean;
|
|
352
|
-
personalizedAdsEnabled: boolean;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
type GrantScope =
|
|
356
|
-
| "analytics.measurement"
|
|
357
|
-
| "analytics.storage"
|
|
358
|
-
| "ads.storage"
|
|
359
|
-
| "ads.user_data"
|
|
360
|
-
| "ads.personalization";
|
|
361
|
-
|
|
362
|
-
async function savePrivacySettings(settings: PrivacySettings) {
|
|
363
|
-
const grantedScopes: GrantScope[] = [];
|
|
364
|
-
|
|
365
|
-
if (settings.analyticsEnabled) {
|
|
366
|
-
grantedScopes.push("analytics.measurement", "analytics.storage");
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (settings.personalizedAdsEnabled) {
|
|
370
|
-
grantedScopes.push(
|
|
371
|
-
"ads.storage",
|
|
372
|
-
"ads.user_data",
|
|
373
|
-
"ads.personalization",
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
await client.configure({
|
|
378
|
-
consent: grantedScopes.length > 0 ? grantedScopes : "denied",
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
```
|
|
383
|
-
`defaultConsent` supports:
|
|
384
|
-
- `"pending" | "granted" (default) | "denied" | "revoked"`
|
|
385
|
-
- or a granted-scope list like `["analytics.measurement", "analytics.storage"]`
|
|
386
|
-
|
|
387
|
-
### Impact of different consent settings
|
|
388
|
-
|
|
389
|
-
- Response collection: never affected.
|
|
390
|
-
- On-demand flow display: never affected.
|
|
391
|
-
- Cohort targeting: rules that depend on persisted activity, identity continuity, or storage-backed signals require both `analytics.measurement` and `analytics.storage`.
|
|
392
|
-
- Context targeting: rules based on current-page context (URL, referrer, timing, host signals) require `analytics.measurement` only.
|
|
393
|
-
|
|
394
|
-
## Advanced — open flows on demand
|
|
395
|
-
|
|
396
|
-
### Open a flow
|
|
397
|
-
|
|
398
|
-
```ts
|
|
399
|
-
const BUG_REPORT_FLOW_ID = "YOUR_FLOW_ID";
|
|
400
|
-
const reportBugButton = document.querySelector<HTMLButtonElement>("#report-bug-button");
|
|
401
|
-
|
|
402
|
-
reportBugButton?.addEventListener("click", () => {
|
|
403
|
-
client.open(BUG_REPORT_FLOW_ID);
|
|
404
|
-
});
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
### Prefetch and prerender
|
|
408
|
-
|
|
409
|
-
Prefetching loads flow resources over the network. Prerendering warms up the UI
|
|
410
|
-
before opening. Opening still handles the render step if you have not prerendered
|
|
411
|
-
first.
|
|
412
|
-
|
|
413
|
-
```ts
|
|
414
|
-
const FEEDBACK_FLOW_ID = "YOUR_FLOW_ID";
|
|
415
|
-
const helpMenuFeedbackItem = document.querySelector<HTMLButtonElement>("#help-menu-feedback");
|
|
416
|
-
|
|
417
|
-
helpMenuFeedbackItem?.addEventListener("mouseenter", () => {
|
|
418
|
-
client.prefetch(FEEDBACK_FLOW_ID);
|
|
419
|
-
client.prerender(FEEDBACK_FLOW_ID);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
helpMenuFeedbackItem?.addEventListener("focus", () => {
|
|
423
|
-
client.prerender(FEEDBACK_FLOW_ID);
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
helpMenuFeedbackItem?.addEventListener("click", () => {
|
|
427
|
-
client.open(FEEDBACK_FLOW_ID);
|
|
27
|
+
apiKey: "YOUR_API_KEY",
|
|
428
28
|
});
|
|
429
29
|
```
|
|
430
30
|
|
|
431
|
-
|
|
31
|
+
That is enough to receive flows published for automatic Widget delivery.
|
|
432
32
|
|
|
433
|
-
-
|
|
434
|
-
-
|
|
435
|
-
-
|
|
33
|
+
- [JavaScript SDK guide](https://getuserfeedback.com/docs/get-started/javascript-sdk)
|
|
34
|
+
- [JavaScript SDK reference](https://getuserfeedback.com/docs/reference/javascript-sdk-reference)
|
|
35
|
+
- [Package versions](https://www.npmjs.com/package/@getuserfeedback/sdk?activeTab=versions)
|
|
36
|
+
- [Support](mailto:hello@getuserfeedback.com)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AppEventJsonValue, ListInstanceFeedbackMineRequest, ListInstanceFeedbackMineResponse, CaptureInstanceFeedbackRequest, CaptureInstanceFeedbackResponse } from '@getuserfeedback/protocol';
|
|
2
2
|
export { PublicCommandPayload } from '@getuserfeedback/protocol';
|
|
3
3
|
import { TrackOptions, OpenRequestedDetail, ContainerPolicy, FlowRenderState, WidgetLayoutTransitionPolicy, ResponseMetadataInput, ConfigureOptions, IdentifyOptions, ClientOptions } from '@getuserfeedback/protocol/host';
|
|
4
|
-
export { ActionRegistration, AppEventCapability, AppEventFlag, AppEventFlagProvider, AppEventFlagValue, CapabilitiesInput, ClientOptions, ConfigureOptions, ContainerPolicy, FlagsInput, HostActionDefinition, InitOptions, TrackOptions } from '@getuserfeedback/protocol/host';
|
|
4
|
+
export { ActionRegistration, ActionsConfig, AppEventCapability, AppEventFlag, AppEventFlagProvider, AppEventFlagValue, CapabilitiesInput, ClientOptions, ConfigureOptions, ContainerPolicy, FlagsInput, HostActionDefinition, InitOptions, LinkRequest, LinkRouter, LinksConfig, TrackOptions } from '@getuserfeedback/protocol/host';
|
|
5
5
|
|
|
6
6
|
type EventProperties = Record<string, AppEventJsonValue>;
|
|
7
7
|
type EventOptions = TrackOptions;
|
|
@@ -134,11 +134,17 @@ type Client = {
|
|
|
134
134
|
flow: (flowId: string) => FlowRun;
|
|
135
135
|
/** Close all open flows. */
|
|
136
136
|
close: () => Promise<void>;
|
|
137
|
-
/**
|
|
137
|
+
/** Close all open flows, clear JWT authentication, and reset user identity. */
|
|
138
138
|
reset: () => Promise<void>;
|
|
139
139
|
/**
|
|
140
140
|
* Update color scheme, consent, or auth. Pass a fresh JWT here after login
|
|
141
|
-
* and whenever your auth provider refreshes the session token.
|
|
141
|
+
* and whenever your auth provider refreshes the session token. Await the
|
|
142
|
+
* returned promise or handle its rejection when applying runtime updates.
|
|
143
|
+
*
|
|
144
|
+
* When using `disableAutoLoad`, call `load()` first. Calls made before `load()`
|
|
145
|
+
* resolve without applying the update. Provide the initial color scheme,
|
|
146
|
+
* default consent, and capabilities to `createClient()`; configure auth after
|
|
147
|
+
* `load()`.
|
|
142
148
|
*
|
|
143
149
|
* @see https://getuserfeedback.com/docs/security-and-privacy/jwt-auth
|
|
144
150
|
*/
|
|
@@ -150,7 +156,8 @@ type Client = {
|
|
|
150
156
|
* system. Without a user ID, pass options as `client.identify(traits, options)`,
|
|
151
157
|
* or use `client.identify(traits, undefined, options)` when your call site needs
|
|
152
158
|
* the explicit three-argument form. Do not put Segment-shaped `externalIds` in
|
|
153
|
-
* traits.
|
|
159
|
+
* traits. Some invalid arguments throw synchronously; other validation or
|
|
160
|
+
* command-processing failures reject the returned promise.
|
|
154
161
|
*
|
|
155
162
|
* @see https://getuserfeedback.com/docs/guides/identity-resolution
|
|
156
163
|
*/
|
|
@@ -164,12 +171,17 @@ type Client = {
|
|
|
164
171
|
*
|
|
165
172
|
* Use `options.externalIds` when the event carries a Segment-compatible
|
|
166
173
|
* identifier from another system. Do not put Segment-shaped `externalIds` in
|
|
167
|
-
* properties.
|
|
174
|
+
* properties. Some invalid arguments throw synchronously; other validation or
|
|
175
|
+
* command-processing failures reject the returned promise.
|
|
168
176
|
*
|
|
169
177
|
* @see https://getuserfeedback.com/docs/reference/events
|
|
170
178
|
*/
|
|
171
179
|
track: (eventName: string, properties?: EventProperties, options?: EventOptions) => Promise<void>;
|
|
172
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* Record the current browser page or a named page location. Some invalid
|
|
182
|
+
* arguments throw synchronously; other validation or command-processing
|
|
183
|
+
* failures reject the returned promise.
|
|
184
|
+
*/
|
|
173
185
|
page: (name?: string, properties?: EventProperties, options?: EventOptions) => Promise<void>;
|
|
174
186
|
/** Record directed relationship observations through the analytics pipeline. */
|
|
175
187
|
graph: GraphOperations;
|
|
@@ -180,7 +192,7 @@ type Client = {
|
|
|
180
192
|
* Prevention applies only to that presentation attempt; it does not create a
|
|
181
193
|
* public retry schedule.
|
|
182
194
|
*
|
|
183
|
-
* @example —
|
|
195
|
+
* @example — suppress open flow requests if the user is busy
|
|
184
196
|
* ```ts
|
|
185
197
|
* client.onOpenRequested((event) => {
|
|
186
198
|
* if (userIsBusy()) {
|