Skip to content

Commit

Permalink
use the same service/version type in init() and startView()
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Jun 10, 2024
1 parent 81981c0 commit 15d6ede
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 13 additions & 0 deletions packages/rum-core/src/domain/view/trackViews.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,19 @@ describe('start view', () => {
)
})

it('should ignore null service/version', () => {
setupBuilder.build()
const { getViewUpdate, startView } = viewTest

startView({ service: null, version: null })
expect(getViewUpdate(2)).toEqual(
jasmine.objectContaining({
service: undefined,
version: undefined,
})
)
})

it('should use the provided clock to stop the current view and start the new one', () => {
const { clock } = setupBuilder.withFakeClock().build()
const { getViewUpdate, startView } = viewTest
Expand Down
10 changes: 5 additions & 5 deletions packages/rum-core/src/domain/view/trackViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type { LifeCycle } from '../lifeCycle'
import { LifeCycleEventType } from '../lifeCycle'
import type { EventCounts } from '../trackEventCounts'
import type { LocationChange } from '../../browser/locationChangeObservable'
import type { RumConfiguration } from '../configuration'
import type { RumConfiguration, RumInitConfiguration } from '../configuration'
import { trackViewEventCounts } from './trackViewEventCounts'
import { trackInitialViewMetrics } from './viewMetrics/trackInitialViewMetrics'
import type { InitialViewMetrics } from './viewMetrics/trackInitialViewMetrics'
Expand Down Expand Up @@ -75,8 +75,8 @@ export const KEEP_TRACKING_AFTER_VIEW_DELAY = 5 * ONE_MINUTE

export interface ViewOptions {
name?: string
service?: string
version?: string
service?: RumInitConfiguration['service']
version?: RumInitConfiguration['version']
}

export function trackViews(
Expand Down Expand Up @@ -185,8 +185,8 @@ function newView(
let version: string | undefined
if (viewOptions) {
name = viewOptions.name
service = viewOptions.service
version = viewOptions.version
service = viewOptions.service || undefined
version = viewOptions.version || undefined
}

const viewCreatedEvent = {
Expand Down

0 comments on commit 15d6ede

Please sign in to comment.