@sidebandai/sideband-web 1.4.1-rc.2 → 1.4.3

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
@@ -1,139 +1,41 @@
1
- # @sidebandai/sideband-web
1
+ # Sideband Web SDK
2
2
 
3
- Sideband event tracking and Pulse presentation for websites, with no framework
4
- dependency. Styles are isolated from your application using Shadow DOM.
3
+ Sideband adds in-app Pulse prompts and event tracking to websites, with no
4
+ framework dependency.
5
+
6
+ ## Requirements
7
+
8
+ - A Sideband API key
9
+ - Your application's version
5
10
 
6
11
  ## Install
7
12
 
8
13
  ```bash
9
- npm install @sidebandai/sideband-web@rc
14
+ npm install @sidebandai/sideband-web
10
15
  ```
11
16
 
12
- The `rc` tag selects the latest release candidate. Installation uses the public
13
- npm registry and requires no registry credentials. Core is installed automatically.
17
+ ## Configure
14
18
 
15
- ## Quick start
19
+ Configure Sideband once when your app starts in the browser:
16
20
 
17
21
  ```ts
18
22
  import { Sideband } from '@sidebandai/sideband-web'
19
23
 
20
- Sideband.configure({ apiKey: 'YOUR_API_KEY' })
21
- Sideband.tagUser('user-123')
22
- Sideband.track('checkout_completed', { plan: 'pro' })
23
- Sideband.untagUser()
24
- await Sideband.flush()
25
- ```
26
-
27
- For script-tag use, self-host `dist/sideband.iife.js`. Its `Sideband` global
28
- exposes the same `configure`, `track`, `tagUser`, `untagUser`, and `flush` methods.
29
- Styles are bundled inside Shadow DOM; no stylesheet import is required.
30
-
31
- ## Configuration
32
-
33
- `apiKey` identifies your Sideband application. Requests use the production
34
- endpoint by default. An explicit `baseUrl` overrides the endpoint for custom
35
- deployments and tests.
36
-
37
- `appVersion` is optional and has no default.
38
-
39
- ```ts
40
24
  Sideband.configure({
41
25
  apiKey: 'YOUR_API_KEY',
42
- shouldPresentPulse: async (pulse) => {
43
- // pulseId, version, title, and optional fab; no transport envelope.
44
- return pulse.title.includes('Survey') ? 'notNow' : 'showNow'
45
- },
46
- })
47
- ```
48
-
49
- The presentation callback returns `showNow`, `notNow`, or `never`. Declines are
50
- reported to the server. `onError` receives background errors; `onRateApp` handles
51
- rating completion actions in the host website.
52
-
53
- Browser integrations may also supply `context`, `headers`, `fetch`, or `ui: false`
54
- for headless transport. Without `ui: false`, configuration during SSR is inert.
55
-
56
- ## API
57
-
58
- - `configure(config)` replaces the shared client and returns its instance.
59
- - `track(eventName, metadata?)` queues an event. Metadata is a string-to-string
60
- map; invalid values and empty event names are rejected.
61
- - `tagUser(userId)` persists the opaque identity exactly.
62
- - `untagUser()` clears runtime and persisted identity. An explicitly configured
63
- `context.user_id` is restored after the runtime override is cleared.
64
- - `flush()` forces queued delivery and returns a promise.
65
- - `presentSimulatedPulse({ pulse, sentimentPresentation? })` presents a canonical
66
- `Pulse` locally and returns whether it was accepted. It is also available on
67
- the configured instance and script-tag global.
68
- - `destroy()` tears down the shared client.
69
-
70
- The returned instance also exposes `sync`, `openSurvey`, `closeSurvey`,
71
- `getDeviceId`, and `destroy` for advanced browser integrations. Raw `sync` is a
72
- one-shot request; background queued delivery owns batching and retries.
73
-
74
- Device identity is persisted in localStorage; session identity is per-tab.
75
- Event queues are in memory. Background/pagehide delivery uses fetch keepalive.
76
- See `SidebandWebConfig` for delivery tuning options.
77
-
78
- ## Event metadata and Pulse targeting
79
-
80
- Pass metadata to `track` as string key-value pairs. Use metadata to describe an
81
- event without creating a separate event name for each source, item type, or mode.
82
- Only these six keys support Pulse trigger filters and event-history conditions:
83
-
84
- | Key | Value format | Example |
85
- | --- | --- | --- |
86
- | `source` | String | `'home'` |
87
- | `item_type` | String | `'article'` |
88
- | `mode` | String | `'manual'` |
89
- | `variant` | String | `'control'` |
90
- | `count` | Integer sent as a string | `'3'` |
91
- | `duration` | Seconds sent as a string; fractions allowed | `'12.5'` |
92
-
93
- Use the exact lowercase key names. The server trims and lowercases values for
94
- `source`, `item_type`, `mode`, and `variant`. These keys support equals and
95
- not-equals comparisons. It compares `count` and `duration` numerically, with
96
- equals, not-equals, greater-than, greater-than-or-equal, less-than, and
97
- less-than-or-equal comparisons. Send `duration` in seconds, not milliseconds.
98
-
99
- ```ts
100
- Sideband.track('content_created', {
101
- source: 'editor',
102
- item_type: 'article',
103
- count: '3',
104
- duration: '12.5',
105
- content_id: 'article-123',
26
+ appVersion: '1.0.0',
106
27
  })
107
28
  ```
108
29
 
109
- Custom keys such as `content_id`, `screen`, or `plan` are stored unchanged, but
110
- cannot be used in Pulse targeting filters. A missing key does not match any
111
- filter, including not-equals.
112
-
113
- The server stores at most 20 metadata properties per event. It keeps valid
114
- targeting keys first, then fills the remaining slots with custom keys in sorted
115
- key order. It drops empty keys and invalid targeting values without rejecting
116
- the event. For example, `count: '3.5'` and `count: '3.0'` are invalid; use
117
- `count: '3'`. Normalization and numeric comparison happen on the server, not in
118
- the SDK. Script-tag integrations use the same metadata rules.
119
-
120
- ## Snackbar simulations
30
+ Replace `1.0.0` with your application's version, not the SDK version.
31
+ `appVersion` must be a non-empty string of at most 64 characters.
121
32
 
122
- ```ts
123
- Sideband.presentSimulatedPulse({
124
- pulse, // A canonical Pulse value, including its FAB configuration.
125
- sentimentPresentation: 'snackbar',
126
- })
127
- ```
33
+ Sideband presents available Pulses automatically. Styles are included; no
34
+ stylesheet import is required.
128
35
 
129
- The local preference defaults to `'sheet'`, matching the native SDKs. Snackbar
130
- requires a FAB and a root `yes_no` question with exactly two answers and no
131
- `system_other` option; other pulses use their normal presentation. Server-delivered
132
- pulses use FAB/sheet presentation. This option only applies to local simulations.
36
+ ## Install Without a Bundler
133
37
 
134
- Simulations do not report impressions or responses, or invoke `onRateApp`.
135
- The configured runtime's normal event delivery continues independently.
136
- The snackbar uses the root question prompt, sheet-derived colors, and the FAB's
137
- artwork, placement, timeout, and `none`/`bar`/`fill` timer. Selecting an answer
138
- freezes the timer and retains the answer through the card acknowledgement and
139
- branch transition. Use `closeSurvey()` or the close control to dismiss it.
38
+ Copy `node_modules/@sidebandai/sideband-web/dist/sideband.iife.js` to your
39
+ website's public assets and load it before your application script. The bundle
40
+ exposes `window.Sideband`; call `window.Sideband.configure` with the same
41
+ configuration shown above.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { EventMetadata, SidebandCoreConfig, SidebandRuntime, SimulatedPulseDefinition, TrackOptions } from '@sidebandai/sideband-core';
2
2
  export { createSidebandClient, getDeviceId, getSessionId, SidebandApiError, SurveySessionStore, buildFabTitle, getChoiceValue, SyncEngine, } from '@sidebandai/sideband-core';
3
- export type { AnsweredInteraction, ApiErrorDetail, ClientContext, CompletionActionStyle, CompletionActionType, CompletionIconType, CompletionType, DismissedInteraction, EventMetadata, EventRecord, Fab, FabOffset, FabPlacement, FabPoint, FabState, Interaction, Platform, PendingPulse, SyncEndpoint, Pulse, PulseAnswer, PulseCompletion, PulseCompletionAction, PulseQuestion, QuestionType, SentimentPresentation, SimulatedPulseDefinition, SidebandClient, SidebandClientConfig, SidebandCoreConfig, SurveyAnswerDraft, SurveyAnswerMap, SurveyAnswerValue, SurveySessionState, SurveyStoreSnapshot, SurveyStoreUpdateReason, SyncEngineDeps, SyncEngineOptions, SyncErrorResponse, ServiceUnavailableError, SyncOptions, SyncRequest, SyncResponse, TrackedEvent, TrackOptions, Theme, ThemeColor, TimerStyle, SurveyPresentationDecision, SurveyPresentationKind, } from '@sidebandai/sideband-core';
3
+ export type { AnsweredInteraction, ApiErrorDetail, ClientContext, CompletionActionStyle, CompletionActionType, CompletionIconType, CompletionType, DismissedInteraction, EventMetadata, EventRecord, Fab, FabOffset, FabPlacement, FabPoint, FabState, Interaction, Platform, PendingPulse, SyncEndpoint, Pulse, PulseAnswer, PulseCompletion, PulseCompletionAction, PulseQuestion, QuestionType, SentimentPresentation, SentimentPresentationOptions, BarPosition, BarBehavior, SimulatedPulseDefinition, SidebandClient, SidebandClientConfig, SidebandCoreConfig, SurveyAnswerDraft, SurveyAnswerMap, SurveyAnswerValue, SurveySessionState, SurveyStoreSnapshot, SurveyStoreUpdateReason, SyncEngineDeps, SyncEngineOptions, SyncErrorResponse, ServiceUnavailableError, SyncOptions, SyncRequest, SyncResponse, TrackedEvent, TrackOptions, Theme, ThemeColor, TimerStyle, SurveyPresentationDecision, SurveyPresentationKind, } from '@sidebandai/sideband-core';
4
4
  export type SidebandWebConfig = SidebandCoreConfig & {
5
5
  ui?: boolean;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,YAAY,EACb,MAAM,2BAA2B,CAAA;AAIlC,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,UAAU,GACX,MAAM,2BAA2B,CAAA;AAClC,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,GAAG,EACH,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,UAAU,EACV,UAAU,EACV,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,2BAA2B,CAAA;AAElC,MAAM,MAAM,iBAAiB,GAAG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