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

sentry/react feedback example for "Bring Your Own Button" doesn't compile #10331

Open
chdsbd opened this issue Jun 8, 2024 · 3 comments
Open
Labels
Type: Content Issues about the contents of our docs Waiting for: Support

Comments

@chdsbd
Copy link

chdsbd commented Jun 8, 2024

Core or SDK?

Platform/SDK

Which part? Which one?

React User Feedback Configuration

Description

In this code example, @sentry/react doesn't export Feedback in the latest SDK.

import { BrowserClient, Feedback, getClient } from "@sentry/react";

function MyFeedbackButton() {
  const client = getClient<BrowserClient>();
  const feedback = client?.getIntegration(Feedback);

  // Don't render custom feedback button if Feedback integration isn't installed
  if (!feedback) {
    return null;
  }

  return (
    <button
      type="button"
      onClick={async () => {
        const form = await feedback.createForm();
        form.appendToDom();
        form.open();
      }}
    >
      Give me feedback
    </button>
  );
}

Suggested Solution

import { BrowserClient, feedbackIntegration, getClient } from "@sentry/react";

type FeedbackIntegration = ReturnType<typeof feedbackIntegration>

function MyFeedbackButton() {
  const client = getClient<BrowserClient>();
  const feedback = client?.getIntegrationByName<FeedbackIntegration>('Feedback');

  // Don't render custom feedback button if Feedback integration isn't installed
  if (!feedback) {
    return null;
  }

  return (
    <button
      type="button"
      onClick={async () => {
        const form = await feedback.createForm();
        form.appendToDom();
        form.open();
      }}
    >
      Give me feedback
    </button>
  );
}
@chdsbd chdsbd added the Type: Content Issues about the contents of our docs label Jun 8, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Jun 8, 2024

Assigning to @getsentry/support for routing ⏲️

@Stanzilla
Copy link

That results in this, which seems a bit wrong? But yes the current example just doesn't work.

image

@SheetalParanjpeKodiak
Copy link

Is there an update on this issue? I have had to use the workaround for custom UI as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Content Issues about the contents of our docs Waiting for: Support
Projects
Status: Waiting for: Support
Development

No branches or pull requests

3 participants