Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sentry): Allow other Red Hat Services to be incapsulated by sentry #3026

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 105 additions & 77 deletions src/utils/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ let sentryInitialized = false;

function getAppDetails() {
const pathName = window.location.pathname.split('/');
let appGroup;
let appGroup = 'insights';
let appName;
let betaCheck;

let environment = 'stable';
if (pathName[1] === 'beta') {
betaCheck = ' Beta';
appGroup = pathName[2];
appName = appGroup === 'landing' ? 'landing' : pathName[3];
appName = pathName[3];
environment = 'beta';
} else {
betaCheck = '';
appGroup = pathName[1];
appName = appGroup === 'landing' ? 'landing' : pathName[2];
if (appGroup === 'openshift') {
appName = pathName[3];
} else {
appName = pathName[2];
if (appGroup === 'landing') {
appName = 'landing';
}
}
}

const appDetails = {
beta: betaCheck,
env: environment,
app: {
group: appGroup,
name: appName,
Expand All @@ -45,76 +50,98 @@ function initSentry() {
if (sentryInitialized) {
return;
}
type ConfiguredApp = {
appName: string;
dsn: string;
project: string;
};

type ConfiguredApps = {
[key: string]: ConfiguredApp[];
};
sentryInitialized = true;
const appDetails = getAppDetails();
const configuredApps = [
{
appName: 'inventory',
dsn: 'https://[email protected]/4507454722211840',
project: 'inventory-rhel',
},
{
appName: 'patch',
dsn: 'https://[email protected]/4508683262951424',
project: 'patchman-rhel',
},
{
appName: 'advisor',
dsn: 'https://[email protected]/4505397435367424',
project: 'advisor-rhel',
},
{
appName: 'dashboard',
dsn: 'https://[email protected]/4508683243028485',
project: 'dashboard-rhel',
},
{
appName: 'policies',
dsn: 'https://[email protected]/4508683264262144',
project: 'policies-rhel',
},
{
appName: 'vulnerability',
dsn: 'https://[email protected]/4508683271077888',
project: 'vulnerability-rhel',
},
{
appName: 'compliance',
dsn: 'https://[email protected]/4508083145408512',
project: 'compliance-rhel',
},
{
appName: 'malware',
dsn: 'https://[email protected]/4508683260002304',
project: 'malware-rhel',
},
{
appName: 'remediations',
dsn: 'https://[email protected]/4508683233787904',
project: 'remediations-rhel',
},
{
appName: 'tasks',
dsn: 'https://[email protected]/4508683269570560',
project: 'tasks-rhel',
},
{
appName: 'registration',
dsn: 'https://[email protected]/4508683266686976',
project: 'registration-assistant-rhel',
},
{
appName: 'connector',
dsn: 'https://[email protected]/4508683268128768',
project: 'sed-frontend-rhc',
},
{
appName: 'image-builder',
dsn: 'https://[email protected]/4508297557901312',
project: 'image-builder-rhel',
},
];
const configuredApps: ConfiguredApps = {
insights: [
{
appName: 'inventory',
dsn: 'https://[email protected]/4507454722211840',
project: 'inventory-rhel',
},
{
appName: 'patch',
dsn: 'https://[email protected]/4508683262951424',
project: 'patchman-rhel',
},
{
appName: 'advisor',
dsn: 'https://[email protected]/4505397435367424',
project: 'advisor-rhel',
},
{
appName: 'dashboard',
dsn: 'https://[email protected]/4508683243028485',
project: 'dashboard-rhel',
},
{
appName: 'policies',
dsn: 'https://[email protected]/4508683264262144',
project: 'policies-rhel',
},
{
appName: 'vulnerability',
dsn: 'https://[email protected]/4508683271077888',
project: 'vulnerability-rhel',
},
{
appName: 'compliance',
dsn: 'https://[email protected]/4508083145408512',
project: 'compliance-rhel',
},
{
appName: 'malware',
dsn: 'https://[email protected]/4508683260002304',
project: 'malware-rhel',
},
{
appName: 'remediations',
dsn: 'https://[email protected]/4508683233787904',
project: 'remediations-rhel',
},
{
appName: 'tasks',
dsn: 'https://[email protected]/4508683269570560',
project: 'tasks-rhel',
},
{
appName: 'registration',
dsn: 'https://[email protected]/4508683266686976',
project: 'registration-assistant-rhel',
},
{
appName: 'connector',
dsn: 'https://[email protected]/4508683268128768',
project: 'sed-frontend-rhc',
},
{
appName: 'image-builder',
dsn: 'https://[email protected]/4508297557901312',
project: 'image-builder-rhel',
},
],
openshift: [
{
appName: 'advisor',
dsn: 'https://[email protected]/4508683272454144',
project: 'ocp-advisor',
},
{
appName: 'vulnerability',
dsn: 'https://[email protected]/4508683273830400',
project: 'ocp-vulnerability',
},
],
};

// dsn: key
// environment: logs Prod or Prod Beta for filtering
Expand All @@ -131,7 +158,7 @@ function initSentry() {
Sentry.init({
//default api_key -> cp-001-insights
dsn: 'https://[email protected]/1484024',
environment: `Prod${appDetails.beta}`,
environment: `Prod${appDetails.env}`,
maxBreadcrumbs: 50,
attachStacktrace: true,
integrations: [
Expand All @@ -152,7 +179,8 @@ function initSentry() {
.filter((frame) => frame.module_metadata && frame.module_metadata.dsn)
.map((v) => v.module_metadata)
.slice(-1); // using top frame only
const configuredApp = configuredApps.filter((app) => app.appName === event.tags?.app_name);
const configuredApp = configuredApps[appDetails.app.group].filter((app) => app.appName === event.tags?.app_name);

if (routeTo.length) {
event.extra = {
...event.extra,
Expand Down
Loading