Skip to content

Commit

Permalink
Merge branch 'alpha' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
derevnjuk committed Oct 11, 2023
2 parents 75b8bd0 + 4e3fdd9 commit 8d4dfcb
Show file tree
Hide file tree
Showing 13 changed files with 367 additions and 45 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ jobs:

- name: Build package
run: npm run build

env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}

- name: Pack artifacts
run: npm pack

Expand Down
179 changes: 145 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@neuralegion/capture-har": "^0.3.4",
"@neuralegion/os-service": "^1.2.2",
"@neuralegion/raw-socket": "^1.8.2",
"@sentry/node": "^7.70.0",
"ajv": "^6.12.6",
"amqplib": "~0.10.2",
"arch": "^2.2.0",
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/RunRepeater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ export class RunRepeater implements CommandModule {
['SIGTERM', 'SIGINT', 'SIGHUP'].forEach((event) =>
process.on(event, async () => {
await repeaterLauncher.close();
process.exit(0);
process.exitCode = 0;
})
);

await repeaterLauncher.run(args.id as string, args.run as boolean);
} catch (e) {
logger.error(e.message);
logger.error(e);
await repeaterLauncher.close();
process.exit(1);
process.exitCode = 1;
}
}
}
43 changes: 41 additions & 2 deletions src/Config/CliBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CliConfig, ConfigReader } from './ConfigReader';
import { ClusterArgs, Helpers, logger, LogLevel } from '../Utils';
import { ClusterArgs, Helpers, logger, LogLevel, Sentry } from '../Utils';
import { SystemConfigReader } from './SystemConfigReader';
import { CliInfo } from './CliInfo';
import { Arguments, Argv, CommandModule } from 'yargs';

Expand Down Expand Up @@ -85,7 +86,11 @@ export class CliBuilder {
);

return commands
.reduce((acc: Argv, item: CommandModule) => acc.command(item), cli)
.reduce(
(acc: Argv, item: CommandModule) =>
acc.command(this.wrapWithSentry(item)),
cli
)
.recommendCommands()
.demandCommand(1)
.strict(true)
Expand All @@ -95,4 +100,38 @@ export class CliBuilder {
.alias('h', 'help')
.wrap(null);
}

private wrapWithSentry(command: CommandModule) {
const handler = command.handler.bind(command);

command.handler = async (args: Arguments) => {
const systemConfigReader = new SystemConfigReader(args.api as string);
const systemConfig = await systemConfigReader.read();

Sentry.init({
attachStacktrace: true,
dsn: systemConfig.sentryDsn,
release: process.env.VERSION,
beforeSend(event) {
if (event.contexts.args) {
event.contexts.args = {
...event.contexts.args,
t: event.contexts.args.t && '[Filtered]',
token: event.contexts.args.token && '[Filtered]'
};
}

return event;
}
});

return Sentry.runWithAsyncContext(() => {
Sentry.setContext('args', args);

return handler(args);
});
};

return command;
}
}
Loading

0 comments on commit 8d4dfcb

Please sign in to comment.