@@ -85,41 +85,41 @@ export class BrowserClient extends Client<BrowserClientOptions> {
8585
8686 super ( opts ) ;
8787
88- // eslint-disable-next-line @typescript-eslint/no-this-alias
89- const client = this ;
90- const { sendDefaultPii, _experiments } = client . _options ;
88+ const { sendDefaultPii, sendClientReports, _experiments } = this . _options ;
9189 const enableLogs = _experiments ?. enableLogs ;
9290
93- if ( opts . sendClientReports && WINDOW . document ) {
91+ if ( WINDOW . document && ( sendClientReports || enableLogs ) ) {
9492 WINDOW . document . addEventListener ( 'visibilitychange' , ( ) => {
9593 if ( WINDOW . document . visibilityState === 'hidden' ) {
96- this . _flushOutcomes ( ) ;
94+ if ( sendClientReports ) {
95+ this . _flushOutcomes ( ) ;
96+ }
9797 if ( enableLogs ) {
98- _INTERNAL_flushLogsBuffer ( client ) ;
98+ _INTERNAL_flushLogsBuffer ( this ) ;
9999 }
100100 }
101101 } ) ;
102102 }
103103
104104 if ( enableLogs ) {
105- client . on ( 'flush' , ( ) => {
106- _INTERNAL_flushLogsBuffer ( client ) ;
105+ this . on ( 'flush' , ( ) => {
106+ _INTERNAL_flushLogsBuffer ( this ) ;
107107 } ) ;
108108
109- client . on ( 'afterCaptureLog' , ( ) => {
110- if ( client . _logFlushIdleTimeout ) {
111- clearTimeout ( client . _logFlushIdleTimeout ) ;
109+ this . on ( 'afterCaptureLog' , ( ) => {
110+ if ( this . _logFlushIdleTimeout ) {
111+ clearTimeout ( this . _logFlushIdleTimeout ) ;
112112 }
113113
114- client . _logFlushIdleTimeout = setTimeout ( ( ) => {
115- _INTERNAL_flushLogsBuffer ( client ) ;
114+ this . _logFlushIdleTimeout = setTimeout ( ( ) => {
115+ _INTERNAL_flushLogsBuffer ( this ) ;
116116 } , DEFAULT_FLUSH_INTERVAL ) ;
117117 } ) ;
118118 }
119119
120120 if ( sendDefaultPii ) {
121- client . on ( 'postprocessEvent' , addAutoIpAddressToUser ) ;
122- client . on ( 'beforeSendSession' , addAutoIpAddressToSession ) ;
121+ this . on ( 'postprocessEvent' , addAutoIpAddressToUser ) ;
122+ this . on ( 'beforeSendSession' , addAutoIpAddressToSession ) ;
123123 }
124124 }
125125
0 commit comments