@microsurveysai/react-native 0.0.0-stage → 0.1.1
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 +96 -2
- package/dist/index.cjs +1986 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +393 -0
- package/dist/index.d.ts +393 -0
- package/dist/index.js +1957 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MicroSurveys
|
|
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,97 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MicroSurveys React Native SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
In-app micro-surveys for React Native and Expo apps, published to npm as
|
|
4
|
+
`@microsurveysai/react-native`. The React Native counterpart to the
|
|
5
|
+
[MicroSurveys iOS SDK](https://github.com/MicroSurveysAI/microsurveys-ios), for apps built on
|
|
6
|
+
[MicroSurveys](https://microsurveys.ai). Surveys you publish in the dashboard
|
|
7
|
+
are evaluated **on-device** against the events you already track, and presented natively as a
|
|
8
|
+
bottom sheet or dialog. Works with Expo (including Expo Go) and bare React Native, on iOS and
|
|
9
|
+
Android.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx expo install @microsurveysai/react-native @react-native-async-storage/async-storage react-native-safe-area-context
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { MicroSurveys, MicroSurveysProvider } from "@microsurveysai/react-native";
|
|
19
|
+
|
|
20
|
+
export const ms = new MicroSurveys({ apiKey: "ms_live_…" });
|
|
21
|
+
|
|
22
|
+
export default function App() {
|
|
23
|
+
return (
|
|
24
|
+
<MicroSurveysProvider instance={ms}>
|
|
25
|
+
<RootNavigator />
|
|
26
|
+
</MicroSurveysProvider>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then either forward your Amplitude events:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { add } from "@amplitude/analytics-react-native";
|
|
35
|
+
|
|
36
|
+
add(ms.amplitudePlugin()); // events + identity flow in; events pass through unmodified
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
or track and identify manually:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
ms.identify("user_123", { plan: "pro" });
|
|
43
|
+
ms.track("checkout_completed", { amount: 42 });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Inside components, `useMicroSurveys()` returns the same `track` / `identify`.
|
|
47
|
+
|
|
48
|
+
## Inline surveys
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import { MicroSurvey } from "@microsurveysai/react-native";
|
|
52
|
+
|
|
53
|
+
<MicroSurvey surveyId="svy_abc" onComplete={(result) => console.log(result)} />;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Options
|
|
57
|
+
|
|
58
|
+
| `new MicroSurveys({...})` | Default | |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| `apiKey` | — | Your project API key. |
|
|
61
|
+
| `apiBaseURL` | `https://console.microsurveys.ai` | For self-hosted deployments. |
|
|
62
|
+
| `refreshOnForeground` | `true` | On app foreground, retry queued ingest and refresh a stale config. |
|
|
63
|
+
| `configTTLms` | 12h | How long the cached config counts as fresh. |
|
|
64
|
+
| `storage` | AsyncStorage | A synchronous store (e.g. MMKV) to persist into instead. |
|
|
65
|
+
| `appVersion` | — | Your app's version (e.g. `"3.2.0"`), sent with responses so results can be compared across releases. With Expo, pass `Application.nativeApplicationVersion` from `expo-application`. |
|
|
66
|
+
|
|
67
|
+
`<MicroSurveysProvider>` also takes `autoStart` (default `true`) and `fontFamily` (a font your app
|
|
68
|
+
registered, e.g. with `expo-font`; surveys use the system font otherwise).
|
|
69
|
+
|
|
70
|
+
To preview a survey without a backend, render `<SurveyModal survey={…} theme={…} />` directly.
|
|
71
|
+
|
|
72
|
+
Full guide: https://docs.microsurveys.ai/react-native-sdk
|
|
73
|
+
|
|
74
|
+
## Example app
|
|
75
|
+
|
|
76
|
+
[`example/`](./example) is an Expo app that presents every question type without a backend:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cd example && npm install && npx expo start --ios
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install
|
|
86
|
+
npm run typecheck
|
|
87
|
+
npm test # vitest
|
|
88
|
+
npm run build # tsup → ESM + CJS + d.ts
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
> Releases are published to npm and tagged here, with notes on the
|
|
92
|
+
> [Releases](https://github.com/MicroSurveysAI/microsurveys-react-native/releases) page. This
|
|
93
|
+
> repository doesn't take pull requests; found a bug or need something? Open an issue.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|