-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(feedback): New feedback integration with screenshots #10590
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
Conversation
72d3b27
to
0de030f
Compare
size-limit report 📦
|
This allows you to configure Sucrase for rollup bundles. Needed for our work on the Feedback screenshotting feature as we want to use Preact + JSX in the project. (ref: #10590)
…elp once submitting works
This is building off a version of #10590, specifically working towards async loading of the Dialog component, and rewriting it in preact in order to host and interact with the screenshot feature in an easier way. Setup in my test app is (gives screenshots): ``` import { feedback2Integration, feedback2ModalIntegration, feedback2ScreenshotIntegration } from "@sentry-internal/feedback2"; integrations: [ feedback2Integration({ colorScheme: 'light', isNameRequired: false, isEmailRequired: false, }), feedback2ModalIntegration(), feedback2ScreenshotIntegration(), ] ```
style.textContent = ` | ||
:host { | ||
--bottom: 1rem; | ||
--right: 1rem; | ||
--right: 1rem; /* this is the font-size of the page, not the shadowroot */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment in the right place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is, sorta... we don't need this comment, it's more like a TODO or 'dont forget'
The rem
unit is relative to the page, so it could be set to something other than 16px and thus our modal spacing from the edge would be different as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove this or make it a JS comment, otherwise it may just add unnecessary bytes I guess?
position: fixed; | ||
left: var(--left); | ||
right: var(--right); | ||
bottom: var(--bottom); | ||
top: var(--top); | ||
z-index: var(--z-index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has been moved into Actor.css
packages/feedback/.eslintrc.js
Outdated
rules: { | ||
'no-console': 'off', | ||
'@sentry-internal/sdk/no-unsupported-es6-methods': 'off', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove this, we have since removed this rule :)
packages/feedback/.eslintrc.js
Outdated
rules: { | ||
'@typescript-eslint/naming-convention': 'off', | ||
'no-console': 'off', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, do we really want to disable this? IMHO we should leave this on to avoid debugging stuff leaking in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't even leverage that this is off. i'm removing it.
} | ||
|
||
client.emit('beforeSendFeedback', feedbackEvent, { includeReplay: Boolean(includeReplay) }); | ||
try { | ||
const response = await transport.send( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So instead of this, I think we can/should just use client.sendEvent(feedbackEvent)
. This will also take care of getsentry/sentry#66214 (comment), I believe. Or is there anything that is preventing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replacing this call seems to work fine, but we've got no response
now, so the error messages are not going to come from this file.
|
||
if (attachments && attachments.length) { | ||
// TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/ | ||
await transport.send( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above, instead we can do client.sendEvent(feedbackEvent, { attachments })
to send another event with the attachments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with either the transport.send or the client.sendEvent i'm not seeing a screenshot coming into sentry today. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea sendEvent
currently doesn't work with attachments due to our backend. If there's an attachment and a feedback within the same envelope, the screenshot doesn't come in. We have to send them in seperate envelopes, but once the backend is fixed we will be using sendEvent client.sendEvent(feedbackEvent, { attachments })
|
||
const envelope = createEventEnvelope(feedbackEvent, dsn, client.getOptions()._metadata, client.getOptions().tunnel); | ||
// TODO (v8): we can remove this guard once transport.send's type signature doesn't include void anymore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should already be done, so you can remove this check!
let response: TransportMakeRequestResponse; | ||
// Require valid status codes, otherwise can assume feedback was not sent successfully | ||
if (typeof response.statusCode === 'number' && (response.statusCode < 200 || response.statusCode >= 300)) { | ||
throw new Error('Unable to send Feedback. Invalid response from server.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are at it, or in a follow up, we could check for statusCode === 0 and show a message like:
Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker.
Or something along these lines...!
@@ -0,0 +1,330 @@ | |||
// eslint-disable max-lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is currently a bit long, but we will be iterating and will tidy up as we go.
try 1 at fixing ts3.8 integration test failure: #11088 |
Right now the feedback PR fails ts3.8 e2e tests. This is because of TS issues, preact types do not work well with older TS types: ``` > @sentry-internal/ts3.8-test@ type-check /home/runner/work/sentry-javascript/sentry-javascript/dev-packages/e2e-tests/test-applications/generic-ts3.8 > tsc --project tsconfig.json ##[debug]Dropping file value '/home/runner/work/sentry-javascript/sentry-javascript/node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts'. Path does not exist Error: node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts(1462,3): error TS2304: Cannot find name 'SubmitEvent'. ##[debug]Dropping file value '/home/runner/work/sentry-javascript/sentry-javascript/node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts'. Path does not exist Error: node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts(1479,25): error TS2304: Cannot find name 'PictureInPictureEvent'. ##[debug]Dropping file value '/home/runner/work/sentry-javascript/sentry-javascript/node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts'. Path does not exist Error: node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts(2549,65): error TS2304: Cannot find name 'MathMLElement'. ##[debug]Dropping file value '/home/runner/work/sentry-javascript/sentry-javascript/node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts'. Path does not exist Error: node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts(2565,49): error TS2304: Cannot find name 'MathMLElement'. ##[debug]Dropping file value '/home/runner/work/sentry-javascript/sentry-javascript/node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts'. Path does not exist Error: node_modules/.pnpm/[email protected]/node_modules/preact/src/jsx.d.ts(2571,52): error TS2304: Cannot find name 'MathMLElement'. ``` Essentially these types don't work on older versions and because the feedback package is depended on by the browser package, we will break a certain set of our users. We have to fix this before we can ship because of the browser package dependency. To get around this, we do a workaround with `packages/feedback/scripts/shim-preact-export.js`. Essentially we shim the preact type in our exports, which should change what the declaration files themselves point to. So something like the following: ```ts import type { ComponentChildren, VNode } from 'preact'; ``` turns into ```ts // no preact to be seen! type ComponentChildren: any; type VNode: any; ```
walk(filePath); | ||
} else { | ||
if (filePath.endsWith('.d.ts')) { | ||
const content = fs.readFileSync(filePath, 'utf8'); |
Check failure
Code scanning / CodeQL
Potential file system race condition
const newContent = content.replace(preactImportRegex, '// replaced import from preact'); | ||
|
||
// and write the new content to the file | ||
fs.writeFileSync(filePath, snippet + newContent, 'utf8'); |
Check failure
Code scanning / CodeQL
Potential file system race condition
Merging this in to add to the alpha release! |
Replace the current screenshot package with a new package that has screenshots and uses Preact for better readability. It will also allow for lazy loading in the future.
Relates to: getsentry/sentry#63749