File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ var _Raven = window.Raven,
15
15
ignoreUrls : [ ] ,
16
16
whitelistUrls : [ ] ,
17
17
includePaths : [ ] ,
18
- tags : { }
18
+ tags : { } ,
19
+ extra : { }
19
20
} ;
20
21
21
22
var TK = TraceKit . noConflict ( ) ;
@@ -496,11 +497,13 @@ function send(data) {
496
497
'sentry.interfaces.Http' : getHttpData ( )
497
498
} , data ) ;
498
499
499
- // Merge in the tags separately since arrayMerge doesn't handle a deep merge
500
+ // Merge in the tags and extra separately since arrayMerge doesn't handle a deep merge
500
501
data . tags = arrayMerge ( globalOptions . tags , data . tags ) ;
502
+ data . extra = arrayMerge ( globalOptions . extra , data . extra ) ;
501
503
502
- // If there are no tags, strip the key from the payload alltogther.
504
+ // If there are no tags/extra , strip the key from the payload alltogther.
503
505
if ( ! data . tags ) delete data . tags ;
506
+ if ( ! data . extra ) delete data . extra ;
504
507
505
508
if ( globalUser ) data [ 'sentry.interfaces.User' ] = globalUser ;
506
509
Original file line number Diff line number Diff line change @@ -560,6 +560,38 @@ describe('globals', function() {
560
560
} ] ) ;
561
561
} ) ;
562
562
563
+ it ( 'should merge in global extra' , function ( ) {
564
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
565
+ this . sinon . stub ( window , 'makeRequest' ) ;
566
+ this . sinon . stub ( window , 'getHttpData' ) . returns ( {
567
+ url : 'http://localhost/?a=b' ,
568
+ headers : { 'User-Agent' : 'lolbrowser' }
569
+ } ) ;
570
+
571
+ globalProject = 2 ;
572
+ globalOptions = {
573
+ logger : 'javascript' ,
574
+ site : 'THE BEST' ,
575
+ extra : { key1 : 'value1' }
576
+ } ;
577
+
578
+
579
+ send ( { extra : { key2 : 'value2' } } ) ;
580
+ assert . deepEqual ( window . makeRequest . lastCall . args , [ {
581
+ project : 2 ,
582
+ logger : 'javascript' ,
583
+ site : 'THE BEST' ,
584
+ platform : 'javascript' ,
585
+ 'sentry.interfaces.Http' : {
586
+ url : 'http://localhost/?a=b' ,
587
+ headers : {
588
+ 'User-Agent' : 'lolbrowser'
589
+ }
590
+ } ,
591
+ extra : { key1 : 'value1' , key2 : 'value2' }
592
+ } ] ) ;
593
+ } ) ;
594
+
563
595
it ( 'should let dataCallback override everything' , function ( ) {
564
596
this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
565
597
this . sinon . stub ( window , 'makeRequest' ) ;
You can’t perform that action at this time.
0 commit comments