Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/feedback/src/modal/integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,26 @@ import type {
FeedbackFormData,
FeedbackModalIntegration,
IntegrationFn,
User,
} from '@sentry/types';
import { h, render } from 'preact';
import { DOCUMENT } from '../constants';
import { Dialog } from './components/Dialog';
import { createDialogStyles } from './components/Dialog.css';

function getUser(): User | undefined {
const currentUser = getCurrentScope().getUser();
const isolationUser = getIsolationScope().getUser();
const globalUser = getGlobalScope().getUser();
if (currentUser && Object.keys(currentUser).length) {
return currentUser;
}
if (isolationUser && Object.keys(isolationUser).length) {
return isolationUser;
}
return globalUser;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this also return the empty object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it can. We want to check all scopes to see if any have been set, and if not, it'll return an empty object. We were using null coalescing before, which didn't work for empty objects, and would return the empty object without checking the other scopes.

}

export const feedbackModalIntegration = ((): FeedbackModalIntegration => {
return {
name: 'FeedbackModal',
Expand All @@ -19,7 +33,7 @@ export const feedbackModalIntegration = ((): FeedbackModalIntegration => {
createDialog: ({ options, screenshotIntegration, sendFeedback, shadow }: CreateDialogProps) => {
const shadowRoot = shadow as unknown as ShadowRoot;
const userKey = options.useSentryUser;
const user = getCurrentScope().getUser() || getIsolationScope().getUser() || getGlobalScope().getUser();
const user = getUser();

const el = DOCUMENT.createElement('div');
const style = createDialogStyles();
Expand Down