Skip to content

Commit b2c872c

Browse files
committed
chore(event-broker): 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 99ccd85 commit b2c872c

7 files changed

Lines changed: 36 additions & 43 deletions

File tree

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
const { pathsToModuleNameMapper } = require('ts-jest');
2-
const { compilerOptions } = require('./tsconfig.build.json');
2+
const { compilerOptions } = require('../../tsconfig.base.json');
33
module.exports = {
4-
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
5-
modulePaths: ['<rootDir>/../dist/'],
4+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
5+
prefix: '<rootDir>/../../../',
6+
}),
7+
modulePaths: ['<rootDir>/../../../'],
68
moduleFileExtensions: ['js', 'json', 'ts'],
79
rootDir: 'src',
810
testRegex: '.spec.ts$',
911
transform: {
10-
'^.+\\.(t|j)s$': [
11-
'ts-jest',
12-
{
13-
isolatedModules: true,
14-
},
15-
],
12+
'^.+\\.(t|j)s$': 'ts-jest',
1613
},
17-
transformIgnorePatterns: [
18-
"/node_modules/(?!axios/)",
19-
],
14+
transformIgnorePatterns: ['/node_modules/(?!axios/)'],
2015
coverageDirectory: './coverage',
2116
testEnvironment: 'node',
2217
};

packages/fxa-event-broker/package.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,6 @@
8484
"tsconfig-paths": "^4.2.0",
8585
"typescript": "5.5.3"
8686
},
87-
"jest": {
88-
"moduleFileExtensions": [
89-
"js",
90-
"json",
91-
"ts"
92-
],
93-
"rootDir": "src",
94-
"testRegex": ".spec.ts$",
95-
"transform": {
96-
"^.+\\.(t|j)s$": [
97-
"ts-jest",
98-
{
99-
"isolatedModules": true
100-
}
101-
]
102-
},
103-
"coverageDirectory": "../coverage",
104-
"testEnvironment": "node"
105-
},
10687
"nx": {
10788
"tags": [
10889
"scope:broker",

packages/fxa-event-broker/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import convict from 'convict';
66
import fs from 'fs';
77
import path from 'path';
8-
import { tracingConfig } from 'fxa-shared/tracing/config';
8+
import { tracingConfig } from '@fxa/shared/otel';
99

1010
const FIVE_MINUTES = 60 * 5;
1111

packages/fxa-event-broker/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ConfigService } from '@nestjs/config';
1313
import { NestFactory } from '@nestjs/core';
1414
import mozLog from 'mozlog';
1515

16-
import { initTracing } from 'fxa-shared/tracing/node-tracing';
16+
import { initTracing } from '@fxa/shared/otel';
1717

1818
import { AppModule } from './app.module';
1919
import Config, { AppConfig } from './config';

packages/fxa-event-broker/src/monitoring.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,33 @@
44

55
import Config, { AppConfig } from './config';
66
import mozLog from 'mozlog';
7-
import { initTracing } from 'fxa-shared/tracing/node-tracing';
8-
import { initSentry } from 'fxa-shared/sentry/node';
7+
import { initTracing } from '@fxa/shared/otel';
8+
import { initSentry } from '@fxa/shared/sentry-node';
99

1010
const log = mozLog(Config.getProperties().log)(Config.getProperties().log.app);
1111
const appConfig = Config.getProperties() as AppConfig;
1212
initTracing(appConfig.tracing, log);
13-
initSentry(appConfig, log);
13+
initSentry(appConfig, {
14+
error(type: string, data: unknown) {
15+
log.error(type, toObject(data));
16+
},
17+
debug(type: string, data: unknown) {
18+
log.debug(type, toObject(data));
19+
},
20+
info(type: string, data: unknown) {
21+
log.info(type, toObject(data));
22+
},
23+
warn(type: string, data: unknown) {
24+
log.warn(type, toObject(data));
25+
},
26+
});
27+
28+
function toObject(data: unknown): object {
29+
if (data === null) {
30+
return {};
31+
}
32+
if (typeof data === 'object') {
33+
return data;
34+
}
35+
return { data };
36+
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
{
22
"extends": "./tsconfig.json",
3-
"compilerOptions": {
4-
"paths": {
5-
"@fxa/shared/pem-jwk": ["libs/shared/pem-jwk/src/index"],
6-
"@fxa/vendored/jwtool": ["libs/vendored/jwtool/src/index"],
7-
"@fxa/vendored/typesafe-node-firestore": ["libs/vendored/typesafe-node-firestore/src/index"]
8-
}
9-
},
103
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
114
}

packages/fxa-event-broker/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"experimentalDecorators": true,
1010
"noEmitHelpers": true,
1111
"importHelpers": true,
12+
"isolatedModules": true,
1213
"types": ["jest"]
1314
},
1415
"include": ["src"]

0 commit comments

Comments
 (0)