@bbearai/react-native 0.3.7 → 0.3.9

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.
Files changed (4) hide show
  1. package/README.md +139 -92
  2. package/dist/index.js +343 -171
  3. package/dist/index.mjs +346 -173
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -34,6 +34,7 @@ function App() {
34
34
  getCurrentUser: async () => ({
35
35
  id: user.id,
36
36
  email: user.email,
37
+ name: user.name, // Optional, shown on reports
37
38
  }),
38
39
  }}
39
40
  >
@@ -44,6 +45,138 @@ function App() {
44
45
  }
45
46
  ```
46
47
 
48
+ ## Configuration Options
49
+
50
+ ```tsx
51
+ <BugBearProvider
52
+ config={{
53
+ // Required
54
+ projectId: 'your-project-id',
55
+ getCurrentUser: async () => ({ id: user.id, email: user.email }),
56
+
57
+ // Optional — rich context for bug reports
58
+ getAppContext: () => ({
59
+ currentRoute: currentScreenName, // Current screen name
60
+ userRole: currentUser?.role, // 'owner', 'manager', 'guest', etc.
61
+ propertyId: selectedProperty?.id, // App-specific context
62
+ custom: { theme: 'dark' }, // Any additional data
63
+ }),
64
+
65
+ // Optional — callbacks
66
+ dashboardUrl: 'https://app.bugbear.ai', // Web dashboard link in widget
67
+ onNavigate: (route) => navigation.navigate(route), // Deep link handler for test cases
68
+ onReportSubmitted: (report) => { ... }, // After report submission
69
+ getNavigationHistory: () => [...recentScreens], // Custom nav tracking
70
+
71
+ // Optional — self-hosted
72
+ supabaseUrl: '...',
73
+ supabaseAnonKey: '...',
74
+ }}
75
+ enabled={isAuthReady} // Delay init until auth is ready (default: true)
76
+ >
77
+ ```
78
+
79
+ ### Why use `getAppContext`?
80
+
81
+ When a tester reports a bug, BugBear attaches the app context to the report. This tells the developer fixing the bug:
82
+ - **Which screen** the bug is on
83
+ - **What role** the user has (critical for role-dependent bugs)
84
+ - **App-specific state** like selected property, active filters, etc.
85
+
86
+ The bug report form also includes a **"Which screen?"** field so testers can specify the affected screen manually.
87
+
88
+ ## Automatic Context Capture
89
+
90
+ BugBearProvider automatically captures debugging context with zero configuration:
91
+
92
+ | Data | Details |
93
+ |------|---------|
94
+ | **Console logs** | Last 50 `console.log/warn/error/info` calls |
95
+ | **Network requests** | Last 20 `fetch()` calls with method, URL, status, duration |
96
+ | **Failed response bodies** | First 500 chars of 4xx/5xx response bodies |
97
+ | **Performance** | Page load time, memory usage |
98
+ | **Environment** | Language, timezone, online status |
99
+
100
+ This data is attached to every bug report and available to the MCP server's `get_report_context` tool for AI-assisted debugging.
101
+
102
+ > **Note:** For React Native, navigation history is not auto-captured (no `pushState`). Use `getNavigationHistory` or React Navigation integration below for screen tracking.
103
+
104
+ ## Navigation Tracking
105
+
106
+ ### React Navigation integration
107
+
108
+ ```tsx
109
+ import { useNavigationContainerRef } from '@react-navigation/native';
110
+
111
+ function App() {
112
+ const navigationRef = useNavigationContainerRef();
113
+ const routeHistory = useRef<string[]>([]);
114
+
115
+ return (
116
+ <BugBearProvider
117
+ config={{
118
+ projectId: 'your-project-id',
119
+ getCurrentUser: async () => ({ id: user.id, email: user.email }),
120
+ getNavigationHistory: () => routeHistory.current,
121
+ getAppContext: () => ({
122
+ currentRoute: navigationRef.getCurrentRoute()?.name || 'unknown',
123
+ userRole: currentUser?.role,
124
+ }),
125
+ }}
126
+ >
127
+ <NavigationContainer
128
+ ref={navigationRef}
129
+ onStateChange={() => {
130
+ const name = navigationRef.getCurrentRoute()?.name;
131
+ if (name) {
132
+ routeHistory.current.push(name);
133
+ // Keep last 20
134
+ if (routeHistory.current.length > 20) routeHistory.current.shift();
135
+ }
136
+ }}
137
+ >
138
+ {/* Your navigation */}
139
+ </NavigationContainer>
140
+ <BugBearButton />
141
+ </BugBearProvider>
142
+ );
143
+ }
144
+ ```
145
+
146
+ ## Widget Architecture
147
+
148
+ The widget uses a navigation stack pattern with 10 screens:
149
+
150
+ | Screen | Purpose |
151
+ |--------|---------|
152
+ | **Home** | Smart hero banner + 2x2 action grid + progress bar + web dashboard link |
153
+ | **Test Detail** | One-test-at-a-time execution with pass/fail/skip actions |
154
+ | **Test List** | All assignments grouped by folder with filter bar |
155
+ | **Test Feedback** | Star rating + quality flags after pass/fail |
156
+ | **Report** | Bug/feedback submission with type, severity, description, affected screen |
157
+ | **Report Success** | Confirmation with auto-return to home |
158
+ | **Message List** | Thread list with unread badges + compose button |
159
+ | **Thread Detail** | Chat bubbles + reply composer |
160
+ | **Compose Message** | New thread form with subject + message |
161
+ | **Profile** | Tester info, stats, and editable fields |
162
+
163
+ ## Button Configuration
164
+
165
+ The BugBear button is draggable by default with edge-snapping behavior:
166
+
167
+ ```tsx
168
+ <BugBearButton
169
+ draggable={true} // Enable/disable dragging (default: true)
170
+ position="bottom-right" // Initial position: 'bottom-right' | 'bottom-left'
171
+ initialX={100} // Custom initial X position (optional)
172
+ initialY={500} // Custom initial Y position (optional)
173
+ minY={100} // Minimum Y from top (default: 100)
174
+ maxYOffset={160} // Max Y offset from bottom (default: 160)
175
+ />
176
+ ```
177
+
178
+ The button automatically snaps to the nearest screen edge when released.
179
+
47
180
  ## Monorepo Setup
48
181
 
49
182
  When using BugBear in a monorepo (e.g., with Turborepo, Nx, or Yarn Workspaces), you may encounter React duplicate instance errors like:
@@ -105,90 +238,6 @@ If you're using Yarn workspaces, you can also configure hoisting to ensure a sin
105
238
  }
106
239
  ```
107
240
 
108
- ## Configuration Options
109
-
110
- ```tsx
111
- <BugBearProvider
112
- config={{
113
- projectId: 'your-project-id', // Required: Your BugBear project ID
114
- getCurrentUser: async () => {...}, // Required: Return current user info
115
- dashboardUrl: 'https://app.bugbear.ai', // Optional: Web dashboard link in widget
116
- getNavigationHistory: () => [...], // Optional: Custom navigation tracking
117
- onNavigate: (route) => {...}, // Optional: Deep link handler for test cases
118
- onReportSubmitted: (report) => {...}, // Optional: Callback after report submission
119
- }}
120
- >
121
- ```
122
-
123
- ## Widget Architecture
124
-
125
- The widget uses a navigation stack pattern with 10 screens:
126
-
127
- | Screen | Purpose |
128
- |--------|---------|
129
- | **Home** | Smart hero banner + 2x2 action grid + progress bar + web dashboard link |
130
- | **Test Detail** | One-test-at-a-time execution with pass/fail/skip actions |
131
- | **Test List** | All assignments grouped by folder with filter bar |
132
- | **Test Feedback** | Star rating + quality flags after pass/fail |
133
- | **Report** | Bug/feedback submission with type, severity, description |
134
- | **Report Success** | Confirmation with auto-return to home |
135
- | **Message List** | Thread list with unread badges + compose button |
136
- | **Thread Detail** | Chat bubbles + reply composer |
137
- | **Compose Message** | New thread form with subject + message |
138
- | **Profile** | Tester info, stats, and editable fields |
139
-
140
- ## Navigation Tracking
141
-
142
- BugBear can automatically track navigation history for better bug context. If you're using React Navigation:
143
-
144
- ```tsx
145
- import { useNavigationContainerRef } from '@react-navigation/native';
146
-
147
- function App() {
148
- const navigationRef = useNavigationContainerRef();
149
- const routeNameRef = useRef<string>();
150
-
151
- return (
152
- <BugBearProvider
153
- projectId="your-project-id"
154
- getCurrentUser={...}
155
- getNavigationHistory={() => routeNameRef.current ? [routeNameRef.current] : []}
156
- >
157
- <NavigationContainer
158
- ref={navigationRef}
159
- onReady={() => {
160
- routeNameRef.current = navigationRef.getCurrentRoute()?.name;
161
- }}
162
- onStateChange={() => {
163
- const currentRouteName = navigationRef.getCurrentRoute()?.name;
164
- routeNameRef.current = currentRouteName;
165
- }}
166
- >
167
- {/* Your navigation */}
168
- </NavigationContainer>
169
- <BugBearWidget />
170
- </BugBearProvider>
171
- );
172
- }
173
- ```
174
-
175
- ## Button Configuration
176
-
177
- The BugBear button is draggable by default with edge-snapping behavior:
178
-
179
- ```tsx
180
- <BugBearButton
181
- draggable={true} // Enable/disable dragging (default: true)
182
- position="bottom-right" // Initial position: 'bottom-right' | 'bottom-left'
183
- initialX={100} // Custom initial X position (optional)
184
- initialY={500} // Custom initial Y position (optional)
185
- minY={100} // Minimum Y from top (default: 100)
186
- maxYOffset={160} // Max Y offset from bottom (default: 160)
187
- />
188
- ```
189
-
190
- The button automatically snaps to the nearest screen edge when released.
191
-
192
241
  ## Troubleshooting
193
242
 
194
243
  ### Widget not showing
@@ -203,10 +252,12 @@ If you're using your own Supabase instance, provide the credentials:
203
252
 
204
253
  ```tsx
205
254
  <BugBearProvider
206
- projectId="your-project-id"
207
- supabaseUrl="https://your-instance.supabase.co"
208
- supabaseAnonKey="your-anon-key"
209
- getCurrentUser={...}
255
+ config={{
256
+ projectId: 'your-project-id',
257
+ supabaseUrl: 'https://your-instance.supabase.co',
258
+ supabaseAnonKey: 'your-anon-key',
259
+ getCurrentUser: async () => ({ id: user.id, email: user.email }),
260
+ }}
210
261
  >
211
262
  ```
212
263
 
@@ -216,15 +267,11 @@ If you're using your own Supabase instance, provide the credentials:
216
267
 
217
268
  The BugBear button renders within the normal React Native view hierarchy using absolute positioning. When your app displays modals, bottom sheets, or the keyboard, the button may be hidden behind them.
218
269
 
219
- This is a platform limitation - React Native doesn't provide a built-in way to render views above all modals without using a Modal component (which would block touch events on the underlying app).
220
-
221
270
  **Workarounds:**
222
271
  - Accept that the button won't be accessible when modals are open
223
272
  - Consider dismissing the modal to access BugBear
224
273
  - For testing flows that involve modals, provide an alternative way to trigger the BugBear widget
225
274
 
226
- We're investigating solutions using `react-native-portal` or similar libraries for future releases.
227
-
228
275
  ## License
229
276
 
230
277
  MIT