@sidebandai/sideband-react 1.4.5-rc.1 → 1.4.5-rc.2

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
@@ -9,7 +9,8 @@ Sideband adds in-app Pulse prompts and event tracking to React apps.
9
9
  - Your application's version
10
10
 
11
11
  For React 18 apps, use [`@sidebandai/sideband-web`](https://www.npmjs.com/package/@sidebandai/sideband-web),
12
- which has no framework dependency.
12
+ which has no framework dependency. Its README has a server-rendered React 18
13
+ example that starts the SDK once per page load under StrictMode.
13
14
 
14
15
  ## Install
15
16
 
@@ -43,6 +44,61 @@ non-empty string of at most 64 characters.
43
44
  The provider presents available Pulses automatically. In server-rendered apps,
44
45
  place it within a client component.
45
46
 
47
+ ## Content Security Policy
48
+
49
+ If your site sends a Content Security Policy, allow the Sideband API origin in
50
+ `connect-src`. Without it, the browser blocks every send: no events arrive and
51
+ no pulses show.
52
+
53
+ | Endpoint | `connect-src` | `img-src` (pulse images) |
54
+ | --- | --- | --- |
55
+ | Production (default) | `https://api.sideband.ai` | `https://images.sideband.ai` |
56
+ | Development (`syncEndpoint: 'dev'`) | `https://api.dev-sideband.ai` | `https://images-dev.sideband.ai` |
57
+ | A custom `baseUrl` | That URL's origin, and the final origin if it redirects | That environment's image host |
58
+
59
+ If your policy restricts images, `img-src` must allow `data:` (the close
60
+ button's icon is a `data:` image in the stylesheet) and the image host above.
61
+
62
+ The React package does not inject a `<style>` element. When your bundler
63
+ extracts `style.css` into a stylesheet file, it does not need `'unsafe-inline'`
64
+ in `style-src`; your policy must allow that file (usually `'self'`). A bundler
65
+ that injects CSS as a `<style>` element, as some do in development, changes
66
+ this: that element then needs whatever your policy requires for inline styles.
67
+
68
+ A blocked send appears in the browser console as a Content Security Policy
69
+ error, and `onError` receives a network error. The React package was not run
70
+ under these policies; this section comes from its code.
71
+
72
+ ## Consent
73
+
74
+ Your app decides when Sideband runs. If Sideband needs consent on your site,
75
+ render `SidebandProvider` only after the user gives it, and remove it when the
76
+ user withdraws it; unmounting the provider stops the SDK. Which consent category
77
+ applies is your decision; this README does not give legal advice.
78
+
79
+ A user who declines sends no events and sees no pulses. `useSideband()` throws
80
+ outside `SidebandProvider`, so components that track events while the provider
81
+ may be absent should call your own wrapper, which does nothing without consent.
82
+ The SDK has no consent setting of its own.
83
+
84
+ ## Language
85
+
86
+ The SDK reports the browser's language (for example `de` from `de-AT`). The
87
+ server shows a pulse only when that language matches the pulse's base language
88
+ or one of its published translations. If nothing matches, the pulse is not
89
+ shown, even without a language rule in its targeting. There is no fallback
90
+ language today.
91
+
92
+ If your site has one UI language, you can report that language instead, so
93
+ pulses match the page rather than the browser:
94
+
95
+ ```tsx
96
+ <SidebandProvider config={{ apiKey: 'YOUR_API_KEY', appVersion: '1.0.0', context: { language: 'en' } }}>
97
+ ```
98
+
99
+ If your site is translated, pass the page's current language the same way. Test
100
+ with a browser set to a language that differs from your site's language.
101
+
46
102
  ## Identify users
47
103
 
48
104
  Tag the signed-in user wherever your app knows who they are: after sign-up and
@@ -108,6 +164,28 @@ When the page is hidden or unloads, the SDK tries to send queued events with
108
164
  `keepalive`. This is best effort: a send already in progress can delay it. For an
109
165
  event tracked just before your code navigates away, await `flush()` from `useSideband()` first.
110
166
 
167
+ A pulse answer is sent when the user presses the final button (for example
168
+ Done), or closes the pulse, which sends the answers given so far. As in the iOS
169
+ and Android SDKs, nothing is sent while the thank-you screen is showing, so
170
+ answers are kept across a page load only after Done or a close; leaving the page
171
+ on the thank-you screen loses them. If the user leaves the page before the
172
+ server accepts the answer, the SDK tries again after the next page load in the
173
+ same tab. This is best effort.
174
+ The SDK keeps pending answers in the tab's `sessionStorage`, separately for each
175
+ API key and endpoint, and sends each answer only while the same user is tagged
176
+ (or the same `context.user_id` is configured). An answer is still lost when:
177
+
178
+ - storage is unavailable or full (`onError` receives a
179
+ `PendingInteractionStorageError` with `reason` `storage_unavailable` or
180
+ `storage_write_failed`);
181
+ - more than 10 answers are pending: the oldest are not kept (`reason`
182
+ `queue_full`);
183
+ - it is still unsent 24 hours after it was given;
184
+ - the server rejects it permanently, with a 4xx response other than 408, 425 or
185
+ 429 (`onError` receives the error);
186
+ - the user closes the tab, or does not return to that tab with the same user
187
+ and configuration.
188
+
111
189
  ## Events the SDK sends itself
112
190
 
113
191
  Do not track these yourself:
@@ -134,6 +212,14 @@ pulses. After each send, the server sets a minimum wait before the next
134
212
  regular send, and the SDK honors it. A pulse therefore usually shows a few
135
213
  seconds after its trigger event, not exactly one second after it.
136
214
 
215
+ Ordinary event batches wait for that interval, so a trigger tracked soon after
216
+ a send waits for the rest of it, including after a client-side route change.
217
+ Some sends do not wait, and queued events go with them: a new pulse answer, a pulse
218
+ impression, the page being hidden, and an explicit `flush()`. On a quiet page, a
219
+ new page load sends `system_app_launch` about one second after the SDK starts,
220
+ with the default `flushIntervalSeconds`. Tagging the user right after start
221
+ sends it sooner.
222
+
137
223
  `SidebandProviderConfig` in the package's type definitions lists the optional
138
224
  settings, such as `shouldPresentPulse` to hold a Pulse back for a better
139
225
  moment and `onError` for background errors. `useSideband()` also returns
@@ -142,20 +228,27 @@ moment and `onError` for background errors. `useSideband()` also returns
142
228
  ## Automated test builds
143
229
 
144
230
  Builds that use your Development channel's key also receive the pulses you
145
- publish there. In unattended UI tests, a pulse can cover the page and break the
146
- next step. To keep sending events but hold pulses back in those builds, return
147
- `'notNow'` from `shouldPresentPulse`:
231
+ publish there. Treat two kinds of automated run differently.
232
+
233
+ **Event-only automation.** In unattended UI tests, a pulse can cover the page
234
+ and break the next step. To keep sending events but hold pulses back in those
235
+ builds, return `'notNow'` from `shouldPresentPulse`:
148
236
 
149
237
  ```tsx
150
238
  <SidebandProvider
151
239
  config={{
152
240
  apiKey: 'YOUR_API_KEY',
153
241
  appVersion: '1.0.0',
154
- shouldPresentPulse: () => (isAutomatedTest ? 'notNow' : 'showNow'),
242
+ shouldPresentPulse: () => (holdPulses ? 'notNow' : 'showNow'),
155
243
  }}
156
244
  >
157
245
  ```
158
246
 
159
- `isAutomatedTest` stands for however your test runs mark themselves, such as a
247
+ `holdPulses` stands for an explicit setting your test runs turn on, such as a
160
248
  build-time variable. The SDK reports each pulse held back this way as a "not
161
249
  now" dismissal.
250
+
251
+ **A deliberate pulse test.** When a test is meant to show and answer a pulse,
252
+ turn that setting off for that run only. Use the same explicit setting; do not
253
+ detect automation from the browser (for example `navigator.webdriver`) and then
254
+ hide that signal to let a pulse through.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import './style.css';
2
- export { createSidebandClient, SidebandApiError, SurveySessionStore, buildFabTitle, getChoiceValue, } from '@sidebandai/sideband-core';
2
+ export { createSidebandClient, PendingInteractionStorageError, SidebandApiError, SurveySessionStore, buildFabTitle, getChoiceValue, } from '@sidebandai/sideband-core';
3
3
  export { SidebandProvider } from './context/SidebandProvider';
4
4
  export type { SidebandProviderConfig } from './context/SidebandProvider';
5
5
  export { useSideband } from './hooks/useSideband';
6
- export type { AnsweredInteraction, ClientContext, CompletionActionStyle, CompletionActionType, CompletionIconType, CompletionType, DismissedInteraction, EventMetadata, EventRecord, Fab, FabOffset, FabPlacement, FabPoint, Interaction, Pulse, PendingPulse, SyncEndpoint, PulseAnswer, PulseCompletion, PulseCompletionAction, PulseQuestion, QuestionType, SentimentPresentation, SentimentPresentationOptions, BarPosition, BarBehavior, SimulatedPulseDefinition, SidebandClientConfig, SidebandCoreConfig, ServiceUnavailableError, SurveyAnswerMap, SurveyAnswerValue, SyncErrorResponse, SyncOptions, SyncRequest, SyncResponse, TrackedEvent, TrackOptions, Theme, ThemeColor, TimerStyle, } from '@sidebandai/sideband-core';
6
+ export type { AnsweredInteraction, ClientContext, CompletionActionStyle, CompletionActionType, CompletionIconType, CompletionType, DismissedInteraction, EventMetadata, EventRecord, Fab, FabOffset, FabPlacement, FabPoint, Interaction, Pulse, PendingInteractionStorageReason, PendingPulse, SyncEndpoint, PulseAnswer, PulseCompletion, PulseCompletionAction, PulseQuestion, QuestionType, SentimentPresentation, SentimentPresentationOptions, BarPosition, BarBehavior, SimulatedPulseDefinition, SidebandClientConfig, SidebandCoreConfig, ServiceUnavailableError, SurveyAnswerMap, SurveyAnswerValue, SyncErrorResponse, SyncOptions, SyncRequest, SyncResponse, TrackedEvent, TrackOptions, Theme, ThemeColor, TimerStyle, } from '@sidebandai/sideband-core';
7
7
  import type { EventMetadata, SidebandClientConfig, SyncOptions, SyncRequest, TrackOptions } from '@sidebandai/sideband-core';
8
8
  export declare function sync(config: SidebandClientConfig, request: Omit<SyncRequest, 'context'> & {
9
9
  context?: SyncRequest['context'];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,GACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,YAAY,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,GAAG,EACH,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,4BAA4B,EAC5B,WAAW,EACX,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,UAAU,EACV,UAAU,GACX,MAAM,2BAA2B,CAAA;AAGlC,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,YAAY,EACb,MAAM,2BAA2B,CAAA;AAElC,wBAAgB,IAAI,CAClB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;CAAE,EAC5E,OAAO,CAAC,EAAE,WAAW,6DAGtB;AAED,wBAAgB,KAAK,CACnB,MAAM,EAAE,oBAAoB,EAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,aAAa,EACxB,OAAO,CAAC,EAAE,YAAY,6DAGvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,GACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,YAAY,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,GAAG,EACH,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,+BAA+B,EAC/B,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,4BAA4B,EAC5B,WAAW,EACX,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,UAAU,EACV,UAAU,GACX,MAAM,2BAA2B,CAAA;AAGlC,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,YAAY,EACb,MAAM,2BAA2B,CAAA;AAElC,wBAAgB,IAAI,CAClB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;CAAE,EAC5E,OAAO,CAAC,EAAE,WAAW,6DAGtB;AAED,wBAAgB,KAAK,CACnB,MAAM,EAAE,oBAAoB,EAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,aAAa,EACxB,OAAO,CAAC,EAAE,YAAY,6DAGvB"}
package/dist/index.js CHANGED
@@ -1,37 +1,37 @@
1
1
  import { t as e } from "./SurveyRenderer-C7_hRSWY.js";
2
- import { SidebandApiError as t, SurveySessionStore as n, SurveySessionStore as r, buildFabTitle as i, createSidebandClient as a, createSidebandClient as o, createSidebandRuntime as s, getChoiceValue as c } from "@sidebandai/sideband-core";
3
- import { createContext as l, useCallback as u, useContext as d, useEffect as f, useMemo as p, useRef as m, useState as h, useSyncExternalStore as g } from "react";
4
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
2
+ import { PendingInteractionStorageError as t, SidebandApiError as n, SurveySessionStore as r, SurveySessionStore as i, buildFabTitle as a, createSidebandClient as o, createSidebandClient as s, createSidebandRuntime as c, getChoiceValue as l } from "@sidebandai/sideband-core";
3
+ import { createContext as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h, useState as g, useSyncExternalStore as _ } from "react";
4
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
5
5
  //#region src/lib/context/sideband-context.ts
6
- var y = l(null), b = {
6
+ var b = u(null), x = {
7
7
  state: null,
8
8
  destroyed: !1
9
- }, x = (e) => () => {}, S = () => b, C = () => /* @__PURE__ */ Error("Sideband provider unmounted before the runtime became ready."), w = /* @__PURE__ */ new WeakMap(), T = 0;
10
- function E(e, t = /* @__PURE__ */ new WeakSet()) {
9
+ }, S = (e) => () => {}, C = () => x, w = () => /* @__PURE__ */ Error("Sideband provider unmounted before the runtime became ready."), T = /* @__PURE__ */ new WeakMap(), E = 0;
10
+ function D(e, t = /* @__PURE__ */ new WeakSet()) {
11
11
  if (e === null || typeof e == "string" || typeof e == "boolean") return JSON.stringify(e);
12
12
  if (typeof e == "number") return Number.isFinite(e) ? String(e) : null;
13
13
  if (Array.isArray(e)) {
14
- let n = e.map((e) => E(e, t));
14
+ let n = e.map((e) => D(e, t));
15
15
  return n.some((e) => e === null) ? null : `[${n.join(",")}]`;
16
16
  }
17
17
  if (!e || typeof e != "object" || Object.getPrototypeOf(e) !== Object.prototype || t.has(e)) return null;
18
18
  t.add(e);
19
19
  let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => {
20
- let r = E(n, t);
20
+ let r = D(n, t);
21
21
  return r === null ? null : `${JSON.stringify(e)}:${r}`;
22
22
  });
23
23
  return n.some((e) => e === null) ? null : `{${n.join(",")}}`;
24
24
  }
25
- function D(e, t) {
26
- let n = E(e), r = E(t ? { keepalive: t.keepalive } : {});
25
+ function O(e, t) {
26
+ let n = D(e), r = D(t ? { keepalive: t.keepalive } : {});
27
27
  if (n === null || r === null) return null;
28
28
  let i = t?.signal;
29
29
  if (!i) return `${n}|${r}|signal:none`;
30
- let a = i, o = w.get(a) ?? ++T;
31
- return w.set(a, o), `${n}|${r}|signal:${o}`;
30
+ let a = i, o = T.get(a) ?? ++E;
31
+ return T.set(a, o), `${n}|${r}|signal:${o}`;
32
32
  }
33
- function O(e, t) {
34
- let n = { current: null }, i = new r({
33
+ function k(e, t) {
34
+ let n = { current: null }, r = new i({
35
35
  syncInteraction: async (e) => n.current?.submitInteraction(e),
36
36
  trackEvent: (e, t) => n.current?.track(e, t),
37
37
  shouldPresentPulse: (e) => t.current.shouldPresentPulse?.(e) ?? "showNow",
@@ -40,40 +40,40 @@ function O(e, t) {
40
40
  let n = t.current.onError;
41
41
  n ? n(e) : console.error("[sideband]", e);
42
42
  }
43
- }), a = s({
43
+ }), a = c({
44
44
  ...e,
45
- libraryVersion: "1.4.5-rc.1",
46
- onSyncResponse: (e) => i.handleSyncResponse(e)
45
+ libraryVersion: "1.4.5-rc.2",
46
+ onSyncResponse: (e) => r.handleSyncResponse(e)
47
47
  });
48
48
  return n.current = a, {
49
49
  runtime: a,
50
- store: i,
50
+ store: r,
51
51
  ready: !1
52
52
  };
53
53
  }
54
- function k({ children: t, config: n }) {
55
- let r = m(n), i = m(n), a = m(null), o = m("starting"), s = m([]), c = m(/* @__PURE__ */ new Map()), l = m(null), [d, b] = h(null);
56
- f(() => {
54
+ function A({ children: t, config: n }) {
55
+ let r = h(n), i = h(n), a = h(null), o = h("starting"), s = h([]), c = h(/* @__PURE__ */ new Map()), l = h(null), [u, f] = g(null);
56
+ p(() => {
57
57
  i.current = n;
58
58
  }, [n]);
59
- let w = u((e) => {
59
+ let x = d((e) => {
60
60
  let t = a.current;
61
- o.current === "unmounted" ? e.reject?.(C()) : t?.ready && o.current === "live" ? e.run(t) : s.current.push(e);
62
- }, []), T = p(() => ({
63
- track: (e, t, n) => w({ run: (r) => r.runtime.track(e, t, n) }),
64
- tagUser: (e) => w({ run: (t) => t.runtime.tagUser(e) }),
65
- untagUser: () => w({ run: (e) => e.runtime.untagUser() }),
61
+ o.current === "unmounted" ? e.reject?.(w()) : t?.ready && o.current === "live" ? e.run(t) : s.current.push(e);
62
+ }, []), T = m(() => ({
63
+ track: (e, t, n) => x({ run: (r) => r.runtime.track(e, t, n) }),
64
+ tagUser: (e) => x({ run: (t) => t.runtime.tagUser(e) }),
65
+ untagUser: () => x({ run: (e) => e.runtime.untagUser() }),
66
66
  sync: (e, t) => new Promise((n, r) => {
67
67
  let i = a.current;
68
68
  if (o.current === "unmounted") {
69
- r(C());
69
+ r(w());
70
70
  return;
71
71
  }
72
72
  if (i?.ready && o.current === "live") {
73
73
  i.runtime.sync(e, t).then(n, r);
74
74
  return;
75
75
  }
76
- let l = D(e, t), u = l ? c.current.get(l) : void 0;
76
+ let l = O(e, t), u = l ? c.current.get(l) : void 0;
77
77
  if (u) {
78
78
  u.resolves.push(n), u.rejects.push(r);
79
79
  return;
@@ -93,7 +93,7 @@ function k({ children: t, config: n }) {
93
93
  flush: () => new Promise((e, t) => {
94
94
  let n = a.current;
95
95
  if (o.current === "unmounted") {
96
- t(C());
96
+ t(w());
97
97
  return;
98
98
  }
99
99
  if (n?.ready && o.current === "live") {
@@ -117,67 +117,67 @@ function k({ children: t, config: n }) {
117
117
  };
118
118
  l.current = i, s.current.push(i.command);
119
119
  }),
120
- closeSurvey: () => new Promise((e, t) => w({
120
+ closeSurvey: () => new Promise((e, t) => x({
121
121
  run: (n) => {
122
122
  n.store.closeSurvey().then(e, t);
123
123
  },
124
124
  reject: t
125
125
  })),
126
- openSurvey: () => w({ run: (e) => e.store.openSurvey() }),
127
- presentSimulatedPulse: (e) => new Promise((t, n) => w({
126
+ openSurvey: () => x({ run: (e) => e.store.openSurvey() }),
127
+ presentSimulatedPulse: (e) => new Promise((t, n) => x({
128
128
  run: (n) => t(n.store.presentSimulatedPulse(e)),
129
129
  reject: n
130
130
  }))
131
- }), [w]), E = g(u((e) => d ? d.store.subscribe(e) : x(e), [d]), u(() => d ? d.store.getSnapshot() : S(), [d]), S).state;
132
- f(() => {
133
- let e = !0, t = s, n = c, u = l, d = O(r.current, i);
131
+ }), [x]), E = _(d((e) => u ? u.store.subscribe(e) : S(e), [u]), d(() => u ? u.store.getSnapshot() : C(), [u]), C).state;
132
+ p(() => {
133
+ let e = !0, t = s, n = c, u = l, d = k(r.current, i);
134
134
  return o.current = "starting", d.runtime.start(), a.current = d, queueMicrotask(() => {
135
135
  if (!e || a.current !== d) return;
136
- d.ready = !0, o.current = "live", b(d);
136
+ d.ready = !0, o.current = "live", f(d);
137
137
  let r = t.current.splice(0);
138
138
  n.current.clear(), u.current = null;
139
139
  for (let e of r) e.run(d);
140
140
  }), () => {
141
- e = !1, d.ready = !1, a.current === d && (a.current = null), o.current = "cleanup", d.runtime.destroy(), d.store.destroy(), queueMicrotask(() => b((e) => e === d ? null : e)), queueMicrotask(() => {
141
+ e = !1, d.ready = !1, a.current === d && (a.current = null), o.current = "cleanup", d.runtime.destroy(), d.store.destroy(), queueMicrotask(() => f((e) => e === d ? null : e)), queueMicrotask(() => {
142
142
  if (a.current) return;
143
143
  o.current = "unmounted";
144
144
  let e = t.current.splice(0);
145
145
  n.current.clear(), u.current = null;
146
- for (let t of e) t.reject?.(C());
146
+ for (let t of e) t.reject?.(w());
147
147
  });
148
148
  };
149
149
  }, []);
150
- let k = p(() => ({
150
+ let D = m(() => ({
151
151
  ...T,
152
152
  survey: E?.survey ?? null,
153
153
  fabState: E?.fabState ?? "hidden",
154
154
  isSurveyOpen: !!E?.isOpen,
155
155
  isThankYouVisible: !!E?.completion,
156
- store: d?.store ?? null
156
+ store: u?.store ?? null
157
157
  }), [
158
158
  T,
159
- d,
159
+ u,
160
160
  E
161
161
  ]);
162
- return /* @__PURE__ */ v(y.Provider, {
163
- value: k,
164
- children: [t, d ? /* @__PURE__ */ _(e, { store: d.store }) : null]
162
+ return /* @__PURE__ */ y(b.Provider, {
163
+ value: D,
164
+ children: [t, u ? /* @__PURE__ */ v(e, { store: u.store }) : null]
165
165
  });
166
166
  }
167
167
  //#endregion
168
168
  //#region src/lib/hooks/useSideband.ts
169
- function A() {
170
- let e = d(y);
169
+ function j() {
170
+ let e = f(b);
171
171
  if (!e) throw Error("useSideband must be used within a SidebandProvider.");
172
172
  return e;
173
173
  }
174
174
  //#endregion
175
175
  //#region src/lib/index.ts
176
- function j(e, t, n) {
177
- return o(e).sync(t, n);
176
+ function M(e, t, n) {
177
+ return s(e).sync(t, n);
178
178
  }
179
- function M(e, t, n, r) {
180
- return o(e).track(t, n, r);
179
+ function N(e, t, n, r) {
180
+ return s(e).track(t, n, r);
181
181
  }
182
182
  //#endregion
183
- export { t as SidebandApiError, k as SidebandProvider, n as SurveySessionStore, i as buildFabTitle, a as createSidebandClient, c as getChoiceValue, j as sync, M as track, A as useSideband };
183
+ export { t as PendingInteractionStorageError, n as SidebandApiError, A as SidebandProvider, r as SurveySessionStore, a as buildFabTitle, o as createSidebandClient, l as getChoiceValue, M as sync, N as track, j as useSideband };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sidebandai/sideband-react",
3
- "version": "1.4.5-rc.1",
3
+ "version": "1.4.5-rc.2",
4
4
  "description": "React SDK for Sideband client sync surveys and prompts.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "react-dom": "^19.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@sidebandai/sideband-core": "1.4.5-rc.1"
42
+ "@sidebandai/sideband-core": "1.4.5-rc.2"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "vite build --config ../../vite.react.config.ts && tsc -p tsconfig.lib.json && node ../../scripts/prepare-react-package.mjs",