@coralogix/react-native-plugin 0.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/CxSdk.podspec +45 -0
  3. package/LICENSE +201 -0
  4. package/README.md +187 -0
  5. package/android/build.gradle +87 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/java/com/cxsdk/CxSdkModule.kt +457 -0
  9. package/android/src/main/java/com/cxsdk/CxSdkPackage.kt +16 -0
  10. package/android/src/main/java/com/cxsdk/ICxSdkModule.kt +24 -0
  11. package/index.cjs.js +682 -0
  12. package/index.d.ts +1 -0
  13. package/index.esm.js +678 -0
  14. package/ios/CxSdk-Bridging-Header.h +2 -0
  15. package/ios/CxSdk.mm +81 -0
  16. package/ios/CxSdk.swift +371 -0
  17. package/package.json +34 -0
  18. package/src/CoralogixPropgator.d.ts +2 -0
  19. package/src/consts.d.ts +23 -0
  20. package/src/index.d.ts +10 -0
  21. package/src/instrumentations/error/ErrorInstrumentation.d.ts +18 -0
  22. package/src/instrumentations/error/error.consts.d.ts +7 -0
  23. package/src/instrumentations/error/error.enums.d.ts +4 -0
  24. package/src/instrumentations/mobile-vitals/JsRefreshRateSamplerInstrumentation.d.ts +8 -0
  25. package/src/instrumentations/mobile-vitals/loopDetectorInstrumentation.d.ts +16 -0
  26. package/src/instrumentations/network/FetchInstrumentation.d.ts +5 -0
  27. package/src/instrumentations/network/network.enums.d.ts +10 -0
  28. package/src/logger.d.ts +16 -0
  29. package/src/model/ApplicationContextConfig.d.ts +4 -0
  30. package/src/model/CoralogixDomain.d.ts +10 -0
  31. package/src/model/CoralogixOtelWebOptionsInstrumentations.d.ts +9 -0
  32. package/src/model/CoralogixOtelWebType.d.ts +49 -0
  33. package/src/model/CoralogixRumLabels.d.ts +1 -0
  34. package/src/model/CustomMeasurement.d.ts +4 -0
  35. package/src/model/NetworkRequestDetails.d.ts +14 -0
  36. package/src/model/SendLog.d.ts +10 -0
  37. package/src/model/Types.d.ts +209 -0
  38. package/src/model/UserContextConfig.d.ts +8 -0
  39. package/src/model/ViewContextConfig.d.ts +3 -0
  40. package/src/utils.d.ts +5 -0
@@ -0,0 +1,49 @@
1
+ import type { SendLog } from './SendLog';
2
+ import type { CoralogixRumLabels } from './CoralogixRumLabels';
3
+ import { CoralogixBrowserSdkConfig } from './Types';
4
+ import { UserContextConfig } from './UserContextConfig';
5
+ import { ViewContextConfig } from './ViewContextConfig';
6
+ import { ApplicationContextConfig } from './ApplicationContextConfig';
7
+ import { CustomMeasurement } from './CustomMeasurement';
8
+ import { NetworkRequestDetails } from './NetworkRequestDetails';
9
+ export interface CoralogixOtelWebType extends SendLog {
10
+ /**
11
+ * Init CoralogixRum.
12
+ */
13
+ init: (options: CoralogixBrowserSdkConfig) => void;
14
+ /**
15
+ * Turn CoralogixRum off.
16
+ */
17
+ shutdown: () => void;
18
+ /** Sets labels to be added to every log after CoralogixRum initialization. */
19
+ setLabels: (labels: CoralogixRumLabels) => void;
20
+ /**
21
+ * Provides access to computed, final value of global attributes, which are applied to all created logs.
22
+ */
23
+ getLabels: () => Promise<CoralogixRumLabels>;
24
+ /** Sets user context to be added to every log after CoralogixRum initialization. */
25
+ setUserContext: (userContext: UserContextConfig) => void;
26
+ /** Sets user context to be added to every log after CoralogixRum initialization. */
27
+ setViewContext: (viewContext: ViewContextConfig) => void;
28
+ /** Sets application context to be added to every log after CoralogixRum initialization. */
29
+ setApplicationContext: (applicationContext: ApplicationContextConfig) => void;
30
+ /**
31
+ * Provides access to computed, final value of user context, which applied to all created logs.
32
+ */
33
+ getUserContext: () => Promise<UserContextConfig | undefined>;
34
+ /**
35
+ * Provides the session id.
36
+ */
37
+ getSessionId: () => Promise<string> | undefined;
38
+ /**
39
+ * Send custom key value pair
40
+ */
41
+ sendCustomMeasurement: (measurement: CustomMeasurement) => void;
42
+ reportError: (error: Error, isCrash: boolean) => void;
43
+ /**
44
+ * Report a network request to the underlying Coralogix SDK
45
+ * @param details
46
+ */
47
+ reportNetworkRequest: (details: NetworkRequestDetails) => void;
48
+ readonly isInited: boolean;
49
+ }
@@ -0,0 +1 @@
1
+ export type CoralogixRumLabels = Record<string, string>;
@@ -0,0 +1,4 @@
1
+ export type CustomMeasurement = {
2
+ name: string;
3
+ value: number;
4
+ };
@@ -0,0 +1,14 @@
1
+ export type NetworkRequestDetails = {
2
+ method: string;
3
+ statusCode: number;
4
+ url: string;
5
+ fragments: string;
6
+ host: string;
7
+ schema: string;
8
+ statusText: string;
9
+ duration: number;
10
+ responseContentLength: number;
11
+ errorMessage?: string | null;
12
+ customTraceId: string;
13
+ customSpanId: string;
14
+ };
@@ -0,0 +1,10 @@
1
+ import { CoralogixLogSeverity } from './Types';
2
+ export interface SendLog {
3
+ log: (severity: CoralogixLogSeverity, message: string, data?: Record<string, any>) => void;
4
+ debug: (message: string, data?: any) => void;
5
+ verbose: (message: string, data?: any) => void;
6
+ info: (message: string, data?: any) => void;
7
+ warn: (message: string, data?: any) => void;
8
+ error: (message: string, data?: any) => void;
9
+ critical: (message: string, data?: any) => void;
10
+ }
@@ -0,0 +1,209 @@
1
+ import type { CoralogixRumLabels } from './CoralogixRumLabels';
2
+ import type { CoralogixOtelWebOptionsInstrumentations } from './CoralogixOtelWebOptionsInstrumentations';
3
+ import { CoralogixDomain } from './CoralogixDomain';
4
+ import { UserContextConfig } from './UserContextConfig';
5
+ import { ViewContextConfig } from './ViewContextConfig';
6
+ export interface CxSpan {
7
+ version_metadata: VersionMetaData;
8
+ applicationName: string;
9
+ subsystemName: string;
10
+ timestamp: number;
11
+ severity: CoralogixLogSeverity;
12
+ isErrorWithStacktrace: boolean;
13
+ instrumentation_data?: any;
14
+ text: {
15
+ cx_rum: CxRumEvent;
16
+ };
17
+ }
18
+ export interface UserMetadata {
19
+ user_id: string;
20
+ user_name?: string;
21
+ user_email?: string;
22
+ user_metadata?: {
23
+ [key: string]: any;
24
+ };
25
+ }
26
+ export interface SessionContext extends UserMetadata {
27
+ device: string | undefined;
28
+ os: string | undefined;
29
+ osVersion: string | number | undefined;
30
+ }
31
+ export interface DeviceState {
32
+ battery: string | undefined;
33
+ network_type: string | undefined;
34
+ }
35
+ export interface DeviceContext {
36
+ device: string | undefined;
37
+ deviceName: string | undefined;
38
+ emulator: boolean | undefined;
39
+ os: string | undefined;
40
+ osVersion: string | number | undefined;
41
+ }
42
+ interface VersionMetaData {
43
+ app_name: string;
44
+ app_version: string;
45
+ }
46
+ export declare enum CoralogixEventType {
47
+ ERROR = "error",
48
+ NETWORK_REQUEST = "network-request",
49
+ LOG = "log",
50
+ USER_INTERACTION = "user-interaction",
51
+ WEB_VITALS = "web-vitals",
52
+ LONG_TASK = "longtask",
53
+ RESOURCES = "resources",
54
+ INTERNAL = "internal",
55
+ NAVIGATION = "navigation"
56
+ }
57
+ export declare enum EventSource {
58
+ CONSOLE = "console",
59
+ FETCH = "fetch",
60
+ CODE = "code",
61
+ UNHANDLED_REJECTION = "unhandledrejection"
62
+ }
63
+ export declare enum CoralogixLogSeverity {
64
+ Debug = 1,
65
+ Verbose = 2,
66
+ Info = 3,
67
+ Warn = 4,
68
+ Error = 5,
69
+ Critical = 6
70
+ }
71
+ export interface EventContext {
72
+ type: CoralogixEventType;
73
+ source: EventSource;
74
+ severity: CoralogixLogSeverity;
75
+ }
76
+ export interface ErrorContext {
77
+ domain?: string;
78
+ code?: string;
79
+ error_message?: string;
80
+ user_info?: string;
81
+ original_stacktrace?: Array<Record<string, any>>;
82
+ error_type?: string;
83
+ is_crashed?: boolean;
84
+ event_type?: string;
85
+ error_context?: string;
86
+ crash_timestamp?: string;
87
+ process_name?: string;
88
+ application_identifier?: string;
89
+ triggered_by_thread?: string;
90
+ base_address?: string;
91
+ arch?: string;
92
+ threads?: Array<Record<string, any>>;
93
+ }
94
+ export interface LogContext {
95
+ message: string;
96
+ data?: any;
97
+ }
98
+ export interface NetworkRequestContext {
99
+ method: string;
100
+ status_code: number;
101
+ url: string;
102
+ fragments: string;
103
+ host: string;
104
+ schema: string;
105
+ status_text: string;
106
+ response_content_length: string;
107
+ duration: number;
108
+ }
109
+ export interface SnapshotContext {
110
+ timestamp: number;
111
+ errorCount: number;
112
+ viewCount: number;
113
+ actionCount: number;
114
+ hasRecording: boolean;
115
+ }
116
+ export interface CxRumEvent {
117
+ platform: string;
118
+ version_metadata: VersionMetaData;
119
+ session_context: SessionContext;
120
+ device_context: DeviceContext;
121
+ device_state: DeviceState;
122
+ view_context: ViewContextConfig;
123
+ event_context: EventContext;
124
+ error_context?: ErrorContext;
125
+ log_context?: LogContext;
126
+ network_request_context?: NetworkRequestContext;
127
+ snapshot_context?: SnapshotContext;
128
+ labels: CoralogixRumLabels;
129
+ spanId: string;
130
+ traceId: string;
131
+ environment: string;
132
+ timestamp: number;
133
+ isSnapshotEvent?: boolean;
134
+ }
135
+ export interface EditableCxRumEvent extends Omit<CxRumEvent, 'session_context' | 'timestamp'> {
136
+ session_context: Pick<SessionContext, keyof UserMetadata>;
137
+ }
138
+ export type BeforeSendResult = EditableCxRumEvent | null;
139
+ export interface TraceParentInHeader {
140
+ enabled: boolean;
141
+ options?: {
142
+ /** urls outside of origin that should also add Traceparent to header */
143
+ propagateTraceHeaderCorsUrls?: Array<string | RegExp>;
144
+ };
145
+ }
146
+ export interface CoralogixStackFrame {
147
+ readonly functionName: string;
148
+ readonly fileName: string;
149
+ readonly lineNumber: number;
150
+ readonly columnNumber: number;
151
+ }
152
+ export interface CoralogixBrowserSdkConfig {
153
+ /** Publicly-visible `public_key` value */
154
+ public_key: string;
155
+ /** Sets a value for the `application` attribute */
156
+ application: string;
157
+ /** Coralogix account domain */
158
+ coralogixDomain: CoralogixDomain;
159
+ /** Sets a value for the 'app.version' attribute */
160
+ version: string;
161
+ /** Configuration for user context. */
162
+ user_context?: UserContextConfig;
163
+ /** Configuration for view context. */
164
+ view_context?: ViewContextConfig;
165
+ /** Turns on/off internal debug logging */
166
+ debug?: boolean;
167
+ /** Sets labels added to every Span. */
168
+ labels?: CoralogixRumLabels;
169
+ /**
170
+ * Applies for XHR and Fetch URLs. URLs that partially match any regex in ignoreUrls will not be traced.
171
+ * In addition, URLs that are _exact matches_ of strings in ignoreUrls will also not be traced.
172
+ * */
173
+ ignoreUrls?: Array<string | RegExp>;
174
+ /**
175
+ A pattern for error messages which should not be sent to Coralogix. By default, all errors will be sent.
176
+ * */
177
+ ignoreErrors?: Array<string | RegExp>;
178
+ /** Configuration for instrumentation modules. */
179
+ instrumentations?: CoralogixOtelWebOptionsInstrumentations;
180
+ /** Add trace context propagation in headers across service boundaries */
181
+ traceParentInHeader?: TraceParentInHeader;
182
+ /** Interval for fps sampling, defaults to 300 (5 minutes) */
183
+ fpsSamplingSeconds?: number;
184
+ /** Sets a value for the `environment` attribute */
185
+ environment?: string;
186
+ /** Percentage of overall sessions being tracked, defaults to 100% */
187
+ sessionSampleRate?: number;
188
+ /** Collect IP data */
189
+ collectIPData?: boolean;
190
+ /** Enable event access and modification before sending to Coralogix, supporting content modification, and event discarding. */
191
+ beforeSend?: (event: EditableCxRumEvent) => BeforeSendResult;
192
+ /** Send requests through a proxy */
193
+ proxyUrl?: string;
194
+ /**
195
+ * JS refresh rate metric collection configuration.
196
+ */
197
+ jsRefreshRateSampleRate?: {
198
+ /** Duration of each FPS measurement window in milliseconds (default: 5000) */
199
+ sampleDurationMs?: number;
200
+ /** Interval between FPS measurements in milliseconds (default: 300000 = 5 minutes) */
201
+ sampleIntervalMs?: number;
202
+ };
203
+ }
204
+ export type HybridMetric = {
205
+ name: string;
206
+ value: number;
207
+ units: string;
208
+ };
209
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface UserContextConfig {
2
+ user_id: string;
3
+ user_name: string;
4
+ user_email?: string;
5
+ user_metadata?: {
6
+ [key: string]: any;
7
+ };
8
+ }
@@ -0,0 +1,3 @@
1
+ export interface ViewContextConfig {
2
+ view: string;
3
+ }
package/src/utils.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { CoralogixBrowserSdkConfig } from './model/Types';
2
+ export declare const hrTimeToMilliseconds: ([seconds, nanoseconds]: [number, number]) => number;
3
+ export declare const getUrlFragments: (url: string) => string;
4
+ export declare function isSamplingOn(threshold: number): boolean;
5
+ export declare function resolveCoralogixOtelWebConfig(config: CoralogixBrowserSdkConfig): CoralogixBrowserSdkConfig;