Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry-internal/feedback

Package Overview
Dependencies
Maintainers
9
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry-internal/feedback

Sentry SDK integration for user feedback

  • 0.0.1-alpha.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.7M
decreased by-16.32%
Maintainers
9
Weekly downloads
 
Created
Source

Sentry

Sentry Integration for Feedback

This SDK is considered experimental and in an alpha state. It may experience breaking changes, and may be discontinued at any time. Please reach out on GitHub if you have any feedback/concerns.

Pre-requisites

@sentry-internal/feedback currently can only be used by browsers with Shadow DOM support.

Installation

During the alpha phase, the feedback integration will need to be imported from @sentry-internal/feedback. This will be changed for the general release.

npm add @sentry-internal/feedback

Setup

To set up the integration, add the following to your Sentry initialization. This will inject a feedback button to the bottom right corner of your application. Users can then click it to open up a feedback form where they can submit feedback.

Several options are supported and passable via the integration constructor. See the configuration section below for more details.

import * as Sentry from '@sentry/browser';
// or from a framework specific SDK, e.g.
// import * as Sentry from '@sentry/react';
import { Feedback } from '@sentry-internal/feedback';

Sentry.init({
  dsn: '__DSN__',
  integrations: [
    new Feedback({
      // Additional SDK configuration goes in here, for example:
      // See below for all available options
    })
  ],
  // ...
});

Configuration

General Integration Configuration

The following options can be configured as options to the integration, in new Feedback({}):

keytypedefaultdescription
autoInjectbooleantrueInjects the Feedback widget into the application when the integration is added. This is useful to turn off if you bring your own button, or only want to show the widget on certain views.
showBrandingbooleantrueDisplays the Sentry logo inside of the dialog
colorScheme"system" | "light" | "dark""system"The color theme to use. "system" will follow your OS colorscheme.
keytypedefaultdescription
showNamebooleantrueDisplays the name field on the feedback form, however will still capture the name (if available) from Sentry SDK context.
showEmailbooleantrueDisplays the email field on the feedback form, however will still capture the email (if available) from Sentry SDK context.
isAnonymousbooleanfalseHides both name and email fields and does not use Sentry SDK's user context.
useSentryUserRecord<string, string>{ email: 'email', name: 'username'}Map of the email and name fields to the corresponding Sentry SDK user fields that were called with Sentry.setUser.

By default the Feedback integration will attempt to fill in the name/email fields if you have set a user context via Sentry.setUser. By default it expects the email and name fields to be email and username. Below is an example configuration with non-default user fields.

Sentry.setUser({
    email: 'foo@example.com',
    fullName: 'Jane Doe',
});


new Feedback({
    useSentryUser({
        email: 'email',
        name: 'fullName',
    }),
})

Text Customization

Most text that you see in the default Feedback widget can be customized.

keydefaultdescription
buttonLabelReport a BugThe label of the widget button.
submitButtonLabelSend Bug ReportThe label of the submit button used in the feedback form dialog.
cancelButtonLabelCancelThe label of the cancel button used in the feedback form dialog.
formTitleReport a BugThe title at the top of the feedback form dialog.
nameLabelNameThe label of the name input field.
namePlaceholderYour NameThe placeholder for the name input field.
emailLabelEmailThe label of the email input field.
emailPlaceholderyour.email@example.orgThe placeholder for the email input field.
messageLabelDescriptionThe label for the feedback description input field.
messagePlaceholderWhat's the bug? What did you expect?The placeholder for the feedback description input field.
successMessageTextThank you for your report!The message to be displayed after a succesful feedback submission.

Example of customization

new Feedback({
  buttonLabel: 'Feedback',
  submitButtonLabel: 'Send Feedback',
  formTitle: 'Send Feedback',
});

Theme Customization

Colors can be customized via the Feedback constructor or by defining CSS variables on the widget button. If you use the default widget button, it will have an id="sentry-feedback, meaning you can use the #sentry-feedback selector to define CSS variables to override.

keycss variablelightdarkdescription
background--background#ffffff#29232fBackground color of the widget actor and dialog
backgroundHover--background-hover#f6f6f7#352f3bBackground color of widget actor when in a hover state
foreground--foreground#2b2233#ebe6efForeground color, e.g. text color
error--error#df3338#f55459Color used for error related components (e.g. text color when there was an error submitting feedback)
success--success#268d75#2da98cColor used for success-related components (e.g. text color when feedback is submitted successfully)
border--border1.5px solid rgba(41, 35, 47, 0.13)1.5px solid rgba(235, 230, 239, 0.15)The border style used for the widget actor and dialog
boxShadow--box-shadow0px 4px 24px 0px rgba(43, 34, 51, 0.12)0px 4px 24px 0px rgba(43, 34, 51, 0.12)The box shadow style used for the widget actor and dialog
submitBackground--submit-backgroundrgba(88, 74, 192, 1)rgba(88, 74, 192, 1)Background color for the submit button
submitBackgroundHover--submit-background-hoverrgba(108, 95, 199, 1)rgba(108, 95, 199, 1)Background color when hovering over the submit button
submitBorder--submit-borderrgba(108, 95, 199, 1)rgba(108, 95, 199, 1)Border style for the submit button
submitForeground--submit-foreground#ffffff#ffffffForeground color for the submit button
cancelBackground--cancel-backgroundtransparenttransparentBackground color for the cancel button
cancelBackgroundHover--cancel-background-hovervar(--background-hover)var(--background-hover)Background color when hovering over the cancel button
cancelBorder--cancel-bordervar(--border)var(--border)Border style for the cancel button
cancelForeground--cancel-foregroundvar(--foreground)var(--foreground)Foreground color for the cancel button
inputBackground--input-backgroundinheritinheritBackground color for form inputs
inputForeground--input-foregroundinheritinheritForeground color for form inputs
inputBorder--input-bordervar(--border)var(--border)Border styles for form inputs
inputBorderFocus--input-border-focusrgba(108, 95, 199, 1)rgba(108, 95, 199, 1)Border styles for form inputs when focused

Here is an example of customizing only the background color for the light theme using the Feedback constructor configuration.

new Feedback({
    themeLight: {
        background: "#cccccc",
    },
})

Or the same example above but using the CSS variables method:

#sentry-feedback {
  --background: #cccccc;
}

Additional UI Customization

Similar to theme customization above, these are additional CSS variables that can be overridden. Note these are not supported in the constructor.

VariableDefaultDescription
--bottom1remBy default the widget has a position of fixed, and is in the bottom right corner.
--right1remBy default the widget has a position of fixed, and is in the bottom right corner.
--topautoBy default the widget has a position of fixed, and is in the bottom right corner.
--leftautoBy default the widget has a position of fixed, and is in the bottom right corner.
--z-index100000The z-index of the widget
--font-family"'Helvetica Neue', Arial, sans-serif"Default font-family to use
--font-size14pxFont size

Event Callbacks

Sometimes it’s important to know when someone has started to interact with the feedback form, so you can add custom logging, or start/stop background timers on the page until the user is done.

Pass these callbacks when you initialize the Feedback integration:

new Feedback({
  onActorClick: () => {},
  onDialogOpen: () => {},
  onDialogClose: () => {},
  onSubmitSuccess: () => {},
  onSubmitError: () => {},
});

Further Customization

There are two more methods in the integration that can help customization.

Bring Your Own Button

You can skip the default widget button and use your own button. Call feedback.attachTo() to have the SDK attach a click listener to your own button. You can additionally supply the same customization options that the constructor accepts (e.g. for text labels and colors).

const feedback = new Feedback({
  // Disable injecting the default widget
  autoInject: false,
});

feedback.attachTo(document.querySelector('#your-button'), {
    formTitle: "Report a Bug!"
});

Bring Your Own Widget

You can also bring your own widget and UI and simply pass a feedback object to the sendFeedback() function.

<form id="my-feedback-form">
  <input name="name" />
  <input name="email" />
  <textarea name="message" placeholder="What's the issue?" />
</form>

<script>
document.getElementById('my-feedback-form').addEventListener('submit', (event) => {
  const formData = new FormData(event.currentTarget);
  Feedback.sendFeedback(formData);
  event.preventDefault();
});
</script>

Alerting on User Feedback Reports

Note: The following instructions are to be followed in the Sentry product.

If you have Sentry's default issue alert ("Alert me on every new issue") turned on for the project you are setting up User Feedback on, no action is required to have alerting on each user feedback report.

If you don't have Sentry's default issue alert turned on, follow these steps:

  1. Navigate to Create New Alert Rule in Sentry (Click "Alerts" in the left-nav menu, "Create Alert" in the top right corner, ensure the "Issues" radio button is selected under the "Errors" category, and then click "Set Conditions")
  2. In "Set conditions", add an "IF" filter for The issue's category is equal to "Feedback"
  3. Add any other alert rules

Feedback Alert Rule Creation Screenshot

FAQs

Package last updated on 02 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc