@@ -2,12 +2,14 @@ import type { FlushEvent, Context, Telemetry } from '@datadog/browser-core'
22import { Observable , resetExperimentalFeatures } from '@datadog/browser-core'
33import type { Clock , MockTelemetry } from '@datadog/browser-core/test'
44import { mockClock , startMockTelemetry } from '@datadog/browser-core/test'
5- import { mockRumConfiguration } from '../../test'
65import { RumEventType } from '../rawRumEvent.types'
76import type { RumEvent } from '../rumEvent.types'
87import { LifeCycle , LifeCycleEventType } from './lifeCycle'
9- import { MEASURES_PERIOD_DURATION , startCustomerDataTelemetry } from './startCustomerDataTelemetry'
10- import type { RumConfiguration } from './configuration'
8+ import {
9+ MEASURES_PERIOD_DURATION ,
10+ startCustomerDataTelemetry ,
11+ CUSTOMER_DATA_METRIC_NAME ,
12+ } from './startCustomerDataTelemetry'
1113
1214describe ( 'customerDataTelemetry' , ( ) => {
1315 let clock : Clock
@@ -17,12 +19,6 @@ describe('customerDataTelemetry', () => {
1719 let lifeCycle : LifeCycle
1820 const viewEvent = { type : RumEventType . VIEW } as RumEvent & Context
1921
20- const config : Partial < RumConfiguration > = {
21- telemetrySampleRate : 100 ,
22- customerDataTelemetrySampleRate : 100 ,
23- maxTelemetryEventsPerPage : 2 ,
24- }
25-
2622 function generateBatch ( {
2723 eventNumber,
2824 batchBytesCount = 1 ,
@@ -46,15 +42,18 @@ describe('customerDataTelemetry', () => {
4642 } )
4743 }
4844
49- function setupCustomerTelemetryCollection ( partialConfig : Partial < RumConfiguration > = config ) {
50- const configuration = mockRumConfiguration ( partialConfig )
45+ function setupCustomerTelemetryCollection ( telemetryEnabled : boolean = true ) {
5146 batchFlushObservable = new Observable ( )
5247 lifeCycle = new LifeCycle ( )
5348 fakeContextBytesCount = 1
5449
5550 telemetry = startMockTelemetry ( )
5651
57- startCustomerDataTelemetry ( configuration , { enabled : true } as Telemetry , lifeCycle , batchFlushObservable )
52+ startCustomerDataTelemetry (
53+ { enabledMetrics : { [ CUSTOMER_DATA_METRIC_NAME ] : telemetryEnabled } } as unknown as Telemetry ,
54+ lifeCycle ,
55+ batchFlushObservable
56+ )
5857 }
5958
6059 beforeEach ( ( ) => {
@@ -132,10 +131,7 @@ describe('customerDataTelemetry', () => {
132131 } )
133132
134133 it ( 'should not collect customer data telemetry when telemetry disabled' , async ( ) => {
135- setupCustomerTelemetryCollection ( {
136- telemetrySampleRate : 100 ,
137- customerDataTelemetrySampleRate : 0 ,
138- } )
134+ setupCustomerTelemetryCollection ( false )
139135
140136 generateBatch ( { eventNumber : 1 } )
141137 clock . tick ( MEASURES_PERIOD_DURATION )
0 commit comments