File tree Expand file tree Collapse file tree 5 files changed +26
-5
lines changed Expand file tree Collapse file tree 5 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
62
62
...this . _options . transportOptions ,
63
63
dsn : this . _options . dsn ,
64
64
tunnel : this . _options . tunnel ,
65
+ sendClientReports : this . _options . sendClientReports ,
65
66
_metadata : this . _options . _metadata ,
66
67
} ;
67
68
Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ export function init(options: BrowserOptions = {}): void {
88
88
if ( options . autoSessionTracking === undefined ) {
89
89
options . autoSessionTracking = true ;
90
90
}
91
+ if ( options . sendClientReports === undefined ) {
92
+ options . sendClientReports = true ;
93
+ }
91
94
92
95
initAndBind ( BrowserClient , options ) ;
93
96
Original file line number Diff line number Diff line change @@ -42,11 +42,13 @@ export abstract class BaseTransport implements Transport {
42
42
// eslint-disable-next-line deprecation/deprecation
43
43
this . url = this . _api . getStoreEndpointWithUrlEncodedAuth ( ) ;
44
44
45
- document . addEventListener ( 'visibilitychange' , ( ) => {
46
- if ( document . visibilityState === 'hidden' ) {
47
- this . _flushOutcomes ( ) ;
48
- }
49
- } ) ;
45
+ if ( this . options . sendClientReport ) {
46
+ document . addEventListener ( 'visibilitychange' , ( ) => {
47
+ if ( document . visibilityState === 'hidden' ) {
48
+ this . _flushOutcomes ( ) ;
49
+ }
50
+ } ) ;
51
+ }
50
52
}
51
53
52
54
/**
@@ -67,6 +69,10 @@ export abstract class BaseTransport implements Transport {
67
69
* @inheritDoc
68
70
*/
69
71
public recordLostEvent ( type : Outcome ) : void {
72
+ if ( ! this . options . sendClientReport ) {
73
+ return ;
74
+ }
75
+
70
76
logger . log ( `Adding ${ type } outcome` ) ;
71
77
this . _outcomes [ type ] = ( this . _outcomes [ type ] ?? 0 ) + 1 ;
72
78
}
@@ -75,6 +81,10 @@ export abstract class BaseTransport implements Transport {
75
81
* Send outcomes as an envelope
76
82
*/
77
83
protected _flushOutcomes ( ) : void {
84
+ if ( ! this . options . sendClientReport ) {
85
+ return ;
86
+ }
87
+
78
88
if ( ! navigator || typeof navigator . sendBeacon !== 'function' ) {
79
89
logger . warn ( 'Beacon API not available, skipping sending outcomes.' ) ;
80
90
return ;
Original file line number Diff line number Diff line change @@ -132,6 +132,11 @@ export interface Options {
132
132
*/
133
133
autoSessionTracking ?: boolean ;
134
134
135
+ /**
136
+ * Automatically send SDK Client Report
137
+ */
138
+ sendClientReports ?: boolean ;
139
+
135
140
/**
136
141
* Initial data to populate scope.
137
142
*/
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ export interface TransportOptions {
64
64
fetchParameters ?: { [ key : string ] : string } ;
65
65
/** The envelope tunnel to use. */
66
66
tunnel ?: string ;
67
+ /** Automatically send SDK Client Report */
68
+ sendClientReport ?: boolean ;
67
69
/**
68
70
* Set of metadata about the SDK that can be internally used to enhance envelopes and events,
69
71
* and provide additional data about every request.
You can’t perform that action at this time.
0 commit comments