File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -725,7 +725,12 @@ function send(data) {
725
725
if ( globalOptions . release ) data . release = globalOptions . release ;
726
726
727
727
if ( isFunction ( globalOptions . dataCallback ) ) {
728
- data = globalOptions . dataCallback ( data ) ;
728
+ data = globalOptions . dataCallback ( data ) || data ;
729
+ }
730
+
731
+ // Why??????????
732
+ if ( ! data || isEmptyObject ( data ) ) {
733
+ return ;
729
734
}
730
735
731
736
// Check if the request should be filtered or not
Original file line number Diff line number Diff line change @@ -976,6 +976,39 @@ describe('globals', function() {
976
976
} ] ) ;
977
977
} ) ;
978
978
979
+ it ( 'should ignore dataCallback if it does not return anything' , function ( ) {
980
+ this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
981
+ this . sinon . stub ( window , 'makeRequest' ) ;
982
+ this . sinon . stub ( window , 'getHttpData' ) . returns ( {
983
+ url : 'http://localhost/?a=b' ,
984
+ headers : { 'User-Agent' : 'lolbrowser' }
985
+ } ) ;
986
+
987
+ globalProject = '2' ;
988
+ globalOptions = {
989
+ logger : 'javascript' ,
990
+ dataCallback : function ( ) {
991
+ return ;
992
+ }
993
+ } ;
994
+
995
+ send ( { foo : 'bar' } ) ;
996
+ assert . deepEqual ( window . makeRequest . lastCall . args [ 0 ] , {
997
+ project : '2' ,
998
+ logger : 'javascript' ,
999
+ platform : 'javascript' ,
1000
+ request : {
1001
+ url : 'http://localhost/?a=b' ,
1002
+ headers : {
1003
+ 'User-Agent' : 'lolbrowser'
1004
+ }
1005
+ } ,
1006
+ event_id : 'abc123' ,
1007
+ foo : 'bar' ,
1008
+ extra : { 'session:duration' : 100 }
1009
+ } ) ;
1010
+ } ) ;
1011
+
979
1012
it ( 'should strip empty tags' , function ( ) {
980
1013
this . sinon . stub ( window , 'isSetup' ) . returns ( true ) ;
981
1014
this . sinon . stub ( window , 'makeRequest' ) ;
You can’t perform that action at this time.
0 commit comments