-
-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathNativeRNSentry.ts
159 lines (148 loc) · 4.73 KB
/
NativeRNSentry.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import type { Package } from '@sentry/core';
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
import type { UnsafeObject } from './utils/rnlibrariesinterface';
// There has to be only one interface and it has to be named `Spec`
// Only extra allowed definitions are types (probably codegen bug)
export interface Spec extends TurboModule {
addListener: (eventType: string) => void;
removeListeners: (id: number) => void;
getNewScreenTimeToDisplay(): Promise<number | undefined | null>;
addBreadcrumb(breadcrumb: UnsafeObject): void;
captureEnvelope(
bytes: string,
options: {
hardCrashed: boolean;
},
): Promise<boolean>;
captureScreenshot(): Promise<NativeScreenshot[] | undefined | null>;
clearBreadcrumbs(): void;
crash(): void;
closeNativeSdk(): Promise<void>;
disableNativeFramesTracking(): void;
fetchNativeRelease(): Promise<NativeReleaseResponse>;
fetchNativeSdkInfo(): Promise<Package | null>;
fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse | null>;
fetchNativeAppStart(): Promise<NativeAppStartResponse | null>;
fetchNativeFrames(): Promise<NativeFramesResponse | null>;
initNativeSdk(options: UnsafeObject): Promise<boolean>;
setUser(defaultUserKeys: UnsafeObject | null, otherUserKeys: UnsafeObject | null): void;
setContext(key: string, value: UnsafeObject | null): void;
setExtra(key: string, value: string): void;
setTag(key: string, value: string): void;
enableNativeFramesTracking(): void;
fetchModules(): Promise<string | undefined | null>;
fetchViewHierarchy(): Promise<number[] | undefined | null>;
startProfiling(platformProfilers: boolean): { started?: boolean; error?: string };
stopProfiling(): {
profile?: string;
nativeProfile?: UnsafeObject;
androidProfile?: UnsafeObject;
error?: string;
};
fetchNativePackageName(): string | undefined | null;
fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | undefined | null;
initNativeReactNavigationNewFrameTracking(): Promise<void>;
captureReplay(isHardCrash: boolean): Promise<string | undefined | null>;
getCurrentReplayId(): string | undefined | null;
crashedLastRun(): Promise<boolean | undefined | null>;
getDataFromUri(uri: string): Promise<number[]>;
}
export type NativeStackFrame = {
platform: string;
/**
* The instruction address of this frame.
* Formatted as hex with 0x prefix.
*/
instruction_addr: string;
package?: string;
/**
* The debug image address of this frame.
* Formatted as hex with 0x prefix.
*/
image_addr?: string;
in_app?: boolean;
/**
* The symbol name of this frame.
* If symbolicated locally.
*/
function?: string;
/**
* The symbol address of this frame.
* If symbolicated locally.
* Formatted as hex with 0x prefix.
*/
symbol_addr?: string;
};
export type NativeDebugImage = {
name?: string;
type?: string;
uuid?: string;
debug_id?: string;
image_addr?: string;
image_size?: number;
code_file?: string;
image_vmaddr?: string;
};
export type NativeStackFrames = {
frames: NativeStackFrame[];
debugMetaImages?: NativeDebugImage[];
};
export type NativeAppStartResponse = {
type: 'cold' | 'warm' | 'unknown';
has_fetched: boolean;
app_start_timestamp_ms?: number;
spans: {
description: string;
start_timestamp_ms: number;
end_timestamp_ms: number;
}[];
};
export type NativeFramesResponse = {
totalFrames: number;
slowFrames: number;
frozenFrames: number;
};
export type NativeReleaseResponse = {
build: string;
id: string;
version: string;
};
/**
* This type describes serialized scope from sentry-cocoa and sentry-android
* https://github.com/getsentry/sentry-cocoa/blob/master/Sources/Sentry/SentryScope.m
* https://github.com/getsentry/sentry-java/blob/a461f7e125b65240004e6162b341f383ce2e1394/sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java#L32
*/
export type NativeDeviceContextsResponse = {
[key: string]: unknown;
tags?: Record<string, string>;
extra?: Record<string, unknown>;
contexts?: Record<string, Record<string, unknown>>;
user?: {
userId?: string;
email?: string;
username?: string;
ipAddress?: string;
segment?: string;
data?: Record<string, unknown>;
};
dist?: string;
environment?: string;
fingerprint?: string[];
level?: string;
breadcrumbs?: {
level?: string;
timestamp?: string;
category?: string;
type?: string;
message?: string;
data?: Record<string, unknown>;
}[];
};
export type NativeScreenshot = {
data: number[];
contentType: string;
filename: string;
};
// The export must be here to pass codegen even if not used
export default TurboModuleRegistry.getEnforcing<Spec>('RNSentry');