Skip to content

Commit 474af12

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 b8d1ac2 commit 474af12

6 files changed

Lines changed: 19 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(),
@@ -659,7 +659,7 @@ describe('Integration serviceName error handling', () => {
659659
(useLocalSignedInQueryState as jest.Mock).mockRestore();
660660
(useSession as jest.Mock).mockRestore();
661661
(currentAccount as jest.Mock).mockRestore();
662-
(sentryMetrics.captureException as jest.Mock).mockClear();
662+
(sentryWrapper.captureException as jest.Mock).mockClear();
663663
});
664664

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

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

Lines changed: 4 additions & 4 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
@@ -185,7 +185,7 @@ export const App = ({
185185
// - we can't send any identifying metrics to sentry
186186
// - we can't determine whether or not they have opted out
187187
if (isSignedInData === undefined || isSignedInData.isSignedIn === false) {
188-
sentryMetrics.enable();
188+
enableSentry();
189189
}
190190

191191
const config = useConfig();
@@ -359,10 +359,10 @@ export const App = ({
359359

360360
useEffect(() => {
361361
if (metricsEnabled || isSignedIn === false) {
362-
sentryMetrics.enable();
362+
enableSentry();
363363
maybeRecordWebAuthnCapabilities();
364364
} else {
365-
sentryMetrics.disable();
365+
disableSentry();
366366
}
367367
}, [
368368
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)