@appilots/sdk 0.7.0 → 0.10.0
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 +46 -4
- package/dist/.build-meta.json +5 -0
- package/dist/{chunk-KYFAXT6V.js → chunk-2GCWCPSD.js} +19 -16
- package/dist/{chunk-R4D34FEW.mjs → chunk-AHHDOUVX.mjs} +2151 -333
- package/dist/{chunk-DR75QTYK.mjs → chunk-IHPLS5FE.mjs} +16 -13
- package/dist/{chunk-HFRIB4YN.js → chunk-VX7AL4SA.js} +1049 -1162
- package/dist/{chunk-KUFWRJC4.mjs → chunk-XHR65V2W.mjs} +831 -949
- package/dist/{chunk-DZ7QRFHD.js → chunk-YB77RYCC.js} +2178 -332
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +11 -11
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-nI-s3Exg.d.mts → index-BPZ0j71S.d.mts} +315 -15
- package/dist/{index-nI-s3Exg.d.ts → index-BPZ0j71S.d.ts} +315 -15
- package/dist/index.d.mts +325 -22
- package/dist/index.d.ts +325 -22
- package/dist/index.js +340 -227
- package/dist/index.mjs +274 -173
- package/dist/navigation/index.d.mts +171 -3
- package/dist/navigation/index.d.ts +171 -3
- package/dist/navigation/index.js +13 -13
- package/dist/navigation/index.mjs +2 -2
- package/metro.d.ts +16 -1
- package/metro.js +104 -10
- package/package.json +16 -6
- package/dist/registerScreen-D1oGm28T.d.mts +0 -159
- package/dist/registerScreen-D1oGm28T.d.ts +0 -159
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@ pnpm add @appilots/sdk
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import { AppilotsProvider, AppilotsChat } from '@appilots/sdk';
|
|
18
|
+
import { AppilotsProvider, AppilotsNavigationContainer, AppilotsChat } from '@appilots/sdk';
|
|
19
|
+
import { NavigationContainer } from '@react-navigation/native';
|
|
19
20
|
|
|
20
21
|
function App() {
|
|
21
22
|
return (
|
|
@@ -24,15 +25,56 @@ function App() {
|
|
|
24
25
|
projectId: 'your-project-id',
|
|
25
26
|
}}
|
|
26
27
|
>
|
|
27
|
-
<
|
|
28
|
-
{/* Your app screens */}
|
|
29
|
-
</
|
|
28
|
+
<AppilotsNavigationContainer>
|
|
29
|
+
<NavigationContainer>{/* Your app screens */}</NavigationContainer>
|
|
30
|
+
</AppilotsNavigationContainer>
|
|
30
31
|
<AppilotsChat />
|
|
31
32
|
</AppilotsProvider>
|
|
32
33
|
);
|
|
33
34
|
}
|
|
34
35
|
```
|
|
35
36
|
|
|
37
|
+
## What happens when Appilots breaks
|
|
38
|
+
|
|
39
|
+
The SDK renders inside your app, so a bug of ours must never become an
|
|
40
|
+
outage of yours. Both render surfaces sit behind an error boundary:
|
|
41
|
+
|
|
42
|
+
- If the **provider** throws, your app keeps rendering. The assistant
|
|
43
|
+
goes inert — `AppilotsChat` renders nothing, and `useAppilots()` keeps
|
|
44
|
+
returning a context (with `degraded: true`) so your own code does not
|
|
45
|
+
throw either.
|
|
46
|
+
- If the **chat** throws, only the chat disappears.
|
|
47
|
+
- If the **auto-tracking interceptor** throws on some element, that
|
|
48
|
+
element renders untouched; the agent just does not see it.
|
|
49
|
+
|
|
50
|
+
In every case we log a `console.error` that says plainly it is our bug,
|
|
51
|
+
not yours, and the failure is reported to the Appilots dashboard on the
|
|
52
|
+
next session so we find out without you having to file anything.
|
|
53
|
+
|
|
54
|
+
Degradation lasts for the session — a surface that crashed once usually
|
|
55
|
+
crashes again, and an assistant blinking in and out of your product is
|
|
56
|
+
worse than an absent one. An exception thrown by **your** components is
|
|
57
|
+
never swallowed: it propagates to your own error boundary as it would
|
|
58
|
+
without us.
|
|
59
|
+
|
|
60
|
+
## Native confirmation dialogs
|
|
61
|
+
|
|
62
|
+
When the user approves a destructive action on the chat's confirm card
|
|
63
|
+
and your code then calls `Alert.alert` to double-check, the SDK answers
|
|
64
|
+
that dialog once on their behalf — otherwise they are asked the same
|
|
65
|
+
question twice and the second dialog is one the agent cannot press.
|
|
66
|
+
|
|
67
|
+
Doing that means briefly replacing `Alert.alert`, a global that belongs
|
|
68
|
+
to your app. The replacement is refcounted, restored even if the action
|
|
69
|
+
throws, answers at most one dialog, never presses a `style: 'cancel'`
|
|
70
|
+
button, and expires about a second after the press so unrelated alerts
|
|
71
|
+
(background sync, push handlers) are never touched. To turn it off and
|
|
72
|
+
show your own dialog instead:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<AppilotsProvider config={{ projectId: '…', suppressNativeConfirm: false }}>
|
|
76
|
+
```
|
|
77
|
+
|
|
36
78
|
## Documentation
|
|
37
79
|
|
|
38
80
|
Full documentation available at [docs.appilots.com](https://docs.appilots.com)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYB77RYCC_js = require('./chunk-YB77RYCC.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -15,24 +15,27 @@ function getActiveRouteName(state) {
|
|
|
15
15
|
return route.name;
|
|
16
16
|
}
|
|
17
17
|
function AppilotsNavigationContainer({ children }) {
|
|
18
|
-
const { emit } =
|
|
18
|
+
const { emit } = chunkYB77RYCC_js.useAppilotsContext();
|
|
19
19
|
const internalRef = React.useRef(null);
|
|
20
|
-
const handleRef = React.useCallback(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const handleRef = React.useCallback(
|
|
21
|
+
(instance) => {
|
|
22
|
+
internalRef.current = instance;
|
|
23
|
+
chunkYB77RYCC_js.setNavigationRef(instance);
|
|
24
|
+
const childRef = children.ref;
|
|
25
|
+
if (typeof childRef === "function") childRef(instance);
|
|
26
|
+
else if (childRef && typeof childRef === "object") childRef.current = instance;
|
|
27
|
+
if (instance) {
|
|
28
|
+
chunkYB77RYCC_js.appilotsDebugLog("NavigationContainer ref captured");
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
[children]
|
|
32
|
+
);
|
|
30
33
|
const handleStateChange = React.useCallback(
|
|
31
34
|
(state) => {
|
|
32
35
|
const routeName = getActiveRouteName(state);
|
|
33
36
|
if (routeName) {
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
chunkYB77RYCC_js.appilotsDebugLog(`Screen changed \u2192 "${routeName}"`);
|
|
38
|
+
chunkYB77RYCC_js.setCurrentScreen(routeName);
|
|
36
39
|
emit({
|
|
37
40
|
type: "navigation:change",
|
|
38
41
|
timestamp: Date.now(),
|
|
@@ -47,8 +50,8 @@ function AppilotsNavigationContainer({ children }) {
|
|
|
47
50
|
const timer = setTimeout(() => {
|
|
48
51
|
const route = internalRef.current?.getCurrentRoute?.();
|
|
49
52
|
if (route?.name) {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
chunkYB77RYCC_js.appilotsDebugLog(`Initial screen \u2192 "${route.name}"`);
|
|
54
|
+
chunkYB77RYCC_js.setCurrentScreen(route.name);
|
|
52
55
|
emit({
|
|
53
56
|
type: "navigation:change",
|
|
54
57
|
timestamp: Date.now(),
|