@sidebandai/sideband-web 1.4.5-rc.3 → 1.4.5-rc.5

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
@@ -182,13 +182,22 @@ export function startSideband() {
182
182
  loading = import('@sidebandai/sideband-web').then(({ Sideband }) => {
183
183
  if (current !== generation) return // stopped while loading
184
184
  Sideband.configure({ apiKey: 'YOUR_API_KEY', appVersion: '1.0.0' })
185
+ sdk = Sideband // set first, so that stopSideband() can always stop it
185
186
  // The SDK restores the last tagged ID from localStorage. Set the current
186
187
  // one before sending held events.
187
188
  if (userId !== null) Sideband.tagUser(userId)
188
189
  else Sideband.untagUser()
189
- for (const event of held) Sideband.track(event.name, event.metadata)
190
+ const ready = held
190
191
  held = []
191
- sdk = Sideband
192
+ for (const event of ready) {
193
+ try {
194
+ Sideband.track(event.name, event.metadata)
195
+ } catch (error) {
196
+ // track throws on an empty name or a metadata value that is not a
197
+ // string. Drop that event and send the others.
198
+ console.warn('Sideband did not accept a held event', event.name, error)
199
+ }
200
+ }
192
201
  }).catch((error: unknown) => {
193
202
  if (current === generation) loading = null // the next start retries
194
203
  throw error
@@ -228,6 +237,11 @@ so catch it, and the next `startSideband()` retries. Events held before the
228
237
  failure are kept, still capped at 50, and sent after a later start succeeds.
229
238
  Events tracked between the failure and the next start are dropped.
230
239
 
240
+ `Sideband.track` throws on an empty event name or a metadata value that is not
241
+ a string. The wrapper drops a held event that throws and sends the others, so
242
+ one bad event cannot stop the start or leave the SDK running after
243
+ `stopSideband()`.
244
+
231
245
  ## Language
232
246
 
233
247
  The SDK reports the browser's language (for example `de` from `de-AT`). The
@@ -343,6 +357,18 @@ Do not track these yourself:
343
357
  | `system_logout` | `untagUser` clears the user ID, or `tagUser` replaces it. `metadata.user_id` is the previous ID. |
344
358
  | `system_did_present_pulse` | A Pulse is shown to the user. |
345
359
 
360
+ A snackbar or bar counts as shown only when a person can see it: the tab is
361
+ visible, the entry is rendered (not `display: none` or `visibility: hidden`) and
362
+ inside the viewport, and it is not clipped away by a scrolling container. Until
363
+ then the SDK checks again about every 200 ms. The browser's
364
+ `IntersectionObserver` decides the viewport and clipping part; in a browser
365
+ without it, the SDK uses its own approximate geometry check. A close, Escape or answer by the
366
+ person also counts. If the SDK runs in an iframe, the SDK also checks the
367
+ `<iframe>` element in the parent page, but only when the parent is on the same
368
+ origin. A cross-origin parent cannot be read, so a cross-origin `<iframe>` that
369
+ the parent hides with CSS (for example `visibility: hidden`) can still be counted
370
+ as shown.
371
+
346
372
  Switching from user A to user B sends `system_logout` for A, then `system_login`
347
373
  for B, with the same timestamp. Repeating the same ID, clearing an ID that is
348
374
  not set, and restoring the stored ID on a page load send nothing.