Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💥 [RUMF-730] use v2 events format #627

Merged
merged 11 commits into from
Dec 14, 2020
5 changes: 4 additions & 1 deletion packages/rum/src/boot/rum.entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ export function makeRumGlobal(startRumImpl: StartRum) {
})
}),

/**
* @deprecated
* @see addAction
*/
addUserAction: (name: string, context?: Context) => {
// TODO deprecate in v2
rumGlobal.addAction(name, context)
},

Expand Down
55 changes: 0 additions & 55 deletions packages/rum/src/boot/rum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ function collectServerEvents(lifeCycle: LifeCycle) {
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, ({ serverRumEvent }) => {
serverRumEvents.push(serverRumEvent as any)
})
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_V2_COLLECTED, ({ serverRumEvent }) => {
serverRumEvents.push(serverRumEvent as any)
})
return serverRumEvents
}

Expand All @@ -54,34 +51,6 @@ describe('rum session', () => {
setupBuilder.cleanup()
})

it('when the session is renewed, a new view event should be sent (v1)', () => {
let sessionId = '42'
const { lifeCycle } = setupBuilder
.withSession({
getId: () => sessionId,
isTracked: () => true,
isTrackedWithResource: () => true,
})
.withConfiguration({
isEnabled: () => false,
})
.build()

expect(serverRumEvents.length).toEqual(1)
expect(serverRumEvents[0].evt.category).toEqual('view')
expect(serverRumEvents[0].session_id).toEqual('42')

sessionId = '43'
lifeCycle.notify(LifeCycleEventType.SESSION_RENEWED)

expect(serverRumEvents.length).toEqual(2)

// New view event
expect(serverRumEvents[1].evt.category).toEqual('view')
expect(serverRumEvents[1].session_id).toEqual('43')
expect(serverRumEvents[1].view.id).not.toEqual(serverRumEvents[0].view.id)
})

it('when the session is renewed, a new view event should be sent', () => {
let sessionId = '42'
const { lifeCycle } = setupBuilder
Expand Down Expand Up @@ -135,30 +104,6 @@ describe('rum session keep alive', () => {
setupBuilder.cleanup()
})

it('should send a view update regularly (v1)', () => {
const { clock } = setupBuilder
.withConfiguration({
isEnabled: () => false,
})
.build()

// clear initial events
clock.tick(SESSION_KEEP_ALIVE_INTERVAL * 0.9)
serverRumEvents.length = 0

clock.tick(SESSION_KEEP_ALIVE_INTERVAL * 0.1)

// view update
expect(serverRumEvents.length).toEqual(1)
expect(serverRumEvents[0].evt.category).toEqual('view')

clock.tick(SESSION_KEEP_ALIVE_INTERVAL)

// view update
expect(serverRumEvents.length).toEqual(2)
expect(serverRumEvents[1].evt.category).toEqual('view')
})

it('should send a view update regularly', () => {
const { clock } = setupBuilder.build()

Expand Down
4 changes: 1 addition & 3 deletions packages/rum/src/boot/rum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { combine, commonInit, Configuration, Context } from '@datadog/browser-co
import { startDOMMutationCollection } from '../browser/domMutationCollection'
import { startPerformanceCollection } from '../browser/performanceCollection'
import { startRumAssembly } from '../domain/assembly'
import { startRumAssemblyV2 } from '../domain/assemblyV2'
import { startInternalContext } from '../domain/internalContext'
import { LifeCycle } from '../domain/lifeCycle'
import { startParentContexts } from '../domain/parentContexts'
Expand Down Expand Up @@ -47,7 +46,7 @@ export function startRum(userConfiguration: RumUserConfiguration, getGlobalConte
startPerformanceCollection(lifeCycle, configuration)
startDOMMutationCollection(lifeCycle)

const internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts, configuration)
const internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts)

return {
addAction,
Expand All @@ -67,7 +66,6 @@ export function startRumEventCollection(
const parentContexts = startParentContexts(lifeCycle, session)
const batch = startRumBatch(configuration, lifeCycle)
startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext)
startRumAssemblyV2(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext)
startLongTaskCollection(lifeCycle, configuration)
startResourceCollection(lifeCycle, configuration, session)
startViewCollection(lifeCycle, configuration, location)
Expand Down
Loading