Skip to content

Commit f8cebde

Browse files
authored
feat(feedback): Include Feedback package in browser SDK (#9586)
Add feedback to craft publish list, and export `Feedback` integration from browser SDK Depends on - [x] #9588 - [x] #9604 Relates to: getsentry/team-replay#273
1 parent 0830866 commit f8cebde

23 files changed

+238
-19
lines changed

.craft.yml

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ targets:
2828
- name: npm
2929
id: '@sentry/opentelemetry'
3030
includeNames: /^sentry-opentelemetry-\d.*\.tgz$/
31+
## 1.7 Feedback package (browser only)
32+
- name: npm
33+
id: '@sentry-internal/feedback'
34+
includeNames: /^sentry-internal-feedback-\d.*\.tgz$/
3135

3236
## 2. Browser & Node SDKs
3337
- name: npm

.size-limit.js

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
module.exports = [
22
// Main browser webpack builds
3+
{
4+
name: '@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped)',
5+
path: 'packages/browser/build/npm/esm/index.js',
6+
import: '{ init, Replay, BrowserTracing, Feedback }',
7+
gzip: true,
8+
limit: '90 KB',
9+
},
310
{
411
name: '@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped)',
512
path: 'packages/browser/build/npm/esm/index.js',
613
import: '{ init, Replay, BrowserTracing }',
714
gzip: true,
8-
limit: '90 KB',
15+
limit: '75 KB',
916
},
1017
{
1118
name: '@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped)',
1219
path: 'packages/browser/build/npm/esm/index.js',
1320
import: '{ init, Replay, BrowserTracing }',
1421
gzip: true,
15-
limit: '90 KB',
22+
limit: '75 KB',
1623
modifyWebpackConfig: function (config) {
1724
const webpack = require('webpack');
1825
config.plugins.push(
@@ -33,6 +40,13 @@ module.exports = [
3340
gzip: true,
3441
limit: '35 KB',
3542
},
43+
{
44+
name: '@sentry/browser (incl. Feedback) - Webpack (gzipped)',
45+
path: 'packages/browser/build/npm/esm/index.js',
46+
import: '{ init, Feedback }',
47+
gzip: true,
48+
limit: '50 KB',
49+
},
3650
{
3751
name: '@sentry/browser - Webpack (gzipped)',
3852
path: 'packages/browser/build/npm/esm/index.js',
@@ -42,11 +56,17 @@ module.exports = [
4256
},
4357

4458
// Browser CDN bundles (ES6)
59+
{
60+
name: '@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped)',
61+
path: 'packages/browser/build/bundles/bundle.tracing.replay.feedback.min.js',
62+
gzip: true,
63+
limit: '75 KB',
64+
},
4565
{
4666
name: '@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped)',
4767
path: 'packages/browser/build/bundles/bundle.tracing.replay.min.js',
4868
gzip: true,
49-
limit: '90 KB',
69+
limit: '75 KB',
5070
},
5171
{
5272
name: '@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped)',
@@ -96,7 +116,7 @@ module.exports = [
96116
path: 'packages/react/build/esm/index.js',
97117
import: '{ init, BrowserTracing, Replay }',
98118
gzip: true,
99-
limit: '90 KB',
119+
limit: '75 KB',
100120
},
101121
{
102122
name: '@sentry/react - Webpack (gzipped)',
@@ -126,6 +146,6 @@ module.exports = [
126146
path: 'packages/feedback/build/npm/esm/index.js',
127147
import: '{ Feedback }',
128148
gzip: true,
129-
limit: '35 KB',
149+
limit: '25 KB',
130150
},
131151
];

packages/browser/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26+
"@sentry-internal/feedback": "0.0.1-alpha.17",
2627
"@sentry-internal/tracing": "7.84.0",
2728
"@sentry/core": "7.84.0",
2829
"@sentry/replay": "7.84.0",

packages/browser/rollup.bundle.config.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ targets.forEach(jsVersion => {
2929
});
3030

3131
if (targets.includes('es6')) {
32-
// Replay bundles only available for es6
32+
// Replay/Feedback bundles only available for es6
3333
const replayBaseBundleConfig = makeBaseBundleConfig({
3434
bundleType: 'standalone',
3535
entrypoints: ['src/index.bundle.replay.ts'],
@@ -38,6 +38,14 @@ if (targets.includes('es6')) {
3838
outputFileBase: () => 'bundles/bundle.replay',
3939
});
4040

41+
const feedbackBaseBundleConfig = makeBaseBundleConfig({
42+
bundleType: 'standalone',
43+
entrypoints: ['src/index.bundle.feedback.ts'],
44+
jsVersion: 'es6',
45+
licenseTitle: '@sentry/browser & @sentry/feedback',
46+
outputFileBase: () => 'bundles/bundle.feedback',
47+
});
48+
4149
const tracingReplayBaseBundleConfig = makeBaseBundleConfig({
4250
bundleType: 'standalone',
4351
entrypoints: ['src/index.bundle.tracing.replay.ts'],
@@ -46,9 +54,19 @@ if (targets.includes('es6')) {
4654
outputFileBase: () => 'bundles/bundle.tracing.replay',
4755
});
4856

57+
const tracingReplayFeedbackBaseBundleConfig = makeBaseBundleConfig({
58+
bundleType: 'standalone',
59+
entrypoints: ['src/index.bundle.tracing.replay.feedback.ts'],
60+
jsVersion: 'es6',
61+
licenseTitle: '@sentry/browser & @sentry/tracing & @sentry/replay & @sentry/feedback',
62+
outputFileBase: () => 'bundles/bundle.tracing.replay.feedback',
63+
});
64+
4965
builds.push(
5066
...makeBundleConfigVariants(replayBaseBundleConfig),
67+
...makeBundleConfigVariants(feedbackBaseBundleConfig),
5168
...makeBundleConfigVariants(tracingReplayBaseBundleConfig),
69+
...makeBundleConfigVariants(tracingReplayFeedbackBaseBundleConfig),
5270
);
5371
}
5472

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This is exported so the loader does not fail when switching off Replay/Tracing
2+
import { Feedback } from '@sentry-internal/feedback';
3+
import { BrowserTracing, Replay, addTracingExtensions } from '@sentry-internal/integration-shims';
4+
5+
import * as Sentry from './index.bundle.base';
6+
7+
// TODO (v8): Remove this as it was only needed for backwards compatibility
8+
Sentry.Integrations.Replay = Replay;
9+
10+
Sentry.Integrations.BrowserTracing = BrowserTracing;
11+
12+
export * from './index.bundle.base';
13+
export { BrowserTracing, addTracingExtensions, Replay, Feedback };
14+
// Note: We do not export a shim for `Span` here, as that is quite complex and would blow up the bundle

packages/browser/src/index.bundle.replay.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This is exported so the loader does not fail when switching off Replay/Tracing
2-
import { BrowserTracing, addTracingExtensions } from '@sentry-internal/integration-shims';
2+
import { BrowserTracing, Feedback, addTracingExtensions } from '@sentry-internal/integration-shims';
33
import { Replay } from '@sentry/replay';
44

55
import * as Sentry from './index.bundle.base';
@@ -10,5 +10,5 @@ Sentry.Integrations.Replay = Replay;
1010
Sentry.Integrations.BrowserTracing = BrowserTracing;
1111

1212
export * from './index.bundle.base';
13-
export { BrowserTracing, addTracingExtensions, Replay };
13+
export { BrowserTracing, addTracingExtensions, Replay, Feedback };
1414
// Note: We do not export a shim for `Span` here, as that is quite complex and would blow up the bundle
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Feedback } from '@sentry-internal/feedback';
2+
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
3+
import { Replay } from '@sentry/replay';
4+
5+
import * as Sentry from './index.bundle.base';
6+
7+
// TODO (v8): Remove this as it was only needed for backwards compatibility
8+
// We want replay to be available under Sentry.Replay, to be consistent
9+
// with the NPM package version.
10+
Sentry.Integrations.Replay = Replay;
11+
12+
Sentry.Integrations.BrowserTracing = BrowserTracing;
13+
14+
// We are patching the global object with our hub extension methods
15+
addExtensionMethods();
16+
17+
export { Feedback, Replay, BrowserTracing, Span, addExtensionMethods };
18+
export * from './index.bundle.base';

packages/browser/src/index.bundle.tracing.replay.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Feedback } from '@sentry-internal/integration-shims';
12
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
23
import { Replay } from '@sentry/replay';
34

@@ -13,5 +14,5 @@ Sentry.Integrations.BrowserTracing = BrowserTracing;
1314
// We are patching the global object with our hub extension methods
1415
addExtensionMethods();
1516

16-
export { Replay, BrowserTracing, Span, addExtensionMethods };
17+
export { Feedback, Replay, BrowserTracing, Span, addExtensionMethods };
1718
export * from './index.bundle.base';

packages/browser/src/index.bundle.tracing.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This is exported so the loader does not fail when switching off Replay
2-
import { Replay } from '@sentry-internal/integration-shims';
2+
import { Feedback, Replay } from '@sentry-internal/integration-shims';
33
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
44

55
import * as Sentry from './index.bundle.base';
@@ -14,5 +14,5 @@ Sentry.Integrations.BrowserTracing = BrowserTracing;
1414
// We are patching the global object with our hub extension methods
1515
addExtensionMethods();
1616

17-
export { Replay, BrowserTracing, Span, addExtensionMethods };
17+
export { Feedback, Replay, BrowserTracing, Span, addExtensionMethods };
1818
export * from './index.bundle.base';

packages/browser/src/index.bundle.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This is exported so the loader does not fail when switching off Replay/Tracing
2-
import { BrowserTracing, Replay, addTracingExtensions } from '@sentry-internal/integration-shims';
2+
import { BrowserTracing, Feedback, Replay, addTracingExtensions } from '@sentry-internal/integration-shims';
33

44
import * as Sentry from './index.bundle.base';
55

@@ -9,5 +9,5 @@ Sentry.Integrations.Replay = Replay;
99
Sentry.Integrations.BrowserTracing = BrowserTracing;
1010

1111
export * from './index.bundle.base';
12-
export { BrowserTracing, addTracingExtensions, Replay };
12+
export { BrowserTracing, addTracingExtensions, Replay, Feedback };
1313
// Note: We do not export a shim for `Span` here, as that is quite complex and would blow up the bundle

packages/browser/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export type {
3333
ReplaySpanFrameEvent,
3434
} from '@sentry/replay';
3535

36+
export { Feedback } from '@sentry-internal/feedback';
37+
3638
export {
3739
BrowserTracing,
3840
defaultRequestInstrumentationOptions,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { BrowserTracing as BrowserTracingShim, Replay as ReplayShim } from '@sentry-internal/integration-shims';
2+
import { Feedback } from '@sentry/browser';
3+
4+
import * as TracingReplayBundle from '../../src/index.bundle.feedback';
5+
6+
describe('index.bundle.feedback', () => {
7+
it('has correct exports', () => {
8+
Object.keys(TracingReplayBundle.Integrations).forEach(key => {
9+
// Skip BrowserTracing because it doesn't have a static id field.
10+
if (key === 'BrowserTracing') {
11+
return;
12+
}
13+
14+
expect((TracingReplayBundle.Integrations[key] as any).id).toStrictEqual(expect.any(String));
15+
});
16+
17+
expect(TracingReplayBundle.Integrations.Replay).toBe(ReplayShim);
18+
expect(TracingReplayBundle.Replay).toBe(ReplayShim);
19+
20+
expect(TracingReplayBundle.Integrations.BrowserTracing).toBe(BrowserTracingShim);
21+
expect(TracingReplayBundle.BrowserTracing).toBe(BrowserTracingShim);
22+
23+
expect(TracingReplayBundle.Feedback).toBe(Feedback);
24+
});
25+
});

packages/browser/test/unit/index.bundle.replay.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowserTracing as BrowserTracingShim } from '@sentry-internal/integration-shims';
1+
import { BrowserTracing as BrowserTracingShim, Feedback as FeedbackShim } from '@sentry-internal/integration-shims';
22
import { Replay } from '@sentry/browser';
33

44
import * as TracingReplayBundle from '../../src/index.bundle.replay';
@@ -19,5 +19,7 @@ describe('index.bundle.replay', () => {
1919

2020
expect(TracingReplayBundle.Integrations.BrowserTracing).toBe(BrowserTracingShim);
2121
expect(TracingReplayBundle.BrowserTracing).toBe(BrowserTracingShim);
22+
23+
expect(TracingReplayBundle.Feedback).toBe(FeedbackShim);
2224
});
2325
});

packages/browser/test/unit/index.bundle.test.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { BrowserTracing as BrowserTracingShim, Replay as ReplayShim } from '@sentry-internal/integration-shims';
1+
import {
2+
BrowserTracing as BrowserTracingShim,
3+
Feedback as FeedbackShim,
4+
Replay as ReplayShim,
5+
} from '@sentry-internal/integration-shims';
26

37
import * as TracingBundle from '../../src/index.bundle';
48

@@ -18,5 +22,7 @@ describe('index.bundle', () => {
1822

1923
expect(TracingBundle.Integrations.BrowserTracing).toBe(BrowserTracingShim);
2024
expect(TracingBundle.BrowserTracing).toBe(BrowserTracingShim);
25+
26+
expect(TracingBundle.Feedback).toBe(FeedbackShim);
2127
});
2228
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { BrowserTracing } from '@sentry-internal/tracing';
2+
import { Feedback, Replay } from '@sentry/browser';
3+
4+
import * as TracingReplayFeedbackBundle from '../../src/index.bundle.tracing.replay.feedback';
5+
6+
describe('index.bundle.tracing.replay.feedback', () => {
7+
it('has correct exports', () => {
8+
Object.keys(TracingReplayFeedbackBundle.Integrations).forEach(key => {
9+
// Skip BrowserTracing because it doesn't have a static id field.
10+
if (key === 'BrowserTracing') {
11+
return;
12+
}
13+
14+
expect((TracingReplayFeedbackBundle.Integrations[key] as any).id).toStrictEqual(expect.any(String));
15+
});
16+
17+
expect(TracingReplayFeedbackBundle.Integrations.Replay).toBe(Replay);
18+
expect(TracingReplayFeedbackBundle.Replay).toBe(Replay);
19+
20+
expect(TracingReplayFeedbackBundle.Integrations.BrowserTracing).toBe(BrowserTracing);
21+
expect(TracingReplayFeedbackBundle.BrowserTracing).toBe(BrowserTracing);
22+
23+
expect(TracingReplayFeedbackBundle.Feedback).toBe(Feedback);
24+
});
25+
});

packages/browser/test/unit/index.bundle.tracing.replay.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Feedback as FeedbackShim } from '@sentry-internal/integration-shims';
12
import { BrowserTracing } from '@sentry-internal/tracing';
23
import { Replay } from '@sentry/browser';
34

@@ -19,5 +20,7 @@ describe('index.bundle.tracing.replay', () => {
1920

2021
expect(TracingReplayBundle.Integrations.BrowserTracing).toBe(BrowserTracing);
2122
expect(TracingReplayBundle.BrowserTracing).toBe(BrowserTracing);
23+
24+
expect(TracingReplayBundle.Feedback).toBe(FeedbackShim);
2225
});
2326
});

packages/browser/test/unit/index.bundle.tracing.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Replay as ReplayShim } from '@sentry-internal/integration-shims';
1+
import { Feedback as FeedbackShim, Replay as ReplayShim } from '@sentry-internal/integration-shims';
22
import { BrowserTracing } from '@sentry-internal/tracing';
33

44
import * as TracingBundle from '../../src/index.bundle.tracing';
@@ -19,5 +19,7 @@ describe('index.bundle.tracing', () => {
1919

2020
expect(TracingBundle.Integrations.BrowserTracing).toBe(BrowserTracing);
2121
expect(TracingBundle.BrowserTracing).toBe(BrowserTracing);
22+
23+
expect(TracingBundle.Feedback).toBe(FeedbackShim);
2224
});
2325
});

packages/feedback/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry-internal/feedback",
3-
"version": "7.84.0",
3+
"version": "0.0.1-alpha.17",
44
"description": "Sentry SDK integration for user feedback",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/feedback",
@@ -42,7 +42,7 @@
4242
"build:types:watch": "tsc -p tsconfig.types.json --watch",
4343
"build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm",
4444
"circularDepCheck": "madge --circular src/index.ts",
45-
"clean": "rimraf build sentry-replay-*.tgz",
45+
"clean": "rimraf build sentry-feedback-*.tgz",
4646
"fix": "eslint . --format stylish --fix",
4747
"lint": "eslint . --format stylish",
4848
"test": "jest",

packages/feedback/src/integration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class Feedback implements Integration {
155155
}
156156

157157
/**
158-
* Setup and initialize replay container
158+
* Setup and initialize feedback container
159159
*/
160160
public setupOnce(): void {
161161
if (!isBrowser()) {

0 commit comments

Comments
 (0)