Skip to content

Commit 6c56eb1

Browse files
authored
feat: Add new captureFeedback API to RN SDK (#4320)
1 parent 416f465 commit 6c56eb1

File tree

7 files changed

+539
-5
lines changed

7 files changed

+539
-5
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@
88
99
## Unreleased
1010

11+
### Features
12+
13+
- Adds new `captureFeedback` and deprecates the `captureUserFeedback` API ([#4320](https://github.com/getsentry/sentry-react-native/pull/4320))
14+
15+
```jsx
16+
import * as Sentry from "@sentry/react-native";
17+
18+
const eventId = Sentry.lastEventId();
19+
20+
Sentry.captureFeedback({
21+
name: "John Doe",
22+
23+
message: "Hello World!",
24+
associatedEventId: eventId, // optional
25+
});
26+
```
27+
1128
### Fixes
1229

1330
- Return `lastEventId` export from `@sentry/core` ([#4315](https://github.com/getsentry/sentry-react-native/pull/4315))

packages/core/src/js/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
8585

8686
/**
8787
* Sends user feedback to Sentry.
88+
* @deprecated Use `Sentry.captureFeedback` instead.
8889
*/
8990
public captureUserFeedback(feedback: UserFeedback): void {
9091
const envelope = createUserFeedbackEnvelope(feedback, {

packages/core/src/js/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type {
44
SdkInfo,
55
Event,
66
Exception,
7+
SendFeedbackParams,
78
SeverityLevel,
89
StackFrame,
910
Stacktrace,
@@ -16,6 +17,7 @@ export {
1617
addBreadcrumb,
1718
captureException,
1819
captureEvent,
20+
captureFeedback,
1921
captureMessage,
2022
Scope,
2123
setContext,

packages/core/src/js/sdk.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable complexity */
2-
import { getClient, getGlobalScope,getIntegrationsToSetup, getIsolationScope,initAndBind, withScope as coreWithScope } from '@sentry/core';
2+
import { captureFeedback, getClient, getGlobalScope,getIntegrationsToSetup, getIsolationScope,initAndBind, withScope as coreWithScope } from '@sentry/core';
33
import {
44
defaultStackParser,
55
makeFetchTransport,
66
} from '@sentry/react';
7-
import type { Breadcrumb, BreadcrumbHint, Integration, Scope, UserFeedback } from '@sentry/types';
7+
import type { Breadcrumb, BreadcrumbHint, Integration, Scope, SendFeedbackParams, UserFeedback } from '@sentry/types';
88
import { logger, stackParserFromStackParserOptions } from '@sentry/utils';
99
import * as React from 'react';
1010

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

220220
/**
221221
* Captures user feedback and sends it to Sentry.
222+
* @deprecated Use `Sentry.captureFeedback` instead.
222223
*/
223224
export function captureUserFeedback(feedback: UserFeedback): void {
224-
getClient<ReactNativeClient>()?.captureUserFeedback(feedback);
225+
const feedbackParams: SendFeedbackParams = {
226+
name: feedback.name,
227+
email: feedback.email,
228+
message: feedback.comments,
229+
associatedEventId: feedback.event_id,
230+
};
231+
captureFeedback(feedbackParams);
225232
}
226233

227234
/**

0 commit comments

Comments
 (0)