@guidelytech/react-native 0.0.0-stage → 0.4.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/README.md +119 -2
- package/dist/index.cjs +4490 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +718 -0
- package/dist/index.d.ts +718 -0
- package/dist/index.js +4451 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -3
package/README.md
CHANGED
|
@@ -1,3 +1,120 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @guidelytech/react-native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Guidely for React Native and Expo: product tours, tooltips, spotlights, hotspots, banners,
|
|
4
|
+
checklists, surveys and a resource center, authored in the Guidely dashboard and rendered with
|
|
5
|
+
native React Native components. Pure JavaScript (no native module), so it works in Expo Go,
|
|
6
|
+
development builds and bare React Native 0.72+.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @guidelytech/react-native @react-native-async-storage/async-storage
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Setup
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
16
|
+
import { NavigationContainer, useNavigationContainerRef } from "@react-navigation/native";
|
|
17
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
18
|
+
import { GuidelyProvider, guidelyScreenLayout, useGuidelyNavigation } from "@guidelytech/react-native";
|
|
19
|
+
|
|
20
|
+
export default function App() {
|
|
21
|
+
const navigationRef = useNavigationContainerRef();
|
|
22
|
+
return (
|
|
23
|
+
<GuidelyProvider
|
|
24
|
+
projectId="pk_prod_xxx" // Settings → Environments
|
|
25
|
+
apiUrl="https://guidelytech.com"
|
|
26
|
+
storage={AsyncStorage} // persists identity, guide history and queued events
|
|
27
|
+
insets={useSafeAreaInsets()}
|
|
28
|
+
user={user ? { id: user.id, traits: { plan: user.plan, role: user.role } } : null}
|
|
29
|
+
onNavigate={(url) => routeInsideApp(url)} // relative / custom-scheme links from guides
|
|
30
|
+
>
|
|
31
|
+
<Navigation navigationRef={navigationRef} />
|
|
32
|
+
</GuidelyProvider>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function Navigation({ navigationRef }) {
|
|
37
|
+
const guidely = useGuidelyNavigation(navigationRef); // route changes → screen views
|
|
38
|
+
return (
|
|
39
|
+
<NavigationContainer ref={navigationRef} {...guidely}>
|
|
40
|
+
<Tab.Navigator screenLayout={guidelyScreenLayout}>{/* screens */}</Tab.Navigator>
|
|
41
|
+
</NavigationContainer>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
* Put the provider at the root, outside navigators, so guides draw above every screen.
|
|
47
|
+
* Guides reach the app only when **iOS** and/or **Android** is ticked under *Trigger → Platforms*
|
|
48
|
+
in the guide editor.
|
|
49
|
+
* Screens: route names become screen names. URL patterns in the dashboard match the screen path
|
|
50
|
+
`/<RouteName>`. Without React Navigation call `guidely.screen("Name")` or
|
|
51
|
+
`useGuidelyScreen("Name")` yourself.
|
|
52
|
+
* `screenLayout={guidelyScreenLayout}` (React Navigation 7) tells Guidely which screen each target is
|
|
53
|
+
on. Navigators keep inactive tabs mounted, so without it a tooltip could point at a button on a
|
|
54
|
+
hidden tab. Elsewhere, wrap a screen in `<GuidelyScreenScope name="Deals">`.
|
|
55
|
+
|
|
56
|
+
## Targets
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { GuidelyTarget, useGuidelyTarget } from "@guidelytech/react-native";
|
|
60
|
+
|
|
61
|
+
<GuidelyTarget id="new-deal-button" style={{ alignSelf: "flex-start" }}>
|
|
62
|
+
<Button title="New deal" onPress={create} />
|
|
63
|
+
</GuidelyTarget>
|
|
64
|
+
|
|
65
|
+
// or without a wrapper view
|
|
66
|
+
const target = useGuidelyTarget("pipeline-summary");
|
|
67
|
+
<View {...target} style={styles.card}>…</View>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
In the editor, choose the **Guidely id** selector kind and enter the same id. On the web the same
|
|
71
|
+
id is `data-guidely-id`, so one guide can target web and mobile. Taps on targets are observed, never
|
|
72
|
+
intercepted (they drive *Element clicked* triggers, click-to-advance steps and click checklist
|
|
73
|
+
tasks).
|
|
74
|
+
|
|
75
|
+
## API
|
|
76
|
+
|
|
77
|
+
| | |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `useGuidely()` | Client: `identify(id, traits?, account?)`, `setAccount`, `updateTraits`, `reset()`, `track(name, props?)`, `screen(name)`, `startGuide(idOrKey)`, `stopGuide()`, `dismissGuide()`, `openChecklist(key)`, `closeChecklist(key)`, `completeChecklistTask(key, taskId)`, `openResourceCenter()`, `closeResourceCenter()`, `refresh()`, `setConsent()`, `on(event, cb)`, `getGuides()`, `getActiveGuide()`, `getState()` |
|
|
80
|
+
| `useGuidelyReady()` | `true` once config is loaded |
|
|
81
|
+
| `useGuidelyIdentify(id, traits?, account?)` | Identify when the signed-in user changes |
|
|
82
|
+
| `useGuidelyScreen(name)` | Report a screen view from a component |
|
|
83
|
+
| `useGuidelyNavigation(ref, { screenName? })` | React Navigation bridge (`onReady`, `onStateChange`) |
|
|
84
|
+
| `useGuidelyEvent(name, cb)` | Subscribe to `ready`, `guide:start`, `guide:step`, `guide:complete`, `guide:dismiss`, `guide:skip`, `checklist:task`, `checklist:complete`, `survey:submit`, `resource-center:open`, `track`, `identify`, `error` |
|
|
85
|
+
| `useChecklistProgress(key)`, `useGuideState(key)`, `useActiveGuide()` | Live state |
|
|
86
|
+
| `<GuidelyTarget id>`, `useGuidelyTarget(id)` | Guide targets |
|
|
87
|
+
| `<GuidelyScreenScope name>`, `guidelyScreenLayout` | Screen scoping for targets |
|
|
88
|
+
|
|
89
|
+
Provider props: `projectId`, `apiUrl`, `environment`, `storage`, `user`, `debug`, `analytics`,
|
|
90
|
+
`consent` (`granted` / `pending` / `denied`), `appVersion` (for *App version* rules), `theme`,
|
|
91
|
+
`configRefreshMs`, `onNavigate`, `onError`, `showChecklistLauncher` (default `true`),
|
|
92
|
+
`showResourceCenterLauncher` (default `false`), `showMessengerLauncher` (default `true`), `insets`,
|
|
93
|
+
`launcherOffset` (default 72).
|
|
94
|
+
|
|
95
|
+
## Scout messenger
|
|
96
|
+
|
|
97
|
+
When Scout is on for iOS/Android (dashboard → Scout → *Show it on*), a chat bubble opens a native
|
|
98
|
+
messenger sheet (Home, Messages, Help). Scout's replies stream in with article citations and "Show
|
|
99
|
+
me" guide buttons; team replies arrive while the thread is open, and the bubble shows an unread badge.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
const guidely = useGuidely();
|
|
103
|
+
guidely.openMessenger(); // or "home" | "messages" | "help"
|
|
104
|
+
guidely.showNewMessage("I need help with exports");
|
|
105
|
+
guidely.closeMessenger();
|
|
106
|
+
useGuidelyEvent("conversation:message", ({ message }) => console.log(message.body));
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`showMessengerLauncher={false}` hides the bubble so you can open the messenger from your own UI.
|
|
110
|
+
`openResourceCenter()` opens the Help tab while the messenger is on, and `reset()` forgets the
|
|
111
|
+
install's conversations.
|
|
112
|
+
|
|
113
|
+
## Behaviour
|
|
114
|
+
|
|
115
|
+
Config is cached in storage with an ETag and refreshed every 5 minutes and when the app returns to
|
|
116
|
+
the foreground; guides keep working offline. Events are queued, batched and retried; a new
|
|
117
|
+
session starts after the project's inactivity timeout. The SDK never throws into your app — errors
|
|
118
|
+
go to `onError` and, with `debug`, the console.
|
|
119
|
+
|
|
120
|
+
Full guide: [docs/mobile.md](../../docs/mobile.md). Example app: `mobile/react-native/example`.
|