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

feat(session replay): remove recording terms #618

Merged
merged 1 commit into from
Nov 10, 2023
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
3 changes: 1 addition & 2 deletions packages/session-replay-browser/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions packages/session-replay-browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 0 additions & 5 deletions packages/session-replay-browser/src/session-replay-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 1 addition & 9 deletions packages/session-replay-browser/src/session-replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export type SessionReplayOptions = Omit<Partial<SessionReplayConfig>, 'apiKey'>;
export interface AmplitudeSessionReplay {
init: (apiKey: string, options: SessionReplayOptions) => AmplitudeReturn<void>;
setSessionId: (sessionId: number) => void;
getSessionRecordingProperties: () => { [key: string]: boolean | string | null };
getSessionReplayProperties: () => { [key: string]: boolean | string | null };
shutdown: () => void;
}
4 changes: 2 additions & 2 deletions packages/session-replay-browser/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
44 changes: 1 addition & 43 deletions packages/session-replay-browser/test/session-replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ describe('SessionReplayPlugin', () => {

const result = sessionReplay.getSessionReplayProperties();
expect(result).toEqual({
'[Amplitude] Session Recorded': true,
'[Amplitude] Session Replay ID': '1a2b3c/123',
});
});
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Loading