Skip to content

Commit 8c77773

Browse files
committed
ref(replay): Send SDK version in Replay events
1 parent fdf9ff8 commit 8c77773

File tree

5 files changed

+4
-38
lines changed

5 files changed

+4
-38
lines changed

packages/replay/jest.setup.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
22
import { getCurrentHub } from '@sentry/core';
33
import type { ReplayRecordingData, Transport } from '@sentry/types';
4-
import {TextEncoder} from 'util';
4+
import { TextEncoder } from 'util';
55

66
import type { ReplayContainer, Session } from './src/types';
77

8-
// @ts-ignore TS error, this is replaced in prod builds bc of rollup
9-
global.__SENTRY_REPLAY_VERSION__ = 'version:Test';
10-
118
(global as any).TextEncoder = TextEncoder;
129

1310
type MockTransport = jest.MockedFunction<Transport['send']>;

packages/replay/rollup.bundle.config.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
1-
import replace from '@rollup/plugin-replace';
2-
31
import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/index.js';
42

5-
import pkg from './package.json';
6-
73
const baseBundleConfig = makeBaseBundleConfig({
84
bundleType: 'addon',
95
entrypoints: ['src/index.ts'],
106
jsVersion: 'es6',
117
licenseTitle: '@sentry/replay',
128
outputFileBase: () => 'bundles/replay',
13-
packageSpecificConfig: {
14-
plugins: [
15-
replace({
16-
preventAssignment: true,
17-
values: {
18-
__SENTRY_REPLAY_VERSION__: JSON.stringify(pkg.version),
19-
},
20-
}),
21-
],
22-
},
239
});
2410

2511
const builds = makeBundleConfigVariants(baseBundleConfig);

packages/replay/rollup.npm.config.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
import replace from '@rollup/plugin-replace';
2-
31
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index';
42

5-
import pkg from './package.json';
6-
73
export default makeNPMConfigVariants(
84
makeBaseNPMConfig({
95
hasBundles: true,
106
packageSpecificConfig: {
11-
plugins: [
12-
// TODO: Remove this - replay version will be in sync w/ SDK version
13-
replace({
14-
preventAssignment: true,
15-
values: {
16-
__SENTRY_REPLAY_VERSION__: JSON.stringify(pkg.version),
17-
},
18-
}),
19-
],
207
output: {
218
// set exports to 'named' or 'auto' so that rollup doesn't warn about
229
// the default export in `worker/worker.js`

packages/replay/src/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ export interface WorkerRequest {
2929
args: unknown[];
3030
}
3131

32-
declare global {
33-
const __SENTRY_REPLAY_VERSION__: string;
34-
}
35-
3632
// PerformancePaintTiming and PerformanceNavigationTiming are only available with TS 4.4 and newer
3733
// Therefore, we're exporting them here to make them available in older TS versions
3834
export type PerformancePaintTiming = PerformanceEntry;

packages/replay/src/util/prepareReplayEvent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ export async function prepareReplayEvent({
3030

3131
// extract the SDK name because `client._prepareEvent` doesn't add it to the event
3232
const metadata = client.getSdkMetadata && client.getSdkMetadata();
33-
const name = (metadata && metadata.sdk && metadata.sdk.name) || 'sentry.javascript.unknown';
33+
const { name, version } = (metadata && metadata.sdk) || {};
3434

3535
preparedEvent.sdk = {
3636
...preparedEvent.sdk,
37-
version: __SENTRY_REPLAY_VERSION__,
38-
name,
37+
name: name || 'sentry.javascript.unknown',
38+
version: version || '0.0.0',
3939
};
4040

4141
return preparedEvent;

0 commit comments

Comments
 (0)