Skip to content

build(replay): Revert "Remove replay version string replacement (#6367)" #6378

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

Closed
wants to merge 1 commit into from
Closed
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: 3 additions & 0 deletions packages/replay/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { Transport } from '@sentry/types';
import { Replay } from './src';
import { Session } from './src/session/Session';

// @ts-ignore TS error, this is replaced in prod builds bc of rollup
global.__SENTRY_REPLAY_VERSION__ = 'version:Test';

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

jest.mock('./src/util/isBrowser', () => {
Expand Down
35 changes: 35 additions & 0 deletions packages/replay/rollup.bundle.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import commonjs from '@rollup/plugin-commonjs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think these changes are accidentially reverted here, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, would have really helped to look at the changed files 🙈 give me a sec...


import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/index.js';

import pkg from './package.json';

const builds = [];

// TODO: Do we even need es5 bundles?
[/* 'es5', */ 'es6'].forEach(jsVersion => {
const baseBundleConfig = makeBaseBundleConfig({
bundleType: 'addon',
entrypoints: ['src/index.ts'],
jsVersion,
licenseTitle: '@sentry/replay',
outputFileBase: () => `bundles/replay${jsVersion === 'es5' ? '.es5' : ''}`, // TODO: simplify if no es5 bundles
packageSpecificConfig: {
external: [...Object.keys(pkg.peerDependencies || {})],
plugins: [
// lodash.debouce is commonJs and hence we have to first convert it to es6
commonjs(),
],
output: {
// set exports to 'named' or 'auto' so that rollup doesn't warn about
// the default export in `worker/worker.js`
exports: 'auto',
// format: 'esm',
},
},
});

builds.push(...makeBundleConfigVariants(baseBundleConfig));
});

export default builds;
11 changes: 11 additions & 0 deletions packages/replay/rollup.npm.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import replace from '@rollup/plugin-replace';

import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index';

import pkg from './package.json';
Expand All @@ -7,6 +9,15 @@ export default makeNPMConfigVariants(
hasBundles: true,
packageSpecificConfig: {
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
plugins: [
// TODO: Remove this - replay version will be in sync w/ SDK version
replace({
preventAssignment: true,
values: {
__SENTRY_REPLAY_VERSION__: JSON.stringify(pkg.version),
},
}),
],
output: {
// set exports to 'named' or 'auto' so that rollup doesn't warn about
// the default export in `worker/worker.js`
Expand Down
4 changes: 2 additions & 2 deletions packages/replay/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-lines */ // TODO: We might want to split this file up
import { WINDOW } from '@sentry/browser';
import { addGlobalEventProcessor, getCurrentHub, Scope, SDK_VERSION, setContext } from '@sentry/core';
import { addGlobalEventProcessor, getCurrentHub, Scope, setContext } from '@sentry/core';
import { Breadcrumb, Client, Event, Integration } from '@sentry/types';
import { addInstrumentationHandler, createEnvelope, logger } from '@sentry/utils';
import debounce from 'lodash.debounce';
Expand Down Expand Up @@ -1208,7 +1208,7 @@ export class Replay implements Integration {

const sdkInfo = {
name: 'sentry.javascript.integration.replay',
version: SDK_VERSION,
version: __SENTRY_REPLAY_VERSION__,
};

const replayEvent = await new Promise(resolve => {
Expand Down
4 changes: 4 additions & 0 deletions packages/replay/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export interface WorkerRequest {
args: unknown[];
}

declare global {
const __SENTRY_REPLAY_VERSION__: string;
}

// PerformancePaintTiming and PerformanceNavigationTiming are only available with TS 4.4 and newer
// Therefore, we're exporting them here to make them available in older TS versions
export type PerformancePaintTiming = PerformanceEntry;
Expand Down