@logbrew/react-native 0.1.43 → 0.1.45
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 +26 -0
- package/android/src/main/java/co/logbrew/reactnative/FatalStoreModuleImpl.java +14 -0
- package/android/src/newarch/java/co/logbrew/reactnative/FatalStoreModule.java +5 -0
- package/android/src/oldarch/java/co/logbrew/reactnative/FatalStoreModule.java +5 -0
- package/app-start.js +67 -0
- package/index.cjs +1 -1
- package/index.native.d.ts +7 -1
- package/index.native.js +7 -1
- package/ios/AppleDiagnostics/LBRNAppleNativeDiagnostics.swift +2 -1
- package/ios/GeneratedAppleDiagnostics/LogBrew/AppStartMetric.swift +117 -0
- package/ios/GeneratedAppleDiagnostics/LogBrew/LogBrewClient.swift +16 -1
- package/ios/GeneratedAppleDiagnostics/LogBrew/PublicTypes.swift +3 -0
- package/ios/GeneratedAppleDiagnostics/SOURCE-MANIFEST.json +3 -2
- package/ios/LBRNFatalStoreModule.mm +17 -0
- package/package.json +3 -2
- package/src/NativeLogBrewFatalStore.ts +1 -0
package/README.md
CHANGED
|
@@ -91,6 +91,32 @@ sends after authentication, usage-limit, or non-retryable failures. Do not add a
|
|
|
91
91
|
Helpers generate a fresh opaque event ID by default. Explicit `id` and
|
|
92
92
|
`idFactory` values remain available for app-owned idempotency.
|
|
93
93
|
|
|
94
|
+
### App Start Metric
|
|
95
|
+
|
|
96
|
+
The React Native client sends one cold start metric per process. You do not
|
|
97
|
+
need extra app code. The metric has these values:
|
|
98
|
+
|
|
99
|
+
- `name`: `app.start.duration`
|
|
100
|
+
- `kind`: `histogram`, with `temporality` `delta`
|
|
101
|
+
- `unit`: `ms`
|
|
102
|
+
- `value`: the time from process start to the first frame after the package
|
|
103
|
+
loads
|
|
104
|
+
- `metadata`: `{ startType: "cold" }`
|
|
105
|
+
|
|
106
|
+
The process start time comes from the linked native module, so the metric
|
|
107
|
+
needs a development build or a bare app. Expo Go sends no metric. The metric
|
|
108
|
+
is not sent for iOS prewarmed launches or for values above 60 seconds.
|
|
109
|
+
Import the package and create the client in your app entry file, before the
|
|
110
|
+
first screen renders. To turn the metric off, set `captureAppStart: false`:
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
const client = createLogBrewReactNativeClient({
|
|
114
|
+
clientKey,
|
|
115
|
+
captureAppStart: false,
|
|
116
|
+
transport: createReactNativeFetchTransport()
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
94
120
|
## Confirm Hosted Delivery And Event Visibility
|
|
95
121
|
|
|
96
122
|
Call `verifyLogBrewSetup()` once from a development-only button or setup
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
package co.logbrew.reactnative;
|
|
2
2
|
|
|
3
|
+
import android.os.Build;
|
|
4
|
+
import android.os.Process;
|
|
5
|
+
import android.os.SystemClock;
|
|
3
6
|
import com.facebook.react.bridge.Arguments;
|
|
4
7
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
8
|
import com.facebook.react.bridge.ReadableArray;
|
|
@@ -46,6 +49,17 @@ final class FatalStoreModuleImpl {
|
|
|
46
49
|
eventStoreParent = root;
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
double processStartTime() {
|
|
53
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
long startedAt =
|
|
57
|
+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
|
|
58
|
+
? Process.getStartRequestedElapsedRealtime()
|
|
59
|
+
: Process.getStartElapsedRealtime();
|
|
60
|
+
return System.currentTimeMillis() - (SystemClock.elapsedRealtime() - startedAt);
|
|
61
|
+
}
|
|
62
|
+
|
|
49
63
|
String secureRandomHex(double length) {
|
|
50
64
|
Integer byteCount = integer(length);
|
|
51
65
|
if (byteCount == null || byteCount < 1 || byteCount > 64) {
|
|
@@ -18,6 +18,11 @@ final class FatalStoreModule extends NativeLogBrewFatalStoreSpec {
|
|
|
18
18
|
return FatalStoreModuleImpl.NAME;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
@Override
|
|
22
|
+
public double processStartTime() {
|
|
23
|
+
return implementation.processStartTime();
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
@Override
|
|
22
27
|
public String secureRandomHex(double length) {
|
|
23
28
|
return implementation.secureRandomHex(length);
|
|
@@ -20,6 +20,11 @@ final class FatalStoreModule extends ReactContextBaseJavaModule {
|
|
|
20
20
|
return FatalStoreModuleImpl.NAME;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
24
|
+
public double processStartTime() {
|
|
25
|
+
return implementation.processStartTime();
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
24
29
|
public String secureRandomHex(double length) {
|
|
25
30
|
return implementation.secureRandomHex(length);
|
package/app-start.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import random from "./index-random.cjs";
|
|
2
|
+
import { readField } from "./native-diagnostics-values.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @import { LogBrewClient } from "@logbrew/sdk"
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MAX_APP_START_MS = 60_000;
|
|
9
|
+
|
|
10
|
+
/** @type {Promise<number>} */
|
|
11
|
+
const firstFrameAt = new Promise((resolve) => {
|
|
12
|
+
const markFrame = () => {
|
|
13
|
+
resolve(Date.now());
|
|
14
|
+
};
|
|
15
|
+
const requestFrame = readField(globalThis, "requestAnimationFrame");
|
|
16
|
+
if (typeof requestFrame === "function") {
|
|
17
|
+
Reflect.apply(requestFrame, globalThis, [markFrame]);
|
|
18
|
+
} else {
|
|
19
|
+
setTimeout(markFrame, 0);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
let claimed = false;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {LogBrewClient} client
|
|
26
|
+
* @param {unknown} nativeRuntime
|
|
27
|
+
* @param {number} frameAt
|
|
28
|
+
*/
|
|
29
|
+
function sendAppStartMetric(client, nativeRuntime, frameAt) {
|
|
30
|
+
const processStartTime = readField(nativeRuntime, "processStartTime");
|
|
31
|
+
/** @type {unknown} */
|
|
32
|
+
const startedAt = typeof processStartTime === "function" ? Reflect.apply(processStartTime, nativeRuntime, []) : undefined;
|
|
33
|
+
if (typeof startedAt !== "number" || startedAt <= 0) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const durationMs = frameAt - startedAt;
|
|
37
|
+
if (!(durationMs >= 0 && durationMs <= MAX_APP_START_MS)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
client.metric(random.defaultEventId("app_start"), new Date(frameAt).toISOString(), {
|
|
41
|
+
name: "app.start.duration",
|
|
42
|
+
description: "Time from process start to the first frame.",
|
|
43
|
+
kind: "histogram",
|
|
44
|
+
value: durationMs,
|
|
45
|
+
unit: "ms",
|
|
46
|
+
temporality: "delta",
|
|
47
|
+
metadata: { startType: "cold" }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sends one cold start metric per process after the first frame.
|
|
53
|
+
*
|
|
54
|
+
* @param {LogBrewClient} client
|
|
55
|
+
* @param {unknown} nativeRuntime
|
|
56
|
+
*/
|
|
57
|
+
function captureAppStart(client, nativeRuntime) {
|
|
58
|
+
if (claimed) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
claimed = true;
|
|
62
|
+
firstFrameAt.then((frameAt) => {
|
|
63
|
+
sendAppStartMetric(client, nativeRuntime, frameAt);
|
|
64
|
+
}).catch(() => undefined);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { captureAppStart };
|
package/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ const { getReactNativeContext } = require("./index-values.cjs");
|
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
const DEFAULT_SDK_NAME = "logbrew-react-native";
|
|
39
|
-
const DEFAULT_SDK_VERSION = "0.1.
|
|
39
|
+
const DEFAULT_SDK_VERSION = "0.1.45";
|
|
40
40
|
const DEFAULT_REACT_NATIVE_DELIVERY_INTERVAL_MS = 1000;
|
|
41
41
|
const DEFAULT_MAX_RETRIES = 2;
|
|
42
42
|
|
package/index.native.d.ts
CHANGED
|
@@ -25,7 +25,13 @@ import type indexDefault from "./index.js";
|
|
|
25
25
|
type ReactNativePersistentQueueMode = "auto" | "required" | "disabled";
|
|
26
26
|
|
|
27
27
|
type CreateNativeLogBrewReactNativeClientConfig =
|
|
28
|
-
Omit<CreateLogBrewReactNativeClientConfig, "eventStore"> &
|
|
28
|
+
Omit<CreateLogBrewReactNativeClientConfig, "eventStore"> & {
|
|
29
|
+
/**
|
|
30
|
+
* Sends one `app.start.duration` metric per process: milliseconds from process start
|
|
31
|
+
* to the first frame. Defaults to `true`. Set `false` to turn it off.
|
|
32
|
+
*/
|
|
33
|
+
captureAppStart?: boolean;
|
|
34
|
+
} & ({
|
|
29
35
|
/**
|
|
30
36
|
* `auto` uses the linked app-private native queue when available and otherwise uses memory.
|
|
31
37
|
* `required` fails client creation when the native queue is unavailable. `disabled` uses memory.
|
package/index.native.js
CHANGED
|
@@ -9,6 +9,7 @@ import baseDefault, {
|
|
|
9
9
|
createLogBrewReactNativeClient as createPlatformNeutralClient,
|
|
10
10
|
getReactNativeContext
|
|
11
11
|
} from "./index.js";
|
|
12
|
+
import { captureAppStart } from "./app-start.js";
|
|
12
13
|
import { bindAndroidNativeDelivery, bindAppleNativeCrashBreadcrumbs } from "./native-client-bindings.js";
|
|
13
14
|
import {
|
|
14
15
|
getLogBrewAndroidNativeDiagnosticsStatus,
|
|
@@ -87,6 +88,7 @@ function createLogBrewReactNativeClient(config = {}) {
|
|
|
87
88
|
const input = isObjectInput(config) ? config : {};
|
|
88
89
|
const {
|
|
89
90
|
apiKey,
|
|
91
|
+
captureAppStart: shouldCaptureAppStart = true,
|
|
90
92
|
clientKey,
|
|
91
93
|
eventStore,
|
|
92
94
|
maxQueueBytes,
|
|
@@ -107,7 +109,11 @@ function createLogBrewReactNativeClient(config = {}) {
|
|
|
107
109
|
maxQueueSize,
|
|
108
110
|
persistentQueue
|
|
109
111
|
});
|
|
110
|
-
|
|
112
|
+
const client = createResolvedClient({ ...forwarded, apiKey, clientKey, maxQueueBytes, maxQueueSize }, resolved);
|
|
113
|
+
if (shouldCaptureAppStart !== false) {
|
|
114
|
+
captureAppStart(client, nativeRuntime);
|
|
115
|
+
}
|
|
116
|
+
return client;
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
/**
|
|
@@ -3,7 +3,7 @@ import Foundation
|
|
|
3
3
|
@objc(LBRNAppleNativeDiagnostics)
|
|
4
4
|
public final class LBRNAppleNativeDiagnostics: NSObject, @unchecked Sendable {
|
|
5
5
|
private static let shared = LBRNAppleNativeDiagnostics()
|
|
6
|
-
private static let sdkVersion = "0.1.
|
|
6
|
+
private static let sdkVersion = "0.1.45"
|
|
7
7
|
|
|
8
8
|
private let lock = NSLock()
|
|
9
9
|
private let replayQueue = DispatchQueue(label: "co.logbrew.react-native.apple-diagnostics-replay")
|
|
@@ -87,6 +87,7 @@ public final class LBRNAppleNativeDiagnostics: NSObject, @unchecked Sendable {
|
|
|
87
87
|
apiKey: configuration.apiKey,
|
|
88
88
|
sdkName: "logbrew-react-native-apple",
|
|
89
89
|
sdkVersion: Self.sdkVersion,
|
|
90
|
+
includeAppStartMetric: false,
|
|
90
91
|
)
|
|
91
92
|
let transport = try HTTPTransport(endpoint: configuration.endpoint)
|
|
92
93
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Generated by scripts/sync-apple-native-sources.mjs.
|
|
2
|
+
// Edit the canonical Swift source, then regenerate this package boundary.
|
|
3
|
+
import Foundation
|
|
4
|
+
|
|
5
|
+
struct AppStartSource: Sendable {
|
|
6
|
+
let processStartMs: Double?
|
|
7
|
+
let isPrewarmed: Bool
|
|
8
|
+
let firstFrameNotification: Notification.Name?
|
|
9
|
+
let notificationCenter: NotificationCenter
|
|
10
|
+
let nowMs: @Sendable () -> Double
|
|
11
|
+
|
|
12
|
+
static let current = AppStartSource(
|
|
13
|
+
processStartMs: kernelProcessStartMs(),
|
|
14
|
+
isPrewarmed: ProcessInfo.processInfo.environment["ActivePrewarm"] == "1",
|
|
15
|
+
firstFrameNotification: platformFirstFrameNotification(),
|
|
16
|
+
notificationCenter: .default,
|
|
17
|
+
nowMs: { Date().timeIntervalSince1970 * 1000 },
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
final class AppStartRecorder: @unchecked Sendable {
|
|
22
|
+
static let process = AppStartRecorder(source: .current)
|
|
23
|
+
|
|
24
|
+
let source: AppStartSource
|
|
25
|
+
private let lock = NSLock()
|
|
26
|
+
private var finished: Bool
|
|
27
|
+
private var observer: (any NSObjectProtocol)?
|
|
28
|
+
private weak var client: LogBrewClient?
|
|
29
|
+
|
|
30
|
+
init(source: AppStartSource) {
|
|
31
|
+
self.source = source
|
|
32
|
+
finished = source.isPrewarmed || source.processStartMs == nil
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func install(for client: LogBrewClient) {
|
|
36
|
+
guard let name = source.firstFrameNotification else {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
lock.lock()
|
|
40
|
+
defer {
|
|
41
|
+
lock.unlock()
|
|
42
|
+
}
|
|
43
|
+
guard !finished, observer == nil else {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
self.client = client
|
|
47
|
+
observer = source.notificationCenter.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in
|
|
48
|
+
DispatchQueue.main.async {
|
|
49
|
+
self?.finish(client: nil)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@discardableResult
|
|
55
|
+
func finish(client explicitClient: LogBrewClient?) -> Bool {
|
|
56
|
+
let endMs = source.nowMs()
|
|
57
|
+
lock.lock()
|
|
58
|
+
guard !finished, let startMs = source.processStartMs else {
|
|
59
|
+
lock.unlock()
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
finished = true
|
|
63
|
+
let target = explicitClient ?? client
|
|
64
|
+
let registeredObserver = observer
|
|
65
|
+
observer = nil
|
|
66
|
+
client = nil
|
|
67
|
+
lock.unlock()
|
|
68
|
+
if let registeredObserver {
|
|
69
|
+
source.notificationCenter.removeObserver(registeredObserver)
|
|
70
|
+
}
|
|
71
|
+
let durationMs = endMs - startMs
|
|
72
|
+
guard let target, durationMs >= 0, durationMs <= 60000 else {
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
let eventID = "evt_app_start_\(UUID().uuidString.replacingOccurrences(of: "-", with: "").lowercased())"
|
|
76
|
+
return (try? target.metric(
|
|
77
|
+
eventID,
|
|
78
|
+
timestamp: currentTelemetryTimestamp(),
|
|
79
|
+
attributes: MetricAttributes(
|
|
80
|
+
name: "app.start.duration",
|
|
81
|
+
kind: .histogram,
|
|
82
|
+
value: durationMs,
|
|
83
|
+
unit: "ms",
|
|
84
|
+
temporality: .delta,
|
|
85
|
+
metadata: ["startType": "cold"],
|
|
86
|
+
description: "Time from process start to the first frame.",
|
|
87
|
+
),
|
|
88
|
+
)) != nil
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private func platformFirstFrameNotification() -> Notification.Name? {
|
|
93
|
+
#if os(iOS) || os(tvOS) || os(visionOS)
|
|
94
|
+
Notification.Name("UIApplicationDidBecomeActiveNotification")
|
|
95
|
+
#elseif os(watchOS)
|
|
96
|
+
Notification.Name("WKApplicationDidBecomeActiveNotification")
|
|
97
|
+
#elseif os(macOS)
|
|
98
|
+
Notification.Name("NSApplicationDidFinishLaunchingNotification")
|
|
99
|
+
#else
|
|
100
|
+
nil
|
|
101
|
+
#endif
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private func kernelProcessStartMs() -> Double? {
|
|
105
|
+
#if canImport(Darwin)
|
|
106
|
+
var information = kinfo_proc()
|
|
107
|
+
var size = MemoryLayout<kinfo_proc>.stride
|
|
108
|
+
var mib: [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
|
|
109
|
+
guard sysctl(&mib, u_int(mib.count), &information, &size, nil, 0) == 0 else {
|
|
110
|
+
return nil
|
|
111
|
+
}
|
|
112
|
+
let start = information.kp_proc.p_un.__p_starttime
|
|
113
|
+
return Double(start.tv_sec) * 1000 + Double(start.tv_usec) / 1000
|
|
114
|
+
#else
|
|
115
|
+
nil
|
|
116
|
+
#endif
|
|
117
|
+
}
|
|
@@ -6,6 +6,7 @@ public final class LogBrewClient: @unchecked Sendable {
|
|
|
6
6
|
private let engine: DeliveryEngine
|
|
7
7
|
private let baseContext: TelemetryContext?
|
|
8
8
|
private let breadcrumbStore = IssueBreadcrumbStore()
|
|
9
|
+
private let appStart: AppStartRecorder?
|
|
9
10
|
|
|
10
11
|
public static func create(
|
|
11
12
|
apiKey: String,
|
|
@@ -14,6 +15,7 @@ public final class LogBrewClient: @unchecked Sendable {
|
|
|
14
15
|
maxRetries: Int = 2,
|
|
15
16
|
context: TelemetryContext? = nil,
|
|
16
17
|
includeAutomaticContext: Bool = true,
|
|
18
|
+
includeAppStartMetric: Bool = true,
|
|
17
19
|
) throws -> LogBrewClient {
|
|
18
20
|
try LogBrewClient(
|
|
19
21
|
config: ClientConfig(
|
|
@@ -23,11 +25,16 @@ public final class LogBrewClient: @unchecked Sendable {
|
|
|
23
25
|
maxRetries: maxRetries,
|
|
24
26
|
context: context,
|
|
25
27
|
includeAutomaticContext: includeAutomaticContext,
|
|
28
|
+
includeAppStartMetric: includeAppStartMetric,
|
|
26
29
|
),
|
|
27
30
|
)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
public init(config: ClientConfig) throws {
|
|
33
|
+
public convenience init(config: ClientConfig) throws {
|
|
34
|
+
try self.init(config: config, appStart: .process)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
init(config: ClientConfig, appStart: AppStartRecorder) throws {
|
|
31
38
|
try requireNonEmpty("api_key", config.apiKey)
|
|
32
39
|
try requireNonEmpty("sdk_name", config.sdkName)
|
|
33
40
|
try requireNonEmpty("sdk_version", config.sdkVersion)
|
|
@@ -40,6 +47,14 @@ public final class LogBrewClient: @unchecked Sendable {
|
|
|
40
47
|
sdk: SDKInfo(name: config.sdkName, language: "swift", version: config.sdkVersion),
|
|
41
48
|
maxRetries: config.maxRetries,
|
|
42
49
|
)
|
|
50
|
+
self.appStart = config.includeAppStartMetric ? appStart : nil
|
|
51
|
+
self.appStart?.install(for: self)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// End the cold start measurement now if the first frame has not ended it yet.
|
|
55
|
+
@discardableResult
|
|
56
|
+
public func markAppReady() -> Bool {
|
|
57
|
+
appStart?.finish(client: self) ?? false
|
|
43
58
|
}
|
|
44
59
|
|
|
45
60
|
public func pendingEvents() -> Int {
|
|
@@ -107,6 +107,7 @@ public struct ClientConfig: Equatable, Sendable {
|
|
|
107
107
|
public let maxRetries: Int
|
|
108
108
|
public let context: TelemetryContext?
|
|
109
109
|
public let includeAutomaticContext: Bool
|
|
110
|
+
public let includeAppStartMetric: Bool
|
|
110
111
|
|
|
111
112
|
public init(
|
|
112
113
|
apiKey: String,
|
|
@@ -115,6 +116,7 @@ public struct ClientConfig: Equatable, Sendable {
|
|
|
115
116
|
maxRetries: Int = 2,
|
|
116
117
|
context: TelemetryContext? = nil,
|
|
117
118
|
includeAutomaticContext: Bool = true,
|
|
119
|
+
includeAppStartMetric: Bool = true,
|
|
118
120
|
) {
|
|
119
121
|
self.apiKey = apiKey
|
|
120
122
|
self.sdkName = sdkName
|
|
@@ -122,6 +124,7 @@ public struct ClientConfig: Equatable, Sendable {
|
|
|
122
124
|
self.maxRetries = maxRetries
|
|
123
125
|
self.context = context
|
|
124
126
|
self.includeAutomaticContext = includeAutomaticContext
|
|
127
|
+
self.includeAppStartMetric = includeAppStartMetric
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"sources": {
|
|
4
|
+
"swift/logbrew-swift/Sources/LogBrew/AppStartMetric.swift": "00ad61c062366b68674a5cccc9940dfbe83827e80b00b74648c215c082987d9f",
|
|
4
5
|
"swift/logbrew-swift/Sources/LogBrew/AutomaticTelemetryContext.swift": "76ab7f8a7c79db1d54ba13da8d61d96af62c509116b7df0f9d220d5c88364c00",
|
|
5
6
|
"swift/logbrew-swift/Sources/LogBrew/DeliveryEngine.swift": "274ca2ed671add1f7c51494e2a4e254b0fecd6fd7d80321ee0836e3521c2b02b",
|
|
6
7
|
"swift/logbrew-swift/Sources/LogBrew/DeliveryEngineAutomatic.swift": "d261e2364edffe82ccb7e962f12e6864a0077d41204e0b021c8160635cc843b2",
|
|
@@ -14,14 +15,14 @@
|
|
|
14
15
|
"swift/logbrew-swift/Sources/LogBrew/IssueDiagnostics.swift": "bbdfe6169961ff27b8f2cee63c7dcdeacf2e5cee6a3ca17f6a26b933f0adfc39",
|
|
15
16
|
"swift/logbrew-swift/Sources/LogBrew/IssueExceptionChain.swift": "10f81cbce95b47da0a44ef9e515b150e60d71dfcc8b04be24b037b1222a373a5",
|
|
16
17
|
"swift/logbrew-swift/Sources/LogBrew/LifecycleTrace.swift": "738cd3f129fac821a892404d1d42ee92bd806b6583d3dbb5379e88b14ab23c16",
|
|
17
|
-
"swift/logbrew-swift/Sources/LogBrew/LogBrewClient.swift": "
|
|
18
|
+
"swift/logbrew-swift/Sources/LogBrew/LogBrewClient.swift": "1dd933fcb4e889694ef29a120edbc942b27dfb72adc37fa35473c110c473180b",
|
|
18
19
|
"swift/logbrew-swift/Sources/LogBrew/LogBrewLogger.swift": "96e440f411c6276056e10c5feca82eb24fce9824632c7dbcedfd99b49d8332fc",
|
|
19
20
|
"swift/logbrew-swift/Sources/LogBrew/LogBrewTrace.swift": "f67edf4ca464e6a6eb1c7a22cd4997928cd27b6c2d07535855a18a053d8de924",
|
|
20
21
|
"swift/logbrew-swift/Sources/LogBrew/Metadata.swift": "65840ebb3f3b79fbfc1f5faa3026c2583319e89ff26061676dc552c03ee15dbe",
|
|
21
22
|
"swift/logbrew-swift/Sources/LogBrew/NativeStackFrame.swift": "ecbd418969ec4a31503d9916a8bf27f22e6863356c6fabe457c1e61027a8d805",
|
|
22
23
|
"swift/logbrew-swift/Sources/LogBrew/OperationTrace.swift": "d7383d1926c7276cc97f03537e4587e20e4495f80226b5113e8ef10397f9c702",
|
|
23
24
|
"swift/logbrew-swift/Sources/LogBrew/ProductTimeline.swift": "209906aa0e8f096a347e35832840522710eadfb530053253cd73c748518e362d",
|
|
24
|
-
"swift/logbrew-swift/Sources/LogBrew/PublicTypes.swift": "
|
|
25
|
+
"swift/logbrew-swift/Sources/LogBrew/PublicTypes.swift": "ab1831ae31dea4504bc756fce0b83e41aeec2cbe4da62cfc2ce45c0deea85b3f",
|
|
25
26
|
"swift/logbrew-swift/Sources/LogBrew/TelemetryContext.swift": "ce3ac93a62a345f8c9a8f4c69ce84efc991bf02a688f49bad5e68edcff2f6e08",
|
|
26
27
|
"swift/logbrew-swift/Sources/LogBrew/TelemetryContextValidation.swift": "ab5811b48df308bf8f6435efee30a24f91a62bfe8b6dea612a2077c8ae0eb302",
|
|
27
28
|
"swift/logbrew-swift/Sources/LogBrew/TraceEvidence.swift": "40aaa42976164c53d9f4d9e9e30d236534238da43bbe90832a673c8809ad54b6",
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
#import <Security/SecRandom.h>
|
|
8
8
|
#import <TargetConditionals.h>
|
|
9
9
|
#import <math.h>
|
|
10
|
+
#import <sys/sysctl.h>
|
|
11
|
+
#import <unistd.h>
|
|
10
12
|
|
|
11
13
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
12
14
|
#import <LogBrewReactNativeSpec/LogBrewReactNativeSpec.h>
|
|
@@ -111,6 +113,21 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(secureRandomHex:(double)length)
|
|
|
111
113
|
return output;
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(processStartTime)
|
|
117
|
+
{
|
|
118
|
+
if ([NSProcessInfo.processInfo.environment[@"ActivePrewarm"] isEqualToString:@"1"]) {
|
|
119
|
+
return @0;
|
|
120
|
+
}
|
|
121
|
+
struct kinfo_proc process;
|
|
122
|
+
size_t size = sizeof(process);
|
|
123
|
+
int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
|
|
124
|
+
if (sysctl(name, 4, &process, &size, NULL, 0) != 0 || size == 0) {
|
|
125
|
+
return @0;
|
|
126
|
+
}
|
|
127
|
+
struct timeval startedAt = process.kp_proc.p_starttime;
|
|
128
|
+
return @((double)startedAt.tv_sec * 1000.0 + (double)startedAt.tv_usec / 1000.0);
|
|
129
|
+
}
|
|
130
|
+
|
|
114
131
|
- (nullable LBRNEventRecordStore *)eventStoreForQueueKey:(NSString *)queueKey
|
|
115
132
|
{
|
|
116
133
|
NSString *queueHash = LBRNQueueHash(queueKey);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logbrew/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"description": "React Native offline delivery, native diagnostics, screen, error, trace, action, and network timeline helpers for LogBrew.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.cjs",
|
|
@@ -235,6 +235,7 @@
|
|
|
235
235
|
"apple-native-diagnostics-module.js",
|
|
236
236
|
"apple-native-diagnostics.d.ts",
|
|
237
237
|
"android-native-diagnostics.js",
|
|
238
|
+
"app-start.js",
|
|
238
239
|
"native-client-bindings.js",
|
|
239
240
|
"native-diagnostics-values.js",
|
|
240
241
|
"native-module-lookup.js",
|
|
@@ -305,6 +306,6 @@
|
|
|
305
306
|
}
|
|
306
307
|
},
|
|
307
308
|
"scripts": {
|
|
308
|
-
"test": "node scripts/sync-apple-native-sources.mjs --check && node --check index.js && node --check index.cjs && node --check index.native.js && node --check apple-native-diagnostics.js && node --check android-native-diagnostics.js && node --check expo.js && node --check expo.cjs && node --check apollo.js && node --check apollo.cjs && node --check instrumentation.js && node --check instrumentation.cjs && node --check lifecycle.js && node --check lifecycle.cjs && node --check global-errors.js && node --check global-errors.native.js && node --check global-errors.cjs && node --check promise-rejections.cjs && node --check fatal-replay.cjs && node --check metadata.js && node --check metadata.cjs && node --check native-bridge.js && node --check native-bridge.cjs && node --check resource-fetch.js && node --check resource-fetch.cjs && node --check release-artifacts.js && node --check release-artifacts.cjs && node --check metro.js && node --check metro.cjs && node --check examples/index.mjs && node --check examples/apollo-link-spans.mjs && node --check examples/instrumentation-kit.mjs && node --check examples/lifecycle-spans.mjs && node --check examples/native-bridge-scope.mjs && node --check examples/navigation-resource-spans.mjs && node --check examples/readme-example.mjs && node --check examples/real-user-smoke.mjs && node --check examples/resource-fetch-spans.mjs && node --check examples/trace-correlation.mjs && node --test"
|
|
309
|
+
"test": "node scripts/sync-apple-native-sources.mjs --check && node --check index.js && node --check index.cjs && node --check index.native.js && node --check app-start.js && node --check apple-native-diagnostics.js && node --check android-native-diagnostics.js && node --check expo.js && node --check expo.cjs && node --check apollo.js && node --check apollo.cjs && node --check instrumentation.js && node --check instrumentation.cjs && node --check lifecycle.js && node --check lifecycle.cjs && node --check global-errors.js && node --check global-errors.native.js && node --check global-errors.cjs && node --check promise-rejections.cjs && node --check fatal-replay.cjs && node --check metadata.js && node --check metadata.cjs && node --check native-bridge.js && node --check native-bridge.cjs && node --check resource-fetch.js && node --check resource-fetch.cjs && node --check release-artifacts.js && node --check release-artifacts.cjs && node --check metro.js && node --check metro.cjs && node --check examples/index.mjs && node --check examples/apollo-link-spans.mjs && node --check examples/instrumentation-kit.mjs && node --check examples/lifecycle-spans.mjs && node --check examples/native-bridge-scope.mjs && node --check examples/navigation-resource-spans.mjs && node --check examples/readme-example.mjs && node --check examples/real-user-smoke.mjs && node --check examples/resource-fetch-spans.mjs && node --check examples/trace-correlation.mjs && node --test"
|
|
309
310
|
}
|
|
310
311
|
}
|
|
@@ -3,6 +3,7 @@ import { TurboModuleRegistry } from "react-native";
|
|
|
3
3
|
|
|
4
4
|
export interface Spec extends TurboModule {
|
|
5
5
|
secureRandomHex(length: number): string;
|
|
6
|
+
processStartTime(): number;
|
|
6
7
|
loadEventRecords(queueKey: string): CodegenTypes.UnsafeObject;
|
|
7
8
|
appendEventRecord(
|
|
8
9
|
queueKey: string,
|