11import { Backend , Options , SentryError } from '@sentry/core' ;
22import { addBreadcrumb , captureEvent } from '@sentry/minimal' ;
3- import { SentryEvent , SentryException } from '@sentry/types' ;
3+ import { SentryEvent } from '@sentry/types' ;
44import { Raven , SendMethod } from './raven' ;
55
66/** Original raven send function. */
77const sendRavenEvent = Raven . _sendProcessedPayload . bind ( Raven ) as SendMethod ;
88
9- /** Normalizes the event so it is consistent with our domain interface. */
10- function normalizeRavenEvent ( event ?: SentryEvent ) : SentryEvent | undefined {
11- const ex = ( ( event && event . exception ) || { } ) as {
12- values ?: SentryException [ ] ;
13- } ;
14- if ( event && ex && ex . values ) {
15- event . exception = ex . values ;
16- }
17- return event ;
18- }
19-
20- /** Prepares an event so it can be send with raven-js. */
21- function prepareEventForRaven ( event : SentryEvent ) : SentryEvent {
22- const ravenEvent = event as any ;
23- if ( event . exception ) {
24- // tslint:disable-next-line:no-unsafe-any
25- ravenEvent . exception = { values : event . exception } ;
26- }
27- return ravenEvent as SentryEvent ;
28- }
29-
309/**
3110 * Configuration options for the Sentry Browser SDK.
3211 * @see BrowserClient for more information.
@@ -95,15 +74,7 @@ export class BrowserBackend implements Backend {
9574 return false ;
9675 } ) ;
9776
98- // Hook into Raven's internal event sending mechanism. This allows us to
99- // pass events to the client, before they will be sent back here for
100- // actual submission.
101- Raven . _sendProcessedPayload = event => {
102- const normalizedEvent = normalizeRavenEvent ( event ) ;
103- if ( normalizedEvent ) {
104- captureEvent ( normalizedEvent ) ;
105- }
106- } ;
77+ Raven . _sendProcessedPayload = captureEvent ;
10778
10879 return true ;
10980 }
@@ -119,11 +90,7 @@ export class BrowserBackend implements Backend {
11990 event = evt ;
12091 } ;
12192 Raven . captureException ( exception ) ;
122- const normalizedEvent = normalizeRavenEvent ( event ) ;
123- if ( normalizedEvent ) {
124- return normalizedEvent ;
125- }
126- throw new SentryError ( 'Event was undefined when it should be an event' ) ;
93+ return event ;
12794 } finally {
12895 Raven . _sendProcessedPayload = originalSend ;
12996 }
@@ -140,11 +107,7 @@ export class BrowserBackend implements Backend {
140107 event = evt ;
141108 } ;
142109 Raven . captureMessage ( message ) ;
143- const normalizedEvent = normalizeRavenEvent ( event ) ;
144- if ( normalizedEvent ) {
145- return normalizedEvent ;
146- }
147- throw new SentryError ( 'Event was undefined when it should be an event' ) ;
110+ return event ;
148111 } finally {
149112 Raven . _sendProcessedPayload = originalSend ;
150113 }
@@ -155,7 +118,7 @@ export class BrowserBackend implements Backend {
155118 */
156119 public async sendEvent ( event : SentryEvent ) : Promise < number > {
157120 return new Promise < number > ( resolve => {
158- sendRavenEvent ( prepareEventForRaven ( event ) , error => {
121+ sendRavenEvent ( event , error => {
159122 // TODO: Check the response status code
160123 resolve ( error ? 500 : 200 ) ;
161124 } ) ;
0 commit comments