Skip to content

Commit 498fa19

Browse files
committed
Add sendClientReport option to disable sdk client reports
1 parent 3f2d081 commit 498fa19

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

packages/browser/src/backend.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
6262
...this._options.transportOptions,
6363
dsn: this._options.dsn,
6464
tunnel: this._options.tunnel,
65+
sendClientReports: this._options.sendClientReports,
6566
_metadata: this._options._metadata,
6667
};
6768

packages/browser/src/sdk.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ export function init(options: BrowserOptions = {}): void {
8888
if (options.autoSessionTracking === undefined) {
8989
options.autoSessionTracking = true;
9090
}
91+
if (options.sendClientReports === undefined) {
92+
options.sendClientReports = true;
93+
}
9194

9295
initAndBind(BrowserClient, options);
9396

packages/browser/src/transports/base.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ export abstract class BaseTransport implements Transport {
6767
* @inheritDoc
6868
*/
6969
public recordLostEvent(type: Outcome): void {
70+
if (!this.options.sendClientReport) {
71+
return;
72+
}
73+
7074
logger.log(`Adding ${type} outcome`);
7175
this._outcomes[type] = (this._outcomes[type] ?? 0) + 1;
7276
}
@@ -75,6 +79,10 @@ export abstract class BaseTransport implements Transport {
7579
* Send outcomes as an envelope
7680
*/
7781
protected _flushOutcomes(): void {
82+
if (!this.options.sendClientReport) {
83+
return;
84+
}
85+
7886
if (!navigator || typeof navigator.sendBeacon !== 'function') {
7987
logger.warn('Beacon API not available, skipping sending outcomes.');
8088
return;

packages/types/src/options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ export interface Options {
132132
*/
133133
autoSessionTracking?: boolean;
134134

135+
/**
136+
* Automatically send SDK Client Report
137+
*/
138+
sendClientReports?: boolean;
139+
135140
/**
136141
* Initial data to populate scope.
137142
*/

packages/types/src/transport.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export interface TransportOptions {
6464
fetchParameters?: { [key: string]: string };
6565
/** The envelope tunnel to use. */
6666
tunnel?: string;
67+
/** Automatically send SDK Client Report */
68+
sendClientReport?: boolean;
6769
/**
6870
* Set of metadata about the SDK that can be internally used to enhance envelopes and events,
6971
* and provide additional data about every request.

0 commit comments

Comments
 (0)