Skip to content

Commit b01dcb7

Browse files
dschomclaude
andcommitted
refactor(sentry): Migrate from fxa-shared/sentry to @fxa/sentry-* packages
Migrated all Sentry imports from the legacy fxa-shared/sentry module to the new scoped @fxa/sentry-* packages in libs/shared/: - Browser code: @fxa/shared/sentry/browser - Node.js code: @fxa/sentry-node - Shared utilities: @fxa/sentry-utils Changes: - Added shorter TypeScript path aliases (@fxa/sentry-*) in tsconfig.base.json - Updated 25 files across auth-server, content-server, settings, admin-panel, event-broker, and payments-server - Removed tagCriticalEvent usage (deprecated) - Added tracesSampler support to SentryConfigOpts types - Deleted legacy packages/fxa-shared/sentry/ directory and tests - Removed sentry exports from fxa-shared package.json This completes the migration to the modular sentry package structure. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent f90a86c commit b01dcb7

44 files changed

Lines changed: 37 additions & 1801 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './lib/joi-message-overrides';
22
export * from './lib/node';
33
export * from './lib/report-validation-error';
4+
export type { InitSentryOpts, Logger } from '@fxa/shared/sentry-utils';

libs/shared/sentry-utils/src/lib/models/sentry-config-opts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export type SentryConfigOpts = {
2929

3030
/** The tracing sample rate. Setting this above 0 will aso result in performance metrics being captured. */
3131
tracesSampleRate?: number;
32+
33+
/** The tracing sampler function. Allows dynamic sampling based on context. */
34+
tracesSampler?: (context: any) => number;
3235
};
3336
};
3437

libs/shared/sentry/src/lib/models/SentryConfigOpts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export type SentryConfigOpts = {
4040
/** The tracing sample rate. Setting this above 0 will aso result in performance metrics being captured. */
4141
tracesSampleRate?: number;
4242

43+
/** The tracing sampler function. Allows dynamic sampling based on context. */
44+
tracesSampler?: (context: any) => number;
45+
4346
/** Indicates if PII can be transeferred. e.g. Send the IP address. */
4447
sendDefaultPii?: boolean;
4548
};

packages/fxa-admin-panel/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import AppErrorBoundary from 'fxa-react/components/AppErrorBoundary';
99
import AppLocalizationProvider from 'fxa-react/lib/AppLocalizationProvider';
1010
import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client';
1111
import { setContext } from '@apollo/client/link/context';
12-
import sentryMetrics from 'fxa-shared/sentry/browser';
12+
import sentryMetrics from '@fxa/shared/sentry/browser';
1313
import { config, readConfigFromMeta, getExtraHeaders } from './lib/config';
1414
import App from './App';
1515
import './styles/tailwind.out.css';

packages/fxa-auth-server/lib/payments/stripe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import { subscriptionProductMetadataValidator } from '../routes/validators';
6868
import {
6969
formatMetadataValidationErrorMessage,
7070
reportValidationError,
71-
} from 'fxa-shared/sentry/report-validation-error';
71+
} from '@fxa/sentry-node';
7272
import { AppConfig, AuthFirestore, AuthLogger, TaxAddress } from '../types';
7373
import { PaymentConfigManager } from './configuration/manager';
7474
import { CurrencyHelper } from './currencies';

packages/fxa-auth-server/lib/sentry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { ignoreErrors } = require('@fxa/accounts/errors');
1212
const {
1313
formatMetadataValidationErrorMessage,
1414
reportValidationError,
15-
} = require('fxa-shared/sentry/report-validation-error');
15+
} = require('@fxa/sentry-node');
1616

1717
function reportSentryMessage(message, captureContext) {
1818
Sentry.withScope((scope) => {

packages/fxa-auth-server/lib/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const { Account } = require('fxa-shared/db/models/auth');
2222
const { determineLocale } = require('../../../libs/shared/l10n/src');
2323
const {
2424
reportValidationError,
25-
} = require('fxa-shared/sentry/report-validation-error');
25+
} = require('@fxa/sentry-node');
2626
const { logErrorWithGlean } = require('./metrics/glean');
2727
const mfa = require('./routes/auth-schemes/mfa');
2828
const verifiedSessionToken = require('./routes/auth-schemes/verified-session-token');

packages/fxa-auth-server/scripts/paypal-processor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { PayPalHelper } from '../lib/payments/paypal/helper';
1313
import { PayPalClient } from '@fxa/payments/paypal';
1414
import { PaypalProcessor } from '../lib/payments/paypal/processor';
1515
import { setupProcessingTaskObjects } from '../lib/payments/processing-tasks-setup';
16-
import { initSentry } from 'packages/fxa-shared/sentry/node';
16+
import { initSentry } from '@fxa/sentry-node';
1717

1818
const pckg = require('../package.json');
1919
const config = require('../config').default.getProperties();

packages/fxa-auth-server/test/local/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const customs = mocks.mockCustoms();
2020
const sandbox = sinon.createSandbox();
2121
const mockReportValidationError = sandbox.stub();
2222
const server = proxyquire(`${ROOT_DIR}/lib/server`, {
23-
'fxa-shared/sentry/report-validation-error': {
23+
'@fxa/sentry-node': {
2424
reportValidationError: mockReportValidationError,
2525
},
2626
});

packages/fxa-content-server/app/scripts/lib/sentry.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import * as Sentry from '@sentry/browser';
55

66
import {
77
buildSentryConfig,
8-
tagCriticalEvent,
98
tagFxaName,
10-
} from 'fxa-shared/sentry';
9+
} from '@fxa/sentry-utils';
1110
import _ from 'underscore';
1211

1312
import Logger from './logger';
@@ -22,7 +21,6 @@ import Logger from './logger';
2221
* @private
2322
*/
2423
function beforeSend(data) {
25-
data = tagCriticalEvent(data);
2624
if (data && data.request) {
2725
if (data.tags) {
2826
const errno = data.tags.errno;

0 commit comments

Comments
 (0)