Skip to content

Commit cd7fedc

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 2f07f9e commit cd7fedc

6 files changed

Lines changed: 21 additions & 16 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
@@ -33,15 +33,15 @@ import { currentAccount } from '../../lib/cache';
3333
import { MozServices } from '../../lib/types';
3434
import mockUseFxAStatus from '../../lib/hooks/useFxAStatus/mocks';
3535
import useFxAStatus from '../../lib/hooks/useFxAStatus';
36-
import sentryMetrics from 'fxa-shared/sentry/browser';
36+
import * as sentryWrapper from '@fxa/shared/sentry-browser';
3737
import { OAuthError } from '../../lib/oauth';
3838

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

44-
jest.mock('fxa-shared/sentry/browser', () => ({
44+
jest.mock('@fxa/shared/sentry/browser', () => ({
4545
__esModule: true,
4646
default: {
4747
enable: jest.fn(),
@@ -653,7 +653,7 @@ describe('Integration serviceName error handling', () => {
653653
(useLocalSignedInQueryState as jest.Mock).mockRestore();
654654
(useSession as jest.Mock).mockRestore();
655655
(currentAccount as jest.Mock).mockRestore();
656-
(sentryMetrics.captureException as jest.Mock).mockClear();
656+
(sentryWrapper.captureException as jest.Mock).mockClear();
657657
});
658658

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

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
} from '../../models/contexts/SettingsContext';
3939
import { AccountStateProvider } from '../../models/contexts/AccountStateContext';
4040

41-
import sentryMetrics from 'fxa-shared/sentry/browser';
41+
import { disableSentry, enableSentry } from '@fxa/shared/sentry-utils';
4242
import { maybeRecordWebAuthnCapabilities } from '../../lib/webauthnCapabilitiesProbe';
4343

4444
// Components
@@ -174,7 +174,7 @@ export const App = ({
174174
// - we can't send any identifying metrics to sentry
175175
// - we can't determine whether or not they have opted out
176176
if (isSignedInData === undefined || isSignedInData.isSignedIn === false) {
177-
sentryMetrics.enable();
177+
enableSentry();
178178
}
179179

180180
const config = useConfig();
@@ -309,7 +309,8 @@ export const App = ({
309309
recoveryKey: data.account.recoveryKey?.exists ?? false,
310310
hasSecondaryVerifiedEmail:
311311
data.account.emails.length > 1 && data.account.emails[1].verified,
312-
totpActive: (data.account.totp?.exists && data.account.totp?.verified) ?? false,
312+
totpActive:
313+
(data.account.totp?.exists && data.account.totp?.verified) ?? false,
313314
});
314315
}
315316
}, [
@@ -328,10 +329,10 @@ export const App = ({
328329

329330
useEffect(() => {
330331
if (metricsEnabled || isSignedIn === false) {
331-
sentryMetrics.enable();
332+
enableSentry();
332333
maybeRecordWebAuthnCapabilities();
333334
} else {
334-
sentryMetrics.disable();
335+
disableSentry();
335336
}
336337
}, [
337338
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';
@@ -51,7 +51,7 @@ try {
5151
});
5252

5353
// Must be configured early. Otherwise baggage and sentry-trace headers won't be added
54-
sentryMetrics.configure({
54+
sentryWrapper.initSentry({
5555
release: config.version,
5656
sentry: {
5757
...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)