File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,15 @@ export interface CDNSettings {
122122 version : number
123123 }
124124 | { }
125+ /**
126+ * Settings for auto instrumentation
127+ */
128+ autoInstrumentationSettings ?: {
129+ /**
130+ * A sample rate to determine what percentage of sessions should send signals, from [0,1]
131+ */
132+ sampleRate : number
133+ }
125134}
126135
127136export interface AnalyticsBrowserSettings {
Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ export class Signals implements ISignals {
8383 * - Registers custom signal generators.
8484 */
8585 async start ( analytics : AnyAnalytics ) : Promise < void > {
86+ if (
87+ ! analytics . settings . cdnSettings . autoInstrumentationSettings ||
88+ Math . random ( ) >
89+ analytics . settings . cdnSettings . autoInstrumentationSettings . sampleRate
90+ )
91+ return
8692 const analyticsService = new AnalyticsService ( analytics )
8793
8894 this . globalSettings . update ( {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export type EdgeFnCDNSettings = {
99}
1010
1111export interface CDNSettings {
12+ autoInstrumentationSettings ?: CDNSettingsAutoInstrumentation
1213 integrations : CDNSettingsIntegrations
1314 edgeFunction ?: EdgeFnCDNSettings | { [ key : string ] : never }
1415}
@@ -72,6 +73,10 @@ export interface CDNSettingsIntegrations {
7273 [ integrationName : string ] : { [ key : string ] : any }
7374}
7475
76+ export interface CDNSettingsAutoInstrumentation {
77+ sampleRate : number
78+ }
79+
7580export type PluginType = 'before' | 'after' | 'destination'
7681
7782export interface Plugin < Analytics = AnyAnalytics , Ctx = Record < string , any > > {
You can’t perform that action at this time.
0 commit comments