@allstak/react-native 0.3.0 → 0.3.2
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/AllStakRN.podspec +25 -0
- package/CHANGELOG.md +63 -0
- package/README.md +379 -145
- package/build-hooks/allstak-sourcemaps.gradle +132 -0
- package/build-hooks/eas-post-bundle.js +127 -0
- package/build-hooks/upload-sourcemaps.js +175 -0
- package/build-hooks/xcode-build-phase.sh +90 -0
- package/dist/build/sourcemaps.d.mts +94 -0
- package/dist/build/sourcemaps.d.ts +94 -0
- package/dist/build/sourcemaps.js +142 -0
- package/dist/build/sourcemaps.js.map +1 -0
- package/dist/build/sourcemaps.mjs +115 -0
- package/dist/build/sourcemaps.mjs.map +1 -0
- package/dist/expo-plugin.js +1 -1
- package/dist/expo-plugin.js.map +1 -1
- package/dist/expo-plugin.mjs +1 -1
- package/dist/expo-plugin.mjs.map +1 -1
- package/dist/index.d.mts +366 -29
- package/dist/index.d.ts +366 -29
- package/dist/index.js +1131 -160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1126 -165
- package/dist/index.mjs.map +1 -1
- package/native/android/build.gradle +3 -1
- package/native/android/src/main/java/io/allstak/rn/AllStakRNModule.java +17 -0
- package/native/ios/AllStakRNModule.m +16 -0
- package/package.json +21 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* in-memory ring buffer
|
|
4
|
+
* Fail-open HTTP transport for React Native. Telemetry sends are best-effort:
|
|
5
|
+
* they use a short timeout, never reject into the host app, and fall into a
|
|
6
|
+
* bounded in-memory ring buffer with circuit-breaker backoff when AllStak is
|
|
7
|
+
* unavailable.
|
|
5
8
|
*
|
|
6
9
|
* No window, no AbortController fallback shims — RN exposes both natively.
|
|
7
10
|
*/
|
|
11
|
+
interface TransportStats {
|
|
12
|
+
queued: number;
|
|
13
|
+
sent: number;
|
|
14
|
+
failed: number;
|
|
15
|
+
dropped: number;
|
|
16
|
+
consecutiveFailures: number;
|
|
17
|
+
circuitOpenUntil: number;
|
|
18
|
+
lastTransportLatencyMs?: number;
|
|
19
|
+
lastFlushDurationMs?: number;
|
|
20
|
+
}
|
|
8
21
|
declare class HttpTransport {
|
|
9
22
|
private baseUrl;
|
|
10
23
|
private apiKey;
|
|
24
|
+
private enabled;
|
|
11
25
|
private buffer;
|
|
12
26
|
private flushing;
|
|
13
|
-
|
|
27
|
+
private consecutiveFailures;
|
|
28
|
+
private circuitOpenUntil;
|
|
29
|
+
private sent;
|
|
30
|
+
private failed;
|
|
31
|
+
private dropped;
|
|
32
|
+
private lastTransportLatencyMs;
|
|
33
|
+
private lastFlushDurationMs;
|
|
34
|
+
constructor(baseUrl: string, apiKey: string, enabled?: boolean);
|
|
14
35
|
send(path: string, payload: unknown): Promise<void>;
|
|
36
|
+
private enqueueOrDispatch;
|
|
37
|
+
private dispatch;
|
|
15
38
|
private doFetch;
|
|
39
|
+
private push;
|
|
40
|
+
private scheduleFlush;
|
|
16
41
|
private flushBuffer;
|
|
42
|
+
private recordFailure;
|
|
17
43
|
getBufferSize(): number;
|
|
44
|
+
noteDropped(count?: number): void;
|
|
45
|
+
getStats(): TransportStats;
|
|
18
46
|
/**
|
|
19
47
|
* Wait for the in-flight retry-buffer to drain. Resolves `true` if the
|
|
20
48
|
* buffer empties within `timeoutMs` (default 2000ms), `false` otherwise.
|
|
@@ -42,6 +70,10 @@ declare class HttpTransport {
|
|
|
42
70
|
/** What instrumentation hands to the module per request. */
|
|
43
71
|
interface HttpRequestEvent {
|
|
44
72
|
type: 'http_request';
|
|
73
|
+
traceId: string;
|
|
74
|
+
requestId: string;
|
|
75
|
+
spanId?: string;
|
|
76
|
+
parentSpanId?: string;
|
|
45
77
|
method: string;
|
|
46
78
|
url: string;
|
|
47
79
|
statusCode?: number;
|
|
@@ -53,11 +85,19 @@ interface HttpRequestEvent {
|
|
|
53
85
|
requestHeaders?: Record<string, string>;
|
|
54
86
|
responseHeaders?: Record<string, string>;
|
|
55
87
|
error?: string;
|
|
56
|
-
|
|
88
|
+
requestBodyStatus?: string;
|
|
89
|
+
responseBodyStatus?: string;
|
|
90
|
+
requestBodyRedactedFields?: string[];
|
|
91
|
+
responseBodyRedactedFields?: string[];
|
|
92
|
+
requestBodyTruncated?: boolean;
|
|
93
|
+
responseBodyTruncated?: boolean;
|
|
94
|
+
capturePolicy?: string;
|
|
95
|
+
linkConfidence?: 'exact' | 'inferred' | 'weak' | 'none';
|
|
57
96
|
}
|
|
58
97
|
interface HttpRequestIngestItem {
|
|
59
98
|
type: 'http_request';
|
|
60
99
|
traceId: string;
|
|
100
|
+
requestId: string;
|
|
61
101
|
direction: 'outbound';
|
|
62
102
|
method: string;
|
|
63
103
|
host: string;
|
|
@@ -72,6 +112,16 @@ interface HttpRequestIngestItem {
|
|
|
72
112
|
requestHeaders?: Record<string, string>;
|
|
73
113
|
responseHeaders?: Record<string, string>;
|
|
74
114
|
error?: string;
|
|
115
|
+
spanId?: string;
|
|
116
|
+
parentSpanId?: string;
|
|
117
|
+
requestBodyStatus?: string;
|
|
118
|
+
responseBodyStatus?: string;
|
|
119
|
+
requestBodyRedactedFields?: string[];
|
|
120
|
+
responseBodyRedactedFields?: string[];
|
|
121
|
+
requestBodyTruncated?: boolean;
|
|
122
|
+
responseBodyTruncated?: boolean;
|
|
123
|
+
capturePolicy?: string;
|
|
124
|
+
linkConfidence?: 'exact' | 'inferred' | 'weak' | 'none';
|
|
75
125
|
environment?: string;
|
|
76
126
|
release?: string;
|
|
77
127
|
dist?: string;
|
|
@@ -239,9 +289,19 @@ interface ReplaySurrogateOptions {
|
|
|
239
289
|
}
|
|
240
290
|
interface SurrogateEvent {
|
|
241
291
|
ts: number;
|
|
242
|
-
k: 'screen' | 'appstate' | 'manual';
|
|
292
|
+
k: 'screen' | 'appstate' | 'manual' | 'request' | 'exception' | 'response' | 'action' | 'retry';
|
|
243
293
|
data: Record<string, unknown>;
|
|
244
294
|
}
|
|
295
|
+
interface TimelineContext {
|
|
296
|
+
traceId?: string;
|
|
297
|
+
requestId?: string;
|
|
298
|
+
spanId?: string;
|
|
299
|
+
eventId?: string;
|
|
300
|
+
release?: string;
|
|
301
|
+
dist?: string;
|
|
302
|
+
screen?: string;
|
|
303
|
+
route?: string;
|
|
304
|
+
}
|
|
245
305
|
declare class ReplaySurrogate {
|
|
246
306
|
private transport;
|
|
247
307
|
private buffer;
|
|
@@ -254,11 +314,13 @@ declare class ReplaySurrogate {
|
|
|
254
314
|
/** Enable recording for this session if sample-rate roll passes. */
|
|
255
315
|
start(): boolean;
|
|
256
316
|
/** Record a screen view. Filters params through the safeParams allow-list. */
|
|
257
|
-
recordScreenView(routeName: string, params?: Record<string, unknown
|
|
317
|
+
recordScreenView(routeName: string, params?: Record<string, unknown>, context?: TimelineContext): void;
|
|
258
318
|
/** Record an AppState transition (foreground/background/inactive). */
|
|
259
|
-
recordAppState(next: string): void;
|
|
319
|
+
recordAppState(next: string, context?: TimelineContext): void;
|
|
260
320
|
/** Record a free-form, customer-validated checkpoint. */
|
|
261
|
-
recordManual(label: string, data?: Record<string, unknown
|
|
321
|
+
recordManual(label: string, data?: Record<string, unknown>, context?: TimelineContext): void;
|
|
322
|
+
/** Record a forensic mobile session timeline marker. This is not replay. */
|
|
323
|
+
recordTimelineMarker(kind: SurrogateEvent['k'], label: string, data?: Record<string, unknown>, context?: TimelineContext): void;
|
|
262
324
|
destroy(): void;
|
|
263
325
|
/** @internal — for tests. */
|
|
264
326
|
isActive(): boolean;
|
|
@@ -268,6 +330,28 @@ declare class ReplaySurrogate {
|
|
|
268
330
|
private flush;
|
|
269
331
|
}
|
|
270
332
|
|
|
333
|
+
/**
|
|
334
|
+
* URL + header + body redaction utilities for HTTP instrumentation.
|
|
335
|
+
*
|
|
336
|
+
* Hard rules:
|
|
337
|
+
* - Authorization, Cookie, X-API-Key, Set-Cookie are ALWAYS redacted
|
|
338
|
+
* (host app cannot opt back into capturing them).
|
|
339
|
+
* - Query params named `token`, `password`, `api_key`, `apikey`,
|
|
340
|
+
* `authorization`, `auth`, `secret`, `access_token`, `refresh_token`,
|
|
341
|
+
* `session` are ALWAYS redacted.
|
|
342
|
+
* - Host app may add additional names via `redactHeaders` /
|
|
343
|
+
* `redactQueryParams`; the always-list is the floor, not the ceiling.
|
|
344
|
+
* - Bodies are truncated to `maxBodyBytes` (default 4096) and replaced
|
|
345
|
+
* with `'<binary>'` when not safely-stringifiable.
|
|
346
|
+
*
|
|
347
|
+
* URL pattern matching for ignoredUrls / allowedUrls accepts strings
|
|
348
|
+
* (substring match) or RegExp (test-based). String matching is
|
|
349
|
+
* case-insensitive on the URL.
|
|
350
|
+
*/
|
|
351
|
+
declare const ALWAYS_REDACT_HEADERS: Set<string>;
|
|
352
|
+
declare const ALWAYS_REDACT_QUERY: Set<string>;
|
|
353
|
+
declare const REDACTED = "[REDACTED]";
|
|
354
|
+
declare const DEFAULT_REDACT_BODY_FIELDS: string[];
|
|
271
355
|
interface HttpTrackingOptions {
|
|
272
356
|
/** Capture request body. Default false. Truncated to maxBodyBytes. */
|
|
273
357
|
captureRequestBody?: boolean;
|
|
@@ -294,11 +378,69 @@ interface HttpTrackingOptions {
|
|
|
294
378
|
allowedUrls?: (string | RegExp)[];
|
|
295
379
|
/** Max bytes per captured body. Default 4096. */
|
|
296
380
|
maxBodyBytes?: number;
|
|
381
|
+
/** Content types eligible for body capture. Default JSON + text payloads. */
|
|
382
|
+
allowedContentTypes?: string[];
|
|
383
|
+
/** Additional JSON body fields to redact recursively. */
|
|
384
|
+
redactBodyFields?: string[];
|
|
385
|
+
}
|
|
386
|
+
interface CapturedBody {
|
|
387
|
+
body?: string;
|
|
388
|
+
status: 'disabled' | 'captured' | 'redacted' | 'truncated' | 'unsupported' | 'empty';
|
|
389
|
+
redactedFields: string[];
|
|
390
|
+
truncated: boolean;
|
|
391
|
+
capturePolicy: string;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Redact sensitive query-string params in a URL. Returns the sanitized
|
|
395
|
+
* URL string. Falls back to the input when URL parsing fails (relative
|
|
396
|
+
* URLs in test environments).
|
|
397
|
+
*/
|
|
398
|
+
declare function redactUrl(url: string, opts: HttpTrackingOptions): string;
|
|
399
|
+
/**
|
|
400
|
+
* Filter + redact an HTTP header dictionary. Returns a NEW object — does
|
|
401
|
+
* not mutate the input. When `captureHeaders` is false returns undefined
|
|
402
|
+
* (no headers in the wire payload at all).
|
|
403
|
+
*/
|
|
404
|
+
declare function sanitizeHeaders(headers: Record<string, string | string[] | undefined> | undefined, opts: HttpTrackingOptions): Record<string, string> | undefined;
|
|
405
|
+
/**
|
|
406
|
+
* Truncate + safely-stringify a body. Returns:
|
|
407
|
+
* - undefined when capture is disabled
|
|
408
|
+
* - the stringified body when it's a string / number / plain object
|
|
409
|
+
* - '<binary>' when it's a Blob / FormData / ArrayBuffer / etc
|
|
410
|
+
* - truncated string with `…[truncated]` suffix when over maxBodyBytes
|
|
411
|
+
*/
|
|
412
|
+
declare function captureBodyResult(body: unknown, enabled: boolean, maxBodyBytes: number, opts?: HttpTrackingOptions, contentType?: string): CapturedBody;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Per-console-method capture flags. Defaults are set to keep the
|
|
416
|
+
* dashboard signal-to-noise high: `warn` and `error` capture by default
|
|
417
|
+
* (most apps fire those at human-meaningful moments), `log` and `info`
|
|
418
|
+
* are OFF by default since typical apps log thousands of debug lines
|
|
419
|
+
* per session.
|
|
420
|
+
*
|
|
421
|
+
* Override per-method:
|
|
422
|
+
*
|
|
423
|
+
* <AllStakProvider captureConsole={{ log: true, info: true }} />
|
|
424
|
+
*
|
|
425
|
+
* Or to fully suppress:
|
|
426
|
+
*
|
|
427
|
+
* <AllStakProvider captureConsole={{ warn: false, error: false }} />
|
|
428
|
+
*
|
|
429
|
+
* Setting `autoConsoleBreadcrumbs={false}` on the provider/install is a
|
|
430
|
+
* higher-level kill switch — it skips wrapping any console method.
|
|
431
|
+
*/
|
|
432
|
+
interface ConsoleCaptureOptions {
|
|
433
|
+
log?: boolean;
|
|
434
|
+
info?: boolean;
|
|
435
|
+
warn?: boolean;
|
|
436
|
+
error?: boolean;
|
|
297
437
|
}
|
|
438
|
+
/** @internal — for tests. Resets the wrap-once flag. */
|
|
439
|
+
declare function __resetConsoleInstrumentationFlagForTest(): void;
|
|
298
440
|
|
|
299
441
|
declare const INGEST_HOST = "https://api.allstak.sa";
|
|
300
442
|
declare const SDK_NAME = "allstak-react-native";
|
|
301
|
-
declare const SDK_VERSION = "0.3.
|
|
443
|
+
declare const SDK_VERSION = "0.3.1";
|
|
302
444
|
|
|
303
445
|
interface AllStakConfig {
|
|
304
446
|
/** Project API key (`ask_live_…`). Required. */
|
|
@@ -351,6 +493,12 @@ interface AllStakConfig {
|
|
|
351
493
|
* are ALWAYS redacted.
|
|
352
494
|
*/
|
|
353
495
|
httpTracking?: HttpTrackingOptions;
|
|
496
|
+
/**
|
|
497
|
+
* Per-console-method capture flags. Defaults: warn + error captured,
|
|
498
|
+
* log + info NOT captured (to avoid breadcrumb spam from typical app
|
|
499
|
+
* logging). Set `{ log: true, info: true }` to opt-in.
|
|
500
|
+
*/
|
|
501
|
+
captureConsole?: ConsoleCaptureOptions;
|
|
354
502
|
maxBreadcrumbs?: number;
|
|
355
503
|
/**
|
|
356
504
|
* Probability in [0, 1] that any given error is sent. Default: 1 (no sampling).
|
|
@@ -363,6 +511,13 @@ interface AllStakConfig {
|
|
|
363
511
|
* — the event is sent as-is so a buggy hook can't black-hole telemetry.
|
|
364
512
|
*/
|
|
365
513
|
beforeSend?: (event: ErrorIngestPayload) => ErrorIngestPayload | null | undefined | Promise<ErrorIngestPayload | null | undefined>;
|
|
514
|
+
/**
|
|
515
|
+
* Optional fail-open screenshot capture. Off by default and provider-based
|
|
516
|
+
* so Expo/RN apps choose their own native or JS screenshot implementation.
|
|
517
|
+
* The SDK bounds timeout/size/sampling and drops screenshots before it can
|
|
518
|
+
* hurt app navigation, JS thread responsiveness, or telemetry delivery.
|
|
519
|
+
*/
|
|
520
|
+
screenshot?: ScreenshotCaptureOptions;
|
|
366
521
|
/** SDK identity overrides (set automatically by installReactNative). */
|
|
367
522
|
sdkName?: string;
|
|
368
523
|
sdkVersion?: string;
|
|
@@ -371,6 +526,28 @@ interface AllStakConfig {
|
|
|
371
526
|
commitSha?: string;
|
|
372
527
|
branch?: string;
|
|
373
528
|
}
|
|
529
|
+
interface ScreenshotArtifact {
|
|
530
|
+
data?: string;
|
|
531
|
+
contentType?: 'image/png' | 'image/jpeg' | 'image/webp';
|
|
532
|
+
width?: number;
|
|
533
|
+
height?: number;
|
|
534
|
+
sizeBytes?: number;
|
|
535
|
+
redacted?: boolean;
|
|
536
|
+
redactionStrategy?: string;
|
|
537
|
+
}
|
|
538
|
+
interface ScreenshotCaptureOptions {
|
|
539
|
+
enabled?: boolean;
|
|
540
|
+
captureOnError?: boolean;
|
|
541
|
+
timeoutMs?: number;
|
|
542
|
+
maxBytes?: number;
|
|
543
|
+
sampleRate?: number;
|
|
544
|
+
provider?: (reason: {
|
|
545
|
+
type: 'error';
|
|
546
|
+
error: Error;
|
|
547
|
+
traceId?: string;
|
|
548
|
+
requestId?: string;
|
|
549
|
+
}) => ScreenshotArtifact | null | undefined | Promise<ScreenshotArtifact | null | undefined>;
|
|
550
|
+
}
|
|
374
551
|
interface Breadcrumb {
|
|
375
552
|
timestamp: string;
|
|
376
553
|
type: string;
|
|
@@ -386,6 +563,7 @@ interface PayloadFrame {
|
|
|
386
563
|
colno?: number;
|
|
387
564
|
inApp?: boolean;
|
|
388
565
|
platform?: string;
|
|
566
|
+
debugId?: string;
|
|
389
567
|
}
|
|
390
568
|
interface ErrorIngestPayload {
|
|
391
569
|
exceptionClass: string;
|
|
@@ -400,6 +578,12 @@ interface ErrorIngestPayload {
|
|
|
400
578
|
environment?: string;
|
|
401
579
|
release?: string;
|
|
402
580
|
sessionId?: string;
|
|
581
|
+
traceId?: string;
|
|
582
|
+
spanId?: string;
|
|
583
|
+
parentSpanId?: string;
|
|
584
|
+
requestId?: string;
|
|
585
|
+
replayId?: string;
|
|
586
|
+
service?: string;
|
|
403
587
|
user?: {
|
|
404
588
|
id?: string;
|
|
405
589
|
email?: string;
|
|
@@ -407,6 +591,12 @@ interface ErrorIngestPayload {
|
|
|
407
591
|
metadata?: Record<string, unknown>;
|
|
408
592
|
breadcrumbs?: Breadcrumb[];
|
|
409
593
|
fingerprint?: string[];
|
|
594
|
+
debugMeta?: {
|
|
595
|
+
images: Array<{
|
|
596
|
+
type: string;
|
|
597
|
+
debugId: string;
|
|
598
|
+
}>;
|
|
599
|
+
};
|
|
410
600
|
}
|
|
411
601
|
declare class AllStakClient {
|
|
412
602
|
private transport;
|
|
@@ -482,8 +672,11 @@ declare class AllStakClient {
|
|
|
482
672
|
}): void;
|
|
483
673
|
getSessionId(): string;
|
|
484
674
|
getConfig(): AllStakConfig;
|
|
675
|
+
getTransportStats(): TransportStats;
|
|
485
676
|
destroy(): void;
|
|
486
677
|
private sendLog;
|
|
678
|
+
private shouldCaptureScreenshot;
|
|
679
|
+
private withScreenshotMetadata;
|
|
487
680
|
private passesSampleRate;
|
|
488
681
|
/**
|
|
489
682
|
* Returns the effective config layer = base config + every scope on the
|
|
@@ -555,11 +748,115 @@ declare const AllStak: {
|
|
|
555
748
|
instrumentAxios<T = any>(axios: T): T;
|
|
556
749
|
getSessionId(): string;
|
|
557
750
|
getConfig(): AllStakConfig | null;
|
|
751
|
+
getTransportStats(): TransportStats;
|
|
558
752
|
destroy(): void;
|
|
559
753
|
/** @internal — exposed for testing */
|
|
560
754
|
_getInstance(): AllStakClient | null;
|
|
561
755
|
};
|
|
562
756
|
|
|
757
|
+
/**
|
|
758
|
+
* React Native runtime integration — ErrorUtils, Hermes promise rejection
|
|
759
|
+
* tracking, Platform tags, AppState breadcrumbs, XHR network capture,
|
|
760
|
+
* fetch breadcrumbs, and console breadcrumbs.
|
|
761
|
+
*
|
|
762
|
+
* Extracted from index.ts so AllStakProvider can call it without circular
|
|
763
|
+
* imports.
|
|
764
|
+
*/
|
|
765
|
+
interface ReactNativeInstallOptions {
|
|
766
|
+
/** Auto-capture unhandled JS exceptions via ErrorUtils. Default: true */
|
|
767
|
+
autoErrorHandler?: boolean;
|
|
768
|
+
/** Auto-capture unhandled promise rejections (Hermes). Default: true */
|
|
769
|
+
autoPromiseRejections?: boolean;
|
|
770
|
+
/** Auto-attach Platform.* info as tags. Default: true */
|
|
771
|
+
autoDeviceTags?: boolean;
|
|
772
|
+
/** Auto-emit breadcrumbs on AppState change. Default: true */
|
|
773
|
+
autoAppStateBreadcrumbs?: boolean;
|
|
774
|
+
/** Auto-instrument XHR (RN's fetch is XHR-based) for network breadcrumbs. Default: true */
|
|
775
|
+
autoNetworkCapture?: boolean;
|
|
776
|
+
/** Wrap `globalThis.fetch` to record HTTP breadcrumbs. Default: true */
|
|
777
|
+
autoFetchBreadcrumbs?: boolean;
|
|
778
|
+
/**
|
|
779
|
+
* Wrap `console.*` methods to record log breadcrumbs. Default: true.
|
|
780
|
+
* Per-method capture is controlled by `captureConsole` in AllStakConfig
|
|
781
|
+
* (warn + error default on, log + info default off).
|
|
782
|
+
*/
|
|
783
|
+
autoConsoleBreadcrumbs?: boolean;
|
|
784
|
+
/**
|
|
785
|
+
* Auto-detect `@react-navigation/native` and patch `NavigationContainer`
|
|
786
|
+
* so route changes ship as breadcrumbs without the host app needing
|
|
787
|
+
* to call `instrumentReactNavigation(ref)`. Default: true. When the
|
|
788
|
+
* package is not installed, this silently no-ops.
|
|
789
|
+
*/
|
|
790
|
+
autoNavigationBreadcrumbs?: boolean;
|
|
791
|
+
/**
|
|
792
|
+
* Emit a `[AllStak] Navigation auto-instrumentation enabled/not applied`
|
|
793
|
+
* console log so developers can confirm the wiring at startup. The
|
|
794
|
+
* provider sets this from its `debug` prop; defaults to false when
|
|
795
|
+
* called manually.
|
|
796
|
+
*/
|
|
797
|
+
debugLogs?: boolean;
|
|
798
|
+
}
|
|
799
|
+
declare function installReactNative(options?: ReactNativeInstallOptions): void;
|
|
800
|
+
|
|
801
|
+
interface AllStakProviderProps extends ReactNativeInstallOptions {
|
|
802
|
+
children: React.ReactNode;
|
|
803
|
+
apiKey: string;
|
|
804
|
+
environment?: string;
|
|
805
|
+
release?: string;
|
|
806
|
+
host?: string;
|
|
807
|
+
user?: {
|
|
808
|
+
id?: string;
|
|
809
|
+
email?: string;
|
|
810
|
+
};
|
|
811
|
+
tags?: Record<string, string>;
|
|
812
|
+
debug?: boolean;
|
|
813
|
+
enableHttpTracking?: boolean;
|
|
814
|
+
httpTracking?: AllStakConfig['httpTracking'];
|
|
815
|
+
/**
|
|
816
|
+
* Per-console-method capture flags. Defaults: warn + error on, log +
|
|
817
|
+
* info off. Set `{ log: true, info: true }` to opt-in to verbose
|
|
818
|
+
* capture, or `{ warn: false, error: false }` to suppress.
|
|
819
|
+
*/
|
|
820
|
+
captureConsole?: AllStakConfig['captureConsole'];
|
|
821
|
+
sampleRate?: number;
|
|
822
|
+
beforeSend?: AllStakConfig['beforeSend'];
|
|
823
|
+
replay?: AllStakConfig['replay'];
|
|
824
|
+
tracesSampleRate?: number;
|
|
825
|
+
service?: string;
|
|
826
|
+
dist?: string;
|
|
827
|
+
/**
|
|
828
|
+
* Tear down the SDK when the provider unmounts. Default `false`.
|
|
829
|
+
*
|
|
830
|
+
* Most apps mount `AllStakProvider` once at the root and never unmount
|
|
831
|
+
* it. Setting this to `true` risks disabling telemetry if the provider
|
|
832
|
+
* re-mounts (Fast Refresh in dev, route key changes, React 18 Strict
|
|
833
|
+
* Mode double-mount, etc.) — there is a brief window between unmount
|
|
834
|
+
* and remount where captures throw.
|
|
835
|
+
*
|
|
836
|
+
* Leave at the default unless you genuinely need to dispose the SDK
|
|
837
|
+
* (e.g. test harness, multi-tenant container that switches projects).
|
|
838
|
+
*/
|
|
839
|
+
destroyOnUnmount?: boolean;
|
|
840
|
+
fallback?: React.ReactNode | ((props: {
|
|
841
|
+
error: Error;
|
|
842
|
+
resetError: () => void;
|
|
843
|
+
}) => React.ReactNode);
|
|
844
|
+
onError?: (error: Error, componentStack?: string) => void;
|
|
845
|
+
}
|
|
846
|
+
declare function AllStakProvider({ children, apiKey, environment, release, host, user, tags, debug, enableHttpTracking, httpTracking, captureConsole, sampleRate, beforeSend, replay, tracesSampleRate, service, dist, destroyOnUnmount, fallback, onError, autoErrorHandler, autoPromiseRejections, autoDeviceTags, autoAppStateBreadcrumbs, autoNetworkCapture, autoFetchBreadcrumbs, autoConsoleBreadcrumbs, autoNavigationBreadcrumbs, }: AllStakProviderProps): React.ReactElement;
|
|
847
|
+
declare function useAllStak(): {
|
|
848
|
+
captureException: (error: Error, ctx?: Record<string, unknown>) => void;
|
|
849
|
+
captureMessage: (msg: string, level?: "fatal" | "error" | "warning" | "info") => void;
|
|
850
|
+
setUser: (user: {
|
|
851
|
+
id?: string;
|
|
852
|
+
email?: string;
|
|
853
|
+
}) => void;
|
|
854
|
+
setTag: (key: string, value: string) => void;
|
|
855
|
+
addBreadcrumb: (type: string, message: string, level?: string, data?: Record<string, unknown>) => void;
|
|
856
|
+
};
|
|
857
|
+
/** @internal — for tests. Resets the module-level remount-guard. */
|
|
858
|
+
declare function __resetProviderInstanceForTest(): void;
|
|
859
|
+
|
|
563
860
|
/**
|
|
564
861
|
* React Native navigation breadcrumbs — two opt-in helpers:
|
|
565
862
|
*
|
|
@@ -611,6 +908,38 @@ declare function instrumentReactNavigation(navigationRef: NavigationRef, options
|
|
|
611
908
|
* as breadcrumbs. No-op if `react-native` isn't available (test env).
|
|
612
909
|
*/
|
|
613
910
|
declare function instrumentNavigationFromLinking(): void;
|
|
911
|
+
/**
|
|
912
|
+
* Best-effort automatic instrumentation of `@react-navigation/native`.
|
|
913
|
+
*
|
|
914
|
+
* **What it does:**
|
|
915
|
+
* - Tries `require('@react-navigation/native')`. If the package is not
|
|
916
|
+
* installed, returns `false` and is otherwise a no-op.
|
|
917
|
+
* - If found, monkey-patches the module's exported `NavigationContainer`
|
|
918
|
+
* with a wrapper that auto-creates an internal ref, forwards the
|
|
919
|
+
* user's `ref` prop, and on mount calls `instrumentReactNavigation`
|
|
920
|
+
* so route changes ship as breadcrumbs.
|
|
921
|
+
* - Idempotent: a flag on the module's exports object prevents double
|
|
922
|
+
* patching across hot-reload cycles or repeated `installReactNative`
|
|
923
|
+
* calls.
|
|
924
|
+
*
|
|
925
|
+
* **Why this works:**
|
|
926
|
+
* Babel's CommonJS interop preserves runtime property lookups for
|
|
927
|
+
* named imports — `import { NavigationContainer } from '@react-navigation/native'`
|
|
928
|
+
* compiles to `_rnav.NavigationContainer` accesses at use-site, so
|
|
929
|
+
* patching the module's exports object before the host app renders
|
|
930
|
+
* means user code transparently picks up our wrapper.
|
|
931
|
+
*
|
|
932
|
+
* **Why it might fail:**
|
|
933
|
+
* - `@react-navigation/native` not installed → returns false silently.
|
|
934
|
+
* - Module exports frozen or sealed (rare in CJS-style RN builds).
|
|
935
|
+
* - User imported `NavigationContainer` via a deep path that bypasses
|
|
936
|
+
* the index module.
|
|
937
|
+
* In any failure case the manual API (`instrumentReactNavigation(ref)`)
|
|
938
|
+
* is still available as a fallback.
|
|
939
|
+
*/
|
|
940
|
+
declare function tryAutoInstrumentNavigation(): boolean;
|
|
941
|
+
/** @internal — for tests. Resets the auto-patch flag on the cached module. */
|
|
942
|
+
declare function __resetAutoNavigationFlagForTest(): void;
|
|
614
943
|
|
|
615
944
|
/**
|
|
616
945
|
* React Native architecture / runtime detection.
|
|
@@ -658,8 +987,21 @@ declare function applyArchitectureTags(setTag: (key: string, value: string) => v
|
|
|
658
987
|
* `document`, `localStorage`, `sessionStorage`, or browser DOM event
|
|
659
988
|
* listeners.
|
|
660
989
|
*
|
|
661
|
-
*
|
|
990
|
+
* Recommended usage (one-liner):
|
|
991
|
+
*
|
|
992
|
+
* import { AllStakProvider } from '@allstak/react-native';
|
|
993
|
+
*
|
|
994
|
+
* export default function App() {
|
|
995
|
+
* return (
|
|
996
|
+
* <AllStakProvider apiKey="YOUR_API_KEY" environment="production">
|
|
997
|
+
* <AppRoot />
|
|
998
|
+
* </AllStakProvider>
|
|
999
|
+
* );
|
|
1000
|
+
* }
|
|
662
1001
|
*
|
|
1002
|
+
* Advanced / manual usage:
|
|
1003
|
+
*
|
|
1004
|
+
* import { AllStak, installReactNative } from '@allstak/react-native';
|
|
663
1005
|
* AllStak.init({ apiKey, environment, release });
|
|
664
1006
|
* installReactNative();
|
|
665
1007
|
*
|
|
@@ -667,29 +1009,24 @@ declare function applyArchitectureTags(setTag: (key: string, value: string) => v
|
|
|
667
1009
|
* under the `native/` directory in this package. See README.
|
|
668
1010
|
*/
|
|
669
1011
|
|
|
670
|
-
interface ReactNativeInstallOptions {
|
|
671
|
-
/** Auto-capture unhandled JS exceptions via ErrorUtils. Default: true */
|
|
672
|
-
autoErrorHandler?: boolean;
|
|
673
|
-
/** Auto-capture unhandled promise rejections (Hermes). Default: true */
|
|
674
|
-
autoPromiseRejections?: boolean;
|
|
675
|
-
/** Auto-attach Platform.* info as tags. Default: true */
|
|
676
|
-
autoDeviceTags?: boolean;
|
|
677
|
-
/** Auto-emit breadcrumbs on AppState change. Default: true */
|
|
678
|
-
autoAppStateBreadcrumbs?: boolean;
|
|
679
|
-
/** Auto-instrument XHR (RN's fetch is XHR-based) for network breadcrumbs. Default: true */
|
|
680
|
-
autoNetworkCapture?: boolean;
|
|
681
|
-
/** Wrap `globalThis.fetch` to record HTTP breadcrumbs. Default: true */
|
|
682
|
-
autoFetchBreadcrumbs?: boolean;
|
|
683
|
-
/** Wrap `console.warn`/`console.error` to record log breadcrumbs. Default: true */
|
|
684
|
-
autoConsoleBreadcrumbs?: boolean;
|
|
685
|
-
}
|
|
686
1012
|
declare function __setNativeModuleForTest(mod: any): void;
|
|
1013
|
+
/**
|
|
1014
|
+
* DEV-ONLY: deliberately trigger a native iOS or Android crash via the
|
|
1015
|
+
* linked AllStak native module. This is intended for verifying the
|
|
1016
|
+
* native-crash → drain → ingest pipeline during SDK development. It
|
|
1017
|
+
* **terminates the app process** — never expose this in production UI.
|
|
1018
|
+
*
|
|
1019
|
+
* import { __devTriggerNativeCrash } from '@allstak/react-native';
|
|
1020
|
+
* if (__DEV__) __devTriggerNativeCrash(); // app dies; relaunch drains
|
|
1021
|
+
*
|
|
1022
|
+
* No-op when the native module is not linked.
|
|
1023
|
+
*/
|
|
1024
|
+
declare function __devTriggerNativeCrash(): Promise<void>;
|
|
687
1025
|
/**
|
|
688
1026
|
* Drain any native crash stashed by AllStakCrashHandler on the previous
|
|
689
1027
|
* launch and ship it to /ingest/v1/errors. No-op when the native module
|
|
690
1028
|
* is not linked (Expo Go, JS-only test runners, etc).
|
|
691
1029
|
*/
|
|
692
1030
|
declare function drainPendingNativeCrashes(release?: string): Promise<void>;
|
|
693
|
-
declare function installReactNative(options?: ReactNativeInstallOptions): void;
|
|
694
1031
|
|
|
695
|
-
export { AllStak, AllStakClient, type AllStakConfig, type ArchitectureInfo, type Breadcrumb, type HttpRequestEvent, HttpRequestModule, type HttpTrackingOptions, INGEST_HOST, type ReactNativeInstallOptions, ReplaySurrogate, type ReplaySurrogateOptions, SDK_NAME, SDK_VERSION, Scope, __setNativeModuleForTest, applyArchitectureTags, detectArchitecture, drainPendingNativeCrashes, installReactNative, instrumentNavigationFromLinking, instrumentReactNavigation };
|
|
1032
|
+
export { ALWAYS_REDACT_HEADERS, ALWAYS_REDACT_QUERY, AllStak, AllStakClient, type AllStakConfig, AllStakProvider, type AllStakProviderProps, type ArchitectureInfo, type Breadcrumb, type ConsoleCaptureOptions, DEFAULT_REDACT_BODY_FIELDS, type HttpRequestEvent, HttpRequestModule, type HttpTrackingOptions, INGEST_HOST, REDACTED, type ReactNativeInstallOptions, ReplaySurrogate, type ReplaySurrogateOptions, SDK_NAME, SDK_VERSION, Scope, type ScreenshotArtifact, type ScreenshotCaptureOptions, type TransportStats, __devTriggerNativeCrash, __resetAutoNavigationFlagForTest, __resetConsoleInstrumentationFlagForTest, __resetProviderInstanceForTest, __setNativeModuleForTest, applyArchitectureTags, captureBodyResult, detectArchitecture, drainPendingNativeCrashes, installReactNative, instrumentNavigationFromLinking, instrumentReactNavigation, redactUrl, sanitizeHeaders, tryAutoInstrumentNavigation, useAllStak };
|