yaver-feedback-react-native 0.5.3 → 0.5.5
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 +30 -0
- package/dist/AuthOverlay.d.ts +16 -0
- package/dist/AuthOverlay.js +104 -0
- package/dist/BlackBox.d.ts +154 -0
- package/dist/BlackBox.js +395 -0
- package/dist/ConnectionScreen.d.ts +13 -0
- package/dist/ConnectionScreen.js +373 -0
- package/dist/Discovery.d.ts +59 -0
- package/dist/Discovery.js +293 -0
- package/dist/FeedbackModal.d.ts +11 -0
- package/dist/FeedbackModal.js +623 -0
- package/dist/FixReport.d.ts +23 -0
- package/dist/FixReport.js +282 -0
- package/dist/FloatingButton.d.ts +71 -0
- package/dist/FloatingButton.js +778 -0
- package/dist/LoginScreen.d.ts +14 -0
- package/dist/LoginScreen.js +317 -0
- package/dist/MachinePickerScreen.d.ts +19 -0
- package/dist/MachinePickerScreen.js +175 -0
- package/dist/P2PClient.d.ts +136 -0
- package/dist/P2PClient.js +357 -0
- package/dist/ShakeDetector.d.ts +39 -0
- package/dist/ShakeDetector.js +133 -0
- package/dist/YaverFeedback.d.ts +198 -0
- package/dist/YaverFeedback.js +707 -0
- package/dist/YaverUpdates.d.ts +78 -0
- package/dist/YaverUpdates.js +272 -0
- package/dist/__tests__/Discovery.test.d.ts +1 -0
- package/dist/__tests__/Discovery.test.js +164 -0
- package/dist/__tests__/P2PClient.test.d.ts +1 -0
- package/dist/__tests__/P2PClient.test.js +169 -0
- package/dist/__tests__/SDKToken.test.d.ts +1 -0
- package/dist/__tests__/SDKToken.test.js +215 -0
- package/dist/__tests__/YaverFeedback.test.d.ts +1 -0
- package/dist/__tests__/YaverFeedback.test.js +161 -0
- package/dist/__tests__/types.test.d.ts +1 -0
- package/dist/__tests__/types.test.js +219 -0
- package/dist/auth.d.ts +105 -0
- package/dist/auth.js +282 -0
- package/dist/capture.d.ts +27 -0
- package/dist/capture.js +74 -0
- package/dist/expo.d.ts +15 -0
- package/dist/expo.js +62 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +80 -0
- package/dist/types.d.ts +282 -0
- package/dist/types.js +2 -0
- package/dist/upload.d.ts +13 -0
- package/dist/upload.js +59 -0
- package/package.json +6 -3
- package/src/ShakeDetector.ts +22 -1
- package/src/YaverFeedback.ts +29 -0
package/README.md
CHANGED
|
@@ -4,6 +4,14 @@ Visual feedback SDK for Yaver. Lets testers and developers shake their phone (or
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g yaver-cli
|
|
9
|
+
cd your-app
|
|
10
|
+
yaver feedback setup
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Manual fallback:
|
|
14
|
+
|
|
7
15
|
```bash
|
|
8
16
|
npm install yaver-feedback-react-native
|
|
9
17
|
```
|
|
@@ -566,12 +574,34 @@ YaverFeedback.init({
|
|
|
566
574
|
});
|
|
567
575
|
```
|
|
568
576
|
|
|
577
|
+
## Running Inside the Yaver Mobile App (super-host)
|
|
578
|
+
|
|
579
|
+
When a third-party app is loaded through Yaver's Hermes-push flow (so the
|
|
580
|
+
Yaver mobile app is the runtime container for your app), the SDK detects
|
|
581
|
+
that situation via the `YaverInfo` native module and **automatically
|
|
582
|
+
no-ops `YaverFeedback.init()`** — no ShakeDetector, no FeedbackModal, no
|
|
583
|
+
BlackBox stream from inside the guest. The user only ever sees Yaver's
|
|
584
|
+
native shake overlay ("Reload" + "Back to Yaver") and uses Yaver's
|
|
585
|
+
built-in feedback flow instead.
|
|
586
|
+
|
|
587
|
+
Standalone installs (TestFlight / App Store / Play from your own dev
|
|
588
|
+
account) are unaffected — the SDK behaves exactly as it did before.
|
|
589
|
+
|
|
590
|
+
If you need to opt out of the auto-suppression in a specific build (for
|
|
591
|
+
example, to compare behaviour in a super-host smoke test), set
|
|
592
|
+
`enabled: true` explicitly — the Yaver-host gate runs before the
|
|
593
|
+
`enabled` flag is evaluated on purpose.
|
|
594
|
+
|
|
569
595
|
## Trigger Modes
|
|
570
596
|
|
|
571
597
|
### Shake (default)
|
|
572
598
|
|
|
573
599
|
Shake the device to open the feedback modal. Uses the built-in shake event on iOS and `ShakeEvent` on Android.
|
|
574
600
|
|
|
601
|
+
When the app is loaded inside the Yaver mobile app (super-host), the
|
|
602
|
+
SDK yields shake handling to Yaver's native overlay — see the
|
|
603
|
+
"Running Inside the Yaver Mobile App" section above.
|
|
604
|
+
|
|
575
605
|
```typescript
|
|
576
606
|
YaverFeedback.init({ authToken, trigger: 'shake' });
|
|
577
607
|
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Presentation layer for the SDK's auth + machine-picker modals.
|
|
4
|
+
*
|
|
5
|
+
* Mounts automatically inside `<FeedbackModal />`, so consumers of the SDK
|
|
6
|
+
* get in-app login with no extra wiring. It listens for events emitted by
|
|
7
|
+
* `YaverFeedback.showLogin()` / `showMachinePicker()`:
|
|
8
|
+
*
|
|
9
|
+
* yaverFeedback:startLogin → show login modal
|
|
10
|
+
* yaverFeedback:startMachinePicker → show machine picker
|
|
11
|
+
*
|
|
12
|
+
* The overlay closes itself once login/pick succeeds, then re-emits
|
|
13
|
+
* `yaverFeedback:startReport` so the user continues straight into the
|
|
14
|
+
* feedback flow they originally triggered.
|
|
15
|
+
*/
|
|
16
|
+
export declare const AuthOverlay: React.FC;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AuthOverlay = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const LoginScreen_1 = require("./LoginScreen");
|
|
40
|
+
const MachinePickerScreen_1 = require("./MachinePickerScreen");
|
|
41
|
+
const YaverFeedback_1 = require("./YaverFeedback");
|
|
42
|
+
const auth_1 = require("./auth");
|
|
43
|
+
/**
|
|
44
|
+
* Presentation layer for the SDK's auth + machine-picker modals.
|
|
45
|
+
*
|
|
46
|
+
* Mounts automatically inside `<FeedbackModal />`, so consumers of the SDK
|
|
47
|
+
* get in-app login with no extra wiring. It listens for events emitted by
|
|
48
|
+
* `YaverFeedback.showLogin()` / `showMachinePicker()`:
|
|
49
|
+
*
|
|
50
|
+
* yaverFeedback:startLogin → show login modal
|
|
51
|
+
* yaverFeedback:startMachinePicker → show machine picker
|
|
52
|
+
*
|
|
53
|
+
* The overlay closes itself once login/pick succeeds, then re-emits
|
|
54
|
+
* `yaverFeedback:startReport` so the user continues straight into the
|
|
55
|
+
* feedback flow they originally triggered.
|
|
56
|
+
*/
|
|
57
|
+
const AuthOverlay = () => {
|
|
58
|
+
const [loginVisible, setLoginVisible] = (0, react_1.useState)(false);
|
|
59
|
+
const [pickerVisible, setPickerVisible] = (0, react_1.useState)(false);
|
|
60
|
+
const [token, setToken] = (0, react_1.useState)(null);
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
let mounted = true;
|
|
63
|
+
(async () => {
|
|
64
|
+
const cached = await (0, auth_1.getToken)();
|
|
65
|
+
if (mounted && cached)
|
|
66
|
+
setToken(cached);
|
|
67
|
+
})();
|
|
68
|
+
const loginSub = react_native_1.DeviceEventEmitter.addListener('yaverFeedback:startLogin', () => setLoginVisible(true));
|
|
69
|
+
const pickerSub = react_native_1.DeviceEventEmitter.addListener('yaverFeedback:startMachinePicker', async () => {
|
|
70
|
+
const cached = await (0, auth_1.getToken)();
|
|
71
|
+
if (cached)
|
|
72
|
+
setToken(cached);
|
|
73
|
+
if (cached)
|
|
74
|
+
setPickerVisible(true);
|
|
75
|
+
});
|
|
76
|
+
return () => {
|
|
77
|
+
mounted = false;
|
|
78
|
+
loginSub.remove();
|
|
79
|
+
pickerSub.remove();
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
const handleLoggedIn = async (newToken) => {
|
|
83
|
+
setToken(newToken);
|
|
84
|
+
await YaverFeedback_1.YaverFeedback.setAuthToken(newToken);
|
|
85
|
+
setLoginVisible(false);
|
|
86
|
+
setPickerVisible(true);
|
|
87
|
+
};
|
|
88
|
+
const handleDevicePicked = async (device) => {
|
|
89
|
+
await YaverFeedback_1.YaverFeedback.setPreferredDevice(device.deviceId);
|
|
90
|
+
setPickerVisible(false);
|
|
91
|
+
// Continue straight into the feedback flow the user originally triggered.
|
|
92
|
+
react_native_1.DeviceEventEmitter.emit('yaverFeedback:startReport');
|
|
93
|
+
};
|
|
94
|
+
return (<>
|
|
95
|
+
<react_native_1.Modal visible={loginVisible} animationType="slide" presentationStyle="fullScreen" onRequestClose={() => setLoginVisible(false)}>
|
|
96
|
+
<LoginScreen_1.YaverLoginScreen onLoggedIn={handleLoggedIn} onCancel={() => setLoginVisible(false)}/>
|
|
97
|
+
</react_native_1.Modal>
|
|
98
|
+
|
|
99
|
+
<react_native_1.Modal visible={pickerVisible && !!token} animationType="slide" presentationStyle="fullScreen" onRequestClose={() => setPickerVisible(false)}>
|
|
100
|
+
{token && (<MachinePickerScreen_1.YaverMachinePickerScreen token={token} onPick={handleDevicePicked} onCancel={() => setPickerVisible(false)}/>)}
|
|
101
|
+
</react_native_1.Modal>
|
|
102
|
+
</>);
|
|
103
|
+
};
|
|
104
|
+
exports.AuthOverlay = AuthOverlay;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Black box event types streamed from the device to the agent.
|
|
3
|
+
* These mirror the Go BlackBoxEvent struct on the agent side.
|
|
4
|
+
*/
|
|
5
|
+
export interface BlackBoxEvent {
|
|
6
|
+
type: 'log' | 'error' | 'navigation' | 'lifecycle' | 'network' | 'state' | 'render' | 'track';
|
|
7
|
+
level?: 'info' | 'warn' | 'error';
|
|
8
|
+
message: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
stack?: string[];
|
|
11
|
+
isFatal?: boolean;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
source?: string;
|
|
14
|
+
duration?: number;
|
|
15
|
+
route?: string;
|
|
16
|
+
prevRoute?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Configuration for the black box stream. */
|
|
19
|
+
export interface BlackBoxConfig {
|
|
20
|
+
/** Device identifier (defaults to a generated UUID). */
|
|
21
|
+
deviceId?: string;
|
|
22
|
+
/** Application name for the agent to display. */
|
|
23
|
+
appName?: string;
|
|
24
|
+
/** Flush interval in ms — how often buffered events are sent. Default: 2000. */
|
|
25
|
+
flushInterval?: number;
|
|
26
|
+
/** Max events to buffer before flushing. Default: 50. */
|
|
27
|
+
maxBufferSize?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Flight-recorder-style streaming from the device to the Yaver agent.
|
|
31
|
+
*
|
|
32
|
+
* Captures logs, errors, navigation, lifecycle events, network requests,
|
|
33
|
+
* and state changes — then streams them continuously to the agent's
|
|
34
|
+
* `/blackbox/events` endpoint.
|
|
35
|
+
*
|
|
36
|
+
* The agent uses this context when the developer asks for a fix — it
|
|
37
|
+
* already knows what the app was doing.
|
|
38
|
+
*
|
|
39
|
+
* **Does not hijack any global handlers.** All capture is explicit:
|
|
40
|
+
* - Call `BlackBox.log()` / `.warn()` / `.error()` for console-style logs
|
|
41
|
+
* - Call `BlackBox.navigation()` for screen changes
|
|
42
|
+
* - Call `BlackBox.networkRequest()` for HTTP activity
|
|
43
|
+
* - Use `BlackBox.wrapConsole()` to intercept console.log/warn/error
|
|
44
|
+
* (only if you explicitly opt in — no auto-hooking)
|
|
45
|
+
*/
|
|
46
|
+
/** Command received from the agent via the SSE command channel. */
|
|
47
|
+
export interface BlackBoxCommand {
|
|
48
|
+
command: string;
|
|
49
|
+
data?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
/** Callback type for handling agent commands. */
|
|
52
|
+
export type CommandHandler = (cmd: BlackBoxCommand) => void;
|
|
53
|
+
export declare class BlackBox {
|
|
54
|
+
private static baseUrl;
|
|
55
|
+
private static authToken;
|
|
56
|
+
private static deviceId;
|
|
57
|
+
private static appName;
|
|
58
|
+
private static buffer;
|
|
59
|
+
private static flushTimer;
|
|
60
|
+
private static flushInterval;
|
|
61
|
+
private static maxBufferSize;
|
|
62
|
+
private static started;
|
|
63
|
+
private static originalConsole;
|
|
64
|
+
private static sseAbortController;
|
|
65
|
+
private static sseReconnectTimer;
|
|
66
|
+
private static commandHandlers;
|
|
67
|
+
private static sseConnected;
|
|
68
|
+
/**
|
|
69
|
+
* Start the black box stream. Call after `YaverFeedback.init()`.
|
|
70
|
+
*
|
|
71
|
+
* The stream sends buffered events to the agent every `flushInterval` ms,
|
|
72
|
+
* or immediately when the buffer reaches `maxBufferSize`.
|
|
73
|
+
*/
|
|
74
|
+
static start(config?: BlackBoxConfig): void;
|
|
75
|
+
/** Stop the black box stream and flush remaining events. */
|
|
76
|
+
static stop(): void;
|
|
77
|
+
/** Whether the black box is currently streaming. */
|
|
78
|
+
static get isStreaming(): boolean;
|
|
79
|
+
static log(message: string, source?: string, metadata?: Record<string, unknown>): void;
|
|
80
|
+
static warn(message: string, source?: string, metadata?: Record<string, unknown>): void;
|
|
81
|
+
static error(message: string, source?: string, metadata?: Record<string, unknown>): void;
|
|
82
|
+
/**
|
|
83
|
+
* Record a business event. Fires into the analytics ledger on
|
|
84
|
+
* the agent — see GET /analytics/events.csv.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* BlackBox.track('purchase_completed', {
|
|
89
|
+
* amount: '9.99',
|
|
90
|
+
* currency: 'USD',
|
|
91
|
+
* plan: 'pro',
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
static track(name: string, props?: Record<string, unknown>, route?: string): void;
|
|
96
|
+
/** Record a caught error with stack trace. Also adds to the feedback error buffer. */
|
|
97
|
+
static captureError(err: Error, isFatal?: boolean, metadata?: Record<string, unknown>): void;
|
|
98
|
+
/** Record a screen/route navigation event. */
|
|
99
|
+
static navigation(route: string, prevRoute?: string, metadata?: Record<string, unknown>): void;
|
|
100
|
+
/** Record an app lifecycle event (mount, unmount, background, foreground). */
|
|
101
|
+
static lifecycle(event: string, metadata?: Record<string, unknown>): void;
|
|
102
|
+
/** Record a network request/response. */
|
|
103
|
+
static networkRequest(method: string, url: string, status?: number, durationMs?: number, metadata?: Record<string, unknown>): void;
|
|
104
|
+
/** Record a state change event (Redux action, context update, etc.). */
|
|
105
|
+
static stateChange(description: string, metadata?: Record<string, unknown>): void;
|
|
106
|
+
/** Record a render/re-render event with optional duration. */
|
|
107
|
+
static render(component: string, durationMs?: number, metadata?: Record<string, unknown>): void;
|
|
108
|
+
/**
|
|
109
|
+
* Wrap `console.log`, `console.warn`, and `console.error` to also
|
|
110
|
+
* stream them to the black box. **Call this explicitly** — the SDK
|
|
111
|
+
* never auto-hooks console.
|
|
112
|
+
*
|
|
113
|
+
* Call `BlackBox.unwrapConsole()` to restore originals.
|
|
114
|
+
*/
|
|
115
|
+
static wrapConsole(): void;
|
|
116
|
+
/** Restore original console methods. */
|
|
117
|
+
static unwrapConsole(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Returns a pass-through error handler that streams errors to the
|
|
120
|
+
* black box AND calls the next handler. Same pattern as
|
|
121
|
+
* `YaverFeedback.wrapErrorHandler`, but streams in real-time.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* const existing = ErrorUtils.getGlobalHandler();
|
|
125
|
+
* ErrorUtils.setGlobalHandler(BlackBox.wrapErrorHandler(existing));
|
|
126
|
+
*/
|
|
127
|
+
static wrapErrorHandler(next?: ((error: Error, isFatal?: boolean) => void) | null): (error: Error, isFatal?: boolean) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Register a handler for commands pushed by the agent.
|
|
130
|
+
* The primary use case is receiving "reload" commands when the vibe coder
|
|
131
|
+
* triggers a reload from the Yaver mobile app.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* BlackBox.onCommand((cmd) => {
|
|
135
|
+
* if (cmd.command === 'reload') {
|
|
136
|
+
* DevSettings.reload(); // or Updates.reloadAsync()
|
|
137
|
+
* }
|
|
138
|
+
* });
|
|
139
|
+
*/
|
|
140
|
+
static onCommand(handler: CommandHandler): () => void;
|
|
141
|
+
/** Whether the SSE command channel is connected. */
|
|
142
|
+
static get isCommandChannelConnected(): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Connect to the agent's /blackbox/stream SSE endpoint.
|
|
145
|
+
* This persistent connection allows the agent to push commands (reload, etc.)
|
|
146
|
+
* back to the SDK. Events are still sent via batch POST /blackbox/events.
|
|
147
|
+
*/
|
|
148
|
+
private static connectSSE;
|
|
149
|
+
private static disconnectSSE;
|
|
150
|
+
private static scheduleSSEReconnect;
|
|
151
|
+
private static push;
|
|
152
|
+
private static flush;
|
|
153
|
+
private static generateDeviceId;
|
|
154
|
+
}
|