@@ -6,6 +6,60 @@ import { loadHtml } from './util/fixtures.js';
66
77// Use minimal browser package, with no optional components added.
88import Rollbar from '../src/browser/core.js' ;
9+ import Tracing from '../src/tracing/tracing.js' ;
10+
11+ describe ( 'options' , function ( ) {
12+ beforeEach ( function ( ) {
13+ Rollbar . setComponents ( {
14+ tracing : Tracing ,
15+ } ) ;
16+ } ) ;
17+
18+ afterEach ( function ( ) {
19+ Rollbar . setComponents ( { } ) ;
20+ } ) ;
21+
22+ it ( 'should set session attributes from constructor' , function ( ) {
23+ const rollbar = new Rollbar ( {
24+ accessToken : 'POST_CLIENT_ITEM_TOKEN' ,
25+ captureUnhandledRejections : false ,
26+ person : {
27+ id : '12345' ,
28+ name : 'Test User' ,
29+ 30+ } ,
31+ codeVersion : 'abc123' ,
32+ } ) ;
33+ const session = rollbar . tracing . session ;
34+ expect ( session ) . to . exist ;
35+ expect ( session . attributes [ 'user.id' ] ) . to . equal ( '12345' ) ;
36+ expect ( session . attributes [ 'user.name' ] ) . to . equal ( 'Test User' ) ;
37+ expect ( session . attributes [ 'user.email' ] ) . to . equal ( '[email protected] ' ) ; 38+ expect ( session . attributes [ 'code_version' ] ) . to . equal ( 'abc123' ) ;
39+ } ) ;
40+
41+ it ( 'should set session attributes from configure' , function ( ) {
42+ const rollbar = new Rollbar ( {
43+ accessToken : 'POST_CLIENT_ITEM_TOKEN' ,
44+ captureUnhandledRejections : false ,
45+
46+ } ) ;
47+ rollbar . configure ( {
48+ person : {
49+ id : '12345' ,
50+ name : 'Test User' ,
51+ 52+ } ,
53+ codeVersion : 'abc123' ,
54+ } ) ;
55+ const session = rollbar . tracing . session ;
56+ expect ( session ) . to . exist ;
57+ expect ( session . attributes [ 'user.id' ] ) . to . equal ( '12345' ) ;
58+ expect ( session . attributes [ 'user.name' ] ) . to . equal ( 'Test User' ) ;
59+ expect ( session . attributes [ 'user.email' ] ) . to . equal ( '[email protected] ' ) ; 60+ expect ( session . attributes [ 'code_version' ] ) . to . equal ( 'abc123' ) ;
61+ } ) ;
62+ } ) ;
963
1064describe ( 'options.captureUncaught' , function ( ) {
1165 let __originalOnError = null ;
0 commit comments