Skip to content
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

feat(feedback): Revamp of user feedback screenshot editing #15424

Merged
merged 18 commits into from
Feb 24, 2025

Conversation

c298lee
Copy link
Contributor

@c298lee c298lee commented Feb 14, 2025

DO NOT MERGE

Allows you to edit screenshots with highlight and hide boxes, with the ability to delete individual boxes and resize the page. This will replace the previous cropping and pen annotation.
image

Closes getsentry/sentry#69786

Copy link
Contributor

github-actions bot commented Feb 14, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.05 KB - -
@sentry/browser - with treeshaking flags 22.84 KB - -
@sentry/browser (incl. Tracing) 36.07 KB - -
@sentry/browser (incl. Tracing, Replay) 73.08 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 66.55 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 77.34 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 89.69 KB -0.66% -608 B 🔽
@sentry/browser (incl. Feedback) 39.62 KB -1.46% -600 B 🔽
@sentry/browser (incl. sendFeedback) 27.68 KB -0.01% -1 B 🔽
@sentry/browser (incl. FeedbackAsync) 32.46 KB -0.06% -17 B 🔽
@sentry/react 24.87 KB - -
@sentry/react (incl. Tracing) 37.95 KB - -
@sentry/vue 27.23 KB - -
@sentry/vue (incl. Tracing) 37.76 KB - -
@sentry/svelte 23.09 KB - -
CDN Bundle 24.25 KB - -
CDN Bundle (incl. Tracing) 36.1 KB - -
CDN Bundle (incl. Tracing, Replay) 70.94 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 76.1 KB -0.01% -6 B 🔽
CDN Bundle - uncompressed 70.91 KB - -
CDN Bundle (incl. Tracing) - uncompressed 107.17 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 218.45 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.99 KB -0.02% -33 B 🔽
@sentry/nextjs (client) 38.94 KB - -
@sentry/sveltekit (client) 36.48 KB - -
@sentry/node 129.25 KB - -
@sentry/node - without tracing 98.03 KB - -
@sentry/aws-serverless 107.45 KB - -

View base workflow run

Copy link

codecov bot commented Feb 14, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4638 1 4637 323
View the top 1 failed test(s) by shortest run time
should report ANR when event loop blocked worker can be stopped and restarted
Stack Traces | 15s run time
Error: thrown: "Exceeded timeout of 15000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
    at .../suites/anr/test.ts:204:3
    at _dispatchDescribe (.../jest-circus/build/index.js:98:26)
    at describe (.../jest-circus/build/index.js:60:5)
    at Object.<anonymous> (.../suites/anr/test.ts:109:1)
    at Runtime._execModule (.../jest-runtime/build/index.js:1646:24)
    at Runtime._loadModule (.../jest-runtime/build/index.js:1185:12)
    at Runtime.requireModule (.../jest-runtime/build/index.js:1009:12)
    at jestAdapter (.../build/legacy-code-todo-rewrite/jestAdapter.js:79:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runTestInternal (.../jest-runner/build/runTest.js:389:16)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@@ -131,12 +132,34 @@ export function createScreenshotInputStyles(styleNonce?: string): HTMLStyleEleme
border: var(--button-border, var(--border));
border-radius: var(--button-border-radius, 6px);
background: var(--button-background, var(--background));
color: var(--button-foreground, var(--foreground));
Copy link
Member

Choose a reason for hiding this comment

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

was this wrong before, not matching docs? now it's fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think when I added the annotation stuff, I mixed up the names and used the wrong one. This is technically not in the docs, but now it matches what's used in the form buttons

}

.editor__tool--active {
background: var(--button-primary-background, var(--accent-background));
color: var(--button-primary-foreground, var(--accent-foreground));
Copy link
Member

Choose a reason for hiding this comment

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

was this wrong before, not matching docs? now it's fixed?

Comment on lines 99 to 103
if (sentryFeedback) {
strokeColor =
getComputedStyle(sentryFeedback).getPropertyValue('--button-primary-background') ||
getComputedStyle(sentryFeedback).getPropertyValue('--accent-background');
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (sentryFeedback) {
strokeColor =
getComputedStyle(sentryFeedback).getPropertyValue('--button-primary-background') ||
getComputedStyle(sentryFeedback).getPropertyValue('--accent-background');
}
if (sentryFeedback) {
const computedStyle = getComputedStyle(sentryFeedback);
strokeColor =
computedStyle.getPropertyValue('--button-primary-background') ||
computedStyle.getPropertyValue('--accent-background');
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also, not sure if this is the best way to do this, but it works

@c298lee c298lee marked this pull request as ready for review February 21, 2025 18:36
@c298lee c298lee requested a review from a team as a code owner February 21, 2025 18:36
@c298lee c298lee requested a review from ryan953 February 21, 2025 19:29
Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

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

mostly nits about naming/comments

<Annotations action={action} imageBuffer={imageBuffer} annotatingRef={annotatingRef} />
<div class="editor__canvas-container" ref={measurementRef}>
<canvas ref={screenshotRef}></canvas>
<canvas class="editor__canvas-annotate" ref={graywashRef} onMouseDown={handleMouseDown}></canvas>
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if the class names and ref name were more aligned. Also, graywash makes me think it's only used to draw the backdrop, but handleMouseDown looks like it's also handling the drawing of the boxes/rects. maybe this doesn't matter as much if we had some code comments about what the different refs are do.

};

const handleMouseUp = (e: MouseEvent): void => {
setCurrentRect(undefined);
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment why we're setting current rect as undefined?

}
}, [currentRect]);

const drawBuffer = hooks.useCallback((): void => {
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of the buffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated with a comment

Comment on lines 136 to 144
const [drawCommands, setDrawCommands] = hooks.useState<Rect[]>([]);
const [currentRect, setCurrentRect] = hooks.useState<Rect | undefined>(undefined);
const measurementRef = hooks.useRef<HTMLDivElement>(null);
const screenshotRef = hooks.useRef<HTMLCanvasElement>(null);
const graywashRef = hooks.useRef<HTMLCanvasElement>(null);
const rectDivRef = hooks.useRef<HTMLDivElement>(null);
const [imageSource, setimageSource] = hooks.useState<HTMLCanvasElement | null>(null);
const [displayEditor, setdisplayEditor] = hooks.useState<boolean>(true);
const [scaleFactor, setScaleFactor] = hooks.useState<number>(1);
Copy link
Member

Choose a reason for hiding this comment

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

It might help to have comments explaining the purposes these (where it makes sense)

e.g. what is the purpose of the graywashRef


// draws outline around rectangle in the same colour as the submit button
let strokeColor;
const sentryFeedback = DOCUMENT.getElementById('sentry-feedback');
Copy link
Member

Choose a reason for hiding this comment

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

is sentry-feedback id always guaranteed to exist?

Copy link
Contributor Author

@c298lee c298lee Feb 21, 2025

Choose a reason for hiding this comment

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

It's the id attribute of the div that contains the feedback widget. Good catch tho, this can actually be customized

@ryan953 ryan953 changed the base branch from develop to ryan953/feedback-highlight-mask February 24, 2025 23:22
@ryan953 ryan953 merged commit c9daae0 into ryan953/feedback-highlight-mask Feb 24, 2025
146 of 148 checks passed
@ryan953 ryan953 deleted the cl/annotations-v2 branch February 24, 2025 23:23
ryan953 pushed a commit that referenced this pull request Feb 24, 2025
Allows you to edit screenshots with highlight and hide boxes, with the
ability to delete individual boxes and resize the page. This will
replace the previous cropping and pen annotation.

![image](https://github.com/user-attachments/assets/9cf9dbfa-b65b-47fc-8933-bafe33687eb8)

Related to getsentry/sentry#69786
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Epic] User Feedback Annotations
3 participants