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: Add new captureFeedback API to RN SDK #4320

Merged
merged 13 commits into from
Dec 2, 2024
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@

## Unreleased

### Features

- Adds new `captureFeedback` and deprecates the `captureUserFeedback` API ([#4320](https://github.com/getsentry/sentry-react-native/pull/4320))

```jsx
import * as Sentry from "@sentry/react-native";

const eventId = Sentry.lastEventId();

Sentry.captureFeedback({
name: "John Doe",
email: "[email protected]",
message: "Hello World!",
associatedEventId: eventId, // optional
});
```

### Fixes

- Return `lastEventId` export from `@sentry/core` ([#4315](https://github.com/getsentry/sentry-react-native/pull/4315))
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {

/**
* Sends user feedback to Sentry.
* @deprecated Use `Sentry.captureFeedback` instead.
*/
public captureUserFeedback(feedback: UserFeedback): void {
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved
const envelope = createUserFeedbackEnvelope(feedback, {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type {
SdkInfo,
Event,
Exception,
SendFeedbackParams,
SeverityLevel,
StackFrame,
Stacktrace,
Expand All @@ -16,6 +17,7 @@ export {
addBreadcrumb,
captureException,
captureEvent,
captureFeedback,
captureMessage,
Scope,
setContext,
Expand Down
13 changes: 10 additions & 3 deletions packages/core/src/js/sdk.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable complexity */
import { getClient, getGlobalScope,getIntegrationsToSetup, getIsolationScope,initAndBind, withScope as coreWithScope } from '@sentry/core';
import { captureFeedback, getClient, getGlobalScope,getIntegrationsToSetup, getIsolationScope,initAndBind, withScope as coreWithScope } from '@sentry/core';
import {
defaultStackParser,
makeFetchTransport,
} from '@sentry/react';
import type { Breadcrumb, BreadcrumbHint, Integration, Scope, UserFeedback } from '@sentry/types';
import type { Breadcrumb, BreadcrumbHint, Integration, Scope, SendFeedbackParams, UserFeedback } from '@sentry/types';
import { logger, stackParserFromStackParserOptions } from '@sentry/utils';
import * as React from 'react';

Expand Down Expand Up @@ -219,9 +219,16 @@ export async function close(): Promise<void> {

/**
* Captures user feedback and sends it to Sentry.
* @deprecated Use `Sentry.captureFeedback` instead.
*/
export function captureUserFeedback(feedback: UserFeedback): void {
getClient<ReactNativeClient>()?.captureUserFeedback(feedback);
const feedbackParams: SendFeedbackParams = {
name: feedback.name,
email: feedback.email,
message: feedback.comments,
associatedEventId: feedback.event_id,
};
captureFeedback(feedbackParams);
}

/**
Expand Down
Loading
Loading