Skip to content

Commit 0205884

Browse files
committed
build(replay): Revert "Remove replay version string replacement (#6367)"
This reverts commit 6e915c3.
1 parent 6e915c3 commit 0205884

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

packages/replay/jest.setup.ts

+3
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', () => {
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import commonjs from '@rollup/plugin-commonjs';
2+
3+
import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/index.js';
4+
5+
import pkg from './package.json';
6+
7+
const builds = [];
8+
9+
// TODO: Do we even need es5 bundles?
10+
[/* 'es5', */ 'es6'].forEach(jsVersion => {
11+
const baseBundleConfig = makeBaseBundleConfig({
12+
bundleType: 'addon',
13+
entrypoints: ['src/index.ts'],
14+
jsVersion,
15+
licenseTitle: '@sentry/replay',
16+
outputFileBase: () => `bundles/replay${jsVersion === 'es5' ? '.es5' : ''}`, // TODO: simplify if no es5 bundles
17+
packageSpecificConfig: {
18+
external: [...Object.keys(pkg.peerDependencies || {})],
19+
plugins: [
20+
// lodash.debouce is commonJs and hence we have to first convert it to es6
21+
commonjs(),
22+
],
23+
output: {
24+
// set exports to 'named' or 'auto' so that rollup doesn't warn about
25+
// the default export in `worker/worker.js`
26+
exports: 'auto',
27+
// format: 'esm',
28+
},
29+
},
30+
});
31+
32+
builds.push(...makeBundleConfigVariants(baseBundleConfig));
33+
});
34+
35+
export default builds;

packages/replay/rollup.npm.config.js

+11
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

+2-2
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';
@@ -1208,7 +1208,7 @@ export class Replay implements Integration {
12081208

12091209
const sdkInfo = {
12101210
name: 'sentry.javascript.integration.replay',
1211-
version: SDK_VERSION,
1211+
version: __SENTRY_REPLAY_VERSION__,
12121212
};
12131213

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

packages/replay/src/types.ts

+4
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)