@drakkar.software/sunglasses-adapter-sentry 0.6.0 → 0.8.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 CHANGED
@@ -1,25 +1,7 @@
1
+ import { Event, EventHint } from '@sentry/core';
1
2
  import { ErrorEventProperties, ISunglassesClient } from '@drakkar.software/sunglasses-core';
2
3
  import React from 'react';
3
4
 
4
- /** Minimal mirror of the Sentry `Event` shape we care about. */
5
- interface SentryLikeEvent {
6
- exception?: {
7
- values?: Array<{
8
- type?: string;
9
- value?: string;
10
- stacktrace?: {
11
- frames?: Array<{
12
- filename?: string;
13
- lineno?: number;
14
- function?: string;
15
- }>;
16
- };
17
- }>;
18
- };
19
- level?: string;
20
- tags?: Record<string, string | number | boolean>;
21
- }
22
- type SentryBeforeSendResult = SentryLikeEvent | null | Promise<SentryLikeEvent | null>;
23
5
  /**
24
6
  * Configuration for the Sentry → SunGlasses bridge.
25
7
  */
@@ -86,7 +68,7 @@ interface SentryBridgeConfig {
86
68
  * });
87
69
  * ```
88
70
  */
89
- declare function createSentryBeforeSend(client: ISunglassesClient, config?: SentryBridgeConfig, originalBeforeSend?: (event: SentryLikeEvent, hint: unknown) => SentryBeforeSendResult): (event: SentryLikeEvent, hint: unknown) => SentryBeforeSendResult;
71
+ declare function createSentryBeforeSend(client: ISunglassesClient, config?: SentryBridgeConfig, originalBeforeSend?: (event: Event, hint: EventHint) => Event | null | Promise<Event | null>): (event: Event, hint: EventHint) => Event | null | Promise<Event | null>;
90
72
 
91
73
  /**
92
74
  * Configuration for `SunglassesErrorBoundary`.
package/dist/index.d.ts CHANGED
@@ -1,25 +1,7 @@
1
+ import { Event, EventHint } from '@sentry/core';
1
2
  import { ErrorEventProperties, ISunglassesClient } from '@drakkar.software/sunglasses-core';
2
3
  import React from 'react';
3
4
 
4
- /** Minimal mirror of the Sentry `Event` shape we care about. */
5
- interface SentryLikeEvent {
6
- exception?: {
7
- values?: Array<{
8
- type?: string;
9
- value?: string;
10
- stacktrace?: {
11
- frames?: Array<{
12
- filename?: string;
13
- lineno?: number;
14
- function?: string;
15
- }>;
16
- };
17
- }>;
18
- };
19
- level?: string;
20
- tags?: Record<string, string | number | boolean>;
21
- }
22
- type SentryBeforeSendResult = SentryLikeEvent | null | Promise<SentryLikeEvent | null>;
23
5
  /**
24
6
  * Configuration for the Sentry → SunGlasses bridge.
25
7
  */
@@ -86,7 +68,7 @@ interface SentryBridgeConfig {
86
68
  * });
87
69
  * ```
88
70
  */
89
- declare function createSentryBeforeSend(client: ISunglassesClient, config?: SentryBridgeConfig, originalBeforeSend?: (event: SentryLikeEvent, hint: unknown) => SentryBeforeSendResult): (event: SentryLikeEvent, hint: unknown) => SentryBeforeSendResult;
71
+ declare function createSentryBeforeSend(client: ISunglassesClient, config?: SentryBridgeConfig, originalBeforeSend?: (event: Event, hint: EventHint) => Event | null | Promise<Event | null>): (event: Event, hint: EventHint) => Event | null | Promise<Event | null>;
90
72
 
91
73
  /**
92
74
  * Configuration for `SunglassesErrorBoundary`.
package/dist/index.js CHANGED
@@ -45,9 +45,10 @@ function createSentryBeforeSend(client, config = {}, originalBeforeSend) {
45
45
  beforeCapture,
46
46
  suppressSentrySend = false
47
47
  } = config;
48
- return (event, hint) => {
49
- const sentryResult = originalBeforeSend ? originalBeforeSend(event, hint) : event;
48
+ return async (event, hint) => {
49
+ const sentryResult = originalBeforeSend ? await originalBeforeSend(event, hint) : event;
50
50
  const result = suppressSentrySend ? null : sentryResult;
51
+ if (sentryResult === null) return result;
51
52
  const exc = event.exception?.values?.[0];
52
53
  const rawMessage = exc?.value ?? "";
53
54
  const message = rawMessage.slice(0, maxMessageLength);
package/dist/index.mjs CHANGED
@@ -8,9 +8,10 @@ function createSentryBeforeSend(client, config = {}, originalBeforeSend) {
8
8
  beforeCapture,
9
9
  suppressSentrySend = false
10
10
  } = config;
11
- return (event, hint) => {
12
- const sentryResult = originalBeforeSend ? originalBeforeSend(event, hint) : event;
11
+ return async (event, hint) => {
12
+ const sentryResult = originalBeforeSend ? await originalBeforeSend(event, hint) : event;
13
13
  const result = suppressSentrySend ? null : sentryResult;
14
+ if (sentryResult === null) return result;
14
15
  const exc = event.exception?.values?.[0];
15
16
  const rawMessage = exc?.value ?? "";
16
17
  const message = rawMessage.slice(0, maxMessageLength);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drakkar.software/sunglasses-adapter-sentry",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Sentry bridge and React error boundary for SunGlasses — captures errors as analytics events",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -16,17 +16,22 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@drakkar.software/sunglasses-core": "0.6.0"
19
+ "@drakkar.software/sunglasses-core": "0.8.0"
20
20
  },
21
21
  "peerDependencies": {
22
+ "@sentry/core": ">=8",
22
23
  "react": ">=17"
23
24
  },
24
25
  "peerDependenciesMeta": {
26
+ "@sentry/core": {
27
+ "optional": true
28
+ },
25
29
  "react": {
26
30
  "optional": true
27
31
  }
28
32
  },
29
33
  "devDependencies": {
34
+ "@sentry/core": "^10.61.0",
30
35
  "@types/react": "^18.3.12",
31
36
  "happy-dom": "^15.11.7",
32
37
  "react": "^18.3.1",