@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,15 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
|
|
4
|
+
@interface RCT_EXTERN_MODULE(BlipitNuggets, RCTEventEmitter)
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(start:(NSString *)key project:(NSString *)project environment:(NSString *)environment release:(NSString *)release endpoint:(NSString *)endpoint triggers:(NSDictionary *)triggers)
|
|
7
|
+
RCT_EXTERN_METHOD(promptAfterCrash:(NSString *)eventId)
|
|
8
|
+
RCT_EXTERN_METHOD(setUser:(NSString *)id email:(NSString *)email username:(NSString *)username)
|
|
9
|
+
RCT_EXTERN_METHOD(setTag:(NSString *)key value:(NSString *)value)
|
|
10
|
+
RCT_EXTERN_METHOD(setReplayConsent:(BOOL)granted)
|
|
11
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(hasReplayConsent)
|
|
12
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(save:(NSString *)data)
|
|
13
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(load)
|
|
14
|
+
|
|
15
|
+
@end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import React
|
|
4
|
+
import BlipitSwift
|
|
5
|
+
|
|
6
|
+
@objc(BlipitNuggets)
|
|
7
|
+
final class BlipitNuggets: RCTEventEmitter {
|
|
8
|
+
private static var started = false
|
|
9
|
+
private static let lock = NSLock()
|
|
10
|
+
private static weak var emitter: BlipitNuggets?
|
|
11
|
+
private var listening = false
|
|
12
|
+
|
|
13
|
+
@objc static func requiresMainQueueSetup() -> Bool { false }
|
|
14
|
+
|
|
15
|
+
override func supportedEvents() -> [String]! { ["BlipitReportTrigger"] }
|
|
16
|
+
|
|
17
|
+
override func startObserving() { listening = true }
|
|
18
|
+
|
|
19
|
+
override func stopObserving() { listening = false }
|
|
20
|
+
|
|
21
|
+
@objc func constantsToExport() -> [AnyHashable: Any]! {
|
|
22
|
+
let info = Bundle.main.infoDictionary ?? [:]
|
|
23
|
+
var size = utsname()
|
|
24
|
+
uname(&size)
|
|
25
|
+
let model = withUnsafePointer(to: &size.machine) { $0.withMemoryRebound(to: CChar.self, capacity: 1) { String(cString: $0) } }
|
|
26
|
+
return [
|
|
27
|
+
"appId": Bundle.main.bundleIdentifier ?? "",
|
|
28
|
+
"appVersion": info["CFBundleShortVersionString"] as? String ?? "",
|
|
29
|
+
"appBuild": info["CFBundleVersion"] as? String ?? "",
|
|
30
|
+
"model": model,
|
|
31
|
+
"osVersion": UIDevice.current.systemVersion,
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private var queue: URL {
|
|
36
|
+
let base = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
|
|
37
|
+
return base.appendingPathComponent("blipit-nuggets/queue.json")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc func start(_ key: String, project: String, environment: String?, release: String?, endpoint: String, triggers: NSDictionary?) {
|
|
41
|
+
BlipitNuggets.emitter = self
|
|
42
|
+
BlipitNuggets.lock.lock()
|
|
43
|
+
defer { BlipitNuggets.lock.unlock() }
|
|
44
|
+
if BlipitNuggets.started { return }
|
|
45
|
+
let flag = { (name: String) in (triggers?[name] as? Bool) ?? false }
|
|
46
|
+
BlipitNuggets.started = Blipit.start(key: key, project: project, environment: environment, release: release, endpoint: endpoint) { options in
|
|
47
|
+
options.shakeToReport = flag("shakeToReport")
|
|
48
|
+
options.screenshotToReport = flag("screenshotToReport")
|
|
49
|
+
options.twoFingerReport = flag("twoFingerReport")
|
|
50
|
+
options.reportAfterCrash = flag("reportAfterCrash")
|
|
51
|
+
options.screenPicker = false
|
|
52
|
+
}
|
|
53
|
+
if #available(iOS 15.0, *), BlipitNuggets.started {
|
|
54
|
+
Blipit.setReportHandler { trigger, crashId in
|
|
55
|
+
guard let emitter = BlipitNuggets.emitter, emitter.listening else { return }
|
|
56
|
+
emitter.sendEvent(withName: "BlipitReportTrigger", body: ["trigger": trigger, "crashId": crashId ?? NSNull()])
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@objc func promptAfterCrash(_ eventId: String) {
|
|
62
|
+
if #available(iOS 15.0, *), BlipitNuggets.started { Blipit.promptAfterCrash(eventId) }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@objc func setUser(_ id: String?, email: String?, username: String?) {
|
|
66
|
+
if BlipitNuggets.started { Blipit.setUser(id: id, email: email, username: username) }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@objc func setTag(_ key: String, value: String) {
|
|
70
|
+
if BlipitNuggets.started { Blipit.setTag(key, value) }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@objc func setReplayConsent(_ granted: Bool) {}
|
|
74
|
+
|
|
75
|
+
@objc func hasReplayConsent() -> NSNumber { false }
|
|
76
|
+
|
|
77
|
+
@objc func save(_ data: String) -> NSNumber {
|
|
78
|
+
let url = queue
|
|
79
|
+
do {
|
|
80
|
+
var dir = url.deletingLastPathComponent()
|
|
81
|
+
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
|
|
82
|
+
var values = URLResourceValues()
|
|
83
|
+
values.isExcludedFromBackup = true
|
|
84
|
+
try? dir.setResourceValues(values)
|
|
85
|
+
try Data(data.utf8).write(to: url, options: [.atomic, .completeFileProtectionUntilFirstUserAuthentication])
|
|
86
|
+
return true
|
|
87
|
+
} catch {
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@objc func load() -> String? {
|
|
93
|
+
guard let data = try? Data(contentsOf: queue) else { return nil }
|
|
94
|
+
return String(data: data, encoding: .utf8)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>NSPrivacyTracking</key>
|
|
6
|
+
<false/>
|
|
7
|
+
<key>NSPrivacyTrackingDomains</key>
|
|
8
|
+
<array/>
|
|
9
|
+
<key>NSPrivacyCollectedDataTypes</key>
|
|
10
|
+
<array>
|
|
11
|
+
<dict>
|
|
12
|
+
<key>NSPrivacyCollectedDataType</key>
|
|
13
|
+
<string>NSPrivacyCollectedDataTypeCrashData</string>
|
|
14
|
+
<key>NSPrivacyCollectedDataTypeLinked</key>
|
|
15
|
+
<false/>
|
|
16
|
+
<key>NSPrivacyCollectedDataTypeTracking</key>
|
|
17
|
+
<false/>
|
|
18
|
+
<key>NSPrivacyCollectedDataTypePurposes</key>
|
|
19
|
+
<array>
|
|
20
|
+
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
|
|
21
|
+
</array>
|
|
22
|
+
</dict>
|
|
23
|
+
<dict>
|
|
24
|
+
<key>NSPrivacyCollectedDataType</key>
|
|
25
|
+
<string>NSPrivacyCollectedDataTypeOtherDiagnosticData</string>
|
|
26
|
+
<key>NSPrivacyCollectedDataTypeLinked</key>
|
|
27
|
+
<false/>
|
|
28
|
+
<key>NSPrivacyCollectedDataTypeTracking</key>
|
|
29
|
+
<false/>
|
|
30
|
+
<key>NSPrivacyCollectedDataTypePurposes</key>
|
|
31
|
+
<array>
|
|
32
|
+
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
|
|
33
|
+
</array>
|
|
34
|
+
</dict>
|
|
35
|
+
</array>
|
|
36
|
+
<key>NSPrivacyAccessedAPITypes</key>
|
|
37
|
+
<array/>
|
|
38
|
+
</dict>
|
|
39
|
+
</plist>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blipit/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Blipit error monitoring for React Native and Expo. Know your app broke before your users tell you.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,11 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
|
+
"android/build.gradle",
|
|
20
|
+
"android/src",
|
|
21
|
+
"ios",
|
|
22
|
+
"BlipitReactNative.podspec",
|
|
19
23
|
"CHANGELOG.md"
|
|
20
24
|
],
|
|
21
25
|
"sideEffects": false,
|
|
22
26
|
"peerDependencies": {
|
|
23
|
-
"@sentry/react-native": ">=6",
|
|
24
27
|
"react": ">=18",
|
|
25
28
|
"react-native": ">=0.72",
|
|
26
29
|
"react-native-view-shot": ">=3"
|
|
@@ -31,7 +34,6 @@
|
|
|
31
34
|
}
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
|
-
"@sentry/react-native": "^8.28.0",
|
|
35
37
|
"@types/node": "^22.0.0",
|
|
36
38
|
"@types/react": "^19.0.0",
|
|
37
39
|
"react": "^19.0.0",
|
|
@@ -56,11 +58,12 @@
|
|
|
56
58
|
"react-native",
|
|
57
59
|
"expo",
|
|
58
60
|
"error-monitoring",
|
|
61
|
+
"crash-reporting",
|
|
59
62
|
"blipit"
|
|
60
63
|
],
|
|
61
64
|
"scripts": {
|
|
62
65
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --external react-native-view-shot",
|
|
63
66
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
64
|
-
"test": "node --experimental-strip-types --experimental-test-module-mocks --import ./test/tsx-hook.mjs --test test/init.test.ts test/report.test.ts test/stuck.test.ts"
|
|
67
|
+
"test": "node --experimental-strip-types --experimental-test-module-mocks --import ./test/tsx-hook.mjs --test test/init.test.ts test/report.test.ts test/nuggets.test.ts test/stuck.test.ts test/triggers.test.ts"
|
|
65
68
|
}
|
|
66
69
|
}
|