Skip to content

Commit

Permalink
Loads current user data on form construction
Browse files Browse the repository at this point in the history
  • Loading branch information
antonis committed Dec 13, 2024
1 parent 6e39119 commit 57d99e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/js/feedback/FeedbackForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { captureFeedback, lastEventId } from '@sentry/core';
import { captureFeedback, getCurrentScope, lastEventId } from '@sentry/core';
import type { SendFeedbackParams } from '@sentry/types';
import * as React from 'react';
import type { KeyboardTypeOptions } from 'react-native';
Expand Down Expand Up @@ -29,7 +29,14 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
public constructor(props: FeedbackFormProps) {
super(props);

this._config = { ...defaultConfiguration, ...props };
const currentUser = {
useSentryUser: {
email: getCurrentScope().getUser().email || '',
name: getCurrentScope().getUser().name || '',
}
}

this._config = { ...defaultConfiguration, ...currentUser, ...props };
this.state = {
isVisible: true,
name: this._config.useSentryUser.name,
Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/js/feedback/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getCurrentScope } from '@sentry/core';
import { Alert } from 'react-native';

import type { FeedbackFormProps } from './FeedbackForm.types';
Expand Down Expand Up @@ -35,10 +34,6 @@ export const defaultConfiguration: Partial<FeedbackFormProps> = {
isNameRequired: false,
showEmail: true,
showName: true,
useSentryUser: {
email: getCurrentScope().getUser().email || '',
name: getCurrentScope().getUser().name || '',
},

// FeedbackTextConfiguration
cancelButtonLabel: CANCEL_BUTTON_LABEL,
Expand Down

0 comments on commit 57d99e9

Please sign in to comment.