@sidebandai/sideband-core 1.4.3 → 1.4.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/README.md
CHANGED
|
@@ -35,3 +35,77 @@ sideband.start()
|
|
|
35
35
|
|
|
36
36
|
Replace `1.0.0` with your application's version, not the SDK version.
|
|
37
37
|
`appVersion` must be a non-empty string of at most 64 characters.
|
|
38
|
+
|
|
39
|
+
## Identify users
|
|
40
|
+
|
|
41
|
+
Tag the signed-in user wherever your app knows who they are: after sign-up and
|
|
42
|
+
sign-in, and when your app restores a signed-in session. Clear the identity at
|
|
43
|
+
sign-out.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
sideband.tagUser('user-123') // sign-up, sign-in, restored session
|
|
47
|
+
sideband.untagUser() // sign-out
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Pass your own stable user ID, not an email address or name. A user ID can have at most 256 characters (Unicode code points). A longer ID is
|
|
51
|
+
rejected without changing the current identity, and `onError` receives the reason. The runtime
|
|
52
|
+
keeps the ID in the browser's localStorage and restores it on the next page
|
|
53
|
+
load.
|
|
54
|
+
|
|
55
|
+
## Track events
|
|
56
|
+
|
|
57
|
+
Call `track` once per user action, after the action succeeds:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
sideband.track('invoice_sent', { source: 'invoice_list', item_type: 'invoice', count: '3' })
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Pass metadata as string key-value pairs. Use metadata to describe an event
|
|
64
|
+
without creating a separate event name for each source, item type, or mode.
|
|
65
|
+
Only these six keys support Pulse trigger filters and event-history conditions:
|
|
66
|
+
|
|
67
|
+
| Key | Value format | Example |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| `source` | String | `'home'` |
|
|
70
|
+
| `item_type` | String | `'article'` |
|
|
71
|
+
| `mode` | String | `'manual'` |
|
|
72
|
+
| `variant` | String | `'control'` |
|
|
73
|
+
| `count` | Integer sent as a string | `'3'` |
|
|
74
|
+
| `duration` | Seconds sent as a string; fractions allowed | `'12.5'` |
|
|
75
|
+
|
|
76
|
+
Use the exact lowercase key names. The server trims and lowercases values for
|
|
77
|
+
`source`, `item_type`, `mode`, and `variant`, and compares them with equals and
|
|
78
|
+
not-equals. It compares `count` and `duration` numerically. Send `duration` in
|
|
79
|
+
seconds, not milliseconds. `count: '3.5'` and `count: '3.0'` are invalid; use
|
|
80
|
+
`count: '3'`.
|
|
81
|
+
|
|
82
|
+
Custom keys such as `content_id`, `screen`, or `plan` are stored unchanged, but
|
|
83
|
+
cannot be used in Pulse targeting. A missing key does not match any filter,
|
|
84
|
+
including not-equals. The server stores at most 20 metadata properties per
|
|
85
|
+
event: valid targeting keys first, then custom keys in sorted key order. It
|
|
86
|
+
drops empty keys and invalid targeting values without rejecting the event.
|
|
87
|
+
|
|
88
|
+
When the page is hidden or unloads, the SDK tries to send queued events with
|
|
89
|
+
`keepalive`. This is best effort: a send already in progress can delay it. For an
|
|
90
|
+
event tracked just before your code navigates away, await `sideband.flush()` first.
|
|
91
|
+
|
|
92
|
+
The SDK sends events in batches, by default about once a second. Set
|
|
93
|
+
`flushIntervalSeconds` in `createSidebandRuntime` (seconds, at least 1) to change it. A pulse can show only
|
|
94
|
+
after the batch that holds its trigger event is sent, so a longer interval delays
|
|
95
|
+
pulses. The server can also ask the SDK to wait before its next send.
|
|
96
|
+
|
|
97
|
+
## Events the SDK sends itself
|
|
98
|
+
|
|
99
|
+
Do not track these yourself:
|
|
100
|
+
|
|
101
|
+
| Event | When |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| `system_app_launch` | The SDK starts (`start()`), usually once per page load. |
|
|
104
|
+
| `system_app_background` | The page is hidden or unloaded: another tab, a minimized window, navigation away. |
|
|
105
|
+
| `system_app_foreground` | The page is visible again after `system_app_background`. |
|
|
106
|
+
| `system_login` | `tagUser` sets a new user ID. `metadata.user_id` is the new ID. |
|
|
107
|
+
| `system_logout` | `untagUser` clears the user ID, or `tagUser` replaces it. `metadata.user_id` is the previous ID. |
|
|
108
|
+
|
|
109
|
+
Switching from user A to user B sends `system_logout` for A, then `system_login`
|
|
110
|
+
for B, with the same timestamp. Repeating the same ID, clearing an ID that is
|
|
111
|
+
not set, and restoring the stored ID on a page load send nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-sideband-runtime.d.ts","sourceRoot":"","sources":["../../src/core/create-sideband-runtime.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAIV,eAAe,EACf,qBAAqB,EAItB,MAAM,UAAU,CAAA;AAEjB,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"create-sideband-runtime.d.ts","sourceRoot":"","sources":["../../src/core/create-sideband-runtime.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAIV,eAAe,EACf,qBAAqB,EAItB,MAAM,UAAU,CAAA;AAEjB,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,CA6EpF"}
|
|
@@ -2,4 +2,7 @@ import type { EventMetadata } from '../types';
|
|
|
2
2
|
export declare function validateApiKey(apiKey: string): void;
|
|
3
3
|
export declare function validateAppVersion(appVersion: string, field?: string): void;
|
|
4
4
|
export declare function validateEvent(eventName: string, metadata?: EventMetadata): void;
|
|
5
|
+
export declare const MAX_TAGGED_USER_ID_LENGTH = 256;
|
|
6
|
+
export declare function taggedUserIdLength(userId: string): number;
|
|
7
|
+
export declare function isTaggedUserIdTooLong(userId: string): boolean;
|
|
5
8
|
//# sourceMappingURL=validate-input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-input.d.ts","sourceRoot":"","sources":["../../src/core/validate-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,QAI5C;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,SAAkC,QAI7F;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,QAaxE"}
|
|
1
|
+
{"version":3,"file":"validate-input.d.ts","sourceRoot":"","sources":["../../src/core/validate-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,QAI5C;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,SAAkC,QAI7F;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,QAaxE;AAED,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAI5C,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,UAEhD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,WAEnD"}
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ function d() {
|
|
|
52
52
|
r("local")?.removeItem(e);
|
|
53
53
|
} catch {}
|
|
54
54
|
}
|
|
55
|
-
function ee(e, t = "1.4.
|
|
55
|
+
function ee(e, t = "1.4.4") {
|
|
56
56
|
let n = {
|
|
57
57
|
device_id: s(),
|
|
58
58
|
platform: "web",
|
|
@@ -81,43 +81,49 @@ function f(e, t, n) {
|
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
83
|
//#region src/core/validate-input.ts
|
|
84
|
-
function
|
|
84
|
+
function p(e) {
|
|
85
85
|
if (typeof e != "string" || !e.trim()) throw TypeError("Sideband.configure apiKey must be a non-empty string.");
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function m(e, t = "Sideband.configure appVersion") {
|
|
88
88
|
if (typeof e != "string" || !e.trim() || Array.from(e).length > 64) throw TypeError(`${t} must be a non-empty string of at most 64 characters.`);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function h(e, t) {
|
|
91
91
|
if (typeof e != "string" || !e.length) throw TypeError("Sideband.track eventName must be a non-empty string.");
|
|
92
92
|
if (t !== void 0) {
|
|
93
93
|
if (typeof t != "object" || !t || Array.isArray(t)) throw TypeError("Sideband.track metadata must be a string-to-string map.");
|
|
94
94
|
for (let [e, n] of Object.entries(t)) if (typeof n != "string") throw TypeError(`Sideband.track metadata value for "${e}" must be a string.`);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
function ne(e) {
|
|
98
|
+
return Array.from(e).length;
|
|
99
|
+
}
|
|
100
|
+
function g(e) {
|
|
101
|
+
return ne(e) > 256;
|
|
102
|
+
}
|
|
97
103
|
//#endregion
|
|
98
104
|
//#region src/core/sync-attempt.ts
|
|
99
|
-
var
|
|
100
|
-
function
|
|
105
|
+
var _ = Symbol("sideband.syncAttemptMetadata"), v = /* @__PURE__ */ new WeakSet();
|
|
106
|
+
function y(e, t) {
|
|
101
107
|
let n = { ...e };
|
|
102
|
-
return n[
|
|
108
|
+
return n[_] = t, n;
|
|
103
109
|
}
|
|
104
|
-
function
|
|
105
|
-
return e?.[
|
|
110
|
+
function b(e) {
|
|
111
|
+
return e?.[_];
|
|
106
112
|
}
|
|
107
|
-
function
|
|
108
|
-
(typeof e == "object" && e || typeof e == "function") &&
|
|
113
|
+
function x(e) {
|
|
114
|
+
(typeof e == "object" && e || typeof e == "function") && v.add(e);
|
|
109
115
|
}
|
|
110
|
-
function
|
|
111
|
-
return (typeof e == "object" && !!e || typeof e == "function") &&
|
|
116
|
+
function S(e) {
|
|
117
|
+
return (typeof e == "object" && !!e || typeof e == "function") && v.has(e);
|
|
112
118
|
}
|
|
113
119
|
//#endregion
|
|
114
120
|
//#region src/client/create-sideband-client.ts
|
|
115
|
-
var
|
|
121
|
+
var C = "/v1/sync", w = {
|
|
116
122
|
local: "https://api.pancake-betelgeuse.ts.net",
|
|
117
123
|
dev: "https://api.dev-sideband.ai",
|
|
118
124
|
prod: "https://api.sideband.ai"
|
|
119
125
|
};
|
|
120
|
-
function
|
|
126
|
+
function re(e) {
|
|
121
127
|
if (e) return e;
|
|
122
128
|
if (typeof fetch != "function") throw Error("Sideband requires a fetch implementation.");
|
|
123
129
|
return fetch;
|
|
@@ -130,7 +136,7 @@ async function ae(e) {
|
|
|
130
136
|
return new Headers(t);
|
|
131
137
|
}
|
|
132
138
|
function oe(e) {
|
|
133
|
-
return new URL(
|
|
139
|
+
return new URL(C, e).toString();
|
|
134
140
|
}
|
|
135
141
|
async function se(e) {
|
|
136
142
|
let t = await e.text();
|
|
@@ -152,7 +158,7 @@ function le(e) {
|
|
|
152
158
|
let r = Date.parse(t);
|
|
153
159
|
if (!Number.isNaN(r)) return Math.max((r - Date.now()) / 1e3, 0);
|
|
154
160
|
}
|
|
155
|
-
var
|
|
161
|
+
var T = class extends Error {
|
|
156
162
|
status;
|
|
157
163
|
body;
|
|
158
164
|
retryAfterSeconds;
|
|
@@ -160,14 +166,14 @@ var C = class extends Error {
|
|
|
160
166
|
super(e), this.name = "SidebandApiError", this.status = t, this.body = n, this.retryAfterSeconds = r;
|
|
161
167
|
}
|
|
162
168
|
};
|
|
163
|
-
function
|
|
164
|
-
if (
|
|
169
|
+
function E(e) {
|
|
170
|
+
if (p(e.apiKey), e.syncEndpoint !== void 0 && !Object.hasOwn(w, e.syncEndpoint)) throw TypeError("Sideband.configure syncEndpoint must be local, dev, or prod.");
|
|
165
171
|
async function t(t, n) {
|
|
166
|
-
let r =
|
|
167
|
-
|
|
168
|
-
let a = await ae(e.headers), o =
|
|
172
|
+
let r = re(e.fetch), i = t.context ?? await ie(e.context);
|
|
173
|
+
m(i.app_version, "Sideband context.app_version");
|
|
174
|
+
let a = await ae(e.headers), o = b(n);
|
|
169
175
|
a.set("content-type", "application/json"), a.set("x-bc-api-key", e.apiKey), a.set("x-bc-sync-attempt", String(o?.attempt ?? 1)), o?.retryReason ? a.set("x-bc-sync-retry-reason", o.retryReason) : a.delete("x-bc-sync-retry-reason");
|
|
170
|
-
let s = oe(e.baseUrl ??
|
|
176
|
+
let s = oe(e.baseUrl ?? w[e.syncEndpoint ?? "prod"]), c = {
|
|
171
177
|
method: "POST",
|
|
172
178
|
headers: a,
|
|
173
179
|
body: JSON.stringify({
|
|
@@ -180,14 +186,14 @@ function w(e) {
|
|
|
180
186
|
try {
|
|
181
187
|
l = await r(s, c);
|
|
182
188
|
} catch (e) {
|
|
183
|
-
throw
|
|
189
|
+
throw x(e), e;
|
|
184
190
|
}
|
|
185
191
|
let u = await se(l);
|
|
186
|
-
if (!l.ok) throw new
|
|
192
|
+
if (!l.ok) throw new T(ce(u, "Sideband sync request failed."), l.status, u, le(l));
|
|
187
193
|
return u;
|
|
188
194
|
}
|
|
189
195
|
async function r(e, r, i) {
|
|
190
|
-
return
|
|
196
|
+
return h(e, r), t({ events: [{
|
|
191
197
|
event_id: n(),
|
|
192
198
|
event_name: e,
|
|
193
199
|
metadata: r,
|
|
@@ -201,22 +207,22 @@ function w(e) {
|
|
|
201
207
|
}
|
|
202
208
|
//#endregion
|
|
203
209
|
//#region src/core/sync-engine.ts
|
|
204
|
-
var
|
|
205
|
-
function
|
|
210
|
+
var D = 20, O = 50, k = 1, A = 15, j = 1e3, M = 300 * 1e3, N = 2147483647;
|
|
211
|
+
function P(e, t, n) {
|
|
206
212
|
return Math.min(Math.max(e, t), n);
|
|
207
213
|
}
|
|
208
|
-
function
|
|
214
|
+
function F(e) {
|
|
209
215
|
let t = e?.status;
|
|
210
216
|
return typeof t != "number" || t === 408 || t === 425 || t === 429 || t >= 500;
|
|
211
217
|
}
|
|
212
|
-
function
|
|
218
|
+
function I(e) {
|
|
213
219
|
let t = e?.retryAfterSeconds;
|
|
214
220
|
return typeof t == "number" && Number.isFinite(t) ? Math.max(t, 0) * 1e3 : void 0;
|
|
215
221
|
}
|
|
216
|
-
function
|
|
217
|
-
return e?.status === 503 &&
|
|
222
|
+
function L(e) {
|
|
223
|
+
return e?.status === 503 && I(e) !== void 0 ? "server_retry" : S(e) ? "network" : "server_error";
|
|
218
224
|
}
|
|
219
|
-
var
|
|
225
|
+
var R = class {
|
|
220
226
|
deps;
|
|
221
227
|
maxBatchSize;
|
|
222
228
|
flushIntervalMs;
|
|
@@ -251,7 +257,7 @@ var I = class {
|
|
|
251
257
|
syncAttempts = 0;
|
|
252
258
|
detachLifecycle = null;
|
|
253
259
|
constructor(e, t = {}) {
|
|
254
|
-
this.deps = e, this.maxBatchSize =
|
|
260
|
+
this.deps = e, this.maxBatchSize = P(t.maxBatchSize ?? D, 1, O), this.flushIntervalMs = Math.max(t.flushIntervalSeconds ?? k, 1) * 1e3, this.retryIntervalMs = Math.max(t.retryIntervalSeconds ?? A, 1) * 1e3, this.maxQueuedEvents = Math.max(t.maxQueuedEvents ?? j, this.maxBatchSize);
|
|
255
261
|
}
|
|
256
262
|
start() {
|
|
257
263
|
this.started || this.destroyed || (this.started = !0, this.attachLifecycle(), this.track("system_app_launch"));
|
|
@@ -270,7 +276,7 @@ var I = class {
|
|
|
270
276
|
};
|
|
271
277
|
}
|
|
272
278
|
track(e, t, n) {
|
|
273
|
-
if (
|
|
279
|
+
if (h(e, t), this.destroyed) return;
|
|
274
280
|
let r = Date.now();
|
|
275
281
|
if (this.enqueueEvent(e, t, n?.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(), r), this.enforceQueueLimit(), e === "system_did_present_pulse") {
|
|
276
282
|
this.requestUrgent();
|
|
@@ -388,7 +394,7 @@ var I = class {
|
|
|
388
394
|
...e.context ? { context: e.context } : {},
|
|
389
395
|
...e.events.length ? { events: e.events.map((e) => e.record) } : {},
|
|
390
396
|
...e.interaction ? { interaction: e.interaction } : {}
|
|
391
|
-
},
|
|
397
|
+
}, y({
|
|
392
398
|
signal: t,
|
|
393
399
|
...e.trigger === "forced-lifecycle" ? { keepalive: !0 } : {}
|
|
394
400
|
}, {
|
|
@@ -426,12 +432,12 @@ var I = class {
|
|
|
426
432
|
this.hasWork() && !this.manualFlushPromise && this.requestRegular();
|
|
427
433
|
}
|
|
428
434
|
handleFailure(e, t) {
|
|
429
|
-
if (this.lastAttemptAccepted = !1, !
|
|
435
|
+
if (this.lastAttemptAccepted = !1, !F(e)) {
|
|
430
436
|
this.retrySnapshot = null, this.automaticRetrySuspended = !0, this.regularDueAt = null, this.reportError(e);
|
|
431
437
|
return;
|
|
432
438
|
}
|
|
433
|
-
this.failureStreak += 1, t.attempt = Math.min(t.attempt + 1, 1e3), t.retryReason =
|
|
434
|
-
let n =
|
|
439
|
+
this.failureStreak += 1, t.attempt = Math.min(t.attempt + 1, 1e3), t.retryReason = L(e), this.retrySnapshot = t;
|
|
440
|
+
let n = I(e), r = Math.min(this.retryIntervalMs * 2 ** (this.failureStreak - 1), M) * (.5 + Math.random() * .5), i = Math.max(r, n ?? 0);
|
|
435
441
|
this.retryUntil = Date.now() + i, this.regularDueAt = this.retryUntil, t.trigger !== "regular" && (this.pendingForcedRetry = t.trigger), this.failureStreak === 1 && this.reportError(e);
|
|
436
442
|
}
|
|
437
443
|
clearRetryState() {
|
|
@@ -492,7 +498,7 @@ var I = class {
|
|
|
492
498
|
}
|
|
493
499
|
this.pendingForcedRetry = null, this.beginAttempt(t);
|
|
494
500
|
}
|
|
495
|
-
}, Math.min(Math.max(e - Date.now(), 0),
|
|
501
|
+
}, Math.min(Math.max(e - Date.now(), 0), N)));
|
|
496
502
|
}
|
|
497
503
|
clearTimer() {
|
|
498
504
|
this.timerId !== null && (clearTimeout(this.timerId), this.timerId = null), this.timerDueAt = null;
|
|
@@ -554,22 +560,22 @@ var I = class {
|
|
|
554
560
|
};
|
|
555
561
|
//#endregion
|
|
556
562
|
//#region src/core/create-sideband-runtime.ts
|
|
557
|
-
function
|
|
558
|
-
|
|
559
|
-
let t =
|
|
563
|
+
function z(e) {
|
|
564
|
+
m(e.appVersion);
|
|
565
|
+
let t = B(e.onError), n = f(e.appVersion, e.context, e.libraryVersion), r = async () => {
|
|
560
566
|
let e = await n();
|
|
561
567
|
return t === null ? e : {
|
|
562
568
|
...e,
|
|
563
569
|
user_id: t
|
|
564
570
|
};
|
|
565
|
-
}, i =
|
|
571
|
+
}, i = E({
|
|
566
572
|
baseUrl: e.baseUrl,
|
|
567
573
|
syncEndpoint: e.syncEndpoint,
|
|
568
574
|
apiKey: e.apiKey,
|
|
569
575
|
context: r,
|
|
570
576
|
headers: e.headers,
|
|
571
577
|
fetch: e.fetch
|
|
572
|
-
}), a = new
|
|
578
|
+
}), a = new R({
|
|
573
579
|
sendSync: (e, t) => i.sync(e, t),
|
|
574
580
|
resolveContext: r,
|
|
575
581
|
onSyncResponse: e.onSyncResponse,
|
|
@@ -580,9 +586,13 @@ function L(e) {
|
|
|
580
586
|
retryIntervalSeconds: e.retryIntervalSeconds,
|
|
581
587
|
maxQueuedEvents: e.maxQueuedEvents,
|
|
582
588
|
maxServerPacingSeconds: e.maxServerPacingSeconds
|
|
583
|
-
}), o = (
|
|
584
|
-
|
|
585
|
-
|
|
589
|
+
}), o = (n) => {
|
|
590
|
+
if (n !== null && g(n)) {
|
|
591
|
+
e.onError?.(/* @__PURE__ */ Error("Sideband.tagUser rejected a user ID longer than 256 characters."));
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
let r = (/* @__PURE__ */ new Date()).toISOString(), i = t;
|
|
595
|
+
t = n, n === null ? d() : u(n), a.tagUser(i, n, r);
|
|
586
596
|
};
|
|
587
597
|
return {
|
|
588
598
|
getDeliveryStatus: () => a.getDeliveryStatus(),
|
|
@@ -602,9 +612,13 @@ function L(e) {
|
|
|
602
612
|
destroy: () => a.destroy()
|
|
603
613
|
};
|
|
604
614
|
}
|
|
615
|
+
function B(e) {
|
|
616
|
+
let t = l();
|
|
617
|
+
return t === null || !g(t) ? t : (d(), e?.(/* @__PURE__ */ Error("Sideband cleared a stored user ID longer than 256 characters.")), null);
|
|
618
|
+
}
|
|
605
619
|
//#endregion
|
|
606
620
|
//#region src/core/snackbar-presentation.ts
|
|
607
|
-
function
|
|
621
|
+
function ue(e) {
|
|
608
622
|
if (!e || typeof e != "object") return !1;
|
|
609
623
|
let t = e;
|
|
610
624
|
return [
|
|
@@ -618,22 +632,22 @@ function R(e) {
|
|
|
618
632
|
return typeof r == "number" && Number.isFinite(r) && typeof i == "number" && Number.isFinite(i) && (e !== "offset" || Number.isInteger(r) && Number.isInteger(i));
|
|
619
633
|
});
|
|
620
634
|
}
|
|
621
|
-
function
|
|
635
|
+
function V(e, t) {
|
|
622
636
|
return {
|
|
623
637
|
imageUrl: e.imageUrl ?? t?.imageUrl,
|
|
624
|
-
placement:
|
|
638
|
+
placement: ue(e.placement) ? e.placement : t?.placement
|
|
625
639
|
};
|
|
626
640
|
}
|
|
627
641
|
//#endregion
|
|
628
642
|
//#region src/core/survey-session-store.ts
|
|
629
|
-
var
|
|
643
|
+
var H = {
|
|
630
644
|
destroyed: !1,
|
|
631
645
|
state: null
|
|
632
|
-
},
|
|
633
|
-
function
|
|
646
|
+
}, U = 0;
|
|
647
|
+
function de(e) {
|
|
634
648
|
return e.fab?.title ?? e.title;
|
|
635
649
|
}
|
|
636
|
-
function
|
|
650
|
+
function fe(e) {
|
|
637
651
|
return e.id;
|
|
638
652
|
}
|
|
639
653
|
function W(e) {
|
|
@@ -695,8 +709,8 @@ function $(e, t) {
|
|
|
695
709
|
}
|
|
696
710
|
return e.next_node_id ?? null;
|
|
697
711
|
}
|
|
698
|
-
var
|
|
699
|
-
snapshot =
|
|
712
|
+
var pe = class {
|
|
713
|
+
snapshot = H;
|
|
700
714
|
listeners = /* @__PURE__ */ new Set();
|
|
701
715
|
deps;
|
|
702
716
|
fabTimeoutId = null;
|
|
@@ -716,7 +730,7 @@ var ue = class {
|
|
|
716
730
|
return this.snapshot;
|
|
717
731
|
}
|
|
718
732
|
getServerSnapshot() {
|
|
719
|
-
return
|
|
733
|
+
return H;
|
|
720
734
|
}
|
|
721
735
|
subscribe(e) {
|
|
722
736
|
return this.destroyed ? () => {} : (this.listeners.add(e), () => this.listeners.delete(e));
|
|
@@ -804,7 +818,7 @@ var ue = class {
|
|
|
804
818
|
beginPulse(e, t, n) {
|
|
805
819
|
let r = K(e, e.root_node_id), i = q(e, e.root_node_id), a = e.sentimentPresentation === "toolbar", o = e.sentimentPresentation === void 0 ? r?.isSnackBar === !0 || r?.isSnackBar !== !1 && t === "snackbar" && !!e.fab : e.sentimentPresentation === "snackbar", s = (a || o) && r?.type === "yes_no" && r.answers?.length === 2 && !r.answers.some(J);
|
|
806
820
|
this.clearSurveyTransitionTimeouts(), this.publish({
|
|
807
|
-
presentationId: ++
|
|
821
|
+
presentationId: ++U,
|
|
808
822
|
sentimentPresentation: s ? a ? "bar" : "snackbar" : "sheet",
|
|
809
823
|
barPosition: "bottom",
|
|
810
824
|
barBehavior: "dismiss",
|
|
@@ -1262,4 +1276,4 @@ var ue = class {
|
|
|
1262
1276
|
}
|
|
1263
1277
|
};
|
|
1264
1278
|
//#endregion
|
|
1265
|
-
export {
|
|
1279
|
+
export { T as SidebandApiError, pe as SurveySessionStore, R as SyncEngine, de as buildFabTitle, f as createContextResolver, E as createSidebandClient, z as createSidebandRuntime, fe as getChoiceValue, s as getDeviceId, c as getSessionId, Y as isPositiveSentimentChoice, J as isSystemOtherChoice, V as resolveSnackbarPresentation };
|