@blipit/react-native 0.4.0 → 0.6.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/BlipitReactNative.podspec +23 -0
- package/CHANGELOG.md +22 -12
- package/README.md +128 -11
- package/android/build.gradle +32 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/io/blipit/reactnative/BlipitNuggetsModule.kt +114 -0
- package/android/src/main/java/io/blipit/reactnative/BlipitNuggetsPackage.kt +12 -0
- package/dist/index.cjs +955 -164
- package/dist/index.d.cts +137 -11
- package/dist/index.d.ts +137 -11
- package/dist/index.js +871 -74
- package/ios/BlipitNuggets.m +15 -0
- package/ios/BlipitNuggets.swift +96 -0
- package/ios/PrivacyInfo.xcprivacy +39 -0
- package/package.json +7 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "BlipitReactNative"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
s.platforms = { :ios => "13.4" }
|
|
13
|
+
s.source = { :git => "https://github.com/blipit-io/blipit.git", :tag => "react-native-v#{s.version}" }
|
|
14
|
+
s.source_files = "ios/*.{h,m,swift}"
|
|
15
|
+
s.resource_bundles = { "BlipitReactNativePrivacy" => ["ios/PrivacyInfo.xcprivacy"] }
|
|
16
|
+
s.swift_version = "5.9"
|
|
17
|
+
s.dependency "React-Core"
|
|
18
|
+
if defined?(spm_dependency)
|
|
19
|
+
spm_dependency(s, url: "https://github.com/blipit-io/blipit-swift", requirement: { kind: "upToNextMinorVersion", minimumVersion: "0.6.0" }, products: ["BlipitSwift"])
|
|
20
|
+
else
|
|
21
|
+
s.dependency "BlipitSwift", "~> 0.6.0"
|
|
22
|
+
end
|
|
23
|
+
end
|
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
## 0.
|
|
1
|
+
## 0.6.0
|
|
2
2
|
|
|
3
|
-
-
|
|
3
|
+
- Shake to report (`shakeToReport`, off by default): one shake opens the bug reporter on the current screen, never while one is already open.
|
|
4
|
+
- Screenshot to report (`screenshotToReport`, off by default): after a normal screenshot, a small prompt asks "Report a bug with this screen?" and opens the reporter with Blipit's own capture. iOS, and Android 14 or later; the gallery is never read.
|
|
5
|
+
- Two-finger press and hold (`twoFingerReport`, off by default) opens the reporter; touches are only watched, never consumed.
|
|
6
|
+
- Report after a crash (`reportAfterCrash`, off by default): on the first launch after a fatal JavaScript error or native crash, the person is asked what they were doing; the report carries the crash `event_id`, so the crash issue and the report link to each other.
|
|
7
|
+
- Which screen? picker (`screenPicker`, on by default, since it only changes the reporter UI): when `showReport()` is called from a menu, the person picks the current screen or one of the last 3 screens from `trackNavigation`. Snapshots stay in memory, are dropped after 3 minutes in the background or on `setEnabled(false)`, and only the chosen one is uploaded.
|
|
8
|
+
- The floating Report a bug button can be turned on from app.blipit.io for everyone or for testers only, matched on the server against the user set with `setUser`; `<BlipitReporter showButton>` keeps working.
|
|
9
|
+
- Needs blipit-android v0.6.0 and blipit-swift 0.6.0. The native module is now an event emitter (`BlipitReportTrigger`).
|
|
10
|
+
- Prompts and the picker are translated into the reporter's 11 languages, right to left in Arabic.
|
|
11
|
+
- Platform mismatch: when Blipit refuses data because the key belongs to a project for another platform (HTTP 409 platform_mismatch), the SDK logs one clear error (`console.error`) and stops sending for the rest of the launch. Events, sessions and bug reports from JavaScript stop; native crashes stop through blipit-android and blipit-swift 0.6.0.
|
|
4
12
|
|
|
5
|
-
## 0.
|
|
13
|
+
## 0.5.0
|
|
6
14
|
|
|
7
|
-
-
|
|
15
|
+
- Runs on blipit-nuggets, Blipit's own capture core. `@sentry/react-native` is no longer a dependency; uninstall it. Events go to Blipit's own `POST /api/v1/events` with the `X-Blipit-Key` header, sessions to `/api/v1/sessions`.
|
|
16
|
+
- Captured on their own: uncaught JavaScript errors (fatal ones are saved to disk before the app closes and sent on the next launch), unhandled promise rejections on Hermes, and native crashes through Blipit's own Android and iOS SDKs, started by the new `BlipitNuggets` native module.
|
|
17
|
+
- Breadcrumbs for `console.warn` and `console.error`, every `fetch` and `XMLHttpRequest` call (no query, headers or bodies), and React Navigation screens with `trackNavigation(ref)`.
|
|
18
|
+
- Offline queue of up to 30 events kept on the device; 429 answers pause sending for the time the server asks for.
|
|
19
|
+
- `ErrorBoundary` with a fallback; `wrap` reports render errors and passes them on.
|
|
20
|
+
- `setEnabled(false)` turns Blipit off and deletes queued events, for consent screens; `setReplayConsent` and `hasReplayConsent` reach the Android SDK.
|
|
21
|
+
- Stuck screens and flows (`waitForReady`, `reportReady`, `startFlow`, `flowStep`, `endFlow`) keep working and their reports now go through the same on-device queue, 429 handling and `setEnabled` switch as errors.
|
|
22
|
+
- Native crashes need blipit-android v0.5.0 (JitPack) and blipit-swift 0.5.0, Blipit's own native cores.
|
|
23
|
+
- Release defaults to `<bundle id>@<version>+<build>`.
|
|
24
|
+
- iOS privacy manifest bundled with the pod. README has App Store, Google Play and AppGallery checklists.
|
|
25
|
+
- Removed: `dsn()` and `withIdentity()`. Options of the old wrapped library are no longer read. `tracesSampleRate` is accepted but performance traces are not sent in this version.
|
|
8
26
|
|
|
9
|
-
## 0.2.1
|
|
10
|
-
|
|
11
|
-
- Events carry the `npm:@blipit/react-native` package and version, so the dashboard can show when this app runs an old Blipit SDK. A `beforeSend` you pass still runs after it. `VERSION` is exported.
|
|
12
|
-
- No development console notice: events leave through the native transport, which does not expose response headers, and swapping it for the fetch transport in development would change how events are queued offline. The dashboard banner covers updates instead.
|
|
13
|
-
|
|
14
|
-
## 0.2.0
|
|
15
|
-
|
|
16
|
-
- `init` with an empty key or project id logs a warning, returns false and leaves Blipit off instead of throwing. It returns true when started.
|
package/README.md
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Blipit error monitoring for React Native and Expo. Know your app broke before your users tell you.
|
|
4
4
|
|
|
5
|
+
Runs on blipit-nuggets, Blipit's own capture core. No third-party monitoring SDK is installed with it.
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```sh
|
|
8
|
-
npm install @blipit/react-native
|
|
10
|
+
npm install @blipit/react-native
|
|
9
11
|
npx pod-install
|
|
10
12
|
```
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
The package links a small native module, `BlipitNuggets`, that starts Blipit's own native SDKs for native crashes: `blipit-android` (JitPack, `com.github.blipit-io:blipit-android:v0.5.0`) and `blipit-swift` (`https://github.com/blipit-io/blipit-swift`, 0.5.0 or newer). The module's Gradle file adds the JitPack repository on its own. If your `settings.gradle` uses `RepositoriesMode.FAIL_ON_PROJECT_REPOS`, add `maven { url "https://jitpack.io" }` there. On iOS, React Native 0.75 and newer pull `blipit-swift` through Swift Package Manager from the podspec; older versions use the `BlipitSwift` 0.5.0 pod.
|
|
15
|
+
|
|
16
|
+
Expo: run `npx expo prebuild` (or use a development build). Expo Go has no custom native code, so JavaScript errors are still reported there but native crashes are not.
|
|
13
17
|
|
|
14
18
|
## Quick start
|
|
15
19
|
|
|
@@ -23,7 +27,48 @@ Blipit.init({ key: "<public key>", project: <project id>, environment: "producti
|
|
|
23
27
|
export default Blipit.wrap(App);
|
|
24
28
|
```
|
|
25
29
|
|
|
26
|
-
Both values are on the project's Keys page at app.blipit.io. If the key or project id is empty, `init` logs a warning, returns `false` and Blipit stays off; it never throws, so a missing key cannot crash the app at launch.
|
|
30
|
+
Both values are on the project's Keys page at app.blipit.io. If the key or project id is empty, `init` logs a warning, returns `false` and Blipit stays off; it never throws, so a missing key cannot crash the app at launch.
|
|
31
|
+
|
|
32
|
+
Without `release`, the release is read from the app: `<bundle id>@<version>+<build>`.
|
|
33
|
+
|
|
34
|
+
What is reported on its own:
|
|
35
|
+
|
|
36
|
+
- Uncaught JavaScript errors, through React Native's global error handler. Fatal ones are written to disk before the app closes and sent on the next launch.
|
|
37
|
+
- Unhandled promise rejections (Hermes, the default engine).
|
|
38
|
+
- Native crashes on Android and iOS, by Blipit's own native SDKs.
|
|
39
|
+
- Sessions (crash-free rate), when a release is known. Turn off with `autoSessionTracking: false`.
|
|
40
|
+
|
|
41
|
+
Breadcrumbs, kept in a ring of 50 and sent with the next error: `console.warn` and `console.error`, every `fetch` and `XMLHttpRequest` call (method, URL without its query, status, duration; never headers or bodies), and screen changes when you connect React Navigation:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
const navigation = useNavigationContainerRef();
|
|
45
|
+
<NavigationContainer ref={navigation} onReady={() => Blipit.trackNavigation(navigation)}>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Events wait in a queue of up to 30, stored on the device, so errors seen offline are sent later. When Blipit answers 429 the SDK waits for the time the server asks for and keeps the events.
|
|
49
|
+
|
|
50
|
+
## Options
|
|
51
|
+
|
|
52
|
+
| Option | Default | |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `key` / `publicKey` | | The project's public key |
|
|
55
|
+
| `project` | | The project id |
|
|
56
|
+
| `endpoint` | `https://in.blipit.io` | |
|
|
57
|
+
| `environment` | `production` | |
|
|
58
|
+
| `release` | from the app | |
|
|
59
|
+
| `sampleRate` | `1` | Share of errors to send |
|
|
60
|
+
| `maxBreadcrumbs` | `50` | At most 100 |
|
|
61
|
+
| `ignoreErrors` | `[]` | Strings or regular expressions |
|
|
62
|
+
| `beforeSend` | | Change or drop an event; return `null` to drop |
|
|
63
|
+
| `enabled` | `true` | `false` starts with Blipit off |
|
|
64
|
+
| `autoSessionTracking` | `true` | |
|
|
65
|
+
| `enableNative` | `true` | `false` if you start blipit-android or blipit-swift yourself |
|
|
66
|
+
| `waitForReady` | `false` | Watch startup until `reportReady()` |
|
|
67
|
+
| `shakeToReport` | `false` | Shaking the phone opens the bug reporter on the current screen |
|
|
68
|
+
| `screenshotToReport` | `false` | After a normal screenshot, offer "Report a bug with this screen?" |
|
|
69
|
+
| `twoFingerReport` | `false` | A two-finger press and hold (about 1 s) opens the bug reporter |
|
|
70
|
+
| `reportAfterCrash` | `false` | On the first launch after a crash, ask what the person was doing |
|
|
71
|
+
| `screenPicker` | `true` | `showReport()` lets the person pick which recent screen the bug is on |
|
|
27
72
|
|
|
28
73
|
## Manual capture
|
|
29
74
|
|
|
@@ -32,11 +77,28 @@ Blipit.captureException(err);
|
|
|
32
77
|
Blipit.captureMessage("cache miss rate above 50%", "warning");
|
|
33
78
|
Blipit.setUser({ id: "42", email: "ana@example.com" });
|
|
34
79
|
Blipit.setTag("region", "ap-southeast-1");
|
|
35
|
-
Blipit.addBreadcrumb({ category: "
|
|
80
|
+
Blipit.addBreadcrumb({ category: "custom", message: "opened checkout" });
|
|
36
81
|
Blipit.captureSecurity("login_failed", "ana@example.com", { ip: "10.0.0.1" });
|
|
37
82
|
await Blipit.flush();
|
|
38
83
|
```
|
|
39
84
|
|
|
85
|
+
`<Blipit.ErrorBoundary fallback={...}>` reports render errors in a part of the tree and shows the fallback. Without a fallback the error is reported and passed on, as before.
|
|
86
|
+
|
|
87
|
+
## Consent and turning Blipit off
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
Blipit.setEnabled(false);
|
|
91
|
+
Blipit.setEnabled(true);
|
|
92
|
+
Blipit.isEnabled();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`setEnabled(false)` stops capture at once and deletes queued events and breadcrumbs from the device. Use it as the switch behind your own consent screen, or start with `enabled: false` and call `setEnabled(true)` once the person agrees. Session replay on Android needs its own consent, passed to the native SDK:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
Blipit.setReplayConsent(true);
|
|
99
|
+
Blipit.hasReplayConsent();
|
|
100
|
+
```
|
|
101
|
+
|
|
40
102
|
## Bug reports
|
|
41
103
|
|
|
42
104
|
Install `react-native-view-shot` for screenshots, wrap your app in `BlipitReporter` (`showButton` adds the floating Report a bug button) and call `showReport()` from your own menu:
|
|
@@ -55,6 +117,39 @@ Blipit.showReport();
|
|
|
55
117
|
|
|
56
118
|
The reporter asks first: Take a screenshot or Skip. The screenshot opens full screen with the tools above and below it; pinch or double-tap to zoom, mark the problem, then add a title and what happened and send. Without `react-native-view-shot` the report is sent as text. Reports arrive under Bug reports at app.blipit.io.
|
|
57
119
|
|
|
120
|
+
### Report from the screen with the bug
|
|
121
|
+
|
|
122
|
+
A "Report a bug" item in a Profile or Settings menu takes a screenshot of that menu, not of the screen with the problem. Turn on the ways that start the reporter where the bug is:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
Blipit.init({
|
|
126
|
+
key: "<public key>",
|
|
127
|
+
project: <project id>,
|
|
128
|
+
shakeToReport: true,
|
|
129
|
+
screenshotToReport: true,
|
|
130
|
+
twoFingerReport: true,
|
|
131
|
+
reportAfterCrash: true,
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- **Shake to report**: one shake opens one reporter on the current screen. Shakes are ignored while a reporter or a Blipit prompt is open.
|
|
136
|
+
- **Screenshot to report**: when the person takes a normal screenshot, a small prompt asks "Report a bug with this screen?" (Report / Not now, gone after 6 seconds). Report opens the reporter with Blipit's own capture of the screen; the screenshot in the gallery is never read. iOS, and Android 14 or later; older Android versions do nothing.
|
|
137
|
+
- **Two-finger press**: hold two fingers still on the screen for about a second. Blipit only watches touches, so your buttons, lists and gestures keep working.
|
|
138
|
+
- **Report after a crash**: on the first launch after a crash Blipit caught (a fatal JavaScript error or a native crash), a prompt asks "The app closed unexpectedly. Tell us what you were doing?". Tell us opens the reporter (text only, or with a screenshot of the current screen) and the report is linked to that crash: the crash issue shows the report and the report shows the crash. It asks once per crash.
|
|
139
|
+
- **Which screen?** (`screenPicker`, on by default): with `trackNavigation(ref)` set up, Blipit keeps a small snapshot of the last 3 screens the person visited, in memory only. When `showReport()` is called from a menu and the person picks Take a screenshot, they choose the current screen or one of those before marking it up. Only the chosen image is uploaded. Snapshots never touch the disk, crash files or logs, and are dropped after 3 minutes in the background or when `setEnabled(false)` is called. Turn it off with `screenPicker: false`.
|
|
140
|
+
|
|
141
|
+
Shake, screenshot, two-finger and crash detection run in Blipit's native Android and iOS SDKs and open this JavaScript reporter, so `BlipitReporter` must wrap the app and `enableNative` must stay on.
|
|
142
|
+
|
|
143
|
+
### Floating button for testers only
|
|
144
|
+
|
|
145
|
+
At app.blipit.io, Bug reports, Widget settings, set "Floating button" to Off, Everyone or Testers only, and list your testers' user ids or emails. Blipit asks the server whether to show the Report a bug button for the person set with `setUser`, so the tester list never ships in the app:
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
Blipit.setUser({ id: user.id, email: user.email });
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The button follows that answer after start and after each `setUser`. `<BlipitReporter showButton>` still shows it for everyone.
|
|
152
|
+
|
|
58
153
|
## Stuck screens and flows
|
|
59
154
|
|
|
60
155
|
Some failures never crash: the splash screen keeps spinning, or a sign-in promise never settles. Tell Blipit when the app is ready and wrap the flows that must finish:
|
|
@@ -75,17 +170,39 @@ If one does not finish in time, Blipit opens a **Stuck** issue with the flow, th
|
|
|
75
170
|
|
|
76
171
|
Call `startFlow` when the person starts the action (taps Continue with Google), not when the screen opens. `endFlow` covers every way out, including the person cancelling. Flow and step names are sent as you write them: use fixed names such as `sign-in` or `google-picker`, never emails, phone numbers or other personal data.
|
|
77
172
|
|
|
78
|
-
|
|
173
|
+
Stuck reports go through the same on-device queue as errors, so they survive going offline and respect `setEnabled(false)`.
|
|
174
|
+
|
|
175
|
+
## Store checklists
|
|
176
|
+
|
|
177
|
+
What the SDK collects: error type, message and stack, breadcrumbs listed above, OS name and version, device model, screen size, app release, and the user id, email or username only if you call `setUser`. No advertising identifier, no IDFA, no Android advertising ID, no location, no contacts. The SDK does not track people across apps or websites.
|
|
178
|
+
|
|
179
|
+
### Apple App Store
|
|
180
|
+
|
|
181
|
+
- The pod bundles `PrivacyInfo.xcprivacy`: `NSPrivacyTracking` false, no tracking domains, collected types Crash Data and Other Diagnostic Data, not linked, purpose App Functionality. It uses no required-reason API.
|
|
182
|
+
- App Privacy answers in App Store Connect: Diagnostics, Crash Data and Other Diagnostic Data, not used for tracking. If you call `setUser`, also declare User ID and, if you pass it, Email Address, linked to the user, purpose App Functionality.
|
|
183
|
+
- No App Tracking Transparency prompt is needed: the SDK never reads the IDFA and links no AdSupport or AppTrackingTransparency framework.
|
|
184
|
+
- blipit-swift ships its own privacy manifest; Xcode merges both into the app's privacy report.
|
|
185
|
+
- Report triggers use public UIKit only: shake is UIKit's motion event (not CoreMotion, so no motion permission and nothing to declare), screenshot to report listens to `UIApplication.userDidTakeScreenshotNotification` and never reads the photo library, and the two-finger press is a gesture recognizer that does not cancel touches. No private API and no new required-reason API.
|
|
186
|
+
|
|
187
|
+
### Google Play
|
|
188
|
+
|
|
189
|
+
- The module adds no permissions of its own. blipit-android 0.6.0 declares `DETECT_SCREEN_CAPTURE`, a normal install-time permission with no prompt, used only on Android 14 or later when `screenshotToReport` is on. Shake uses the accelerometer through `SensorManager` while the app is open, which needs no permission. `INTERNET` comes from React Native itself.
|
|
190
|
+
- Data safety: screenshot to report only learns that a screenshot was taken; it reads no screenshot, photo, gallery or storage data. A bug report sends only what the person chooses to send (their text, the screen they marked up, an optional email).
|
|
191
|
+
- Data safety form: Crash logs and Diagnostics, collected, not shared, encrypted in transit (HTTPS), purpose App functionality. Add User IDs and Email address if you call `setUser`.
|
|
192
|
+
- No advertising ID, no device identifiers beyond the model name; nothing that Play's Families policy forbids. For child-directed apps keep `setUser` to an internal id.
|
|
193
|
+
- Queued events are stored in the app's no-backup folder, so they are not copied by Android backups.
|
|
79
194
|
|
|
80
|
-
|
|
195
|
+
### Huawei AppGallery
|
|
81
196
|
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
- **Huawei AppGallery**: the Android path needs neither Google Play services nor HMS Core. In your privacy statement, list crash and diagnostic data sent to Blipit (Louward Labs FZC LLC) for app stability, and the same items in the AppGallery Connect privacy section.
|
|
197
|
+
- No Google Mobile Services: the module and blipit-android depend on no `com.google.android.gms` or Firebase library, so the app runs on HarmonyOS and Huawei phones without GMS. Shake, screenshot, two-finger and crash prompts work the same there.
|
|
198
|
+
- In your privacy statement and the AppGallery Connect privacy section, list crash and diagnostic data sent to Blipit (Louward Labs FZC LLC) for app stability, the same items as the Google Play Data safety form above.
|
|
85
199
|
|
|
86
|
-
##
|
|
200
|
+
## Moving from 0.4
|
|
87
201
|
|
|
88
|
-
|
|
202
|
+
- Uninstall `@sentry/react-native`; it is no longer used. Remove its Expo config plugin from `app.json` if you added it for Blipit.
|
|
203
|
+
- `dsn()` and `withIdentity()` are gone; events go to `POST /api/v1/events` with the `X-Blipit-Key` header.
|
|
204
|
+
- `init` takes the options in the table above. Options that belonged to the old wrapped library are no longer read.
|
|
205
|
+
- `tracesSampleRate` is accepted but performance traces are not sent by this version.
|
|
89
206
|
|
|
90
207
|
Docs: https://docs.blipit.io/mobile
|
|
91
208
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
def safeExtGet(prop, fallback) {
|
|
2
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
apply plugin: "com.android.library"
|
|
6
|
+
apply plugin: "kotlin-android"
|
|
7
|
+
|
|
8
|
+
android {
|
|
9
|
+
namespace "io.blipit.reactnative"
|
|
10
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 35)
|
|
11
|
+
|
|
12
|
+
defaultConfig {
|
|
13
|
+
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
14
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 35)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
compileOptions {
|
|
18
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
19
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
repositories {
|
|
24
|
+
google()
|
|
25
|
+
mavenCentral()
|
|
26
|
+
maven { url "https://jitpack.io" }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
dependencies {
|
|
30
|
+
implementation "com.facebook.react:react-android"
|
|
31
|
+
implementation "com.github.blipit-io:blipit-android:v0.6.0"
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
package io.blipit.reactnative
|
|
2
|
+
|
|
3
|
+
import android.os.Build
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
|
+
import com.facebook.react.bridge.ReactMethod
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
10
|
+
import io.blipit.android.Blipit
|
|
11
|
+
import io.blipit.android.BlipitOptions
|
|
12
|
+
import java.io.File
|
|
13
|
+
|
|
14
|
+
class BlipitNuggetsModule(private val context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
15
|
+
override fun getName() = "BlipitNuggets"
|
|
16
|
+
|
|
17
|
+
private val queue: File get() = File(context.noBackupFilesDir, "blipit-nuggets/queue.json")
|
|
18
|
+
|
|
19
|
+
override fun getConstants(): Map<String, Any?> {
|
|
20
|
+
val info = runCatching { context.packageManager.getPackageInfo(context.packageName, 0) }.getOrNull()
|
|
21
|
+
val build = info?.let { if (Build.VERSION.SDK_INT >= 28) it.longVersionCode else @Suppress("DEPRECATION") it.versionCode.toLong() }
|
|
22
|
+
return mapOf(
|
|
23
|
+
"appId" to context.packageName,
|
|
24
|
+
"appVersion" to info?.versionName,
|
|
25
|
+
"appBuild" to build?.toString(),
|
|
26
|
+
"model" to Build.MODEL,
|
|
27
|
+
"osVersion" to Build.VERSION.RELEASE,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ReactMethod
|
|
32
|
+
fun start(key: String, project: String, environment: String?, release: String?, endpoint: String, triggers: ReadableMap?) {
|
|
33
|
+
synchronized(BlipitNuggetsModule::class.java) {
|
|
34
|
+
if (started) return
|
|
35
|
+
runCatching {
|
|
36
|
+
Blipit.init(context.applicationContext, BlipitOptions().apply {
|
|
37
|
+
this.key = key
|
|
38
|
+
this.project = project
|
|
39
|
+
this.environment = environment
|
|
40
|
+
this.release = release
|
|
41
|
+
this.endpoint = endpoint
|
|
42
|
+
shakeToReport = flag(triggers, "shakeToReport")
|
|
43
|
+
screenshotToReport = flag(triggers, "screenshotToReport")
|
|
44
|
+
twoFingerReport = flag(triggers, "twoFingerReport")
|
|
45
|
+
reportAfterCrash = flag(triggers, "reportAfterCrash")
|
|
46
|
+
screenPicker = false
|
|
47
|
+
})
|
|
48
|
+
started = true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
runCatching {
|
|
52
|
+
Blipit.setReportHandler { trigger, crashId -> emit(trigger, crashId) }
|
|
53
|
+
context.currentActivity?.let { Blipit.attach(it) }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private fun flag(map: ReadableMap?, name: String): Boolean = runCatching { map?.hasKey(name) == true && map.getBoolean(name) }.getOrDefault(false)
|
|
58
|
+
|
|
59
|
+
private fun emit(trigger: String, crashId: String?) {
|
|
60
|
+
runCatching {
|
|
61
|
+
val body = Arguments.createMap().apply {
|
|
62
|
+
putString("trigger", trigger)
|
|
63
|
+
if (crashId != null) putString("crashId", crashId) else putNull("crashId")
|
|
64
|
+
}
|
|
65
|
+
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java).emit("BlipitReportTrigger", body)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
fun promptAfterCrash(eventId: String) {
|
|
71
|
+
if (started) runCatching { Blipit.promptAfterCrash(eventId) }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@ReactMethod
|
|
75
|
+
fun addListener(eventName: String) {}
|
|
76
|
+
|
|
77
|
+
@ReactMethod
|
|
78
|
+
fun removeListeners(count: Double) {}
|
|
79
|
+
|
|
80
|
+
@ReactMethod
|
|
81
|
+
fun setUser(id: String?, email: String?, username: String?) {
|
|
82
|
+
if (started) runCatching { Blipit.setUser(id, email, username) }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@ReactMethod
|
|
86
|
+
fun setTag(key: String, value: String) {
|
|
87
|
+
if (started) runCatching { Blipit.setTag(key, value) }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@ReactMethod
|
|
91
|
+
fun setReplayConsent(granted: Boolean) {
|
|
92
|
+
runCatching { Blipit.setReplayConsent(granted) }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
96
|
+
fun hasReplayConsent(): Boolean = runCatching { Blipit.hasReplayConsent() }.getOrDefault(false)
|
|
97
|
+
|
|
98
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
99
|
+
fun save(data: String): Boolean = runCatching {
|
|
100
|
+
val target = queue
|
|
101
|
+
target.parentFile?.mkdirs()
|
|
102
|
+
val tmp = File(target.parentFile, "queue.json.tmp")
|
|
103
|
+
tmp.writeText(data)
|
|
104
|
+
tmp.renameTo(target)
|
|
105
|
+
}.getOrDefault(false)
|
|
106
|
+
|
|
107
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
108
|
+
fun load(): String? = runCatching { queue.takeIf { it.exists() }?.readText() }.getOrNull()
|
|
109
|
+
|
|
110
|
+
companion object {
|
|
111
|
+
@Volatile
|
|
112
|
+
private var started = false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package io.blipit.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class BlipitNuggetsPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(context: ReactApplicationContext): List<NativeModule> = listOf(BlipitNuggetsModule(context))
|
|
10
|
+
|
|
11
|
+
override fun createViewManagers(context: ReactApplicationContext): List<ViewManager<*, *>> = emptyList()
|
|
12
|
+
}
|