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): Allow passing tags field to any feedback config param #12197

Merged
merged 11 commits into from
Jun 17, 2024

Conversation

ryan953
Copy link
Member

@ryan953 ryan953 commented May 23, 2024

We were missing the ability to set tags within feedback before, this corrects it.

See getsentry/sentry-docs#10137 for the docs update.

Now a developer can set tags: {...} anytime an options param is passed into feedback. This includes:

  • when we init the integration feedbackIntegration({tags: {hello: 'world'}})
  • when attachTo is called: feedback.attachTo(element, {tags: {hello: 'world'}})
  • when createWidget is called: feedback.createWidget({tags: {hello: 'world'}})
  • when createForm is called: feedback.createForm({tags: {hello: 'world'}})

Users can also pass tags to sendFeedback() which is slightly nicer than having to set them on scope first.

  • Sentry.sendFeedback({tags: {hello: 'world'}})
  • captureFeedback() is unaffected, keeping it closer in style to the other capture*() methods.

I also took the chance to re-use related types in more places. Checkout the first 2 commits on the branch to see those changes individually.

Fixes getsentry/sentry#71254

@ryan953 ryan953 requested a review from a team as a code owner May 23, 2024 21:18
Copy link
Contributor

github-actions bot commented May 23, 2024

size-limit report 📦

Path Size
@sentry/browser 22.03 KB (0%)
@sentry/browser (incl. Tracing) 33.2 KB (0%)
@sentry/browser (incl. Tracing, Replay) 68.94 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.27 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 73.01 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 85.22 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 87.04 KB (+0.06% 🔺)
@sentry/browser (incl. metrics) 26.21 KB (0%)
@sentry/browser (incl. Feedback) 38.26 KB (+0.12% 🔺)
@sentry/browser (incl. sendFeedback) 26.64 KB (+0.1% 🔺)
@sentry/browser (incl. FeedbackAsync) 31.21 KB (+0.14% 🔺)
@sentry/react 24.8 KB (0%)
@sentry/react (incl. Tracing) 36.28 KB (0%)
@sentry/vue 26.03 KB (0%)
@sentry/vue (incl. Tracing) 35.06 KB (0%)
@sentry/svelte 22.17 KB (0%)
CDN Bundle 23.36 KB (0%)
CDN Bundle (incl. Tracing) 34.89 KB (0%)
CDN Bundle (incl. Tracing, Replay) 68.99 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 74.19 KB (+0.05% 🔺)
CDN Bundle - uncompressed 68.68 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 103.29 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 213.74 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 226.31 KB (+0.05% 🔺)
@sentry/nextjs (client) 35.61 KB (0%)
@sentry/sveltekit (client) 33.83 KB (0%)
@sentry/node 112.7 KB (0%)
@sentry/node - without tracing 90.11 KB (+0.01% 🔺)
@sentry/aws-serverless 99.2 KB (0%)

@@ -6,6 +6,8 @@ import type {
FeedbackScreenshotIntegration,
Integration,
IntegrationFn,
OptionalFeedbackConfiguration,
Copy link
Member

Choose a reason for hiding this comment

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

This feels very specific to be exported from types 🤔 I don't see us using this anywhere else? We should really only put stuff in the types package that absolutely has to be there, as this becomes public API for other stuff too etc!

Copy link
Member Author

@ryan953 ryan953 May 28, 2024

Choose a reason for hiding this comment

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

Justification for exportingOptionalFeedbackConfiguration is because exported because it's part of the public api: it's the options for the integration constructor.

The other type OverrideFeedbackConfiguration is also part of the public api, it's used by all the public functions like attachTo & createWidget and so on. It's slightly different from the one above with regards to theme stuff that can't currently be overridden.

So that was the reason, lmk what you think. I use the types changes like https://github.com/getsentry/pokemon-market/pull/7/files. There's a similar bit of code in getsentry that is untyped right now, but could/should be typed.

I touched the both in the pr to highlight the source

Copy link
Member

Choose a reason for hiding this comment

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

Can we give it a better? OptionalFeedbackConfiguration sounds like it should be an internal type rather than public facing

Copy link
Member Author

Choose a reason for hiding this comment

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

gimme a suggestion and we'll do it!

@ryan953 ryan953 requested a review from mydea May 28, 2024 17:24
@ryan953 ryan953 requested a review from billyvg June 11, 2024 22:03
@@ -59,6 +59,7 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
},
},
level: 'info',
tags: {},
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some tests showing that the tags are flowing through?

@ryan953 ryan953 merged commit 8383f8d into develop Jun 17, 2024
114 checks passed
@ryan953 ryan953 deleted the ryan953/71254-feedback-tags branch June 17, 2024 20:35
ryan953 added a commit to getsentry/pokemon-market that referenced this pull request Jun 26, 2024
Depends on getsentry/sentry-javascript#12197
Follows instructions from
getsentry/sentry-docs#10137

---------

Co-authored-by: Catherine Lee <55311782+c298lee@users.noreply.github.com>
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.

[User Feedback] Ability to tag feedback button instances
3 participants