File tree Expand file tree Collapse file tree 4 files changed +20
-21
lines changed Expand file tree Collapse file tree 4 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -242,10 +242,6 @@ export abstract class BaseClient<B extends Backend, O extends Options>
242
242
prepared . release = release ;
243
243
}
244
244
245
- if ( scope ) {
246
- scope . applyToEvent ( prepared , Math . min ( maxBreadcrumbs , MAX_BREADCRUMBS ) ) ;
247
- }
248
-
249
245
if ( prepared . message ) {
250
246
prepared . message = truncate ( prepared . message , MAX_URL_LENGTH ) ;
251
247
}
@@ -265,6 +261,12 @@ export abstract class BaseClient<B extends Backend, O extends Options>
265
261
266
262
prepared . event_id = uuid4 ( ) ;
267
263
264
+ // This should be the last thing called, since we want that
265
+ // {@link Hub.addEventProcessor } gets the finished prepared event.
266
+ if ( scope ) {
267
+ scope . applyToEvent ( prepared , Math . min ( maxBreadcrumbs , MAX_BREADCRUMBS ) ) ;
268
+ }
269
+
268
270
return prepared ;
269
271
}
270
272
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ export function initAndBind<F extends Client, O extends Options>(
27
27
const client = new clientClass ( options ) ;
28
28
client . install ( ) ;
29
29
30
+ // This should happen here if any integration uses {@link Hub.addEventProcessor }
31
+ // there needs to be a client on the hub already.
32
+ getDefaultHub ( ) . bindClient ( client ) ;
33
+
30
34
let integrations = [ ...defaultIntegrations ] ;
31
35
if ( Array . isArray ( options . integrations ) ) {
32
36
integrations = [ ...integrations , ...options . integrations ] ;
@@ -40,6 +44,4 @@ export function initAndBind<F extends Client, O extends Options>(
40
44
integration . install ( ) ;
41
45
} ) ;
42
46
}
43
-
44
- getDefaultHub ( ) . bindClient ( client ) ;
45
47
}
Original file line number Diff line number Diff line change @@ -8,9 +8,6 @@ export class Scope {
8
8
/** Flag if notifiying is happening. */
9
9
protected notifyingListeners : boolean = false ;
10
10
11
- /** Flag if notifiying is happening. */
12
- protected notifyingProcessors : boolean = false ;
13
-
14
11
/** Callback for client to receive scope changes. */
15
12
protected scopeListeners : Array < ( scope : Scope ) => void > = [ ] ;
16
13
@@ -61,15 +58,9 @@ export class Scope {
61
58
* This will be called after {@link applyToEvent} is finished.
62
59
*/
63
60
protected notifyEventProcessors ( event : SentryEvent ) : void {
64
- if ( ! this . notifyingProcessors ) {
65
- this . notifyingProcessors = true ;
66
- setTimeout ( ( ) => {
67
- this . eventProcessors . forEach ( callback => {
68
- callback ( event ) ;
69
- } ) ;
70
- this . notifyingProcessors = false ;
71
- } , 0 ) ;
72
- }
61
+ this . eventProcessors . forEach ( callback => {
62
+ callback ( event ) ;
63
+ } ) ;
73
64
}
74
65
75
66
/**
Original file line number Diff line number Diff line change @@ -227,8 +227,7 @@ describe('Hub', () => {
227
227
} ) ;
228
228
229
229
test ( 'addEventProcessor' , done => {
230
- jest . useFakeTimers ( ) ;
231
- expect . assertions ( 1 ) ;
230
+ expect . assertions ( 2 ) ;
232
231
const event : SentryEvent = {
233
232
extra : { b : 3 } ,
234
233
} ;
@@ -237,9 +236,14 @@ describe('Hub', () => {
237
236
const hub = new Hub ( { a : 'b' } , localScope ) ;
238
237
hub . addEventProcessor ( ( ) => ( processedEvent : SentryEvent ) => {
239
238
expect ( processedEvent . extra ) . toEqual ( { a : 'b' , b : 3 } ) ;
239
+ } ) ;
240
+ hub . addEventProcessor ( ( ) => ( processedEvent : SentryEvent ) => {
241
+ processedEvent . dist = '1' ;
242
+ } ) ;
243
+ hub . addEventProcessor ( ( ) => ( processedEvent : SentryEvent ) => {
244
+ expect ( processedEvent . dist ) . toEqual ( '1' ) ;
240
245
done ( ) ;
241
246
} ) ;
242
247
localScope . applyToEvent ( event ) ;
243
- jest . runAllTimers ( ) ;
244
248
} ) ;
245
249
} ) ;
You can’t perform that action at this time.
0 commit comments