Skip to content

Commit 3034d13

Browse files
committed
chore(settings): Update refs to use libs instead of fxa-shared
Because: - Cleaning up code duplication This Commit: - References @fxa/shared/sentry - References @fxa/shared/otel - References @fxa/shared/monitoring
1 parent 0fd0adc commit 3034d13

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

packages/fxa-settings/src/components/App/index.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ import { currentAccount } from '../../lib/cache';
3434
import { MozServices } from '../../lib/types';
3535
import mockUseFxAStatus from '../../lib/hooks/useFxAStatus/mocks';
3636
import useFxAStatus from '../../lib/hooks/useFxAStatus';
37-
import sentryMetrics from 'fxa-shared/sentry/browser';
37+
import * as sentryWrapper from '@fxa/shared/sentry-browser';
3838
import { OAuthError } from '../../lib/oauth';
3939

4040
jest.mock('../../lib/hooks/useFxAStatus', () => ({
4141
__esModule: true,
4242
default: jest.fn(),
4343
}));
4444

45-
jest.mock('fxa-shared/sentry/browser', () => ({
45+
jest.mock('@fxa/shared/sentry/browser', () => ({
4646
__esModule: true,
4747
default: {
4848
enable: jest.fn(),
@@ -664,7 +664,7 @@ describe('Integration serviceName error handling', () => {
664664
(useLocalSignedInQueryState as jest.Mock).mockRestore();
665665
(useSession as jest.Mock).mockRestore();
666666
(currentAccount as jest.Mock).mockRestore();
667-
(sentryMetrics.captureException as jest.Mock).mockClear();
667+
(sentryWrapper.captureException as jest.Mock).mockClear();
668668
});
669669

670670
it('shows OAuthDataError component when OAuth integration throws', async () => {

packages/fxa-settings/src/components/App/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ import {
4040
} from '../../models/contexts/SettingsContext';
4141
import { AccountStateProvider } from '../../models/contexts/AccountStateContext';
4242

43-
import sentryMetrics from 'fxa-shared/sentry/browser';
43+
import { disableSentry, enableSentry } from '@fxa/shared/sentry-utils';
44+
4445
// Components
4546
import LoadingSpinner from 'fxa-react/components/LoadingSpinner';
4647
import { ScrollToTop } from '../Settings/ScrollToTop';
@@ -206,7 +207,7 @@ export const App = ({
206207
// - we can't send any identifying metrics to sentry
207208
// - we can't determine whether or not they have opted out
208209
if (isSignedInData === undefined || isSignedInData.isSignedIn === false) {
209-
sentryMetrics.enable();
210+
enableSentry();
210211
}
211212

212213
const config = useConfig();
@@ -380,9 +381,9 @@ export const App = ({
380381

381382
useEffect(() => {
382383
if (metricsEnabled || isSignedIn === false) {
383-
sentryMetrics.enable();
384+
enableSentry();
384385
} else {
385-
sentryMetrics.disable();
386+
disableSentry();
386387
}
387388
}, [
388389
data?.account?.metricsEnabled,

packages/fxa-settings/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import React from 'react';
66
import { render } from 'react-dom';
7-
import sentryMetrics from 'fxa-shared/sentry/browser';
7+
import * as sentryWrapper from '@fxa/shared/sentry-browser';
88
import { AppErrorBoundary } from './components/ErrorBoundaries';
99
import App from './components/App';
1010
import { NimbusProvider } from './models/contexts/NimbusContext';
@@ -52,7 +52,7 @@ try {
5252
});
5353

5454
// Must be configured early. Otherwise baggage and sentry-trace headers won't be added
55-
sentryMetrics.configure({
55+
sentryWrapper.initSentry({
5656
release: config.version,
5757
sentry: {
5858
...config.sentry,

packages/fxa-settings/src/lib/metrics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import sentryMetrics from 'fxa-shared/sentry/browser';
5+
import * as sentryWrapper from '@fxa/shared/sentry-browser';
66
import { window } from './window';
77
import { v4 as uuid } from 'uuid';
88
import { QueryParams } from '..';
@@ -323,7 +323,7 @@ export function logEvents(
323323
);
324324
} catch (e) {
325325
console.error('AppError', e);
326-
sentryMetrics.captureException(e);
326+
sentryWrapper.captureException(e);
327327
}
328328
}
329329

packages/fxa-settings/src/models/integrations/oauth-web-integration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export class OAuthWebIntegration extends GenericIntegration<
212212
wantsScopeThatHasKeys = true;
213213
} else {
214214
// Requesting keys, but trying to deliver them to an unexpected uri? Nope.
215+
console.warn('Invalid redirect URI:' + this.clientInfo?.redirectUri);
215216
throw new Error('Invalid redirect parameter');
216217
}
217218
}

packages/fxa-settings/src/pages/Signup/ConfirmSignupCode/container.test.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as HooksModule from '../../../lib/oauth/hooks';
99
import * as OAuthFlowRecoveryModule from '../../../lib/hooks/useOAuthFlowRecovery';
1010
import * as CacheModule from '../../../lib/cache';
1111
import * as ReachRouterModule from '@reach/router';
12-
import * as SentryModule from 'fxa-shared/sentry/browser';
12+
import * as SentryModule from '@fxa/shared/sentry-browser';
1313
import * as ReactUtils from 'fxa-react/lib/utils';
1414

1515
import { screen, waitFor } from '@testing-library/react';
@@ -143,7 +143,7 @@ function applyMocks() {
143143
});
144144
mockLocation();
145145
mockReactUtilsModule();
146-
jest.spyOn(SentryModule.default, 'captureException');
146+
jest.spyOn(SentryModule, 'captureException');
147147
jest.spyOn(OAuthFlowRecoveryModule, 'useOAuthFlowRecovery').mockReturnValue({
148148
isRecovering: false,
149149
recoveryFailed: false,
@@ -326,15 +326,18 @@ describe('confirm-signup-container', () => {
326326
.mockReturnValue({
327327
isRecovering: false,
328328
recoveryFailed: true,
329-
attemptOAuthFlowRecovery: jest.fn().mockResolvedValue({ success: false }),
329+
attemptOAuthFlowRecovery: jest
330+
.fn()
331+
.mockResolvedValue({ success: false }),
330332
});
331333

332334
render();
333335

334336
await waitFor(() => {
335337
expect(mockNavigate).toHaveBeenCalledWith('/signin', {
336338
state: {
337-
localizedErrorMessage: 'Something went wrong. Please sign in again.',
339+
localizedErrorMessage:
340+
'Something went wrong. Please sign in again.',
338341
},
339342
});
340343
});

0 commit comments

Comments
 (0)