Skip to content

Commit

Permalink
PLAT-13781: Adding sentry monitoring to cli (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylor-cb authored Feb 28, 2024
1 parent af89e17 commit 96556f3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ import { info } from "./scripts/info.js";
import { removeModules } from "./scripts/remove.js";
import { commitModules } from "./scripts/commit-module.js";
import { upgradeScaffold } from "./scripts/upgrade.js";
import { valid, invalid, isNameValid, section, isUserEnvironment } from "./utils.js";
import {
valid,
invalid,
isNameValid,
section,
isUserEnvironment
} from "./utils.js";
import { createModule } from "./scripts/create.js";
import { login } from "./scripts/login.js";
import { configFile } from "./scripts/utils/configFile.js";
Expand All @@ -41,6 +47,7 @@ import { analytics } from "./scripts/analytics/wrapper.js";
import { HAS_ASKED_OPT_IN_NAME } from "./scripts/analytics/config.js";
import { EVENT } from "./scripts/analytics/constants.js";
import { askOptIn } from "./scripts/analytics/scripts.js";
import { sentryMonitoring } from "./scripts/utils/sentry.js";

const pkg = JSON.parse(
fs.readFileSync(new URL("package.json", import.meta.url), "utf8")
Expand Down Expand Up @@ -83,6 +90,8 @@ async function dispatcher() {
invalid(`command doesn't exist: ${command}`);
}

sentryMonitoring.registerCommandName(command);

await commands[command]();

if (!analytics.event.name) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"type": "module",
"engines": {
"node": ">16.0"
"node": ">18.0"
},
"scripts": {
"demo": "npx . demo",
Expand Down Expand Up @@ -37,6 +37,7 @@
"@babel/template": "^7.16.7",
"@babel/types": "^7.18.8",
"@segment/analytics-node": "^2.0.0",
"@sentry/node": "^7.103.0",
"ajv": "^8.11.0",
"ajv-formats": "^2.1.1",
"arg": "^5.0.2",
Expand Down
25 changes: 25 additions & 0 deletions scripts/utils/sentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as Sentry from "@sentry/node";

class SentryMonitoring {
constructor() {
try {
Sentry.init({
dsn: "https://[email protected]/4506825798647808",
// Don't log the name of our users computers. Feels a bit much?
serverName: "-"
});
} catch {
// Do nothing, but prevent any sentry errors from blocking commands from executing
}
}

registerCommandName(commandName) {
try {
Sentry.setTag("command", commandName);
} catch {
// Do nothing, but prevent any sentry errors from blocking commands from executing
}
}
}

export const sentryMonitoring = new SentryMonitoring();
39 changes: 39 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,45 @@
node-fetch "^2.6.7"
tslib "^2.4.1"

"@sentry-internal/[email protected]":
version "7.103.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.103.0.tgz#b18ef65f610099ee2fc74f91f9ccfdb0353580c4"
integrity sha512-sZ/Wao8HOvGaBs7WlOdflMpHGAFkOBWL6hBiirHaOy5d+IDm7n7et5U6zhvcfiyYBO4nY36gy1Tg5mw+aNO0Vw==
dependencies:
"@sentry/core" "7.103.0"
"@sentry/types" "7.103.0"
"@sentry/utils" "7.103.0"

"@sentry/[email protected]":
version "7.103.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.103.0.tgz#8f626362c96f9aa4b4a52042c431d16372491dc1"
integrity sha512-LCI+PIDoF/RLqN41fNXum3ilmS6ukni6L7t38vSdibbe2G0804EbPLtOIpv2PkS8E6CFuRW5zOb+8OwEAAtZWw==
dependencies:
"@sentry/types" "7.103.0"
"@sentry/utils" "7.103.0"

"@sentry/node@^7.103.0":
version "7.103.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.103.0.tgz#9cf488086717c2920c43568432d14232b6783a9e"
integrity sha512-/bS/WNeO+PEd0r3o3LN0XGJV+l7hLNy1dTcn61VRgWGVs8SqMBb3uAvXAibZ9zGTCkaX/Ky3JumMcOOoxmNCtg==
dependencies:
"@sentry-internal/tracing" "7.103.0"
"@sentry/core" "7.103.0"
"@sentry/types" "7.103.0"
"@sentry/utils" "7.103.0"

"@sentry/[email protected]":
version "7.103.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.103.0.tgz#f413f922216c97ec86bae39f9d527669d8afedbd"
integrity sha512-NCvKyx8d2AGBQKPARrJemZmZ16DiMo688OEikZg4BbvFNDUzK5Egm2BH0vfLDhbNkU19o3maJowrYo42m8r9Zw==

"@sentry/[email protected]":
version "7.103.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.103.0.tgz#803b76e2adfdcec0d4ab6369cc8990dde19b55f4"
integrity sha512-phkUJt3F0UOkVq+M4GfdAh2ewI3ASrNiJddx9aO7GnT0aDwwVBHZltnqt95qgAB8W+BipTSt1dAh8yUbbq1Ceg==
dependencies:
"@sentry/types" "7.103.0"

"@sideway/address@^4.1.3":
version "4.1.4"
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0"
Expand Down

0 comments on commit 96556f3

Please sign in to comment.