1- import { Event , EventHint , Options , Severity } from '@sentry/types' ;
1+ import { Event , EventHint , Severity } from '@sentry/types' ;
22import {
33 addExceptionMechanism ,
44 addExceptionTypeValue ,
@@ -17,11 +17,13 @@ import { eventFromError, eventFromPlainObject, parseStackFrames } from './parser
1717 * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
1818 * @hidden
1919 */
20- export function eventFromException ( options : Options , exception : unknown , hint ?: EventHint ) : PromiseLike < Event > {
20+ export function eventFromException (
21+ exception : unknown ,
22+ hint ?: EventHint ,
23+ attachStacktrace ?: boolean ,
24+ ) : PromiseLike < Event > {
2125 const syntheticException = ( hint && hint . syntheticException ) || undefined ;
22- const event = eventFromUnknownInput ( exception , syntheticException , {
23- attachStacktrace : options . attachStacktrace ,
24- } ) ;
26+ const event = eventFromUnknownInput ( exception , syntheticException , attachStacktrace ) ;
2527 addExceptionMechanism ( event ) ; // defaults to { type: 'generic', handled: true }
2628 event . level = Severity . Error ;
2729 if ( hint && hint . event_id ) {
@@ -35,15 +37,13 @@ export function eventFromException(options: Options, exception: unknown, hint?:
3537 * @hidden
3638 */
3739export function eventFromMessage (
38- options : Options ,
3940 message : string ,
4041 level : Severity = Severity . Info ,
4142 hint ?: EventHint ,
43+ attachStacktrace ?: boolean ,
4244) : PromiseLike < Event > {
4345 const syntheticException = ( hint && hint . syntheticException ) || undefined ;
44- const event = eventFromString ( message , syntheticException , {
45- attachStacktrace : options . attachStacktrace ,
46- } ) ;
46+ const event = eventFromString ( message , syntheticException , attachStacktrace ) ;
4747 event . level = level ;
4848 if ( hint && hint . event_id ) {
4949 event . event_id = hint . event_id ;
@@ -57,10 +57,8 @@ export function eventFromMessage(
5757export function eventFromUnknownInput (
5858 exception : unknown ,
5959 syntheticException ?: Error ,
60- options : {
61- isRejection ?: boolean ;
62- attachStacktrace ?: boolean ;
63- } = { } ,
60+ attachStacktrace ?: boolean ,
61+ isUnhandledRejection ?: boolean ,
6462) : Event {
6563 let event : Event ;
6664
@@ -85,7 +83,7 @@ export function eventFromUnknownInput(
8583 } else {
8684 const name = domException . name || ( isDOMError ( domException ) ? 'DOMError' : 'DOMException' ) ;
8785 const message = domException . message ? `${ name } : ${ domException . message } ` : name ;
88- event = eventFromString ( message , syntheticException , options ) ;
86+ event = eventFromString ( message , syntheticException , attachStacktrace ) ;
8987 addExceptionTypeValue ( event , message ) ;
9088 }
9189 if ( 'code' in domException ) {
@@ -103,7 +101,7 @@ export function eventFromUnknownInput(
103101 // it manually. This will allow us to group events based on top-level keys which is much better than creating a new
104102 // group on any key/value change.
105103 const objectException = exception as Record < string , unknown > ;
106- event = eventFromPlainObject ( objectException , syntheticException , options . isRejection ) ;
104+ event = eventFromPlainObject ( objectException , syntheticException , isUnhandledRejection ) ;
107105 addExceptionMechanism ( event , {
108106 synthetic : true ,
109107 } ) ;
@@ -119,7 +117,7 @@ export function eventFromUnknownInput(
119117 // - a plain Object
120118 //
121119 // So bail out and capture it as a simple message:
122- event = eventFromString ( exception as string , syntheticException , options ) ;
120+ event = eventFromString ( exception as string , syntheticException , attachStacktrace ) ;
123121 addExceptionTypeValue ( event , `${ exception } ` , undefined ) ;
124122 addExceptionMechanism ( event , {
125123 synthetic : true ,
@@ -131,18 +129,12 @@ export function eventFromUnknownInput(
131129/**
132130 * @hidden
133131 */
134- export function eventFromString (
135- input : string ,
136- syntheticException ?: Error ,
137- options : {
138- attachStacktrace ?: boolean ;
139- } = { } ,
140- ) : Event {
132+ export function eventFromString ( input : string , syntheticException ?: Error , attachStacktrace ?: boolean ) : Event {
141133 const event : Event = {
142134 message : input ,
143135 } ;
144136
145- if ( options . attachStacktrace && syntheticException ) {
137+ if ( attachStacktrace && syntheticException ) {
146138 const frames = parseStackFrames ( syntheticException ) ;
147139 if ( frames . length ) {
148140 event . stacktrace = { frames } ;
0 commit comments