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-513] enable keep alive mechanism #421

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rum/src/rum.entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ datadogRum.init = monitor((userConfiguration: RumUserConfiguration) => {
const session = startRumSession(configuration, lifeCycle)
const globalApi = startRum(rumUserConfiguration.applicationId, lifeCycle, configuration, session, internalMonitoring)

startViewCollection(location, lifeCycle, session, configuration)
startViewCollection(location, lifeCycle, session)
const [requestStartObservable, requestCompleteObservable] = startRequestCollection()
startPerformanceCollection(lifeCycle, session)
startDOMMutationCollection(lifeCycle)
Expand Down
33 changes: 8 additions & 25 deletions packages/rum/src/viewCollection.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
Configuration,
DOM_EVENT,
generateUUID,
monitor,
msToNs,
noop,
ONE_MINUTE,
throttle,
} from '@datadog/browser-core'
import { DOM_EVENT, generateUUID, monitor, msToNs, noop, ONE_MINUTE, throttle } from '@datadog/browser-core'

import { LifeCycle, LifeCycleEventType } from './lifeCycle'
import { PerformancePaintTiming } from './rum'
Expand Down Expand Up @@ -46,12 +37,7 @@ export enum ViewLoadingType {
export const THROTTLE_VIEW_UPDATE_PERIOD = 3000
export const SESSION_KEEP_ALIVE_INTERVAL = 5 * ONE_MINUTE

export function startViewCollection(
location: Location,
lifeCycle: LifeCycle,
session: RumSession,
configuration: Configuration
) {
export function startViewCollection(location: Location, lifeCycle: LifeCycle, session: RumSession) {
let currentLocation = { ...location }
const startOrigin = 0
let currentView = newView(lifeCycle, currentLocation, session, ViewLoadingType.INITIAL_LOAD, startOrigin)
Expand Down Expand Up @@ -80,15 +66,12 @@ export function startViewCollection(
})

// Session keep alive
let keepAliveInterval: number
if (configuration.isEnabled('keep-alive')) {
keepAliveInterval = window.setInterval(
monitor(() => {
currentView.triggerUpdate()
}),
SESSION_KEEP_ALIVE_INTERVAL
)
}
const keepAliveInterval = window.setInterval(
monitor(() => {
currentView.triggerUpdate()
}),
SESSION_KEEP_ALIVE_INTERVAL
)

return {
stop() {
Expand Down
7 changes: 1 addition & 6 deletions packages/rum/test/specHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ export function setup(): TestSetupBuilder {
},
withViewCollection(fakeLocation?: Partial<Location>) {
buildTasks.push(() => {
const { stop } = startViewCollection(
(fakeLocation as Location) || location,
lifeCycle,
session,
configuration as Configuration
)
const { stop } = startViewCollection((fakeLocation as Location) || location, lifeCycle, session)
cleanupTasks.push(stop)
})
return setupBuilder
Expand Down