@drakkar.software/sunglasses-react-native 0.10.0 → 0.11.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/dist/index.d.mts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.js +18 -7
- package/dist/index.mjs +19 -9
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
|
-
import { ISunglassesClient,
|
|
3
|
-
export { CaptureExceptionOptions, ConsentStatus, ISunglassesClient, ScreenTrackingOptions, SunglassesConfig, SunglassesCore, SunglassesEvent, captureException } from '@drakkar.software/sunglasses-core';
|
|
2
|
+
import { ISunglassesClient, AutoCaptureErrorsOptions, ScreenTrackingOptions, CaptureExceptionOptions } from '@drakkar.software/sunglasses-core';
|
|
3
|
+
export { AutoCaptureErrorsOptions, CaptureExceptionOptions, ConsentStatus, ConsoleCaptureOptions, ISunglassesClient, ScreenTrackingOptions, SunglassesConfig, SunglassesCore, SunglassesEvent, captureException, patchConsole } from '@drakkar.software/sunglasses-core';
|
|
4
4
|
|
|
5
5
|
interface SunglassesProviderProps {
|
|
6
6
|
/** An initialized ISunglassesClient (from SunglassesCore.create()). */
|
|
7
7
|
client: ISunglassesClient;
|
|
8
8
|
/**
|
|
9
|
-
* Automatically capture unhandled
|
|
10
|
-
* (`$error_handled: false`)
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* Automatically capture unhandled errors as `$error` events
|
|
10
|
+
* (`$error_handled: false`).
|
|
11
|
+
*
|
|
12
|
+
* - `true` installs a global `ErrorUtils` handler (the previous handler is
|
|
13
|
+
* preserved and still invoked).
|
|
14
|
+
* - An options object additionally lets you toggle `globalHandlers` and opt
|
|
15
|
+
* into `console` capture (`console.error` / `console.warn`), plus configure
|
|
16
|
+
* truncation / stack inclusion / ignore patterns.
|
|
17
|
+
*
|
|
18
|
+
* Default: off.
|
|
14
19
|
*/
|
|
15
|
-
autoCaptureErrors?: boolean |
|
|
20
|
+
autoCaptureErrors?: boolean | AutoCaptureErrorsOptions;
|
|
16
21
|
children: React$1.ReactNode;
|
|
17
22
|
}
|
|
18
23
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import React$1 from 'react';
|
|
2
|
-
import { ISunglassesClient,
|
|
3
|
-
export { CaptureExceptionOptions, ConsentStatus, ISunglassesClient, ScreenTrackingOptions, SunglassesConfig, SunglassesCore, SunglassesEvent, captureException } from '@drakkar.software/sunglasses-core';
|
|
2
|
+
import { ISunglassesClient, AutoCaptureErrorsOptions, ScreenTrackingOptions, CaptureExceptionOptions } from '@drakkar.software/sunglasses-core';
|
|
3
|
+
export { AutoCaptureErrorsOptions, CaptureExceptionOptions, ConsentStatus, ConsoleCaptureOptions, ISunglassesClient, ScreenTrackingOptions, SunglassesConfig, SunglassesCore, SunglassesEvent, captureException, patchConsole } from '@drakkar.software/sunglasses-core';
|
|
4
4
|
|
|
5
5
|
interface SunglassesProviderProps {
|
|
6
6
|
/** An initialized ISunglassesClient (from SunglassesCore.create()). */
|
|
7
7
|
client: ISunglassesClient;
|
|
8
8
|
/**
|
|
9
|
-
* Automatically capture unhandled
|
|
10
|
-
* (`$error_handled: false`)
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* Automatically capture unhandled errors as `$error` events
|
|
10
|
+
* (`$error_handled: false`).
|
|
11
|
+
*
|
|
12
|
+
* - `true` installs a global `ErrorUtils` handler (the previous handler is
|
|
13
|
+
* preserved and still invoked).
|
|
14
|
+
* - An options object additionally lets you toggle `globalHandlers` and opt
|
|
15
|
+
* into `console` capture (`console.error` / `console.warn`), plus configure
|
|
16
|
+
* truncation / stack inclusion / ignore patterns.
|
|
17
|
+
*
|
|
18
|
+
* Default: off.
|
|
14
19
|
*/
|
|
15
|
-
autoCaptureErrors?: boolean |
|
|
20
|
+
autoCaptureErrors?: boolean | AutoCaptureErrorsOptions;
|
|
16
21
|
children: React$1.ReactNode;
|
|
17
22
|
}
|
|
18
23
|
/**
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
SunglassesProvider: () => SunglassesProvider,
|
|
36
36
|
captureDeepLinkUtmParams: () => captureDeepLinkUtmParams,
|
|
37
37
|
captureException: () => import_sunglasses_core3.captureException,
|
|
38
|
+
patchConsole: () => import_sunglasses_core3.patchConsole,
|
|
38
39
|
useExpoRouterScreenTracking: () => useExpoRouterScreenTracking,
|
|
39
40
|
useExpoRouterUtmCapture: () => useExpoRouterUtmCapture,
|
|
40
41
|
useLinkingUtmCapture: () => useLinkingUtmCapture,
|
|
@@ -76,15 +77,24 @@ function SunglassesProvider({
|
|
|
76
77
|
}, [client]);
|
|
77
78
|
(0, import_react2.useEffect)(() => {
|
|
78
79
|
if (!autoCaptureErrors) return;
|
|
79
|
-
if (typeof ErrorUtils === "undefined" || !ErrorUtils.setGlobalHandler) return;
|
|
80
80
|
const options = typeof autoCaptureErrors === "object" ? autoCaptureErrors : {};
|
|
81
|
-
const
|
|
82
|
-
ErrorUtils.setGlobalHandler
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
const cleanups = [];
|
|
82
|
+
if (options.globalHandlers !== false && typeof ErrorUtils !== "undefined" && ErrorUtils.setGlobalHandler) {
|
|
83
|
+
const previous = ErrorUtils.getGlobalHandler?.();
|
|
84
|
+
ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
85
|
+
(0, import_sunglasses_core.captureException)(client, error, { handled: false, ...options });
|
|
86
|
+
previous?.(error, isFatal);
|
|
87
|
+
});
|
|
88
|
+
cleanups.push(() => {
|
|
89
|
+
if (previous) ErrorUtils.setGlobalHandler?.(previous);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (options.console) {
|
|
93
|
+
const consoleOptions = typeof options.console === "object" ? options.console : {};
|
|
94
|
+
cleanups.push((0, import_sunglasses_core.patchConsole)(client, consoleOptions));
|
|
95
|
+
}
|
|
86
96
|
return () => {
|
|
87
|
-
|
|
97
|
+
for (const cleanup of cleanups) cleanup();
|
|
88
98
|
};
|
|
89
99
|
}, [client, autoCaptureErrors]);
|
|
90
100
|
(0, import_react2.useEffect)(() => {
|
|
@@ -266,6 +276,7 @@ var import_sunglasses_core3 = require("@drakkar.software/sunglasses-core");
|
|
|
266
276
|
SunglassesProvider,
|
|
267
277
|
captureDeepLinkUtmParams,
|
|
268
278
|
captureException,
|
|
279
|
+
patchConsole,
|
|
269
280
|
useExpoRouterScreenTracking,
|
|
270
281
|
useExpoRouterUtmCapture,
|
|
271
282
|
useLinkingUtmCapture,
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
// src/SunglassesProvider.tsx
|
|
9
9
|
import { useEffect } from "react";
|
|
10
10
|
import { AppState } from "react-native";
|
|
11
|
-
import { captureException } from "@drakkar.software/sunglasses-core";
|
|
11
|
+
import { captureException, patchConsole } from "@drakkar.software/sunglasses-core";
|
|
12
12
|
|
|
13
13
|
// src/context.ts
|
|
14
14
|
import { createContext, useContext } from "react";
|
|
@@ -38,15 +38,24 @@ function SunglassesProvider({
|
|
|
38
38
|
}, [client]);
|
|
39
39
|
useEffect(() => {
|
|
40
40
|
if (!autoCaptureErrors) return;
|
|
41
|
-
if (typeof ErrorUtils === "undefined" || !ErrorUtils.setGlobalHandler) return;
|
|
42
41
|
const options = typeof autoCaptureErrors === "object" ? autoCaptureErrors : {};
|
|
43
|
-
const
|
|
44
|
-
ErrorUtils.setGlobalHandler
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
const cleanups = [];
|
|
43
|
+
if (options.globalHandlers !== false && typeof ErrorUtils !== "undefined" && ErrorUtils.setGlobalHandler) {
|
|
44
|
+
const previous = ErrorUtils.getGlobalHandler?.();
|
|
45
|
+
ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
46
|
+
captureException(client, error, { handled: false, ...options });
|
|
47
|
+
previous?.(error, isFatal);
|
|
48
|
+
});
|
|
49
|
+
cleanups.push(() => {
|
|
50
|
+
if (previous) ErrorUtils.setGlobalHandler?.(previous);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (options.console) {
|
|
54
|
+
const consoleOptions = typeof options.console === "object" ? options.console : {};
|
|
55
|
+
cleanups.push(patchConsole(client, consoleOptions));
|
|
56
|
+
}
|
|
48
57
|
return () => {
|
|
49
|
-
|
|
58
|
+
for (const cleanup of cleanups) cleanup();
|
|
50
59
|
};
|
|
51
60
|
}, [client, autoCaptureErrors]);
|
|
52
61
|
useEffect(() => {
|
|
@@ -220,13 +229,14 @@ function SunglassesErrorBoundary(props) {
|
|
|
220
229
|
}
|
|
221
230
|
|
|
222
231
|
// src/index.ts
|
|
223
|
-
import { SunglassesCore, captureException as captureException3 } from "@drakkar.software/sunglasses-core";
|
|
232
|
+
import { SunglassesCore, captureException as captureException3, patchConsole as patchConsole2 } from "@drakkar.software/sunglasses-core";
|
|
224
233
|
export {
|
|
225
234
|
SunglassesCore,
|
|
226
235
|
SunglassesErrorBoundary,
|
|
227
236
|
SunglassesProvider,
|
|
228
237
|
captureDeepLinkUtmParams,
|
|
229
238
|
captureException3 as captureException,
|
|
239
|
+
patchConsole2 as patchConsole,
|
|
230
240
|
useExpoRouterScreenTracking,
|
|
231
241
|
useExpoRouterUtmCapture,
|
|
232
242
|
useLinkingUtmCapture,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakkar.software/sunglasses-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "React Native / Expo provider and hooks for SunGlasses event tracking",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@drakkar.software/sunglasses-core": "0.
|
|
19
|
+
"@drakkar.software/sunglasses-core": "0.11.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"expo-router": ">=3.0.0",
|