Skip to content

Commit fe8fc5f

Browse files
authored
Merge branch 'main' into NR-428192-supportability-metrics
2 parents 7366f50 + b502684 commit fe8fc5f

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

src/features/session_replay/aggregate/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { registerHandler } from '../../../common/event-emitter/register-handler'
10-
import { ABORT_REASONS, FEATURE_NAME, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, SR_EVENT_EMITTER_TYPES, TRIGGERS } from '../constants'
10+
import { ABORT_REASONS, ERROR_DURING_REPLAY, FEATURE_NAME, QUERY_PARAM_PADDING, RRWEB_EVENT_TYPES, TRIGGERS } from '../constants'
1111
import { AggregateBase } from '../../utils/aggregate-base'
1212
import { sharedChannel } from '../../../common/constants/shared-channel'
1313
import { obj as encodeObj } from '../../../common/url/encode'
@@ -21,6 +21,7 @@ import { now } from '../../../common/timing/now'
2121
import { MAX_PAYLOAD_SIZE } from '../../../common/constants/agent-constants'
2222
import { cleanURL } from '../../../common/url/clean-url'
2323
import { canEnableSessionTracking } from '../../utils/feature-gates'
24+
import { PAUSE_REPLAY } from '../../../loaders/api/constants'
2425

2526
export class Aggregate extends AggregateBase {
2627
static featureName = FEATURE_NAME
@@ -77,11 +78,11 @@ export class Aggregate extends AggregateBase {
7778
this.mode = data.sessionReplayMode
7879
})
7980

80-
registerHandler(SR_EVENT_EMITTER_TYPES.PAUSE, () => {
81+
registerHandler(PAUSE_REPLAY, () => {
8182
this.forceStop(this.mode === MODE.FULL)
8283
}, this.featureName, this.ee)
8384

84-
registerHandler(SR_EVENT_EMITTER_TYPES.ERROR_DURING_REPLAY, e => {
85+
registerHandler(ERROR_DURING_REPLAY, e => {
8586
this.handleError(e)
8687
}, this.featureName, this.ee)
8788

src/features/session_replay/constants.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import { FEATURE_NAMES } from '../../loaders/features/features'
77

88
export const FEATURE_NAME = FEATURE_NAMES.sessionReplay
99

10-
export const SR_EVENT_EMITTER_TYPES = {
11-
RECORD: 'recordReplay',
12-
PAUSE: 'pauseReplay',
13-
ERROR_DURING_REPLAY: 'errorDuringReplay'
14-
}
10+
export const ERROR_DURING_REPLAY = 'errorDuringReplay'
1511

1612
export const AVG_COMPRESSION = 0.12
1713
export const RRWEB_EVENT_TYPES = {

src/features/session_replay/instrument/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { handle } from '../../../common/event-emitter/handle'
1010
import { DEFAULT_KEY, MODE, PREFIX } from '../../../common/session/constants'
1111
import { InstrumentBase } from '../../utils/instrument-base'
1212
import { hasReplayPrerequisite, isPreloadAllowed } from '../shared/utils'
13-
import { FEATURE_NAME, SR_EVENT_EMITTER_TYPES, TRIGGERS } from '../constants'
13+
import { ERROR_DURING_REPLAY, FEATURE_NAME, TRIGGERS } from '../constants'
1414
import { setupRecordReplayAPI } from '../../../loaders/api/recordReplay'
1515
import { setupPauseReplayAPI } from '../../../loaders/api/pauseReplay'
16+
import { RECORD_REPLAY } from '../../../loaders/api/constants'
1617

1718
export class Instrument extends InstrumentBase {
1819
static featureName = FEATURE_NAME
@@ -34,7 +35,7 @@ export class Instrument extends InstrumentBase {
3435
} catch (err) { }
3536

3637
if (hasReplayPrerequisite(agentRef.init)) {
37-
this.ee.on(SR_EVENT_EMITTER_TYPES.RECORD, () => this.#apiStartOrRestartReplay())
38+
this.ee.on(RECORD_REPLAY, () => this.#apiStartOrRestartReplay())
3839
}
3940

4041
if (this.#canPreloadRecorder(session)) {
@@ -50,7 +51,7 @@ export class Instrument extends InstrumentBase {
5051
if (this.blocked) return
5152
if (this.agentRef.runtime.isRecording) {
5253
this.errorNoticed = true
53-
handle(SR_EVENT_EMITTER_TYPES.ERROR_DURING_REPLAY, [e], undefined, this.featureName, this.ee)
54+
handle(ERROR_DURING_REPLAY, [e], undefined, this.featureName, this.ee)
5455
}
5556
})
5657
}

tests/components/session_replay/aggregate.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { faker } from '@faker-js/faker'
2-
import { SR_EVENT_EMITTER_TYPES } from '../../../src/features/session_replay/constants'
2+
import { ERROR_DURING_REPLAY } from '../../../src/features/session_replay/constants'
33
import { IDEAL_PAYLOAD_SIZE, MAX_PAYLOAD_SIZE } from '../../../src/common/constants/agent-constants'
44
import { MODE, SESSION_EVENTS } from '../../../src/common/session/constants'
55
import { FEATURE_NAMES } from '../../../src/loaders/features/features'
@@ -166,7 +166,7 @@ describe('Session Replay Sample -> Mode Behaviors', () => {
166166

167167
describe('Session Replay Error Mode Behaviors', () => {
168168
test('an error BEFORE rrweb import starts running in ERROR from beginning (when not preloaded)', async () => {
169-
ee.get(mainAgent.agentIdentifier).emit(SR_EVENT_EMITTER_TYPES.ERROR_DURING_REPLAY, ['test1'], undefined, FEATURE_NAMES.sessionReplay, ee.get(mainAgent.agentIdentifier))
169+
ee.get(mainAgent.agentIdentifier).emit(ERROR_DURING_REPLAY, ['test1'], undefined, FEATURE_NAMES.sessionReplay, ee.get(mainAgent.agentIdentifier))
170170

171171
const sessionReplayInstrument = new SessionReplay(mainAgent)
172172
await new Promise(process.nextTick)
@@ -184,7 +184,7 @@ describe('Session Replay Error Mode Behaviors', () => {
184184

185185
expect(sessionReplayAggregate.mode).toEqual(MODE.ERROR)
186186

187-
ee.get(mainAgent.agentIdentifier).emit(SR_EVENT_EMITTER_TYPES.ERROR_DURING_REPLAY, ['test1'], undefined, FEATURE_NAMES.sessionReplay, ee.get(mainAgent.agentIdentifier))
187+
ee.get(mainAgent.agentIdentifier).emit(ERROR_DURING_REPLAY, ['test1'], undefined, FEATURE_NAMES.sessionReplay, ee.get(mainAgent.agentIdentifier))
188188

189189
expect(sessionReplayAggregate.mode).toEqual(MODE.FULL)
190190
})

0 commit comments

Comments
 (0)