diff --git a/packages/replay/jest.setup.ts b/packages/replay/jest.setup.ts index 90bbae56e8bb..f4f6e33ed840 100644 --- a/packages/replay/jest.setup.ts +++ b/packages/replay/jest.setup.ts @@ -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; jest.mock('./src/util/isBrowser', () => { diff --git a/packages/replay/rollup.npm.config.js b/packages/replay/rollup.npm.config.js index 7f626585569d..531ef96aeefa 100644 --- a/packages/replay/rollup.npm.config.js +++ b/packages/replay/rollup.npm.config.js @@ -1,3 +1,5 @@ +import replace from '@rollup/plugin-replace'; + import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index'; import pkg from './package.json'; @@ -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` diff --git a/packages/replay/src/index.ts b/packages/replay/src/index.ts index 588bb133dbd8..d718b6c3502a 100644 --- a/packages/replay/src/index.ts +++ b/packages/replay/src/index.ts @@ -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'; @@ -1186,7 +1186,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 => { diff --git a/packages/replay/src/types.ts b/packages/replay/src/types.ts index cb113db35ffd..ec9cda8db1c6 100644 --- a/packages/replay/src/types.ts +++ b/packages/replay/src/types.ts @@ -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;