@goliapkg/sentori-react-native 4.0.0 → 5.1.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/MIGRATION.md +131 -0
- package/README.md +40 -30
- package/android/build.gradle +21 -0
- package/android/src/main/java/com/sentori/SentoriCrashHandler.kt +29 -0
- package/android/src/main/java/com/sentori/SentoriModule.kt +8 -0
- package/android/src/main/java/com/sentori/SentoriScreenshotCapture.kt +36 -4
- package/android/src/test/java/com/sentori/SentoriCrashHandlerTest.kt +7 -2
- package/android/src/test/resources/robolectric.properties +10 -0
- package/ios/SentoriCrashHandler.swift +48 -4
- package/ios/SentoriModule.swift +12 -0
- package/ios/SentoriScreenshotCapture.swift +34 -3
- package/lib/config.d.ts +17 -47
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -0
- package/lib/config.js.map +1 -1
- package/lib/device.d.ts +5 -0
- package/lib/device.d.ts.map +1 -0
- package/lib/device.js +29 -0
- package/lib/device.js.map +1 -0
- package/lib/emit-hooks.d.ts +7 -0
- package/lib/emit-hooks.d.ts.map +1 -0
- package/lib/emit-hooks.js +24 -0
- package/lib/emit-hooks.js.map +1 -0
- package/lib/error-boundary.d.ts.map +1 -1
- package/lib/error-boundary.js +1 -1
- package/lib/error-boundary.js.map +1 -1
- package/lib/feature-flags.d.ts.map +1 -1
- package/lib/handlers/dev-symbolicate.d.ts +1 -1
- package/lib/handlers/dev-symbolicate.d.ts.map +1 -1
- package/lib/handlers/dev-symbolicate.js +2 -0
- package/lib/handlers/dev-symbolicate.js.map +1 -1
- package/lib/handlers/global.js +1 -1
- package/lib/handlers/global.js.map +1 -1
- package/lib/handlers/lifecycle.js +3 -3
- package/lib/handlers/lifecycle.js.map +1 -1
- package/lib/handlers/network.d.ts +2 -2
- package/lib/handlers/network.d.ts.map +1 -1
- package/lib/handlers/network.js +69 -187
- package/lib/handlers/network.js.map +1 -1
- package/lib/handlers/promise.js +1 -1
- package/lib/handlers/promise.js.map +1 -1
- package/lib/handlers/screenshot.d.ts.map +1 -1
- package/lib/handlers/screenshot.js +3 -12
- package/lib/handlers/screenshot.js.map +1 -1
- package/lib/index.d.ts +32 -109
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +54 -103
- package/lib/index.js.map +1 -1
- package/lib/init.d.ts +3 -150
- package/lib/init.d.ts.map +1 -1
- package/lib/init.js +100 -261
- package/lib/init.js.map +1 -1
- package/lib/long-task-monitor.d.ts +1 -7
- package/lib/long-task-monitor.d.ts.map +1 -1
- package/lib/long-task-monitor.js +37 -58
- package/lib/long-task-monitor.js.map +1 -1
- package/lib/mask.d.ts +5 -13
- package/lib/mask.d.ts.map +1 -1
- package/lib/mask.js +29 -30
- package/lib/mask.js.map +1 -1
- package/lib/mobile-vitals.d.ts +3 -31
- package/lib/mobile-vitals.d.ts.map +1 -1
- package/lib/mobile-vitals.js +22 -61
- package/lib/mobile-vitals.js.map +1 -1
- package/lib/native-pending.d.ts +3 -0
- package/lib/native-pending.d.ts.map +1 -0
- package/lib/native-pending.js +64 -0
- package/lib/native-pending.js.map +1 -0
- package/lib/native.d.ts +4 -11
- package/lib/native.d.ts.map +1 -1
- package/lib/native.js +23 -0
- package/lib/native.js.map +1 -1
- package/lib/navigation.d.ts +3 -17
- package/lib/navigation.d.ts.map +1 -1
- package/lib/navigation.js +32 -133
- package/lib/navigation.js.map +1 -1
- package/lib/netinfo.d.ts +1 -1
- package/lib/netinfo.d.ts.map +1 -1
- package/lib/netinfo.js +2 -2
- package/lib/netinfo.js.map +1 -1
- package/lib/push.d.ts.map +1 -1
- package/lib/push.js +2 -4
- package/lib/push.js.map +1 -1
- package/lib/rage-tap.d.ts.map +1 -1
- package/lib/rage-tap.js +56 -23
- package/lib/rage-tap.js.map +1 -1
- package/lib/replay-screens.d.ts +15 -0
- package/lib/replay-screens.d.ts.map +1 -0
- package/lib/replay-screens.js +87 -0
- package/lib/replay-screens.js.map +1 -0
- package/lib/replay.d.ts.map +1 -1
- package/lib/replay.js +3 -24
- package/lib/replay.js.map +1 -1
- package/lib/responsiveness-detector.d.ts +18 -0
- package/lib/responsiveness-detector.d.ts.map +1 -0
- package/lib/responsiveness-detector.js +55 -0
- package/lib/responsiveness-detector.js.map +1 -0
- package/lib/scope.d.ts +7 -0
- package/lib/scope.d.ts.map +1 -0
- package/lib/scope.js +41 -0
- package/lib/scope.js.map +1 -0
- package/lib/transport.d.ts +19 -92
- package/lib/transport.d.ts.map +1 -1
- package/lib/transport.js +75 -288
- package/lib/transport.js.map +1 -1
- package/lib/verbs.d.ts +16 -0
- package/lib/verbs.d.ts.map +1 -0
- package/lib/verbs.js +153 -0
- package/lib/verbs.js.map +1 -0
- package/package.json +4 -3
- package/src/__tests__/iron-rule.test.ts +128 -0
- package/src/__tests__/replay-screens.test.ts +63 -0
- package/src/__tests__/responsiveness-detector.test.ts +74 -0
- package/src/__tests__/screenshot.test.ts +0 -2
- package/src/__tests__/transport.test.ts +66 -213
- package/src/__tests__/verbs.test.ts +91 -0
- package/src/config.ts +20 -47
- package/src/device.ts +36 -0
- package/src/emit-hooks.ts +30 -0
- package/src/error-boundary.tsx +1 -1
- package/src/handlers/dev-symbolicate.ts +2 -1
- package/src/handlers/global.ts +1 -1
- package/src/handlers/lifecycle.ts +3 -3
- package/src/handlers/network.ts +95 -211
- package/src/handlers/promise.ts +1 -1
- package/src/handlers/screenshot.ts +3 -11
- package/src/index.ts +84 -215
- package/src/init.ts +115 -449
- package/src/long-task-monitor.ts +42 -64
- package/src/mask.ts +29 -31
- package/src/mobile-vitals.ts +22 -82
- package/src/native-pending.ts +92 -0
- package/src/native.ts +33 -0
- package/src/navigation.ts +34 -142
- package/src/netinfo.ts +3 -3
- package/src/push.ts +2 -5
- package/src/rage-tap.tsx +72 -25
- package/src/replay-screens.ts +95 -0
- package/src/replay.ts +3 -20
- package/src/responsiveness-detector.ts +66 -0
- package/src/scope.ts +50 -0
- package/src/transport.ts +84 -371
- package/src/verbs.ts +198 -0
- package/lib/breadcrumbs.d.ts +0 -18
- package/lib/breadcrumbs.d.ts.map +0 -1
- package/lib/breadcrumbs.js +0 -42
- package/lib/breadcrumbs.js.map +0 -1
- package/lib/bundle-info.d.ts +0 -12
- package/lib/bundle-info.d.ts.map +0 -1
- package/lib/bundle-info.js +0 -73
- package/lib/bundle-info.js.map +0 -1
- package/lib/capture.d.ts +0 -140
- package/lib/capture.d.ts.map +0 -1
- package/lib/capture.js +0 -511
- package/lib/capture.js.map +0 -1
- package/lib/compat/sentry.d.ts +0 -126
- package/lib/compat/sentry.d.ts.map +0 -1
- package/lib/compat/sentry.js +0 -332
- package/lib/compat/sentry.js.map +0 -1
- package/lib/control-channel.d.ts +0 -6
- package/lib/control-channel.d.ts.map +0 -1
- package/lib/control-channel.js +0 -96
- package/lib/control-channel.js.map +0 -1
- package/lib/expo-compat.d.ts +0 -270
- package/lib/expo-compat.d.ts.map +0 -1
- package/lib/expo-compat.js +0 -500
- package/lib/expo-compat.js.map +0 -1
- package/lib/feedback-widget.d.ts +0 -35
- package/lib/feedback-widget.d.ts.map +0 -1
- package/lib/feedback-widget.js +0 -193
- package/lib/feedback-widget.js.map +0 -1
- package/lib/feedback.d.ts +0 -2
- package/lib/feedback.d.ts.map +0 -1
- package/lib/feedback.js +0 -17
- package/lib/feedback.js.map +0 -1
- package/lib/heartbeat.d.ts +0 -9
- package/lib/heartbeat.d.ts.map +0 -1
- package/lib/heartbeat.js +0 -138
- package/lib/heartbeat.js.map +0 -1
- package/lib/index.js.bak +0 -64
- package/lib/install-id.d.ts +0 -17
- package/lib/install-id.d.ts.map +0 -1
- package/lib/install-id.js +0 -125
- package/lib/install-id.js.map +0 -1
- package/lib/lifecycle.d.ts +0 -28
- package/lib/lifecycle.d.ts.map +0 -1
- package/lib/lifecycle.js +0 -73
- package/lib/lifecycle.js.map +0 -1
- package/lib/measure.d.ts +0 -4
- package/lib/measure.d.ts.map +0 -1
- package/lib/measure.js +0 -25
- package/lib/measure.js.map +0 -1
- package/lib/metrics.d.ts +0 -24
- package/lib/metrics.d.ts.map +0 -1
- package/lib/metrics.js +0 -81
- package/lib/metrics.js.map +0 -1
- package/lib/pre-crash-sentinel.d.ts +0 -12
- package/lib/pre-crash-sentinel.d.ts.map +0 -1
- package/lib/pre-crash-sentinel.js +0 -116
- package/lib/pre-crash-sentinel.js.map +0 -1
- package/lib/report-security.d.ts +0 -40
- package/lib/report-security.d.ts.map +0 -1
- package/lib/report-security.js +0 -159
- package/lib/report-security.js.map +0 -1
- package/lib/runtime-metrics-fps.d.ts +0 -19
- package/lib/runtime-metrics-fps.d.ts.map +0 -1
- package/lib/runtime-metrics-fps.js +0 -128
- package/lib/runtime-metrics-fps.js.map +0 -1
- package/lib/runtime-metrics-heap.d.ts +0 -13
- package/lib/runtime-metrics-heap.d.ts.map +0 -1
- package/lib/runtime-metrics-heap.js +0 -67
- package/lib/runtime-metrics-heap.js.map +0 -1
- package/lib/runtime-metrics-network.d.ts +0 -23
- package/lib/runtime-metrics-network.d.ts.map +0 -1
- package/lib/runtime-metrics-network.js +0 -99
- package/lib/runtime-metrics-network.js.map +0 -1
- package/lib/runtime-metrics.d.ts +0 -43
- package/lib/runtime-metrics.d.ts.map +0 -1
- package/lib/runtime-metrics.js +0 -115
- package/lib/runtime-metrics.js.map +0 -1
- package/lib/sample-profiler.d.ts +0 -21
- package/lib/sample-profiler.d.ts.map +0 -1
- package/lib/sample-profiler.js +0 -152
- package/lib/sample-profiler.js.map +0 -1
- package/lib/sentinel-context.d.ts +0 -4
- package/lib/sentinel-context.d.ts.map +0 -1
- package/lib/sentinel-context.js +0 -52
- package/lib/sentinel-context.js.map +0 -1
- package/lib/session-tracker.d.ts +0 -6
- package/lib/session-tracker.d.ts.map +0 -1
- package/lib/session-tracker.js +0 -50
- package/lib/session-tracker.js.map +0 -1
- package/lib/stack.d.ts +0 -3
- package/lib/stack.d.ts.map +0 -1
- package/lib/stack.js +0 -7
- package/lib/stack.js.map +0 -1
- package/lib/state-snapshots.d.ts +0 -33
- package/lib/state-snapshots.d.ts.map +0 -1
- package/lib/state-snapshots.js +0 -109
- package/lib/state-snapshots.js.map +0 -1
- package/lib/track.d.ts +0 -34
- package/lib/track.d.ts.map +0 -1
- package/lib/track.js +0 -107
- package/lib/track.js.map +0 -1
- package/lib/trail.d.ts +0 -12
- package/lib/trail.d.ts.map +0 -1
- package/lib/trail.js +0 -28
- package/lib/trail.js.map +0 -1
- package/lib/trust-score.d.ts +0 -20
- package/lib/trust-score.d.ts.map +0 -1
- package/lib/trust-score.js +0 -151
- package/lib/trust-score.js.map +0 -1
- package/lib/types.d.ts +0 -2
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -4
- package/lib/types.js.map +0 -1
- package/lib/uuid.d.ts +0 -2
- package/lib/uuid.d.ts.map +0 -1
- package/lib/uuid.js +0 -3
- package/lib/uuid.js.map +0 -1
- package/src/__tests__/before-send.test.ts +0 -72
- package/src/__tests__/breadcrumbs.test.ts +0 -44
- package/src/__tests__/capture-replay.test.ts +0 -150
- package/src/__tests__/compat-sentry.test.ts +0 -121
- package/src/__tests__/control-channel.test.ts +0 -111
- package/src/__tests__/install-id.test.ts +0 -60
- package/src/__tests__/long-task-monitor.test.ts +0 -59
- package/src/__tests__/measure.test.ts +0 -45
- package/src/__tests__/navigation.test.ts +0 -175
- package/src/__tests__/push.test.ts +0 -238
- package/src/__tests__/report-security.test.ts +0 -106
- package/src/__tests__/runtime-metrics-instruments.test.ts +0 -109
- package/src/__tests__/runtime-metrics-network.test.ts +0 -78
- package/src/__tests__/sample-profiler.test.ts +0 -59
- package/src/__tests__/stack.test.ts +0 -45
- package/src/__tests__/state-snapshots.test.ts +0 -119
- package/src/__tests__/tracing.test.ts +0 -201
- package/src/__tests__/track.test.ts +0 -91
- package/src/__tests__/uuid.test.ts +0 -41
- package/src/breadcrumbs.ts +0 -57
- package/src/bundle-info.ts +0 -95
- package/src/capture.ts +0 -660
- package/src/compat/sentry.ts +0 -490
- package/src/control-channel.ts +0 -98
- package/src/expo-compat.ts +0 -698
- package/src/feedback-widget.tsx +0 -316
- package/src/feedback.ts +0 -21
- package/src/heartbeat.ts +0 -157
- package/src/install-id.ts +0 -146
- package/src/lifecycle.ts +0 -76
- package/src/measure.ts +0 -28
- package/src/metrics.ts +0 -94
- package/src/pre-crash-sentinel.ts +0 -140
- package/src/report-security.ts +0 -165
- package/src/runtime-metrics-fps.ts +0 -137
- package/src/runtime-metrics-heap.ts +0 -78
- package/src/runtime-metrics-network.ts +0 -103
- package/src/runtime-metrics.ts +0 -122
- package/src/sample-profiler.ts +0 -169
- package/src/sentinel-context.ts +0 -60
- package/src/session-tracker.ts +0 -53
- package/src/stack.ts +0 -10
- package/src/state-snapshots.ts +0 -133
- package/src/track.ts +0 -123
- package/src/trail.ts +0 -32
- package/src/trust-score.ts +0 -176
- package/src/types.ts +0 -21
- package/src/uuid.ts +0 -2
package/lib/sample-profiler.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
// v1.1 #4 升级 — JS sample profiler (idle-tick sampler).
|
|
2
|
-
//
|
|
3
|
-
// What it does:
|
|
4
|
-
// • setInterval(50ms) — captures `new Error().stack` of the tick
|
|
5
|
-
// callback, parses out the top frames, increments per-frame
|
|
6
|
-
// counts in a rolling window
|
|
7
|
-
// • every 60 s, emits a `sentori.profile` span with the aggregated
|
|
8
|
-
// flame-data (frame name → tick count) as span data
|
|
9
|
-
//
|
|
10
|
-
// What it does NOT do:
|
|
11
|
-
// • Sample frames during a busy JS task. JS is single-threaded;
|
|
12
|
-
// while the busy code is running, our setInterval can't fire,
|
|
13
|
-
// so the busy stack never gets sampled. Long-task monitor (#4
|
|
14
|
-
// v0.9.6) catches that case from a different angle (duration).
|
|
15
|
-
//
|
|
16
|
-
// Idle-tick sampling is still useful: shows which functions appear
|
|
17
|
-
// most often between busy moments — typically the render hot path,
|
|
18
|
-
// frequent timer callbacks, recurring middleware. Pairs with
|
|
19
|
-
// long-task-monitor (catches the 200ms+ outliers).
|
|
20
|
-
//
|
|
21
|
-
// Real Hermes off-thread sampling profiler (which would catch busy
|
|
22
|
-
// frames too) needs RN-internal HermesAPI access, deferred to v1.2.
|
|
23
|
-
import { startSpan } from '@goliapkg/sentori-core';
|
|
24
|
-
const SAMPLE_INTERVAL_MS = 50;
|
|
25
|
-
const FLUSH_INTERVAL_MS = 60_000;
|
|
26
|
-
const MAX_FRAMES = 200; // safety cap per profile
|
|
27
|
-
const MAX_FRAME_NAME_LEN = 120;
|
|
28
|
-
/** Floor on user-configured sample interval. Going below ~20 ms costs
|
|
29
|
-
* measurable JS-thread time to `new Error().stack` + regex parse on
|
|
30
|
-
* every tick — past that point you'd see the profile drag down the
|
|
31
|
-
* thing you're profiling. */
|
|
32
|
-
const MIN_SAMPLE_INTERVAL_MS = 20;
|
|
33
|
-
/** Floor on flush interval. Sub-5s windows produce a span every few
|
|
34
|
-
* seconds, which is just noise for an aggregator that's looking at
|
|
35
|
-
* per-minute hotspot trends. */
|
|
36
|
-
const MIN_FLUSH_INTERVAL_MS = 5_000;
|
|
37
|
-
/** How many stack-trace lines to keep per tick (after dropping the
|
|
38
|
-
* Error ctor + sampleTick frames). 10 is enough to see the JS-side
|
|
39
|
-
* call shape; deeper than that the bottom frames are usually RN
|
|
40
|
-
* runtime / event loop and not actionable. */
|
|
41
|
-
const FRAMES_PER_TICK = 10;
|
|
42
|
-
let _frameCounts = new Map();
|
|
43
|
-
let _windowStartedAt = 0;
|
|
44
|
-
let _sampleTimer = null;
|
|
45
|
-
let _flushTimer = null;
|
|
46
|
-
/**
|
|
47
|
-
* Start the idle-tick sample profiler. Idempotent — calling twice
|
|
48
|
-
* is a no-op after the first successful start.
|
|
49
|
-
*
|
|
50
|
-
* Pairs naturally with `longTaskMonitor` (≥200ms outliers): the
|
|
51
|
-
* profiler shows the *distribution* of code that runs in idle gaps,
|
|
52
|
-
* the long-task monitor catches the few outliers that are blocking
|
|
53
|
-
* the thread. Together they cover the JS-side perf signal cheaply.
|
|
54
|
-
*/
|
|
55
|
-
export function startSampleProfiler(opts) {
|
|
56
|
-
if (!opts.enabled || _sampleTimer !== null)
|
|
57
|
-
return;
|
|
58
|
-
const sampleMs = Math.max(MIN_SAMPLE_INTERVAL_MS, opts.sampleMs ?? SAMPLE_INTERVAL_MS);
|
|
59
|
-
const flushMs = Math.max(MIN_FLUSH_INTERVAL_MS, opts.flushMs ?? FLUSH_INTERVAL_MS);
|
|
60
|
-
_windowStartedAt = Date.now();
|
|
61
|
-
_sampleTimer = setInterval(() => sampleTick(), sampleMs);
|
|
62
|
-
_flushTimer = setInterval(() => flushWindow(), flushMs);
|
|
63
|
-
_sampleTimer.unref?.();
|
|
64
|
-
_flushTimer.unref?.();
|
|
65
|
-
}
|
|
66
|
-
export function stopSampleProfiler() {
|
|
67
|
-
if (_sampleTimer !== null) {
|
|
68
|
-
clearInterval(_sampleTimer);
|
|
69
|
-
_sampleTimer = null;
|
|
70
|
-
}
|
|
71
|
-
if (_flushTimer !== null) {
|
|
72
|
-
clearInterval(_flushTimer);
|
|
73
|
-
_flushTimer = null;
|
|
74
|
-
}
|
|
75
|
-
_frameCounts.clear();
|
|
76
|
-
_windowStartedAt = 0;
|
|
77
|
-
}
|
|
78
|
-
function sampleTick() {
|
|
79
|
-
const stack = new Error().stack;
|
|
80
|
-
if (!stack)
|
|
81
|
-
return;
|
|
82
|
-
// Skip the first 2 frames — they're our `sampleTick` + `Error
|
|
83
|
-
// ctor` which would dominate every sample.
|
|
84
|
-
const lines = stack.split('\n').slice(2, 2 + FRAMES_PER_TICK);
|
|
85
|
-
for (const line of lines) {
|
|
86
|
-
const frame = parseFrameName(line);
|
|
87
|
-
if (frame) {
|
|
88
|
-
_frameCounts.set(frame, (_frameCounts.get(frame) ?? 0) + 1);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/** Pull a stable identifier from one stack-trace line. Handles:
|
|
93
|
-
*
|
|
94
|
-
* at FunctionName (file://path/Foo.js:123:45)
|
|
95
|
-
* at file://path/Foo.js:123:45 (anonymous)
|
|
96
|
-
* FunctionName@file://path/Foo.js:123:45 (Hermes style)
|
|
97
|
-
*
|
|
98
|
-
* Drops absolute path noise — keeps `Foo.js:Line` so re-deploys
|
|
99
|
-
* with stable code paths bucket together. */
|
|
100
|
-
function parseFrameName(line) {
|
|
101
|
-
const trimmed = line.trim();
|
|
102
|
-
if (trimmed.length === 0)
|
|
103
|
-
return null;
|
|
104
|
-
// Hermes / JSC: `FunctionName@file:line:col` or just `@file:line:col`.
|
|
105
|
-
// Standard: `at FunctionName (file:line:col)`.
|
|
106
|
-
let raw = trimmed.replace(/^at\s+/, '');
|
|
107
|
-
raw = raw.replace(/\s*[(\[].*$/, ''); // strip the file part after `(`
|
|
108
|
-
// Hermes: split on @
|
|
109
|
-
if (raw.includes('@')) {
|
|
110
|
-
raw = raw.split('@')[0] ?? raw;
|
|
111
|
-
}
|
|
112
|
-
raw = raw.trim();
|
|
113
|
-
if (raw.length === 0 || raw.length > MAX_FRAME_NAME_LEN)
|
|
114
|
-
return null;
|
|
115
|
-
// Ignore the obvious noise frames.
|
|
116
|
-
if (raw === 'Object.<anonymous>' || raw === '<anonymous>')
|
|
117
|
-
return null;
|
|
118
|
-
return raw;
|
|
119
|
-
}
|
|
120
|
-
function flushWindow() {
|
|
121
|
-
if (_frameCounts.size === 0)
|
|
122
|
-
return;
|
|
123
|
-
const windowEndedAt = Date.now();
|
|
124
|
-
const durationMs = windowEndedAt - _windowStartedAt;
|
|
125
|
-
// Top-N frames so attachment doesn't bloat unboundedly.
|
|
126
|
-
const top = Array.from(_frameCounts.entries())
|
|
127
|
-
.sort((a, b) => b[1] - a[1])
|
|
128
|
-
.slice(0, MAX_FRAMES);
|
|
129
|
-
const span = startSpan('sentori.profile', {
|
|
130
|
-
name: 'js.sample-profile',
|
|
131
|
-
startNowMs: _windowStartedAt,
|
|
132
|
-
tags: {
|
|
133
|
-
'profile.kind': 'sample',
|
|
134
|
-
'profile.sample_count': String(sampleCount(top)),
|
|
135
|
-
'profile.duration_ms': String(durationMs),
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
span.setData('flameData', Object.fromEntries(top));
|
|
139
|
-
span.finish({ endNowMs: windowEndedAt, status: 'ok' });
|
|
140
|
-
_frameCounts.clear();
|
|
141
|
-
_windowStartedAt = windowEndedAt;
|
|
142
|
-
}
|
|
143
|
-
function sampleCount(entries) {
|
|
144
|
-
let total = 0;
|
|
145
|
-
for (const [, n] of entries)
|
|
146
|
-
total += n;
|
|
147
|
-
return total;
|
|
148
|
-
}
|
|
149
|
-
export function __resetSampleProfilerForTests() {
|
|
150
|
-
stopSampleProfiler();
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=sample-profiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sample-profiler.js","sourceRoot":"","sources":["../src/sample-profiler.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,gBAAgB;AAChB,mEAAmE;AACnE,gEAAgE;AAChE,iCAAiC;AACjC,qEAAqE;AACrE,wDAAwD;AACxD,EAAE;AACF,uBAAuB;AACvB,kEAAkE;AAClE,kEAAkE;AAClE,kEAAkE;AAClE,mEAAmE;AACnE,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,6DAA6D;AAC7D,mDAAmD;AACnD,EAAE;AACF,mEAAmE;AACnE,oEAAoE;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,yBAAyB;AACjD,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;8BAG8B;AAC9B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC;;iCAEiC;AACjC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC;;;+CAG+C;AAC/C,MAAM,eAAe,GAAG,E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,KAAK,IAAI,CAAC,CAAC;IACxC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,kBAAkB,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sentinel-context.d.ts","sourceRoot":"","sources":["../src/sentinel-context.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,wBAAwB,QAAO,MAgC3C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,GAkBnD,CAAC"}
|
package/lib/sentinel-context.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// Shared device + app collectors. Used by both capture.ts (errors)
|
|
2
|
-
// and pre-crash-sentinel.ts (nearCrash). Same shape so the dashboard
|
|
3
|
-
// can render both kinds of events through the same UI components.
|
|
4
|
-
import { getCachedNetworkType } from './netinfo';
|
|
5
|
-
export const collectDeviceForSentinel = () => {
|
|
6
|
-
let os = 'other';
|
|
7
|
-
let osVersion = '0';
|
|
8
|
-
let locale;
|
|
9
|
-
const networkType = getCachedNetworkType();
|
|
10
|
-
try {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
12
|
-
const RN = require('react-native');
|
|
13
|
-
const rnOS = RN.Platform.OS;
|
|
14
|
-
os = rnOS === 'android' || rnOS === 'ios' || rnOS === 'web' ? rnOS : 'other';
|
|
15
|
-
osVersion = String(RN.Platform.Version);
|
|
16
|
-
if (rnOS === 'ios') {
|
|
17
|
-
const s = RN.NativeModules.SettingsManager?.settings;
|
|
18
|
-
locale = s?.AppleLocale ?? s?.AppleLanguages?.[0];
|
|
19
|
-
}
|
|
20
|
-
else if (rnOS === 'android') {
|
|
21
|
-
locale = RN.NativeModules.I18nManager?.localeIdentifier;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
// not in RN runtime
|
|
26
|
-
}
|
|
27
|
-
const device = { os, osVersion };
|
|
28
|
-
if (locale)
|
|
29
|
-
device.locale = locale;
|
|
30
|
-
if (networkType)
|
|
31
|
-
device.networkType = networkType;
|
|
32
|
-
return device;
|
|
33
|
-
};
|
|
34
|
-
export const getAppForSentinel = (release) => {
|
|
35
|
-
const m = /^(?:[^@]+@)?([^+]+)(?:\+(.+))?$/.exec(release);
|
|
36
|
-
const version = m?.[1] ?? '0.0.0';
|
|
37
|
-
const build = m?.[2];
|
|
38
|
-
let rnVersion = 'unknown';
|
|
39
|
-
try {
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
41
|
-
rnVersion = require('react-native/package.json').version;
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// not in RN runtime
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
build,
|
|
48
|
-
framework: { name: 'react-native', version: rnVersion },
|
|
49
|
-
version,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=sentinel-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sentinel-context.js","sourceRoot":"","sources":["../src/sentinel-context.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,qEAAqE;AACrE,kEAAkE;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAW,EAAE;IACnD,IAAI,EAAE,GAAiB,OAAO,CAAC;IAC/B,IAAI,SAAS,GAAG,GAAG,CAAC;IACpB,IAAI,MAA0B,CAAC;IAC/B,MAAM,WAAW,GAAG,oBAAoB,EAAE,CAAC;IAC3C,IAAI,CAAC;QACH,iEAAiE;QACjE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAQhC,CAAC;QACF,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,EAA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AAC,MAAM,CAAC;QACP,oBAAoB;IACtB,CAAC;IAED,OAAO;QACL,KAAK;QACL,SAAS,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE;QACvD,OAAO;KACR,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/session-tracker.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const startSession: () => void;
|
|
2
|
-
export declare const endSession: (status?: "exited") => void;
|
|
3
|
-
export declare const markSessionErrored: () => void;
|
|
4
|
-
export declare const markSessionCrashed: () => void;
|
|
5
|
-
export declare const __resetSessionForTests: () => void;
|
|
6
|
-
//# sourceMappingURL=session-tracker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-tracker.d.ts","sourceRoot":"","sources":["../src/session-tracker.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,YAAY,QAAO,IAS/B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,SAAS,QAAQ,KAAG,IAG9C,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,IAErC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,IAErC,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAO,IAEzC,CAAC"}
|
package/lib/session-tracker.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 26 sub-B: RN session tracker glue.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors the JS SDK's session-tracker but sends through the RN
|
|
5
|
-
* transport. AppState binding lives in `handlers/lifecycle.ts`; this
|
|
6
|
-
* file is just the singleton + the start/end/markErrored/markCrashed
|
|
7
|
-
* surface.
|
|
8
|
-
*/
|
|
9
|
-
import { SessionTracker } from '@goliapkg/sentori-core';
|
|
10
|
-
import { getConfig } from './config';
|
|
11
|
-
import { getUser } from './capture';
|
|
12
|
-
import { sendSessionPing } from './transport';
|
|
13
|
-
let _tracker = null;
|
|
14
|
-
const tracker = () => {
|
|
15
|
-
if (_tracker)
|
|
16
|
-
return _tracker;
|
|
17
|
-
_tracker = new SessionTracker((ping) => {
|
|
18
|
-
const cfg = getConfig();
|
|
19
|
-
if (!cfg)
|
|
20
|
-
return;
|
|
21
|
-
void sendSessionPing(cfg.ingestUrl, cfg.token, ping);
|
|
22
|
-
});
|
|
23
|
-
return _tracker;
|
|
24
|
-
};
|
|
25
|
-
export const startSession = () => {
|
|
26
|
-
const cfg = getConfig();
|
|
27
|
-
if (!cfg)
|
|
28
|
-
return;
|
|
29
|
-
const user = getUser();
|
|
30
|
-
tracker().start({
|
|
31
|
-
environment: cfg.environment,
|
|
32
|
-
release: cfg.release,
|
|
33
|
-
userId: user?.id ?? null,
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
export const endSession = (status) => {
|
|
37
|
-
if (!_tracker)
|
|
38
|
-
return;
|
|
39
|
-
_tracker.end(status);
|
|
40
|
-
};
|
|
41
|
-
export const markSessionErrored = () => {
|
|
42
|
-
_tracker?.markErrored();
|
|
43
|
-
};
|
|
44
|
-
export const markSessionCrashed = () => {
|
|
45
|
-
_tracker?.markCrashed();
|
|
46
|
-
};
|
|
47
|
-
export const __resetSessionForTests = () => {
|
|
48
|
-
_tracker = null;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=session-tracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-tracker.js","sourceRoot":"","sources":["../src/session-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,IAAI,QAAQ,GAA0B,IAAI,CAAC;AAE3C,MAAM,OAAO,GAAG,GAAmB,EAAE;IACnC,IAA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 -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../src/stack.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,KAAK,EACrC,CAAA"}
|
package/lib/stack.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Phase 21: regex + parse loop moved to @goliapkg/sentori-core.
|
|
2
|
-
// RN keeps the long path (no shortFilenames option) because Hermes
|
|
3
|
-
// paths are already short and native symbolication needs the
|
|
4
|
-
// absolute form.
|
|
5
|
-
import { parseStack as parseStackCore } from '@goliapkg/sentori-core';
|
|
6
|
-
export const parseStack = (stack) => parseStackCore(stack);
|
|
7
|
-
//# sourceMappingURL=stack.js.map
|
package/lib/stack.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../src/stack.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,mEAAmE;AACnE,6DAA6D;AAC7D,iBAAiB;AACjB,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAIrE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAyB,EAAW,EAAE,CAC/D,cAAc,CAAC,KAAK,CAAC,CAAA"}
|
package/lib/state-snapshots.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
type StoreLike = {
|
|
2
|
-
getState?: () => unknown;
|
|
3
|
-
subscribe?: (cb: () => void) => () => void;
|
|
4
|
-
};
|
|
5
|
-
export type StateSnapshot = {
|
|
6
|
-
/** Wall-clock when the diff fired. */
|
|
7
|
-
ts: number;
|
|
8
|
-
/** Top-level key/value diff vs the previous snapshot. Empty diff
|
|
9
|
-
* doesn't get recorded. */
|
|
10
|
-
diff: Record<string, unknown>;
|
|
11
|
-
/** Source label so the viewer can show "Redux" / "Zustand" / "Manual". */
|
|
12
|
-
source: string;
|
|
13
|
-
};
|
|
14
|
-
export declare function bindState(opts: {
|
|
15
|
-
redux?: StoreLike;
|
|
16
|
-
zustand?: StoreLike;
|
|
17
|
-
/** Additional named stores. The label is used as the snapshot's
|
|
18
|
-
* `source` and as the diff bucket key. */
|
|
19
|
-
custom?: Record<string, StoreLike>;
|
|
20
|
-
}): void;
|
|
21
|
-
export declare function unbindState(): void;
|
|
22
|
-
/** Manual recording for state not in a subscribed store. */
|
|
23
|
-
export declare function recordState(snapshot: Record<string, unknown>, source?: string): void;
|
|
24
|
-
export declare function getStateSnapshots(): StateSnapshot[];
|
|
25
|
-
export declare function clearStateSnapshots(): void;
|
|
26
|
-
/** Returns the top-level key/value diff (next has the value, prev
|
|
27
|
-
* may not contain the key). Empty diff returns `{}` so callers can
|
|
28
|
-
* no-op on empty. */
|
|
29
|
-
export declare function shallowDiff(prev: unknown, next: unknown): null | Record<string, unknown>;
|
|
30
|
-
/** Test-only. */
|
|
31
|
-
export declare function __resetStateSnapshotsForTests(): void;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=state-snapshots.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-snapshots.d.ts","sourceRoot":"","sources":["../src/state-snapshots.ts"],"names":[],"mappings":"AAwBA,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX;gCAC4B;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAMF,wBAAgB,SAAS,CAAC,IAAI,EAAE;IAC9B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;+CAC2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACpC,GAAG,IAAI,CASP;AAsBD,wBAAgB,WAAW,IAAI,IAAI,CAUlC;AAED,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,SAAW,GAAG,IAAI,CAEtF;AAED,wBAAgB,iBAAiB,IAAI,aAAa,EAAE,CAEnD;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAOD;;sBAEsB;AACtB,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAaxF;AAED,iBAAiB;AACjB,wBAAgB,6BAA6B,IAAI,IAAI,CAGpD"}
|
package/lib/state-snapshots.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// v0.9.2 +S2 — State Time-travel (SDK side).
|
|
2
|
-
//
|
|
3
|
-
// `sentori.bindState({ redux, zustand })` subscribes to a store-like
|
|
4
|
-
// object and records a shallow diff every time it emits a change.
|
|
5
|
-
// A ring buffer of the last N snapshots travels with each
|
|
6
|
-
// captureException as a `stateSnapshot` attachment — the dashboard's
|
|
7
|
-
// time-travel viewer (v0.9.2.1) renders the timeline.
|
|
8
|
-
//
|
|
9
|
-
// Why diffs and not full snapshots:
|
|
10
|
-
// • prod stores can be huge (carts, paginated lists, etc.)
|
|
11
|
-
// • a diff drops to ~1% of full snapshot size in typical apps
|
|
12
|
-
// • the viewer rehydrates by applying diffs forward from a baseline
|
|
13
|
-
//
|
|
14
|
-
// `recordState(obj)` is the manual escape hatch for state that isn't
|
|
15
|
-
// in a redux/zustand store (e.g. `useState` in a deeply-nested
|
|
16
|
-
// component, or React Context). The host calls it where it makes sense.
|
|
17
|
-
//
|
|
18
|
-
// Privacy: the same mask query that protects screenshots is consulted
|
|
19
|
-
// before serializing — any path matching `nativeID` shape isn't yet,
|
|
20
|
-
// but `mask.matchPath` can be added later. v0.9.2 ships without
|
|
21
|
-
// path masking; consumers should keep PII out of bindState scopes.
|
|
22
|
-
const MAX_SNAPSHOTS = 50;
|
|
23
|
-
let _snapshots = [];
|
|
24
|
-
let _unsubscribers = [];
|
|
25
|
-
let _lastByLabel = {};
|
|
26
|
-
export function bindState(opts) {
|
|
27
|
-
unbindState();
|
|
28
|
-
bindOne('redux', opts.redux);
|
|
29
|
-
bindOne('zustand', opts.zustand);
|
|
30
|
-
if (opts.custom) {
|
|
31
|
-
for (const [label, store] of Object.entries(opts.custom)) {
|
|
32
|
-
bindOne(label, store);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function bindOne(label, store) {
|
|
37
|
-
if (!store)
|
|
38
|
-
return;
|
|
39
|
-
if (typeof store.getState !== 'function' || typeof store.subscribe !== 'function')
|
|
40
|
-
return;
|
|
41
|
-
try {
|
|
42
|
-
_lastByLabel[label] = store.getState();
|
|
43
|
-
const unsub = store.subscribe(() => {
|
|
44
|
-
const next = store.getState();
|
|
45
|
-
const prev = _lastByLabel[label];
|
|
46
|
-
const diff = shallowDiff(prev, next);
|
|
47
|
-
if (diff && Object.keys(diff).length > 0) {
|
|
48
|
-
push({ diff, source: label, ts: Date.now() });
|
|
49
|
-
}
|
|
50
|
-
_lastByLabel[label] = next;
|
|
51
|
-
});
|
|
52
|
-
_unsubscribers.push(unsub);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
// ignore bad stores
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export function unbindState() {
|
|
59
|
-
for (const u of _unsubscribers) {
|
|
60
|
-
try {
|
|
61
|
-
u();
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
// ignore
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
_unsubscribers = [];
|
|
68
|
-
_lastByLabel = {};
|
|
69
|
-
}
|
|
70
|
-
/** Manual recording for state not in a subscribed store. */
|
|
71
|
-
export function recordState(snapshot, source = 'manual') {
|
|
72
|
-
push({ diff: snapshot, source, ts: Date.now() });
|
|
73
|
-
}
|
|
74
|
-
export function getStateSnapshots() {
|
|
75
|
-
return _snapshots.slice();
|
|
76
|
-
}
|
|
77
|
-
export function clearStateSnapshots() {
|
|
78
|
-
_snapshots = [];
|
|
79
|
-
}
|
|
80
|
-
function push(s) {
|
|
81
|
-
_snapshots.push(s);
|
|
82
|
-
while (_snapshots.length > MAX_SNAPSHOTS)
|
|
83
|
-
_snapshots.shift();
|
|
84
|
-
}
|
|
85
|
-
/** Returns the top-level key/value diff (next has the value, prev
|
|
86
|
-
* may not contain the key). Empty diff returns `{}` so callers can
|
|
87
|
-
* no-op on empty. */
|
|
88
|
-
export function shallowDiff(prev, next) {
|
|
89
|
-
if (typeof next !== 'object' || next === null)
|
|
90
|
-
return null;
|
|
91
|
-
const nObj = next;
|
|
92
|
-
if (typeof prev !== 'object' || prev === null) {
|
|
93
|
-
return { ...nObj };
|
|
94
|
-
}
|
|
95
|
-
const pObj = prev;
|
|
96
|
-
const out = {};
|
|
97
|
-
const keys = new Set([...Object.keys(pObj), ...Object.keys(nObj)]);
|
|
98
|
-
for (const k of keys) {
|
|
99
|
-
if (pObj[k] !== nObj[k])
|
|
100
|
-
out[k] = nObj[k];
|
|
101
|
-
}
|
|
102
|
-
return out;
|
|
103
|
-
}
|
|
104
|
-
/** Test-only. */
|
|
105
|
-
export function __resetStateSnapshotsForTests() {
|
|
106
|
-
unbindState();
|
|
107
|
-
_snapshots = [];
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=state-snapshots.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-snapshots.js","sourceRoot":"","sources":["../src/state-snapshots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C,CAAC,CAAC;IACnB,OAAO,UAAU,CAAC,MAAM,GAAG,aAAa;QAAE,UAAU,CAAC,KAAK,EAAE,CAAC;AAC/D,CAAC;AAED;;sBAEsB;AACtB,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,IAAa;IACtD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,IAAI,GAAG,IAA+B,CAAC;IAC7C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IACrB,CAAC;IACD,MAAM,IAAI,GAAG,IAA+B,CAAC;IAC7C,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnE,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,iBAAiB;AACjB,MAAM,UAAU,6BAA6B;IAC3C,WAAW,EAAE,CAAC;IACd,UAAU,GAAG,EAAE,CAAC;AAClB,CAAC"}
|
package/lib/track.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export type TrackProps = Record<string, unknown>;
|
|
2
|
-
export type TrackEvent = {
|
|
3
|
-
environment?: string;
|
|
4
|
-
name: string;
|
|
5
|
-
props?: TrackProps;
|
|
6
|
-
release?: string;
|
|
7
|
-
route?: string;
|
|
8
|
-
sessionId?: string;
|
|
9
|
-
ts: string;
|
|
10
|
-
userId?: string;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Record a typed analytics event. Cheap to call from render hooks —
|
|
14
|
-
* pushes into a 500-slot ring drained every 30 s (or on overflow) by
|
|
15
|
-
* the transport flusher.
|
|
16
|
-
*
|
|
17
|
-
* Reserved names start with `$` (e.g. `$pageview`) and are emitted by
|
|
18
|
-
* the SDK itself; you can still call `track('$pageview', …)` from app
|
|
19
|
-
* code to backfill routes the auto-instrumentation missed.
|
|
20
|
-
*
|
|
21
|
-
* Server caps: name ≤ 200 chars, ≤ 40 prop keys. Calls exceeding the
|
|
22
|
-
* cap are dropped client-side (no throw) so app code can fire-and-
|
|
23
|
-
* forget without try/catch.
|
|
24
|
-
*/
|
|
25
|
-
export declare function track(name: string, props?: TrackProps, route?: string): void;
|
|
26
|
-
export declare function flushTrack(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Start the 30 s flush timer. Called once from `init()`. Idempotent.
|
|
29
|
-
* `__resetTrackForTests` is exposed for vitest / bun:test teardown.
|
|
30
|
-
*/
|
|
31
|
-
export declare function startTrackTimer(): void;
|
|
32
|
-
export declare function __peekTrackBuffer(): readonly TrackEvent[];
|
|
33
|
-
export declare function __resetTrackForTests(): void;
|
|
34
|
-
//# sourceMappingURL=track.d.ts.map
|
package/lib/track.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAwBA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAUF;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CA8B5E;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAOhD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAOtC;AAED,wBAAgB,iBAAiB,IAAI,SAAS,UAAU,EAAE,CAEzD;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAM3C"}
|
package/lib/track.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
// v1.1 chunk B — analytics `track` events on the SDK side.
|
|
2
|
-
//
|
|
3
|
-
// `sentori.track(name, props?)` pushes a single typed analytics event
|
|
4
|
-
// into a fixed-size ring. A timer flushes the ring every 30 s (or
|
|
5
|
-
// when the buffer hits 500) to `POST /v1/track:batch`. Best-effort;
|
|
6
|
-
// a flush failure drops the batch — analytics aren't critical
|
|
7
|
-
// telemetry.
|
|
8
|
-
//
|
|
9
|
-
// Why not one fetch per event: a busy app emitting `$pageview` +
|
|
10
|
-
// custom funnel events every nav would saturate the JS thread and
|
|
11
|
-
// the host's outbound connection pool. The same batching shape the
|
|
12
|
-
// metrics module uses keeps `track()` cheap to call from render
|
|
13
|
-
// hooks.
|
|
14
|
-
//
|
|
15
|
-
// Auto-pageview (`$pageview`) is emitted from `useTraceNavigation`
|
|
16
|
-
// in navigation.ts whenever react-navigation swaps the active route.
|
|
17
|
-
// Hosts that don't use react-navigation can call
|
|
18
|
-
// `sentori.track('$pageview', { route: 'Cart' })` themselves.
|
|
19
|
-
import { addInternalBreadcrumb } from './breadcrumbs';
|
|
20
|
-
import { getCurrentUserId } from './capture';
|
|
21
|
-
import { getConfig, isInitialized } from './config';
|
|
22
|
-
import { sendTrackBatch } from './transport';
|
|
23
|
-
const MAX_BUFFER = 500;
|
|
24
|
-
const NAME_MAX = 200;
|
|
25
|
-
const PROPS_KEYS_MAX = 40;
|
|
26
|
-
const FLUSH_INTERVAL_MS = 30_000;
|
|
27
|
-
let _buf = [];
|
|
28
|
-
let _timer = null;
|
|
29
|
-
/**
|
|
30
|
-
* Record a typed analytics event. Cheap to call from render hooks —
|
|
31
|
-
* pushes into a 500-slot ring drained every 30 s (or on overflow) by
|
|
32
|
-
* the transport flusher.
|
|
33
|
-
*
|
|
34
|
-
* Reserved names start with `$` (e.g. `$pageview`) and are emitted by
|
|
35
|
-
* the SDK itself; you can still call `track('$pageview', …)` from app
|
|
36
|
-
* code to backfill routes the auto-instrumentation missed.
|
|
37
|
-
*
|
|
38
|
-
* Server caps: name ≤ 200 chars, ≤ 40 prop keys. Calls exceeding the
|
|
39
|
-
* cap are dropped client-side (no throw) so app code can fire-and-
|
|
40
|
-
* forget without try/catch.
|
|
41
|
-
*/
|
|
42
|
-
export function track(name, props, route) {
|
|
43
|
-
if (!isInitialized())
|
|
44
|
-
return;
|
|
45
|
-
if (typeof name !== 'string' || name.length === 0 || name.length > NAME_MAX) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (props && Object.keys(props).length > PROPS_KEYS_MAX) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const config = getConfig();
|
|
52
|
-
const ev = {
|
|
53
|
-
name,
|
|
54
|
-
props,
|
|
55
|
-
release: config?.release,
|
|
56
|
-
environment: config?.environment,
|
|
57
|
-
route,
|
|
58
|
-
ts: new Date().toISOString(),
|
|
59
|
-
userId: getCurrentUserId(),
|
|
60
|
-
};
|
|
61
|
-
_buf.push(ev);
|
|
62
|
-
// v2.0 W3 — auto-breadcrumb. When `init.capture.trackAutoBreadcrumb`
|
|
63
|
-
// is `true`, push a `{ type: 'track', data: { name, props } }`
|
|
64
|
-
// breadcrumb so the customer journey leading up to a later
|
|
65
|
-
// `captureException` / `captureMessage` is visible in the dashboard.
|
|
66
|
-
// Defaults off — see Config.trackAutoBreadcrumb docstring.
|
|
67
|
-
if (config?.trackAutoBreadcrumb === true) {
|
|
68
|
-
addInternalBreadcrumb('track', props ? { name, props } : { name });
|
|
69
|
-
}
|
|
70
|
-
if (_buf.length >= MAX_BUFFER) {
|
|
71
|
-
void flushTrack();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export async function flushTrack() {
|
|
75
|
-
if (_buf.length === 0)
|
|
76
|
-
return;
|
|
77
|
-
const config = getConfig();
|
|
78
|
-
if (!config)
|
|
79
|
-
return;
|
|
80
|
-
const batch = _buf;
|
|
81
|
-
_buf = [];
|
|
82
|
-
await sendTrackBatch(config.ingestUrl, config.token, batch);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Start the 30 s flush timer. Called once from `init()`. Idempotent.
|
|
86
|
-
* `__resetTrackForTests` is exposed for vitest / bun:test teardown.
|
|
87
|
-
*/
|
|
88
|
-
export function startTrackTimer() {
|
|
89
|
-
if (_timer !== null)
|
|
90
|
-
return;
|
|
91
|
-
_timer = setInterval(() => {
|
|
92
|
-
void flushTrack();
|
|
93
|
-
}, FLUSH_INTERVAL_MS);
|
|
94
|
-
// Don't keep the process alive solely for this timer.
|
|
95
|
-
_timer.unref?.();
|
|
96
|
-
}
|
|
97
|
-
export function __peekTrackBuffer() {
|
|
98
|
-
return _buf;
|
|
99
|
-
}
|
|
100
|
-
export function __resetTrackForTests() {
|
|
101
|
-
if (_timer !== null) {
|
|
102
|
-
clearInterval(_timer);
|
|
103
|
-
_timer = null;
|
|
104
|
-
}
|
|
105
|
-
_buf = [];
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=track.js.map
|
package/lib/track.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"track.js","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE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AAK,IAAI,EAAE,CAAC;QACpB,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,GAAG,EAAE,CAAC;AACZ,CAAC"}
|
package/lib/trail.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TrailBuffer, type TrailStep } from '@goliapkg/sentori-core';
|
|
2
|
-
/**
|
|
3
|
-
* Phase 46 — record a step into the session-trail buffer. The buffer
|
|
4
|
-
* is a fixed-size FIFO (default 30 steps); pushing past capacity
|
|
5
|
-
* drops the oldest entry. Steps are only uploaded if
|
|
6
|
-
* `init({ capture: { sessionTrail: true } })` is on AND a
|
|
7
|
-
* `captureException` follows.
|
|
8
|
-
*/
|
|
9
|
-
export declare const captureStep: (label: string, opts?: Partial<TrailStep>) => void;
|
|
10
|
-
export declare const getTrailBuffer: () => TrailBuffer;
|
|
11
|
-
export declare const __resetTrailForTests: () => void;
|
|
12
|
-
//# sourceMappingURL=trail.d.ts.map
|
package/lib/trail.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trail.d.ts","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIrE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,OAAO,OAAO,CAAC,SAAS,CAAC,KAAG,IAMtE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,WAAqB,CAAC;AAExD,eAAO,MAAM,oBAAoB,QAAO,IAEvC,CAAC"}
|