Skip to content

Commit cb3abc3

Browse files
🔥 Remove start stop action and resource experiment flag (#4677)
1 parent f4e1b06 commit cb3abc3

7 files changed

Lines changed: 46 additions & 90 deletions

File tree

‎packages/core/src/tools/experimentalFeatures.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import { objectHasValue } from './utils/objectUtils'
1616
export enum ExperimentalFeature {
1717
TRACK_INTAKE_REQUESTS = 'track_intake_requests',
1818
FEATURE_OPERATION_VITAL = 'feature_operation_vital',
19-
START_STOP_ACTION = 'start_stop_action',
20-
START_STOP_RESOURCE = 'start_stop_resource',
2119
TOO_MANY_REQUESTS_INVESTIGATION = 'too_many_requests_investigation',
2220
SESSION_RENEWAL_DEBUG_CONTEXT = 'session_renewal_debug_context',
2321
}

‎packages/rum-core/src/boot/preStartRum.spec.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import {
1111
TrackingConsent,
1212
createTrackingConsentState,
1313
DefaultPrivacyLevel,
14-
ExperimentalFeature,
1514
startTelemetry,
16-
addExperimentalFeatures,
1715
startSessionManager,
1816
} from '@datadog/browser-core'
1917
import type { Clock } from '@datadog/browser-core/test'
@@ -918,8 +916,6 @@ describe('preStartRum', () => {
918916
})
919917

920918
it('startAction / stopAction', async () => {
921-
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
922-
923919
const startActionSpy = jasmine.createSpy()
924920
const stopActionSpy = jasmine.createSpy()
925921
doStartRumSpy.and.returnValue({

‎packages/rum-core/src/boot/rumPublicApi.spec.ts‎

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import {
44
display,
55
DefaultPrivacyLevel,
66
timeStampToClocks,
7-
ExperimentalFeature,
87
ResourceType,
98
startTelemetry,
10-
addExperimentalFeatures,
119
startSessionManager,
1210
getTimeStamp,
1311
} from '@datadog/browser-core'
@@ -852,7 +850,6 @@ describe('rum public api', () => {
852850
describe('startAction / stopAction', () => {
853851
it('should call startAction and stopAction on the strategy', async () => {
854852
const clock = mockClock()
855-
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
856853

857854
const startActionSpy = jasmine.createSpy('startAction')
858855
const stopActionSpy = jasmine.createSpy('stopAction')
@@ -894,8 +891,6 @@ describe('rum public api', () => {
894891
})
895892

896893
it('should sanitize startAction and stopAction inputs', async () => {
897-
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
898-
899894
const startActionSpy = jasmine.createSpy()
900895
const { rumPublicApi } = makeRumPublicApiWithDefaults({
901896
startRumResult: {
@@ -920,31 +915,11 @@ describe('rum public api', () => {
920915
})
921916
)
922917
})
923-
924-
it('should not call startAction/stopAction when feature flag is disabled', async () => {
925-
const startActionSpy = jasmine.createSpy()
926-
const stopActionSpy = jasmine.createSpy()
927-
const { rumPublicApi, startRumSpy } = makeRumPublicApiWithDefaults({
928-
startRumResult: {
929-
startAction: startActionSpy,
930-
stopAction: stopActionSpy,
931-
},
932-
})
933-
934-
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION)
935-
rumPublicApi.startAction('purchase', { type: ActionType.CUSTOM })
936-
rumPublicApi.stopAction('purchase')
937-
await collectAsyncCalls(startRumSpy, 1)
938-
939-
expect(startActionSpy).not.toHaveBeenCalled()
940-
expect(stopActionSpy).not.toHaveBeenCalled()
941-
})
942918
})
943919

944920
describe('startResource / stopResource', () => {
945921
it('should call startResource and stopResource on the strategy', async () => {
946922
const clock = mockClock()
947-
addExperimentalFeatures([ExperimentalFeature.START_STOP_RESOURCE])
948923

949924
const startResourceSpy = jasmine.createSpy('startResource')
950925
const stopResourceSpy = jasmine.createSpy('stopResource')
@@ -993,8 +968,6 @@ describe('rum public api', () => {
993968
})
994969

995970
it('should sanitize startResource and stopResource inputs', async () => {
996-
addExperimentalFeatures([ExperimentalFeature.START_STOP_RESOURCE])
997-
998971
const startResourceSpy = jasmine.createSpy()
999972
const { rumPublicApi } = makeRumPublicApiWithDefaults({
1000973
startRumResult: {
@@ -1020,25 +993,6 @@ describe('rum public api', () => {
1020993
})
1021994
)
1022995
})
1023-
1024-
it('should not call startResource/stopResource when feature flag is disabled', async () => {
1025-
const startResourceSpy = jasmine.createSpy()
1026-
const stopResourceSpy = jasmine.createSpy()
1027-
const { rumPublicApi, startRumSpy } = makeRumPublicApiWithDefaults({
1028-
startRumResult: {
1029-
startResource: startResourceSpy,
1030-
stopResource: stopResourceSpy,
1031-
},
1032-
})
1033-
1034-
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION)
1035-
rumPublicApi.startResource('https://api.example.com/data', { type: ResourceType.FETCH })
1036-
rumPublicApi.stopResource('https://api.example.com/data')
1037-
await collectAsyncCalls(startRumSpy, 1)
1038-
1039-
expect(startResourceSpy).not.toHaveBeenCalled()
1040-
expect(stopResourceSpy).not.toHaveBeenCalled()
1041-
})
1042996
})
1043997

1044998
describe('addDurationVital', () => {

‎packages/rum-core/src/boot/rumPublicApi.ts‎

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import {
3434
CustomerContextKey,
3535
defineContextMethod,
3636
startBufferingData,
37-
isExperimentalFeatureEnabled,
38-
ExperimentalFeature,
3937
mockable,
4038
generateUUID,
4139
timeStampNow,
@@ -176,16 +174,29 @@ export interface RumPublicApi extends PublicApi {
176174
addAction: (name: string, context?: object) => void
177175

178176
/**
179-
* [Experimental] Start an action, stored in `@action`
177+
* Start tracking a custom action.
178+
*
179+
* Call {@link stopAction} with the same name (and optional `actionKey`) to send a RUM action event
180+
* with the elapsed duration. Errors and resources triggered between start and stop are associated
181+
* with the action.
180182
*
181183
* @category Data Collection
182184
* @param name - Name of the action
183185
* @param options - Options of the action (@default type: 'custom')
186+
* @example
187+
* ```ts
188+
* datadogRum.startAction('checkout', { context: { cartId: 'abc' } })
189+
* // ... user completes checkout
190+
* datadogRum.stopAction('checkout')
191+
* ```
184192
*/
185193
startAction: (name: string, options?: ActionOptions) => void
186194

187195
/**
188-
* [Experimental] Stop an action, stored in `@action`
196+
* Stop tracking a custom action started with {@link startAction}.
197+
*
198+
* Sends a RUM action event with the elapsed duration since the matching start call. Context from
199+
* start and stop calls is merged into the event.
189200
*
190201
* @category Data Collection
191202
* @param name - Name of the action
@@ -194,16 +205,28 @@ export interface RumPublicApi extends PublicApi {
194205
stopAction: (name: string, options?: ActionOptions) => void
195206

196207
/**
197-
* [Experimental] Start tracking a resource, stored in `@resource`
208+
* Start tracking a resource manually.
209+
*
210+
* Use this for network activity that the SDK cannot automatically instrument. Call {@link stopResource}
211+
* with the same URL (and optional `resourceKey`) to send a RUM resource event with the elapsed duration.
198212
*
199213
* @category Data Collection
200214
* @param url - URL of the resource
201215
* @param options - Options of the resource (@default type: 'other')
216+
* @example
217+
* ```ts
218+
* datadogRum.startResource('https://api.example.com/users', { type: 'fetch', method: 'POST' })
219+
* // ... perform the request
220+
* datadogRum.stopResource('https://api.example.com/users', { statusCode: 201 })
221+
* ```
202222
*/
203223
startResource: (url: string, options?: ResourceOptions) => void
204224

205225
/**
206-
* [Experimental] Stop tracking a resource, stored in `@resource`
226+
* Stop tracking a resource started with {@link startResource}.
227+
*
228+
* Sends a RUM resource event with the elapsed duration since the matching start call. Context from
229+
* start and stop calls is merged into the event.
207230
*
208231
* @category Data Collection
209232
* @param url - URL of the resource
@@ -727,11 +750,7 @@ export function makeRumPublicApi(
727750
},
728751

729752
startAction: monitor((name, options) => {
730-
// Check feature flag only after init; pre-init calls should be buffered
731-
if (strategy.initConfiguration && !isExperimentalFeatureEnabled(ExperimentalFeature.START_STOP_ACTION)) {
732-
return
733-
}
734-
// addTelemetryUsage({ feature: 'start-action' })
753+
addTelemetryUsage({ feature: 'start-action' })
735754
strategy.startAction(sanitize(name)!, {
736755
type: sanitize(options && options.type) as ActionType | undefined,
737756
context: sanitize(options && options.context) as Context,
@@ -740,10 +759,7 @@ export function makeRumPublicApi(
740759
}),
741760

742761
stopAction: monitor((name, options) => {
743-
if (strategy.initConfiguration && !isExperimentalFeatureEnabled(ExperimentalFeature.START_STOP_ACTION)) {
744-
return
745-
}
746-
// addTelemetryUsage({ feature: 'stop-action' })
762+
addTelemetryUsage({ feature: 'stop-action' })
747763
strategy.stopAction(sanitize(name)!, {
748764
type: sanitize(options && options.type) as ActionType | undefined,
749765
context: sanitize(options && options.context) as Context,
@@ -752,11 +768,7 @@ export function makeRumPublicApi(
752768
}),
753769

754770
startResource: monitor((url, options) => {
755-
// Check feature flag only after init; pre-init calls should be buffered
756-
if (strategy.initConfiguration && !isExperimentalFeatureEnabled(ExperimentalFeature.START_STOP_RESOURCE)) {
757-
return
758-
}
759-
// addTelemetryUsage({ feature: 'start-resource' })
771+
addTelemetryUsage({ feature: 'start-resource' })
760772
strategy.startResource(sanitize(url)!, {
761773
type: sanitize(options && options.type) as ResourceType | undefined,
762774
method: sanitize(options && options.method) as string | undefined,
@@ -766,10 +778,7 @@ export function makeRumPublicApi(
766778
}),
767779

768780
stopResource: monitor((url, options) => {
769-
if (strategy.initConfiguration && !isExperimentalFeatureEnabled(ExperimentalFeature.START_STOP_RESOURCE)) {
770-
return
771-
}
772-
// addTelemetryUsage({ feature: 'stop-resource' })
781+
addTelemetryUsage({ feature: 'stop-resource' })
773782
strategy.stopResource(sanitize(url)!, {
774783
type: sanitize(options && options.type) as ResourceType | undefined,
775784
statusCode: options && options.statusCode,

‎packages/rum-core/src/domain/action/trackManualActions.spec.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Duration, ServerDuration } from '@datadog/browser-core'
2-
import { addExperimentalFeatures, ExperimentalFeature, Observable } from '@datadog/browser-core'
2+
import { Observable } from '@datadog/browser-core'
33
import type { Clock } from '@datadog/browser-core/test'
44
import { mockClock, registerCleanupTask } from '@datadog/browser-core/test'
55
import { collectAndValidateRawRumEvents, mockRumConfiguration } from '../../../test'
@@ -21,7 +21,6 @@ describe('trackManualActions', () => {
2121

2222
beforeEach(() => {
2323
clock = mockClock()
24-
addExperimentalFeatures([ExperimentalFeature.START_STOP_ACTION])
2524

2625
const domMutationObservable = new Observable<RumMutationRecord[]>()
2726
const windowOpenObservable = new Observable<void>()

‎test/e2e/scenario/rum/actions.scenario.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ test.describe('action collection with shadow DOM', () => {
607607

608608
test.describe('custom actions with startAction/stopAction', () => {
609609
createTest('track a custom action with startAction/stopAction')
610-
.withRum({ enableExperimentalFeatures: ['start_stop_action'] })
610+
.withRum()
611611
.run(async ({ intakeRegistry, flushEvents, page }) => {
612612
await page.evaluate(() => {
613613
window.DD_RUM!.startAction('checkout')
@@ -623,7 +623,7 @@ test.describe('custom actions with startAction/stopAction', () => {
623623
})
624624

625625
createTest('associate an error to a custom action')
626-
.withRum({ enableExperimentalFeatures: ['start_stop_action'] })
626+
.withRum()
627627
.run(async ({ intakeRegistry, flushEvents, page }) => {
628628
await page.evaluate(() => {
629629
window.DD_RUM!.startAction('checkout')
@@ -646,7 +646,7 @@ test.describe('custom actions with startAction/stopAction', () => {
646646
})
647647

648648
createTest('associate a resource to a custom action')
649-
.withRum({ enableExperimentalFeatures: ['start_stop_action'] })
649+
.withRum()
650650
.run(async ({ intakeRegistry, flushEvents, page }) => {
651651
await page.evaluate(() => {
652652
window.DD_RUM!.startAction('load-data')
@@ -671,7 +671,7 @@ test.describe('custom actions with startAction/stopAction', () => {
671671
})
672672

673673
createTest('track multiple concurrent custom actions with actionKey')
674-
.withRum({ enableExperimentalFeatures: ['start_stop_action'] })
674+
.withRum()
675675
.run(async ({ intakeRegistry, flushEvents, page }) => {
676676
await page.evaluate(() => {
677677
window.DD_RUM!.startAction('click', { actionKey: 'button1' })
@@ -687,7 +687,7 @@ test.describe('custom actions with startAction/stopAction', () => {
687687
})
688688

689689
createTest('merge contexts from start and stop')
690-
.withRum({ enableExperimentalFeatures: ['start_stop_action'] })
690+
.withRum()
691691
.run(async ({ intakeRegistry, flushEvents, page }) => {
692692
await page.evaluate(() => {
693693
window.DD_RUM!.startAction('purchase', { context: { cart_id: 'abc123' } })
@@ -706,7 +706,7 @@ test.describe('custom actions with startAction/stopAction', () => {
706706
})
707707

708708
createTest('preserve timing when startAction is called before init')
709-
.withRum({ enableExperimentalFeatures: ['start_stop_action'] })
709+
.withRum()
710710
.withRumInit((configuration) => {
711711
window.DD_RUM!.startAction('pre_init_action')
712712

@@ -725,7 +725,7 @@ test.describe('custom actions with startAction/stopAction', () => {
725725
})
726726

727727
createTest('attribute errors and resources to action started before init')
728-
.withRum({ enableExperimentalFeatures: ['start_stop_action'] })
728+
.withRum()
729729
.withRumInit((configuration) => {
730730
window.DD_RUM!.startAction('pre_init_action')
731731

‎test/e2e/scenario/rum/resources.scenario.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ test.describe('resource headers with trackResourceHeaders', () => {
506506

507507
test.describe('manual resources with startResource/stopResource', () => {
508508
createTest('track a manual resource with startResource/stopResource')
509-
.withRum({ enableExperimentalFeatures: ['start_stop_resource'] })
509+
.withRum()
510510
.run(async ({ intakeRegistry, flushEvents, page }) => {
511511
await page.evaluate(() => {
512512
window.DD_RUM!.startResource('https://api.example.com/data')
@@ -524,7 +524,7 @@ test.describe('manual resources with startResource/stopResource', () => {
524524
})
525525

526526
createTest('track a manual resource with type and method')
527-
.withRum({ enableExperimentalFeatures: ['start_stop_resource'] })
527+
.withRum()
528528
.run(async ({ intakeRegistry, flushEvents, page }) => {
529529
await page.evaluate(() => {
530530
window.DD_RUM!.startResource('https://api.example.com/users', {
@@ -547,7 +547,7 @@ test.describe('manual resources with startResource/stopResource', () => {
547547
})
548548

549549
createTest('track multiple concurrent manual resources with resourceKey')
550-
.withRum({ enableExperimentalFeatures: ['start_stop_resource'] })
550+
.withRum()
551551
.run(async ({ intakeRegistry, flushEvents, page }) => {
552552
await page.evaluate(() => {
553553
window.DD_RUM!.startResource('https://api.example.com/data', { resourceKey: 'request1' })
@@ -565,7 +565,7 @@ test.describe('manual resources with startResource/stopResource', () => {
565565
})
566566

567567
createTest('merge contexts from start and stop')
568-
.withRum({ enableExperimentalFeatures: ['start_stop_resource'] })
568+
.withRum()
569569
.run(async ({ intakeRegistry, flushEvents, page }) => {
570570
await page.evaluate(() => {
571571
window.DD_RUM!.startResource('https://api.example.com/data', {
@@ -590,7 +590,7 @@ test.describe('manual resources with startResource/stopResource', () => {
590590
})
591591

592592
createTest('preserve timing when startResource is called before init')
593-
.withRum({ enableExperimentalFeatures: ['start_stop_resource'] })
593+
.withRum()
594594
.withRumInit((configuration) => {
595595
window.DD_RUM!.startResource('https://api.example.com/early')
596596

0 commit comments

Comments
 (0)