From 83d156a4d2bf077fa023faad0ef514a4dd074b6f Mon Sep 17 00:00:00 2001 From: Jesse Wang Date: Thu, 2 Nov 2023 13:52:48 -0700 Subject: [PATCH] feat(session replay): remove recording terms --- .../session-replay-browser/src/constants.ts | 3 +- packages/session-replay-browser/src/index.ts | 3 +- .../src/session-replay-factory.ts | 5 --- .../src/session-replay.ts | 10 +---- .../src/typings/session-replay.ts | 1 - .../session-replay-browser/test/index.test.ts | 4 +- .../test/session-replay.test.ts | 44 +------------------ 7 files changed, 6 insertions(+), 64 deletions(-) diff --git a/packages/session-replay-browser/src/constants.ts b/packages/session-replay-browser/src/constants.ts index d55122d65..e7e1444d9 100644 --- a/packages/session-replay-browser/src/constants.ts +++ b/packages/session-replay-browser/src/constants.ts @@ -3,8 +3,7 @@ import { IDBStoreSession } from './typings/session-replay'; export const DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]'; -export const NEW_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`; -export const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Recorded`; +export const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`; export const DEFAULT_SESSION_START_EVENT = 'session_start'; export const DEFAULT_SESSION_END_EVENT = 'session_end'; export const DEFAULT_SAMPLE_RATE = 0; diff --git a/packages/session-replay-browser/src/index.ts b/packages/session-replay-browser/src/index.ts index 0cd9bdbf7..b59f8db65 100644 --- a/packages/session-replay-browser/src/index.ts +++ b/packages/session-replay-browser/src/index.ts @@ -1,3 +1,2 @@ import sessionReplay from './session-replay-factory'; -export const { init, setSessionId, getSessionRecordingProperties, getSessionReplayProperties, shutdown } = - sessionReplay; +export const { init, setSessionId, getSessionReplayProperties, shutdown } = sessionReplay; diff --git a/packages/session-replay-browser/src/session-replay-factory.ts b/packages/session-replay-browser/src/session-replay-factory.ts index b7b57db5a..64b871066 100644 --- a/packages/session-replay-browser/src/session-replay-factory.ts +++ b/packages/session-replay-browser/src/session-replay-factory.ts @@ -22,11 +22,6 @@ const createInstance: () => AmplitudeSessionReplay = () => { 'setSessionId', getLogConfig(sessionReplay), ), - getSessionRecordingProperties: debugWrapper( - sessionReplay.getSessionRecordingProperties.bind(sessionReplay), - 'getSessionRecordingProperties', - getLogConfig(sessionReplay), - ), getSessionReplayProperties: debugWrapper( sessionReplay.getSessionReplayProperties.bind(sessionReplay), 'getSessionReplayProperties', diff --git a/packages/session-replay-browser/src/session-replay.ts b/packages/session-replay-browser/src/session-replay.ts index 6ea44997b..36ab4281c 100644 --- a/packages/session-replay-browser/src/session-replay.ts +++ b/packages/session-replay-browser/src/session-replay.ts @@ -13,7 +13,6 @@ import { MAX_IDB_STORAGE_LENGTH, MAX_INTERVAL, MIN_INTERVAL, - NEW_SESSION_REPLAY_PROPERTY, SESSION_REPLAY_EU_URL as SESSION_REPLAY_EU_SERVER_URL, SESSION_REPLAY_SERVER_URL, STORAGE_PREFIX, @@ -112,20 +111,13 @@ export class SessionReplay implements AmplitudeSessionReplay { if (shouldRecord) { return { - [DEFAULT_SESSION_REPLAY_PROPERTY]: true, - [NEW_SESSION_REPLAY_PROPERTY]: this.config.sessionReplayId ? this.config.sessionReplayId : null, + [DEFAULT_SESSION_REPLAY_PROPERTY]: this.config.sessionReplayId ? this.config.sessionReplayId : null, }; } return {}; } - getSessionRecordingProperties = () => { - this.loggerProvider.warn('Please use getSessionReplayProperties instead of getSessionRecordingProperties.'); - - return this.getSessionReplayProperties(); - }; - blurListener = () => { this.stopRecordingAndSendEvents(); }; diff --git a/packages/session-replay-browser/src/typings/session-replay.ts b/packages/session-replay-browser/src/typings/session-replay.ts index 7eea83da4..f36736c9c 100644 --- a/packages/session-replay-browser/src/typings/session-replay.ts +++ b/packages/session-replay-browser/src/typings/session-replay.ts @@ -47,7 +47,6 @@ export type SessionReplayOptions = Omit, 'apiKey'>; export interface AmplitudeSessionReplay { init: (apiKey: string, options: SessionReplayOptions) => AmplitudeReturn; setSessionId: (sessionId: number) => void; - getSessionRecordingProperties: () => { [key: string]: boolean | string | null }; getSessionReplayProperties: () => { [key: string]: boolean | string | null }; shutdown: () => void; } diff --git a/packages/session-replay-browser/test/index.test.ts b/packages/session-replay-browser/test/index.test.ts index b14e3ad65..a1630a2e8 100644 --- a/packages/session-replay-browser/test/index.test.ts +++ b/packages/session-replay-browser/test/index.test.ts @@ -1,10 +1,10 @@ -import { getSessionRecordingProperties, init, setSessionId, shutdown } from '../src/index'; +import { getSessionReplayProperties, init, setSessionId, shutdown } from '../src/index'; describe('index', () => { test('should expose apis', () => { expect(typeof init).toBe('function'); expect(typeof setSessionId).toBe('function'); - expect(typeof getSessionRecordingProperties).toBe('function'); + expect(typeof getSessionReplayProperties).toBe('function'); expect(typeof shutdown).toBe('function'); }); }); diff --git a/packages/session-replay-browser/test/session-replay.test.ts b/packages/session-replay-browser/test/session-replay.test.ts index 2e7683831..d618bb07b 100644 --- a/packages/session-replay-browser/test/session-replay.test.ts +++ b/packages/session-replay-browser/test/session-replay.test.ts @@ -248,7 +248,6 @@ describe('SessionReplayPlugin', () => { const result = sessionReplay.getSessionReplayProperties(); expect(result).toEqual({ - '[Amplitude] Session Recorded': true, '[Amplitude] Session Replay ID': '1a2b3c/123', }); }); @@ -263,52 +262,11 @@ describe('SessionReplayPlugin', () => { const result = sessionReplay.getSessionReplayProperties(); expect(result).toEqual({ - '[Amplitude] Session Recorded': true, '[Amplitude] Session Replay ID': null, }); }); }); - describe('getSessionRecordingProperties', () => { - test('should return an empty object if config not set', () => { - const sessionReplay = new SessionReplay(); - sessionReplay.loggerProvider = mockLoggerProvider; - - const result = sessionReplay.getSessionRecordingProperties(); - expect(result).toEqual({}); - // eslint-disable-next-line @typescript-eslint/unbound-method - expect(mockLoggerProvider.error).toHaveBeenCalled(); - }); - - test('should return an empty object if shouldRecord is false', async () => { - const sessionReplay = new SessionReplay(); - await sessionReplay.init(apiKey, mockOptions).promise; - sessionReplay.getShouldRecord = () => false; - const result = sessionReplay.getSessionRecordingProperties(); - expect(result).toEqual({}); - }); - - test('should return an default sample rate if not set', async () => { - const sessionReplay = new SessionReplay(); - await sessionReplay.init(apiKey, mockOptions).promise; - sessionReplay.getShouldRecord = () => false; - const result = sessionReplay.getSessionRecordingProperties(); - expect(result).toEqual({}); - }); - - test('should return the session recorded property if shouldRecord is true', async () => { - const sessionReplay = new SessionReplay(); - await sessionReplay.init(apiKey, mockOptions).promise; - sessionReplay.getShouldRecord = () => true; - - const result = sessionReplay.getSessionRecordingProperties(); - expect(result).toEqual({ - '[Amplitude] Session Recorded': true, - '[Amplitude] Session Replay ID': '1a2b3c/123', - }); - }); - }); - describe('initalize', () => { test('should read events from storage and send them if shouldSendStoredEvents is true', async () => { const sessionReplay = new SessionReplay(); @@ -1261,7 +1219,7 @@ describe('SessionReplayPlugin', () => { await sessionReplay.init(apiKey, { ...mockOptions, sampleRate: 0.8 }).promise; const sessionRecordingProperties = sessionReplay.getSessionReplayProperties(); expect(sessionRecordingProperties).toMatchObject({ - [DEFAULT_SESSION_REPLAY_PROPERTY]: true, + [DEFAULT_SESSION_REPLAY_PROPERTY]: '1a2b3c/123', }); // Log is called from setup, but that's not what we're testing here mockLoggerProvider.log.mockClear();