Skip to content

Commit 5542127

Browse files
authored
ref(feedback): Create stub integrations for feedback modal & screenshot integrations (#11342)
We're planning to split up the modal and screenshot functionality of the feedback widget into their own integrations, so they can be loaded async if folks want to do that. Loading async would have the benefit that the code is only needed when the user interacts with the feedback widget, and we're actually going to render the modal whether that be with or without the screenshot input/editor. This PR sets up some stubs for where the code will live. There's a bunch of boilerplate for the new integrations inside packages/* and also lots of exports to setup so that the stubs are available to be imported into apps. Currently if someone wanted to setup feedback with screenshots they would be doing: ```javascript import * as Sentry from "@sentry/browser"; import {feedbackIntegration, feedbackModalIntegration, feedbackScreenshotIntegration} from '@sentry-internal/feedback'; ... integrations: [ feedbackIntegration(), feedbackModalIntegration(), feedbackScreenshotIntegration(), ] ``` **After this PR people will keep doing that.** In a followup PR we'll move the implementation from `@sentry-internal/feedback` into the new `@sentry-internal/feedback-modal` and `@sentry-internal/feedback-screenshot`, so people will be able to do this instead: ```diff import * as Sentry from "@sentry/browser"; - import {feedbackIntegration, feedbackModalIntegration, feedbackScreenshotIntegration} from '@sentry-internal/feedback'; + import {feedbackIntegration} from '@sentry-internal/feedback'; + import {feedbackModalIntegration} from '@sentry-internal/feedback-modal'; + import {feedbackScreenshotIntegration} from '@sentry-internal/feedback-screenshot'; ... integrations: [ feedbackIntegration(), feedbackModalIntegration(), feedbackScreenshotIntegration(), ] ``` Equally valid, is people will be able to import everything from `@sentry/browser` too, ie `import * as Sentry from "@sentry/browser";` with `Sentry.feedbackScreenshotIntegration()` Related to #11435
1 parent db18496 commit 5542127

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+749
-19
lines changed

.craft.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ targets:
3232
- name: npm
3333
id: '@sentry-internal/feedback'
3434
includeNames: /^sentry-internal-feedback-\d.*\.tgz$/
35-
## 1.8 ReplayCanvas package (browser only)
35+
## 1.8 Feedback Modal package (browser only)
36+
- name: npm
37+
id: '@sentry-internal/feedback-modal'
38+
includeNames: /^sentry-internal-feedback-modal-\d.*\.tgz$/
39+
## 1.9 Feedback Screenshot package (browser only)
40+
- name: npm
41+
id: '@sentry-internal/feedback-screenshot'
42+
includeNames: /^sentry-internal-feedback-screenshot-\d.*\.tgz$/
43+
## 1.10 ReplayCanvas package (browser only)
3644
- name: npm
3745
id: '@sentry-internal/replay-canvas'
3846
includeNames: /^sentry-internal-replay-canvas-\d.*\.tgz$/

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ jobs:
105105
- 'packages/replay/**'
106106
- 'packages/replay-canvas/**'
107107
- 'packages/feedback/**'
108+
- 'packages/feedback-modal/**'
109+
- 'packages/feedback-screenshot/**'
108110
- 'packages/wasm/**'
109111
browser_integration:
110112
- *shared

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ packages/replay @getsentry/replay-sdk-web
22
packages/replay-worker @getsentry/replay-sdk-web
33
packages/replay-canvas @getsentry/replay-sdk-web
44
packages/feedback @getsentry/replay-sdk-web
5+
packages/feedback-modal @getsentry/replay-sdk-web
6+
packages/feedback-screenshot @getsentry/replay-sdk-web
57
dev-packages/browser-integration-tests/suites/replay @getsentry/replay-sdk-web

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
"packages/eslint-config-sdk",
5757
"packages/eslint-plugin-sdk",
5858
"packages/feedback",
59+
"packages/feedback-modal",
60+
"packages/feedback-screenshot",
5961
"packages/gatsby",
6062
"packages/google-cloud-serverless",
6163
"packages/integration-shims",

packages/browser/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
},
4444
"dependencies": {
4545
"@sentry-internal/browser-utils": "8.0.0-alpha.9",
46+
"@sentry-internal/feedback-modal": "8.0.0-alpha.9",
47+
"@sentry-internal/feedback-screenshot": "8.0.0-alpha.9",
4648
"@sentry-internal/feedback": "8.0.0-alpha.9",
4749
"@sentry-internal/replay": "8.0.0-alpha.9",
4850
"@sentry-internal/replay-canvas": "8.0.0-alpha.9",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// This is exported so the loader does not fail when switching off Replay/Tracing
22
import { feedbackIntegration, getFeedback } from '@sentry-internal/feedback';
3+
import { feedbackModalIntegration } from '@sentry-internal/feedback-modal';
4+
import { feedbackScreenshotIntegration } from '@sentry-internal/feedback-screenshot';
35
import {
46
addTracingExtensionsShim,
57
browserTracingIntegrationShim,
@@ -12,6 +14,8 @@ export {
1214
addTracingExtensionsShim as addTracingExtensions,
1315
replayIntegrationShim as replayIntegration,
1416
feedbackIntegration,
17+
feedbackModalIntegration,
18+
feedbackScreenshotIntegration,
1519
getFeedback,
1620
};
1721
// 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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
addTracingExtensionsShim,
44
browserTracingIntegrationShim,
55
feedbackIntegrationShim,
6+
feedbackModalIntegrationShim,
7+
feedbackScreenshotIntegrationShim,
68
} from '@sentry-internal/integration-shims';
79
import { replayIntegration } from '@sentry-internal/replay';
810

@@ -12,5 +14,7 @@ export {
1214
addTracingExtensionsShim as addTracingExtensions,
1315
replayIntegration,
1416
feedbackIntegrationShim as feedbackIntegration,
17+
feedbackModalIntegrationShim as feedbackModalIntegration,
18+
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
1519
};
1620
// 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.tracing.replay.feedback.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
startBrowserTracingPageLoadSpan,
55
} from '@sentry-internal/browser-utils';
66
import { feedbackIntegration, getFeedback } from '@sentry-internal/feedback';
7+
import { feedbackModalIntegration } from '@sentry-internal/feedback-modal';
8+
import { feedbackScreenshotIntegration } from '@sentry-internal/feedback-screenshot';
79
import { replayIntegration } from '@sentry-internal/replay';
810
import { addTracingExtensions } from '@sentry/core';
911

@@ -23,6 +25,8 @@ export {
2325

2426
export {
2527
feedbackIntegration,
28+
feedbackModalIntegration,
29+
feedbackScreenshotIntegration,
2630
replayIntegration,
2731
browserTracingIntegration,
2832
addTracingExtensions,

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import {
33
startBrowserTracingNavigationSpan,
44
startBrowserTracingPageLoadSpan,
55
} from '@sentry-internal/browser-utils';
6-
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
6+
import {
7+
feedbackIntegrationShim,
8+
feedbackModalIntegrationShim,
9+
feedbackScreenshotIntegrationShim,
10+
} from '@sentry-internal/integration-shims';
711
import { replayIntegration } from '@sentry-internal/replay';
812
import { addTracingExtensions } from '@sentry/core';
913

@@ -24,6 +28,8 @@ export {
2428
export {
2529
replayIntegration,
2630
feedbackIntegrationShim as feedbackIntegration,
31+
feedbackModalIntegrationShim as feedbackModalIntegration,
32+
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
2733
browserTracingIntegration,
2834
addTracingExtensions,
2935
startBrowserTracingNavigationSpan,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {
44
startBrowserTracingPageLoadSpan,
55
} from '@sentry-internal/browser-utils';
66
// This is exported so the loader does not fail when switching off Replay
7-
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
7+
import {
8+
feedbackIntegrationShim,
9+
feedbackModalIntegrationShim,
10+
feedbackScreenshotIntegrationShim,
11+
replayIntegrationShim,
12+
} from '@sentry-internal/integration-shims';
813
import { addTracingExtensions } from '@sentry/core';
914

1015
// We are patching the global object with our hub extension methods
@@ -23,6 +28,8 @@ export {
2328

2429
export {
2530
feedbackIntegrationShim as feedbackIntegration,
31+
feedbackModalIntegrationShim as feedbackModalIntegration,
32+
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
2633
replayIntegrationShim as replayIntegration,
2734
browserTracingIntegration,
2835
addTracingExtensions,

packages/browser/src/index.bundle.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
addTracingExtensionsShim,
44
browserTracingIntegrationShim,
55
feedbackIntegrationShim,
6+
feedbackModalIntegrationShim,
7+
feedbackScreenshotIntegrationShim,
68
replayIntegrationShim,
79
} from '@sentry-internal/integration-shims';
810

@@ -11,6 +13,8 @@ export {
1113
addTracingExtensionsShim as addTracingExtensions,
1214
browserTracingIntegrationShim as browserTracingIntegration,
1315
feedbackIntegrationShim as feedbackIntegration,
16+
feedbackModalIntegrationShim as feedbackModalIntegration,
17+
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
1418
replayIntegrationShim as replayIntegration,
1519
};
1620
// 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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export {
3535
getFeedback,
3636
sendFeedback,
3737
} from '@sentry-internal/feedback';
38+
export { feedbackModalIntegration } from '@sentry-internal/feedback-modal';
39+
export { feedbackScreenshotIntegration } from '@sentry-internal/feedback-screenshot';
3840

3941
export {
4042
defaultRequestInstrumentationOptions,
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { replayIntegrationShim } from '@sentry-internal/integration-shims';
2-
import { feedbackIntegration } from '@sentry/browser';
2+
import { feedbackIntegration, feedbackModalIntegration, feedbackScreenshotIntegration } from '@sentry/browser';
33

4-
import * as TracingReplayBundle from '../../src/index.bundle.feedback';
4+
import * as FeedbackBundle from '../../src/index.bundle.feedback';
55

66
describe('index.bundle.feedback', () => {
77
it('has correct exports', () => {
8-
expect(TracingReplayBundle.replayIntegration).toBe(replayIntegrationShim);
9-
expect(TracingReplayBundle.feedbackIntegration).toBe(feedbackIntegration);
8+
expect(FeedbackBundle.replayIntegration).toBe(replayIntegrationShim);
9+
expect(FeedbackBundle.feedbackIntegration).toBe(feedbackIntegration);
10+
expect(FeedbackBundle.feedbackModalIntegration).toBe(feedbackModalIntegration);
11+
expect(FeedbackBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegration);
1012
});
1113
});
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
1+
import {
2+
feedbackIntegrationShim,
3+
feedbackModalIntegrationShim,
4+
feedbackScreenshotIntegrationShim,
5+
} from '@sentry-internal/integration-shims';
26
import { replayIntegration } from '@sentry/browser';
37

4-
import * as TracingReplayBundle from '../../src/index.bundle.replay';
8+
import * as ReplayBundle from '../../src/index.bundle.replay';
59

610
describe('index.bundle.replay', () => {
711
it('has correct exports', () => {
8-
expect(TracingReplayBundle.replayIntegration).toBe(replayIntegration);
9-
expect(TracingReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
12+
expect(ReplayBundle.replayIntegration).toBe(replayIntegration);
13+
expect(ReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
14+
expect(ReplayBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
15+
expect(ReplayBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
1016
});
1117
});
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
1+
import {
2+
feedbackIntegrationShim,
3+
feedbackModalIntegrationShim,
4+
feedbackScreenshotIntegrationShim,
5+
replayIntegrationShim,
6+
} from '@sentry-internal/integration-shims';
27

3-
import * as TracingBundle from '../../src/index.bundle';
8+
import * as Bundle from '../../src/index.bundle';
49

510
describe('index.bundle', () => {
611
it('has correct exports', () => {
7-
expect(TracingBundle.replayIntegration).toBe(replayIntegrationShim);
8-
expect(TracingBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
12+
expect(Bundle.replayIntegration).toBe(replayIntegrationShim);
13+
expect(Bundle.feedbackIntegration).toBe(feedbackIntegrationShim);
14+
expect(Bundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
15+
expect(Bundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
916
});
1017
});
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { browserTracingIntegration } from '@sentry-internal/browser-utils';
2-
import { feedbackIntegration, replayIntegration } from '@sentry/browser';
2+
import {
3+
feedbackIntegration,
4+
feedbackModalIntegration,
5+
feedbackScreenshotIntegration,
6+
replayIntegration,
7+
} from '@sentry/browser';
38

49
import * as TracingReplayFeedbackBundle from '../../src/index.bundle.tracing.replay.feedback';
510

@@ -8,5 +13,7 @@ describe('index.bundle.tracing.replay.feedback', () => {
813
expect(TracingReplayFeedbackBundle.replayIntegration).toBe(replayIntegration);
914
expect(TracingReplayFeedbackBundle.browserTracingIntegration).toBe(browserTracingIntegration);
1015
expect(TracingReplayFeedbackBundle.feedbackIntegration).toBe(feedbackIntegration);
16+
expect(TracingReplayFeedbackBundle.feedbackModalIntegration).toBe(feedbackModalIntegration);
17+
expect(TracingReplayFeedbackBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegration);
1118
});
1219
});

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { browserTracingIntegration } from '@sentry-internal/browser-utils';
2-
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
2+
import {
3+
feedbackIntegrationShim,
4+
feedbackModalIntegrationShim,
5+
feedbackScreenshotIntegrationShim,
6+
} from '@sentry-internal/integration-shims';
37
import { replayIntegration } from '@sentry/browser';
48

59
import * as TracingReplayBundle from '../../src/index.bundle.tracing.replay';
@@ -11,5 +15,7 @@ describe('index.bundle.tracing.replay', () => {
1115
expect(TracingReplayBundle.browserTracingIntegration).toBe(browserTracingIntegration);
1216

1317
expect(TracingReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
18+
expect(TracingReplayBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
19+
expect(TracingReplayBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
1420
});
1521
});
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { browserTracingIntegration } from '@sentry-internal/browser-utils';
2-
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
2+
import {
3+
feedbackIntegrationShim,
4+
feedbackModalIntegrationShim,
5+
feedbackScreenshotIntegrationShim,
6+
replayIntegrationShim,
7+
} from '@sentry-internal/integration-shims';
38

49
import * as TracingBundle from '../../src/index.bundle.tracing';
510

@@ -8,5 +13,7 @@ describe('index.bundle.tracing', () => {
813
expect(TracingBundle.replayIntegration).toBe(replayIntegrationShim);
914
expect(TracingBundle.browserTracingIntegration).toBe(browserTracingIntegration);
1015
expect(TracingBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
16+
expect(TracingBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
17+
expect(TracingBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
1118
});
1219
});

packages/feedback-modal/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
build/

packages/feedback-modal/.eslintrc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Note: All paths are relative to the directory in which eslint is being run, rather than the directory where this file
2+
// lives
3+
4+
// ESLint config docs: https://eslint.org/docs/user-guide/configuring/
5+
6+
module.exports = {
7+
extends: ['../../.eslintrc.js'],
8+
overrides: [
9+
{
10+
files: ['jest.setup.ts', 'jest.config.ts'],
11+
parserOptions: {
12+
project: ['tsconfig.test.json'],
13+
},
14+
},
15+
],
16+
};

packages/feedback-modal/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
/*.tgz
3+
.eslintcache
4+
build

packages/feedback-modal/LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (c) 2024 Sentry (https://sentry.io) and individual contributors. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
5+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6+
persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
9+
Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/feedback-modal/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Sentry Integration for Feedback
8+
9+
This integration supports our browser feedback SDK allowing us to code-split heavy UI components as needed.
10+
11+
For the primary Feedback Integration see
12+
[Sentry Feedback SDK](https://github.com/getsentry/sentry-javascript/tree/develop/packages/feedback)
13+
14+
Note: This package is only meant to be used internally.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const baseConfig = require('../../jest/jest.config.js');
2+
3+
module.exports = {
4+
...baseConfig,
5+
testEnvironment: 'jsdom',
6+
};

0 commit comments

Comments
 (0)