Skip to content

Commit da36b2a

Browse files
authored
Revert "build(replay): Remove replay version string replacement (#6367)" (#6379)
Revert 6e915c3 (#6367) as the Replay team would like to continue injecting the version separately from the SDK to detect version package version mismatches more easily. Note: This will not avoid the 7.x bump in the next Replay release, it will just enable a scenario like users use the SDK on e.g. 7.25 and Replay on 7.24 and replay events will have the 7.24 version in their metadata.
1 parent 91c8f37 commit da36b2a

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

packages/replay/jest.setup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { Transport } from '@sentry/types';
55
import { Replay } from './src';
66
import { Session } from './src/session/Session';
77

8+
// @ts-ignore TS error, this is replaced in prod builds bc of rollup
9+
global.__SENTRY_REPLAY_VERSION__ = 'version:Test';
10+
811
type MockTransport = jest.MockedFunction<Transport['send']>;
912

1013
jest.mock('./src/util/isBrowser', () => {

packages/replay/rollup.npm.config.js

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

35
import pkg from './package.json';
@@ -7,6 +9,15 @@ export default makeNPMConfigVariants(
79
hasBundles: true,
810
packageSpecificConfig: {
911
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
12+
plugins: [
13+
// TODO: Remove this - replay version will be in sync w/ SDK version
14+
replace({
15+
preventAssignment: true,
16+
values: {
17+
__SENTRY_REPLAY_VERSION__: JSON.stringify(pkg.version),
18+
},
19+
}),
20+
],
1021
output: {
1122
// set exports to 'named' or 'auto' so that rollup doesn't warn about
1223
// the default export in `worker/worker.js`

packages/replay/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-lines */ // TODO: We might want to split this file up
22
import { WINDOW } from '@sentry/browser';
3-
import { addGlobalEventProcessor, getCurrentHub, Scope, SDK_VERSION, setContext } from '@sentry/core';
3+
import { addGlobalEventProcessor, getCurrentHub, Scope, setContext } from '@sentry/core';
44
import { Breadcrumb, Client, Event, Integration } from '@sentry/types';
55
import { addInstrumentationHandler, createEnvelope, logger } from '@sentry/utils';
66
import debounce from 'lodash.debounce';
@@ -1186,7 +1186,7 @@ export class Replay implements Integration {
11861186

11871187
const sdkInfo = {
11881188
name: 'sentry.javascript.integration.replay',
1189-
version: SDK_VERSION,
1189+
version: __SENTRY_REPLAY_VERSION__,
11901190
};
11911191

11921192
const replayEvent = await new Promise(resolve => {

packages/replay/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export interface WorkerRequest {
3333
args: unknown[];
3434
}
3535

36+
declare global {
37+
const __SENTRY_REPLAY_VERSION__: string;
38+
}
39+
3640
// PerformancePaintTiming and PerformanceNavigationTiming are only available with TS 4.4 and newer
3741
// Therefore, we're exporting them here to make them available in older TS versions
3842
export type PerformancePaintTiming = PerformanceEntry;

0 commit comments

Comments
 (0)