-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move createPreStartStrategy in its own module
Extracted helper functions to check recorder status
- Loading branch information
1 parent
efed90d
commit e103093
Showing
3 changed files
with
63 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { noop } from '@datadog/browser-core' | ||
import type { RumConfiguration } from '@datadog/browser-rum-core' | ||
import type { Strategy } from './postStartStrategy' | ||
|
||
const enum PreStartRecorderStatus { | ||
None, | ||
HadManualStart, | ||
HadManualStop, | ||
} | ||
|
||
export function createPreStartStrategy(): { | ||
strategy: Strategy | ||
shouldStartImmediately: (configuration: RumConfiguration) => boolean | ||
} { | ||
let status = PreStartRecorderStatus.None | ||
return { | ||
strategy: { | ||
start() { | ||
status = PreStartRecorderStatus.HadManualStart | ||
}, | ||
stop() { | ||
status = PreStartRecorderStatus.HadManualStop | ||
}, | ||
isRecording: () => false, | ||
getSessionReplayLink: noop as () => string | undefined, | ||
}, | ||
shouldStartImmediately(configuration) { | ||
return ( | ||
status === PreStartRecorderStatus.HadManualStart || | ||
(status === PreStartRecorderStatus.None && !configuration.startSessionReplayRecordingManually) | ||
) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters