@sidebandai/sideband-react 0.0.0-stage → 1.4.1-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/LICENSE +21 -0
- package/README.md +137 -2
- package/dist/SurveyRenderer-BkUNLbxJ.js +1185 -0
- package/dist/client/create-sideband-client.d.ts +2 -0
- package/dist/client/create-sideband-client.d.ts.map +1 -0
- package/dist/components/SurveyFab.d.ts +11 -0
- package/dist/components/SurveyFab.d.ts.map +1 -0
- package/dist/components/SurveyProgress.d.ts +6 -0
- package/dist/components/SurveyProgress.d.ts.map +1 -0
- package/dist/components/SurveyQuestionView.d.ts +11 -0
- package/dist/components/SurveyQuestionView.d.ts.map +1 -0
- package/dist/components/SurveyRenderer.d.ts +7 -0
- package/dist/components/SurveyRenderer.d.ts.map +1 -0
- package/dist/components/SurveySheet.d.ts +10 -0
- package/dist/components/SurveySheet.d.ts.map +1 -0
- package/dist/components/SurveySnackbar.d.ts +8 -0
- package/dist/components/SurveySnackbar.d.ts.map +1 -0
- package/dist/components/SurveyThankYou.d.ts +9 -0
- package/dist/components/SurveyThankYou.d.ts.map +1 -0
- package/dist/context/SidebandProvider.d.ts +8 -0
- package/dist/context/SidebandProvider.d.ts.map +1 -0
- package/dist/context/sideband-context.d.ts +18 -0
- package/dist/context/sideband-context.d.ts.map +1 -0
- package/dist/hooks/useSideband.d.ts +2 -0
- package/dist/hooks/useSideband.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +183 -0
- package/dist/preview.d.ts +22 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +50 -0
- package/dist/style.css +2 -0
- package/dist/style.css.d.ts +2 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +46 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SidebandAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sidebandai/sideband-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Sideband event tracking and Pulse presentation for React applications.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Requires React 19 and React DOM 19.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @sidebandai/sideband-react@rc react@^19 react-dom@^19
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The `rc` tag selects the latest release candidate. Installation uses the public
|
|
14
|
+
npm registry and requires no registry credentials. Core is installed automatically.
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
Wrap your application in `SidebandProvider` and import the stylesheet once.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { SidebandProvider, useSideband } from '@sidebandai/sideband-react'
|
|
22
|
+
import '@sidebandai/sideband-react/style.css'
|
|
23
|
+
|
|
24
|
+
function Checkout() {
|
|
25
|
+
const { track } = useSideband()
|
|
26
|
+
return <button onClick={() => track('checkout_completed', { plan: 'pro' })}>Checkout</button>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
return (
|
|
31
|
+
<SidebandProvider config={{ apiKey: 'YOUR_API_KEY' }}>
|
|
32
|
+
<Checkout />
|
|
33
|
+
</SidebandProvider>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`useSideband()` exposes `track`, `tagUser`, `untagUser`, `flush`, `sync`,
|
|
39
|
+
`openSurvey`, `closeSurvey`, and `presentSimulatedPulse`. Event metadata is a string-to-string map.
|
|
40
|
+
The provider owns its runtime; it does not configure the HTML package's shared
|
|
41
|
+
client. Runtime resources start after mount and are destroyed on unmount.
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
`apiKey` identifies your Sideband application. Requests use the production
|
|
46
|
+
endpoint by default. `baseUrl` is an optional override for custom deployments
|
|
47
|
+
and tests.
|
|
48
|
+
`appVersion` is optional and has no default.
|
|
49
|
+
|
|
50
|
+
`shouldPresentPulse(pulse)` receives `pulseId`, `version`, `title`, and optional
|
|
51
|
+
`fab`, and returns `showNow`, `notNow`, or `never`, synchronously or asynchronously.
|
|
52
|
+
`onError` and `onRateApp` handle background errors and rating actions.
|
|
53
|
+
|
|
54
|
+
Use `SidebandProviderConfig` for configuration. Transport/pacing configuration is
|
|
55
|
+
captured for the provider lifetime; change its React key to reinitialize.
|
|
56
|
+
Presentation/error/rating callbacks use their latest supplied functions.
|
|
57
|
+
|
|
58
|
+
`mountSidebandPulsePreview` is available from `@sidebandai/sideband-react/preview`
|
|
59
|
+
for rendering canonical `Pulse` values without transport.
|
|
60
|
+
|
|
61
|
+
## Event metadata and Pulse targeting
|
|
62
|
+
|
|
63
|
+
Pass metadata to `track` as string key-value pairs. Use metadata to describe an
|
|
64
|
+
event 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`. These keys support equals and
|
|
78
|
+
not-equals comparisons. It compares `count` and `duration` numerically, with
|
|
79
|
+
equals, not-equals, greater-than, greater-than-or-equal, less-than, and
|
|
80
|
+
less-than-or-equal comparisons. Send `duration` in seconds, not milliseconds.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// Inside a component rendered within SidebandProvider:
|
|
84
|
+
const { track } = useSideband()
|
|
85
|
+
const onCreate = () => track('content_created', {
|
|
86
|
+
source: 'editor',
|
|
87
|
+
item_type: 'article',
|
|
88
|
+
count: '3',
|
|
89
|
+
duration: '12.5',
|
|
90
|
+
content_id: 'article-123',
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Call `onCreate` from the event handler for the completed action, not during
|
|
95
|
+
component rendering.
|
|
96
|
+
|
|
97
|
+
Custom keys such as `content_id`, `screen`, or `plan` are stored unchanged, but
|
|
98
|
+
cannot be used in Pulse targeting filters. A missing key does not match any
|
|
99
|
+
filter, including not-equals.
|
|
100
|
+
|
|
101
|
+
The server stores at most 20 metadata properties per event. It keeps valid
|
|
102
|
+
targeting keys first, then fills the remaining slots with custom keys in sorted
|
|
103
|
+
key order. It drops empty keys and invalid targeting values without rejecting
|
|
104
|
+
the event. For example, `count: '3.5'` and `count: '3.0'` are invalid; use
|
|
105
|
+
`count: '3'`. Normalization and numeric comparison happen on the server, not in
|
|
106
|
+
the SDK.
|
|
107
|
+
|
|
108
|
+
## Snackbar previews and simulations
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { mountSidebandPulsePreview } from '@sidebandai/sideband-react/preview'
|
|
112
|
+
import '@sidebandai/sideband-react/style.css'
|
|
113
|
+
|
|
114
|
+
const preview = mountSidebandPulsePreview('#preview', {
|
|
115
|
+
pulse,
|
|
116
|
+
sentimentPresentation: 'snackbar',
|
|
117
|
+
onInteraction: (interaction) => console.log(interaction),
|
|
118
|
+
})
|
|
119
|
+
// Changing this preference restarts the preview, even with the same pulse.
|
|
120
|
+
preview.update({ sentimentPresentation: 'sheet' })
|
|
121
|
+
preview.destroy()
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
In a configured provider, `useSideband().presentSimulatedPulse({ pulse,
|
|
125
|
+
sentimentPresentation: 'snackbar' })` returns a `Promise<boolean>`. Simulations
|
|
126
|
+
do not report impressions or responses, or invoke the provider's `onRateApp`.
|
|
127
|
+
Standalone previews retain their local `onInteraction`/`onRateApp` callbacks.
|
|
128
|
+
|
|
129
|
+
`sentimentPresentation` defaults to `'sheet'` and is local to previews and
|
|
130
|
+
simulations. It is not a provider configuration or server-payload field.
|
|
131
|
+
Snackbar requires FAB configuration and a root `yes_no` question with exactly
|
|
132
|
+
two answers, excluding `system_other`; unsupported pulses use their normal
|
|
133
|
+
presentation. Live server-delivered pulses keep their existing behavior.
|
|
134
|
+
|
|
135
|
+
Both fixed and inline previews support all three timer styles, sheet-derived
|
|
136
|
+
themes, keyboard controls, and reduced motion. The compact prompt is non-modal;
|
|
137
|
+
answering retains the surface through expansion and sentiment acknowledgement
|
|
138
|
+
before following the selected branch.
|