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,
1515 ignoreUrls : [ ] ,
1616 whitelistUrls : [ ] ,
1717 includePaths : [ ] ,
18- tags : { }
18+ tags : { } ,
19+ extra : { }
1920 } ;
2021
2122var TK = TraceKit . noConflict ( ) ;
@@ -496,11 +497,13 @@ function send(data) {
496497 'sentry.interfaces.Http' : getHttpData ( )
497498 } , data ) ;
498499
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
500501 data . tags = arrayMerge ( globalOptions . tags , data . tags ) ;
502+ data . extra = arrayMerge ( globalOptions . extra , data . extra ) ;
501503
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.
503505 if ( ! data . tags ) delete data . tags ;
506+ if ( ! data . extra ) delete data . extra ;
504507
505508 if ( globalUser ) data [ 'sentry.interfaces.User' ] = globalUser ;
506509
Original file line number Diff line number Diff line change @@ -560,6 +560,38 @@ describe('globals', function() {
560560 } ] ) ;
561561 } ) ;
562562
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+
563595 it ( 'should let dataCallback override everything' , function ( ) {
564596 this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
565597 this . sinon . stub ( window , 'makeRequest' ) ;
You can’t perform that action at this time.
0 commit comments