@allstak/react-native 0.4.0 → 0.5.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/CHANGELOG.md +76 -0
- package/dist/index.d.mts +245 -4
- package/dist/index.d.ts +245 -4
- package/dist/index.js +504 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +504 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -558,9 +558,165 @@ declare function maybeCaptureScreenshot(config: ScreenshotConfig, ctx: Screensho
|
|
|
558
558
|
} | null>;
|
|
559
559
|
declare function pickScreenshotConfig(source: Record<string, unknown>): Partial<ScreenshotConfig>;
|
|
560
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Auto-collected Sentry-shape context bags for React Native events.
|
|
563
|
+
*
|
|
564
|
+
* Lazily requires optional metadata packages and never throws when they
|
|
565
|
+
* are absent. Output uses Sentry's RN context shape so the dashboard can
|
|
566
|
+
* render contexts mechanically:
|
|
567
|
+
*
|
|
568
|
+
* contexts.device — model, manufacturer, family, arch, simulator, …
|
|
569
|
+
* contexts.os — name, version, build
|
|
570
|
+
* contexts.app — app_name, app_identifier, app_build, app_version, …
|
|
571
|
+
* contexts.react_native — react_native_version, expo, hermes, fabric, …
|
|
572
|
+
* contexts.runtime — name, version (e.g. hermes 0.74.x)
|
|
573
|
+
*
|
|
574
|
+
* All collectors fail-open: a missing optional dep means the corresponding
|
|
575
|
+
* context bag is shallow (only what we can read from globals + react-native
|
|
576
|
+
* Platform) rather than failing the whole event.
|
|
577
|
+
*/
|
|
578
|
+
interface SentryContexts {
|
|
579
|
+
device?: Record<string, unknown>;
|
|
580
|
+
os?: Record<string, unknown>;
|
|
581
|
+
app?: Record<string, unknown>;
|
|
582
|
+
react_native?: Record<string, unknown>;
|
|
583
|
+
runtime?: Record<string, unknown>;
|
|
584
|
+
user?: Record<string, unknown>;
|
|
585
|
+
}
|
|
586
|
+
interface AutoTags {
|
|
587
|
+
[key: string]: string;
|
|
588
|
+
}
|
|
589
|
+
interface CollectContextOptions {
|
|
590
|
+
/** Include free/total memory + battery when collectors permit. Default true. */
|
|
591
|
+
captureDeviceContext?: boolean;
|
|
592
|
+
/** Include battery_level + charging. Default false (privacy). */
|
|
593
|
+
captureBattery?: boolean;
|
|
594
|
+
/** Include screen orientation + dimensions. Default true. */
|
|
595
|
+
captureScreenContext?: boolean;
|
|
596
|
+
/** Include user.email if config.user.email present. Default false. */
|
|
597
|
+
sendDefaultPii?: boolean;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Collect all Sentry-shape context bags + a flat tag dictionary in one
|
|
601
|
+
* pass. Safe to call once during init, then re-used by every event via
|
|
602
|
+
* client.config.contexts.
|
|
603
|
+
*
|
|
604
|
+
* Returns null for any context bag whose source data is entirely missing
|
|
605
|
+
* (rather than emitting empty {}); the dashboard renderer can then hide
|
|
606
|
+
* the panel cleanly.
|
|
607
|
+
*/
|
|
608
|
+
declare function collectAutoContexts(opts?: CollectContextOptions): {
|
|
609
|
+
contexts: SentryContexts;
|
|
610
|
+
tags: AutoTags;
|
|
611
|
+
};
|
|
612
|
+
/**
|
|
613
|
+
* Convert a user object to a Sentry-shape `contexts.user` bag,
|
|
614
|
+
* respecting `sendDefaultPii`.
|
|
615
|
+
*/
|
|
616
|
+
declare function buildUserContext(user: {
|
|
617
|
+
id?: string;
|
|
618
|
+
email?: string;
|
|
619
|
+
username?: string;
|
|
620
|
+
ip_address?: string;
|
|
621
|
+
} | undefined, opts?: {
|
|
622
|
+
sendDefaultPii?: boolean;
|
|
623
|
+
}): Record<string, unknown> | undefined;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Engine-agnostic Error.stack parser. Handles V8 / Hermes ("at fn (file:l:c)")
|
|
627
|
+
* and Gecko / JSC ("fn@file:l:c"). Output mirrors the backend
|
|
628
|
+
* ErrorIngestRequest.Frame shape so the dashboard can render frames directly.
|
|
629
|
+
*/
|
|
630
|
+
interface StackFrame {
|
|
631
|
+
filename?: string;
|
|
632
|
+
absPath?: string;
|
|
633
|
+
function?: string;
|
|
634
|
+
lineno?: number;
|
|
635
|
+
colno?: number;
|
|
636
|
+
inApp?: boolean;
|
|
637
|
+
platform?: string;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Mechanism + exception envelope helpers — Sentry-shape exception
|
|
642
|
+
* extraction for AllStak React Native events.
|
|
643
|
+
*
|
|
644
|
+
* Exposes:
|
|
645
|
+
* - MechanismType: literal type of the entry-point classification
|
|
646
|
+
* - buildExceptionChain: walks `error.cause` and returns each linked
|
|
647
|
+
* exception in Sentry's `exception.values` order (innermost first)
|
|
648
|
+
* - extractAxiosRequest: detects `error.isAxiosError === true` and
|
|
649
|
+
* returns a sanitized request panel suitable for the event payload
|
|
650
|
+
* - classifyHttpError: HTTP category one of `http_client_error` |
|
|
651
|
+
* `http_server_error` | `network` | `timeout` | `cancel`
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
type MechanismType = 'onerror' | 'onunhandledrejection' | 'errorboundary' | 'captureException' | 'captureMessage' | 'native_crash';
|
|
655
|
+
interface ExceptionValue {
|
|
656
|
+
type: string;
|
|
657
|
+
value: string;
|
|
658
|
+
module?: string;
|
|
659
|
+
stacktrace?: {
|
|
660
|
+
frames: StackFrame[];
|
|
661
|
+
};
|
|
662
|
+
mechanism?: {
|
|
663
|
+
type: MechanismType;
|
|
664
|
+
handled: boolean;
|
|
665
|
+
synthetic?: boolean;
|
|
666
|
+
data?: Record<string, unknown>;
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
interface SanitizedHttpRequest {
|
|
670
|
+
method?: string;
|
|
671
|
+
url_sanitized: string;
|
|
672
|
+
status_code?: number;
|
|
673
|
+
duration_ms?: number;
|
|
674
|
+
category: 'http_client_error' | 'http_server_error' | 'network' | 'timeout' | 'cancel';
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Strip the query string entirely. Headers/auth/etc never leak in
|
|
678
|
+
* the URL-only sanitizer; bodies are never extracted here.
|
|
679
|
+
*/
|
|
680
|
+
declare function sanitizeUrl(url: string | undefined): string;
|
|
681
|
+
/**
|
|
682
|
+
* Walk `error.cause` recursively and return each linked exception as
|
|
683
|
+
* a Sentry-shape `ExceptionValue`. The outer (most-recent) exception
|
|
684
|
+
* is the LAST element so the dashboard can render innermost → outer
|
|
685
|
+
* — matching Sentry's convention.
|
|
686
|
+
*
|
|
687
|
+
* Hard cap at 5 links to avoid pathological cycles.
|
|
688
|
+
*/
|
|
689
|
+
declare function buildExceptionChain(err: Error, mechanism: MechanismType, handled: boolean): ExceptionValue[];
|
|
690
|
+
/**
|
|
691
|
+
* Detect an axios-style error and pull out the request metadata
|
|
692
|
+
* suitable for inclusion in the event payload's `request` panel.
|
|
693
|
+
* Returns null when this is not an AxiosError-shaped object.
|
|
694
|
+
*
|
|
695
|
+
* Privacy: URL query strings are dropped. NO headers or bodies are
|
|
696
|
+
* extracted here regardless of axios config.
|
|
697
|
+
*/
|
|
698
|
+
declare function extractAxiosRequest(err: unknown): SanitizedHttpRequest | null;
|
|
699
|
+
/**
|
|
700
|
+
* Classify an HTTP/network error into Sentry-style category tags.
|
|
701
|
+
*
|
|
702
|
+
* Priority:
|
|
703
|
+
* 1. AxiosError.code === 'ECONNABORTED' / 'ETIMEDOUT' → 'timeout'
|
|
704
|
+
* 2. AxiosError.code === 'ERR_CANCELED' → 'cancel'
|
|
705
|
+
* 3. status 5xx → 'http_server_error'
|
|
706
|
+
* 4. status 4xx → 'http_client_error'
|
|
707
|
+
* 5. fall back to 'network'
|
|
708
|
+
*/
|
|
709
|
+
declare function classifyHttpError(err: any, status?: number): SanitizedHttpRequest['category'];
|
|
710
|
+
/**
|
|
711
|
+
* Look at a thrown value and decide whether it should carry an HTTP
|
|
712
|
+
* `request` panel (axios is the only auto-detected source today; fetch
|
|
713
|
+
* Response/TypeError still surface as plain errors).
|
|
714
|
+
*/
|
|
715
|
+
declare function maybeExtractHttpRequest(err: unknown): SanitizedHttpRequest | null;
|
|
716
|
+
|
|
561
717
|
declare const INGEST_HOST = "https://api.allstak.sa";
|
|
562
718
|
declare const SDK_NAME = "allstak-react-native";
|
|
563
|
-
declare const SDK_VERSION = "0.
|
|
719
|
+
declare const SDK_VERSION = "0.5.0";
|
|
564
720
|
|
|
565
721
|
interface AllStakConfig {
|
|
566
722
|
/** Project API key (`ask_live_…`). Required. */
|
|
@@ -661,6 +817,35 @@ interface AllStakConfig {
|
|
|
661
817
|
dist?: string;
|
|
662
818
|
commitSha?: string;
|
|
663
819
|
branch?: string;
|
|
820
|
+
/**
|
|
821
|
+
* Auto-collect device/os/app/react_native/runtime contexts on init.
|
|
822
|
+
* Default: true. Optional metadata packages (expo-application,
|
|
823
|
+
* expo-device, expo-constants, react-native-device-info) are
|
|
824
|
+
* lazy-required and missing deps simply produce shallower contexts.
|
|
825
|
+
*/
|
|
826
|
+
captureDeviceContext?: boolean;
|
|
827
|
+
/** Include battery info (requires `expo-battery`). Default false. */
|
|
828
|
+
captureBattery?: boolean;
|
|
829
|
+
/** Include screen dimensions + orientation. Default true. */
|
|
830
|
+
captureScreenContext?: boolean;
|
|
831
|
+
/** Include user.email / user.ip_address on events. Default false. */
|
|
832
|
+
sendDefaultPii?: boolean;
|
|
833
|
+
/** Stamp client.ip on outgoing events. Default false. */
|
|
834
|
+
collectIpAddress?: boolean;
|
|
835
|
+
/**
|
|
836
|
+
* Mutate or drop a breadcrumb before it is appended to the buffer.
|
|
837
|
+
* Return `null` to drop. Errors thrown are swallowed; the original
|
|
838
|
+
* breadcrumb is appended so a buggy hook can't black-hole telemetry.
|
|
839
|
+
*/
|
|
840
|
+
beforeBreadcrumb?: (crumb: Breadcrumb) => Breadcrumb | null | undefined;
|
|
841
|
+
/** Drop HTTP breadcrumbs/events whose URL matches any of these. */
|
|
842
|
+
denyUrls?: (string | RegExp)[];
|
|
843
|
+
/** When set, ONLY emit HTTP breadcrumbs/events for matching URLs. */
|
|
844
|
+
allowUrls?: (string | RegExp)[];
|
|
845
|
+
/** Extra keys to scrub from breadcrumb data + event metadata. */
|
|
846
|
+
scrubKeys?: string[];
|
|
847
|
+
/** Additional regexes to scrub from string values in event data. */
|
|
848
|
+
scrubPatterns?: RegExp[];
|
|
664
849
|
}
|
|
665
850
|
interface ScreenshotArtifact {
|
|
666
851
|
data?: string;
|
|
@@ -733,6 +918,34 @@ interface ErrorIngestPayload {
|
|
|
733
918
|
debugId: string;
|
|
734
919
|
}>;
|
|
735
920
|
};
|
|
921
|
+
/** UUID v4 generated for this event. */
|
|
922
|
+
eventId?: string;
|
|
923
|
+
/** ISO-8601 timestamp when the event was captured (client-side). */
|
|
924
|
+
timestamp?: string;
|
|
925
|
+
/** Was this error handled by the host? false for unhandled JS / promise / native crashes. */
|
|
926
|
+
handled?: boolean;
|
|
927
|
+
/** Entry point that captured the error. */
|
|
928
|
+
mechanism?: MechanismType;
|
|
929
|
+
/** Current screen / route at the time of capture. */
|
|
930
|
+
transaction?: string;
|
|
931
|
+
/** Sentry-shape exception chain (innermost first). Includes mechanism on the outermost. */
|
|
932
|
+
exception?: {
|
|
933
|
+
values: ExceptionValue[];
|
|
934
|
+
};
|
|
935
|
+
/** Sentry-shape context bags: device, os, app, react_native, runtime, user, trace. */
|
|
936
|
+
contexts?: SentryContexts & {
|
|
937
|
+
trace?: {
|
|
938
|
+
trace_id?: string;
|
|
939
|
+
span_id?: string;
|
|
940
|
+
parent_span_id?: string;
|
|
941
|
+
op?: string;
|
|
942
|
+
status?: string;
|
|
943
|
+
};
|
|
944
|
+
};
|
|
945
|
+
/** Sentry-shape tags dictionary (flat key/value). */
|
|
946
|
+
tags?: Record<string, string>;
|
|
947
|
+
/** HTTP request panel for AxiosError-shaped errors. */
|
|
948
|
+
request?: SanitizedHttpRequest;
|
|
736
949
|
}
|
|
737
950
|
declare class AllStakClient {
|
|
738
951
|
private transport;
|
|
@@ -745,6 +958,12 @@ declare class AllStakClient {
|
|
|
745
958
|
private replay;
|
|
746
959
|
private httpRequests;
|
|
747
960
|
private _instrumentAxios;
|
|
961
|
+
/** Auto-collected Sentry-shape contexts (device/os/app/react_native/runtime). */
|
|
962
|
+
private autoContexts;
|
|
963
|
+
/** Auto-collected tags (device.model, os.name, js_engine, …). */
|
|
964
|
+
private autoTags;
|
|
965
|
+
/** Current screen / transaction name — set via setCurrentScreen() or nav auto-instrument. */
|
|
966
|
+
private currentTransaction;
|
|
748
967
|
constructor(config: AllStakConfig);
|
|
749
968
|
/** Access the replay surrogate (or null if not initialized / sampled out). */
|
|
750
969
|
getReplay(): ReplaySurrogate | null;
|
|
@@ -752,7 +971,10 @@ declare class AllStakClient {
|
|
|
752
971
|
instrumentAxios<T = any>(axios: T): T;
|
|
753
972
|
/** Snapshot of recent failed HTTP requests for error-linking. */
|
|
754
973
|
getRecentFailedHttp(): readonly HttpRequestIngestItem[];
|
|
755
|
-
captureException(error: Error, context?: Record<string, unknown
|
|
974
|
+
captureException(error: Error, context?: Record<string, unknown>, opts?: {
|
|
975
|
+
mechanism?: MechanismType;
|
|
976
|
+
handled?: boolean;
|
|
977
|
+
}): void;
|
|
756
978
|
/**
|
|
757
979
|
* Flat screenshot API path. Capture first (so masking primitives can
|
|
758
980
|
* swap), send the event with a `screenshot.status` metadata tag, read
|
|
@@ -778,6 +1000,17 @@ declare class AllStakClient {
|
|
|
778
1000
|
as?: 'log' | 'error' | 'both';
|
|
779
1001
|
}): void;
|
|
780
1002
|
addBreadcrumb(type: string, message: string, level?: string, data?: Record<string, unknown>): void;
|
|
1003
|
+
/**
|
|
1004
|
+
* Set the current screen / route name. Stamps `transaction` on every
|
|
1005
|
+
* subsequent event and emits a `navigation` breadcrumb. Use this when
|
|
1006
|
+
* not on `@react-navigation/native` (the nav auto-instrument calls
|
|
1007
|
+
* this for you).
|
|
1008
|
+
*/
|
|
1009
|
+
setCurrentScreen(name: string): void;
|
|
1010
|
+
/** @internal — current transaction (or undefined). */
|
|
1011
|
+
getCurrentTransaction(): string | undefined;
|
|
1012
|
+
/** @internal — set transaction without emitting a breadcrumb. */
|
|
1013
|
+
__setTransactionSilent(name: string | null): void;
|
|
781
1014
|
clearBreadcrumbs(): void;
|
|
782
1015
|
setUser(user: {
|
|
783
1016
|
id?: string;
|
|
@@ -847,7 +1080,10 @@ declare class AllStakClient {
|
|
|
847
1080
|
}
|
|
848
1081
|
declare const AllStak: {
|
|
849
1082
|
init(config: AllStakConfig): AllStakClient;
|
|
850
|
-
captureException(error: Error, context?: Record<string, unknown
|
|
1083
|
+
captureException(error: Error, context?: Record<string, unknown>, opts?: {
|
|
1084
|
+
mechanism?: MechanismType;
|
|
1085
|
+
handled?: boolean;
|
|
1086
|
+
}): void;
|
|
851
1087
|
captureMessage(message: string, level?: "fatal" | "error" | "warning" | "info", options?: {
|
|
852
1088
|
as?: "log" | "error" | "both";
|
|
853
1089
|
}): void;
|
|
@@ -871,6 +1107,11 @@ declare const AllStak: {
|
|
|
871
1107
|
platform?: string;
|
|
872
1108
|
dist?: string;
|
|
873
1109
|
}): void;
|
|
1110
|
+
/** Set the current screen / transaction name. Stamps event.transaction + emits nav breadcrumb. */
|
|
1111
|
+
setCurrentScreen(name: string): void;
|
|
1112
|
+
getCurrentTransaction(): string | undefined;
|
|
1113
|
+
/** @internal — set transaction without emitting a breadcrumb (nav auto-instrument uses this). */
|
|
1114
|
+
__setTransactionSilent(name: string | null): void;
|
|
874
1115
|
/**
|
|
875
1116
|
* Run `callback` with a fresh scoped context. Any user/tag/extra/context/
|
|
876
1117
|
* fingerprint/level set on the passed `Scope` is visible only inside the
|
|
@@ -1263,4 +1504,4 @@ declare function __devTriggerNativeCrash(): Promise<void>;
|
|
|
1263
1504
|
*/
|
|
1264
1505
|
declare function drainPendingNativeCrashes(release?: string): Promise<void>;
|
|
1265
1506
|
|
|
1266
|
-
export { ALWAYS_REDACT_HEADERS, ALWAYS_REDACT_QUERY, AllStak, AllStakClient, type AllStakConfig, AllStakMaskedView, type AllStakMaskedViewProps, AllStakPrivacyView, AllStakProvider, type AllStakProviderProps, AllStakSensitiveText, type AllStakSensitiveTextProps, AllStakTextInput, type AllStakTextInputProps, type ArchitectureInfo, type Breadcrumb, type ConsoleCaptureOptions, DEFAULT_REDACT_BODY_FIELDS, DEFAULT_SCREENSHOT_CONFIG, type HttpRequestEvent, HttpRequestModule, type HttpTrackingOptions, INGEST_HOST, type PrivacyLevel, REDACTED, type ReactNativeInstallOptions, ReplaySurrogate, type ReplaySurrogateOptions, type RuntimeMode, SDK_NAME, SDK_VERSION, Scope, type ScreenshotArtifact, type ScreenshotCaptureOptions, type ScreenshotConfig, type ScreenshotContext, type ScreenshotFailPolicy, type ScreenshotFormat, type ScreenshotMaskStyle, type ScreenshotMetadata, type ScreenshotNativeMode, type ScreenshotRedactionMode, type ScreenshotUpload, type TransportStats, __devTriggerNativeCrash, __resetAutoNavigationFlagForTest, __resetConsoleInstrumentationFlagForTest, __resetPrivacyStateForTest, __resetProviderInstanceForTest, __resetRuntimeModeForTest, __setNativeModuleForTest, applyArchitectureTags, captureBodyResult, captureViaViewShot, detectArchitecture, detectRuntimeMode, drainPendingNativeCrashes, installReactNative, instrumentNavigationFromLinking, instrumentReactNavigation, isCapturingScreenshot, isViewShotAvailable, maybeCaptureScreenshot, pickScreenshotConfig, redactUrl, registerSensitiveRef, resolveScreenshotConfig, runtimeAllowsScreenshot, sanitizeHeaders, tryAutoInstrumentNavigation, useAllStak, useAllStakPrivacy };
|
|
1507
|
+
export { ALWAYS_REDACT_HEADERS, ALWAYS_REDACT_QUERY, AllStak, AllStakClient, type AllStakConfig, AllStakMaskedView, type AllStakMaskedViewProps, AllStakPrivacyView, AllStakProvider, type AllStakProviderProps, AllStakSensitiveText, type AllStakSensitiveTextProps, AllStakTextInput, type AllStakTextInputProps, type ArchitectureInfo, type Breadcrumb, type CollectContextOptions, type ConsoleCaptureOptions, DEFAULT_REDACT_BODY_FIELDS, DEFAULT_SCREENSHOT_CONFIG, type ExceptionValue, type HttpRequestEvent, HttpRequestModule, type HttpTrackingOptions, INGEST_HOST, type MechanismType, type PrivacyLevel, REDACTED, type ReactNativeInstallOptions, ReplaySurrogate, type ReplaySurrogateOptions, type RuntimeMode, SDK_NAME, SDK_VERSION, type SanitizedHttpRequest, Scope, type ScreenshotArtifact, type ScreenshotCaptureOptions, type ScreenshotConfig, type ScreenshotContext, type ScreenshotFailPolicy, type ScreenshotFormat, type ScreenshotMaskStyle, type ScreenshotMetadata, type ScreenshotNativeMode, type ScreenshotRedactionMode, type ScreenshotUpload, type SentryContexts, type TransportStats, __devTriggerNativeCrash, __resetAutoNavigationFlagForTest, __resetConsoleInstrumentationFlagForTest, __resetPrivacyStateForTest, __resetProviderInstanceForTest, __resetRuntimeModeForTest, __setNativeModuleForTest, applyArchitectureTags, buildExceptionChain, buildUserContext, captureBodyResult, captureViaViewShot, classifyHttpError, collectAutoContexts, detectArchitecture, detectRuntimeMode, drainPendingNativeCrashes, extractAxiosRequest, installReactNative, instrumentNavigationFromLinking, instrumentReactNavigation, isCapturingScreenshot, isViewShotAvailable, maybeCaptureScreenshot, maybeExtractHttpRequest, pickScreenshotConfig, redactUrl, registerSensitiveRef, resolveScreenshotConfig, runtimeAllowsScreenshot, sanitizeHeaders, sanitizeUrl, tryAutoInstrumentNavigation, useAllStak, useAllStakPrivacy };
|