@drakkar.software/sunglasses-react 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 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +22 -11
- package/dist/index.mjs +23 -13
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ISunglassesClient, ScreenTrackingOptions,
|
|
3
|
-
export { CaptureExceptionOptions, ConsentStatus, ISunglassesClient, ScreenTrackingOptions, SunglassesConfig, SunglassesCore, SunglassesEvent, captureException } from '@drakkar.software/sunglasses-core';
|
|
2
|
+
import { ISunglassesClient, ScreenTrackingOptions, AutoCaptureErrorsOptions, ConsentStatus, 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()). */
|
|
@@ -8,12 +8,18 @@ interface SunglassesProviderProps {
|
|
|
8
8
|
/** Optional screen tracking configuration. */
|
|
9
9
|
screenTracking?: ScreenTrackingOptions;
|
|
10
10
|
/**
|
|
11
|
-
* Automatically capture unhandled
|
|
12
|
-
* (`$error_handled: false`).
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Automatically capture unhandled errors as `$error` events
|
|
12
|
+
* (`$error_handled: false`).
|
|
13
|
+
*
|
|
14
|
+
* - `true` installs the global handlers for `window` `'error'` and
|
|
15
|
+
* `'unhandledrejection'`.
|
|
16
|
+
* - An options object additionally lets you toggle `globalHandlers` and opt
|
|
17
|
+
* into `console` capture (`console.error` / `console.warn`), plus configure
|
|
18
|
+
* truncation / stack inclusion / ignore patterns.
|
|
19
|
+
*
|
|
20
|
+
* Default: off.
|
|
15
21
|
*/
|
|
16
|
-
autoCaptureErrors?: boolean |
|
|
22
|
+
autoCaptureErrors?: boolean | AutoCaptureErrorsOptions;
|
|
17
23
|
children: React.ReactNode;
|
|
18
24
|
}
|
|
19
25
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ISunglassesClient, ScreenTrackingOptions,
|
|
3
|
-
export { CaptureExceptionOptions, ConsentStatus, ISunglassesClient, ScreenTrackingOptions, SunglassesConfig, SunglassesCore, SunglassesEvent, captureException } from '@drakkar.software/sunglasses-core';
|
|
2
|
+
import { ISunglassesClient, ScreenTrackingOptions, AutoCaptureErrorsOptions, ConsentStatus, 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()). */
|
|
@@ -8,12 +8,18 @@ interface SunglassesProviderProps {
|
|
|
8
8
|
/** Optional screen tracking configuration. */
|
|
9
9
|
screenTracking?: ScreenTrackingOptions;
|
|
10
10
|
/**
|
|
11
|
-
* Automatically capture unhandled
|
|
12
|
-
* (`$error_handled: false`).
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Automatically capture unhandled errors as `$error` events
|
|
12
|
+
* (`$error_handled: false`).
|
|
13
|
+
*
|
|
14
|
+
* - `true` installs the global handlers for `window` `'error'` and
|
|
15
|
+
* `'unhandledrejection'`.
|
|
16
|
+
* - An options object additionally lets you toggle `globalHandlers` and opt
|
|
17
|
+
* into `console` capture (`console.error` / `console.warn`), plus configure
|
|
18
|
+
* truncation / stack inclusion / ignore patterns.
|
|
19
|
+
*
|
|
20
|
+
* Default: off.
|
|
15
21
|
*/
|
|
16
|
-
autoCaptureErrors?: boolean |
|
|
22
|
+
autoCaptureErrors?: boolean | AutoCaptureErrorsOptions;
|
|
17
23
|
children: React.ReactNode;
|
|
18
24
|
}
|
|
19
25
|
/**
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
SunglassesProvider: () => SunglassesProvider,
|
|
36
36
|
captureException: () => import_sunglasses_core3.captureException,
|
|
37
37
|
captureUtmParams: () => captureUtmParams,
|
|
38
|
+
patchConsole: () => import_sunglasses_core3.patchConsole,
|
|
38
39
|
useCapture: () => useCapture,
|
|
39
40
|
useConsentStatus: () => useConsentStatus,
|
|
40
41
|
useScreenTracking: () => useScreenTracking,
|
|
@@ -132,19 +133,28 @@ function SunglassesProvider({
|
|
|
132
133
|
}, [client]);
|
|
133
134
|
(0, import_react3.useEffect)(() => {
|
|
134
135
|
if (!autoCaptureErrors) return;
|
|
135
|
-
if (typeof window === "undefined") return;
|
|
136
136
|
const options = typeof autoCaptureErrors === "object" ? autoCaptureErrors : {};
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
const cleanups = [];
|
|
138
|
+
if (options.globalHandlers !== false && typeof window !== "undefined") {
|
|
139
|
+
const onError = (event) => {
|
|
140
|
+
(0, import_sunglasses_core.captureException)(client, event.error ?? event.message, { handled: false, ...options });
|
|
141
|
+
};
|
|
142
|
+
const onRejection = (event) => {
|
|
143
|
+
(0, import_sunglasses_core.captureException)(client, event.reason, { handled: false, ...options });
|
|
144
|
+
};
|
|
145
|
+
window.addEventListener("error", onError);
|
|
146
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
147
|
+
cleanups.push(() => {
|
|
148
|
+
window.removeEventListener("error", onError);
|
|
149
|
+
window.removeEventListener("unhandledrejection", onRejection);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (options.console) {
|
|
153
|
+
const consoleOptions = typeof options.console === "object" ? options.console : {};
|
|
154
|
+
cleanups.push((0, import_sunglasses_core.patchConsole)(client, consoleOptions));
|
|
155
|
+
}
|
|
145
156
|
return () => {
|
|
146
|
-
|
|
147
|
-
window.removeEventListener("unhandledrejection", onRejection);
|
|
157
|
+
for (const cleanup of cleanups) cleanup();
|
|
148
158
|
};
|
|
149
159
|
}, [client, autoCaptureErrors]);
|
|
150
160
|
(0, import_react3.useEffect)(() => {
|
|
@@ -249,6 +259,7 @@ var import_sunglasses_core3 = require("@drakkar.software/sunglasses-core");
|
|
|
249
259
|
SunglassesProvider,
|
|
250
260
|
captureException,
|
|
251
261
|
captureUtmParams,
|
|
262
|
+
patchConsole,
|
|
252
263
|
useCapture,
|
|
253
264
|
useConsentStatus,
|
|
254
265
|
useScreenTracking,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/SunglassesProvider.tsx
|
|
2
2
|
import { useEffect as useEffect2 } from "react";
|
|
3
|
-
import { captureException } from "@drakkar.software/sunglasses-core";
|
|
3
|
+
import { captureException, patchConsole } from "@drakkar.software/sunglasses-core";
|
|
4
4
|
|
|
5
5
|
// src/context.ts
|
|
6
6
|
import { createContext, useContext } from "react";
|
|
@@ -88,19 +88,28 @@ function SunglassesProvider({
|
|
|
88
88
|
}, [client]);
|
|
89
89
|
useEffect2(() => {
|
|
90
90
|
if (!autoCaptureErrors) return;
|
|
91
|
-
if (typeof window === "undefined") return;
|
|
92
91
|
const options = typeof autoCaptureErrors === "object" ? autoCaptureErrors : {};
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
const cleanups = [];
|
|
93
|
+
if (options.globalHandlers !== false && typeof window !== "undefined") {
|
|
94
|
+
const onError = (event) => {
|
|
95
|
+
captureException(client, event.error ?? event.message, { handled: false, ...options });
|
|
96
|
+
};
|
|
97
|
+
const onRejection = (event) => {
|
|
98
|
+
captureException(client, event.reason, { handled: false, ...options });
|
|
99
|
+
};
|
|
100
|
+
window.addEventListener("error", onError);
|
|
101
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
102
|
+
cleanups.push(() => {
|
|
103
|
+
window.removeEventListener("error", onError);
|
|
104
|
+
window.removeEventListener("unhandledrejection", onRejection);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (options.console) {
|
|
108
|
+
const consoleOptions = typeof options.console === "object" ? options.console : {};
|
|
109
|
+
cleanups.push(patchConsole(client, consoleOptions));
|
|
110
|
+
}
|
|
101
111
|
return () => {
|
|
102
|
-
|
|
103
|
-
window.removeEventListener("unhandledrejection", onRejection);
|
|
112
|
+
for (const cleanup of cleanups) cleanup();
|
|
104
113
|
};
|
|
105
114
|
}, [client, autoCaptureErrors]);
|
|
106
115
|
useEffect2(() => {
|
|
@@ -197,13 +206,14 @@ function SunglassesErrorBoundary(props) {
|
|
|
197
206
|
}
|
|
198
207
|
|
|
199
208
|
// src/index.ts
|
|
200
|
-
import { SunglassesCore, captureException as captureException3 } from "@drakkar.software/sunglasses-core";
|
|
209
|
+
import { SunglassesCore, captureException as captureException3, patchConsole as patchConsole2 } from "@drakkar.software/sunglasses-core";
|
|
201
210
|
export {
|
|
202
211
|
SunglassesCore,
|
|
203
212
|
SunglassesErrorBoundary,
|
|
204
213
|
SunglassesProvider,
|
|
205
214
|
captureException3 as captureException,
|
|
206
215
|
captureUtmParams,
|
|
216
|
+
patchConsole2 as patchConsole,
|
|
207
217
|
useCapture,
|
|
208
218
|
useConsentStatus,
|
|
209
219
|
useScreenTracking,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakkar.software/sunglasses-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "React (web) 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
|
"react": ">=18.0.0"
|