Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
feat: sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
MitanOmar committed Jan 31, 2024
1 parent 912db0f commit c6b3d9f
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 21 deletions.
48 changes: 48 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,61 @@
import Application from "@ember/application";
import * as Sentry from "@sentry/ember";
import loadInitializers from "ember-load-initializers";
import Resolver from "ember-resolver";
import fastRedact from "fast-redact";
import ResizeObserver from "resize-observer-polyfill";
import config from "timed/config/environment";
// simplebar setup
// see components/scroll-container for further usage
import "simplebar";
import "simplebar/dist/simplebar.css";

const redact = fastRedact({
paths: [
"user.email",
"user.family_name",
"user.given_name",
"user.address",
"user.postalCode",
"user.city",
],
serialize: false,
});

if (config["@sentry/ember"]) {
const sentryConfig = config["@sentry/ember"].sentry;
Sentry.init({

Check warning on line 27 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L26-L27

Added lines #L26 - L27 were not covered by tests
...sentryConfig,
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
beforeSend(_event, hint) {
const event = redact(_event);

Check warning on line 31 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L31

Added line #L31 was not covered by tests
// ignore this differentiation in dev environment
if (event.environment === "production") {
if (window.location.hostname === "test.timed.adfinis.com") {
event.environment = "staging";

Check warning on line 35 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L33-L35

Added lines #L33 - L35 were not covered by tests
}
}

const exception = hint.originalException;
if (

Check warning on line 40 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L39-L40

Added lines #L39 - L40 were not covered by tests
exception &&
Array.isArray(exception.errors) &&
exception.errors.every((e) => e.status === 401)

Check warning on line 43 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L43

Added line #L43 was not covered by tests
) {
event.level = "info";

Check warning on line 45 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L45

Added line #L45 was not covered by tests
}

if (

Check warning on line 48 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L48

Added line #L48 was not covered by tests
config.SENTRY_IGNORE &&
config.SENTRY_IGNORE.includes(hint.originalException.name)
) {
return null;

Check warning on line 52 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L52

Added line #L52 was not covered by tests
}
return event;

Check warning on line 54 in app/app.js

View check run for this annotation

Codecov / codecov/patch

app/app.js#L54

Added line #L54 was not covered by tests
},
});
}

if (!window.ResizeObserver) {
window.ResizeObserver = ResizeObserver;
}
Expand Down
28 changes: 27 additions & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* jshint node: true */

module.exports = function (environment) {
const ENV = {
modulePrefix: "timed",
Expand Down Expand Up @@ -62,6 +61,33 @@ module.exports = function (environment) {
},
};

if (process.env.SENTRY_DSN) {
ENV["@sentry/ember"] = {
// Will silence Ember.onError warning without the need of using Ember debugging tools.
ignoreEmberOnErrorWarning: false,

// All runloop queue durations will be added as spans.
minimumRunloopQueueDuration: 0,

// Will disable automatic instrumentation for components.
// disableInstrumentComponents: true,

// All (non-glimmer) component render durations will be added as spans.
minimumComponentRenderDuration: 0,

// All component definitions will be added as spans.
enableComponentDefinition: true,
sentry: {
environment,
dsn: process.env.SENTRY_DSN,
debug: environment !== "production",
tracesSampleRate: 0.01,
maxBreadcrumbs: 20,
},
};
ENV.SENTRY_IGNORE = ["TransitionAborted"];
}

if (environment === "development") {
ENV["ember-simple-auth-oidc"].host =
"http://timed.local/auth/realms/timed/protocol/openid-connect";
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@html-next/vertical-collection": "4.0.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@sentry/ember": "^7.98.0",
"broccoli-asset-rev": "3.0.0",
"broccoli-funnel": "^3.0.8",
"downloadjs": "1.4.7",
Expand Down Expand Up @@ -88,7 +89,7 @@
"ember-cli-update": "1.0.1",
"ember-component-css": "0.8.1",
"ember-composable-helpers": "5.0.0",
"ember-concurrency": "2.3.4",
"ember-concurrency": "^2.3.7",
"ember-data": "4.4.0",
"ember-decorators": "6.1.1",
"ember-event-helpers": "^0.1.1",
Expand Down Expand Up @@ -139,7 +140,7 @@
"resize-observer-polyfill": "^1.5.1",
"sass": "1.58.3",
"semantic-release": "21.0.7",
"shepherd.js": "^11.1.1",
"shepherd.js": "^11.2.0",
"simplebar": "^6.2.5",
"tracked-built-ins": "3.1.1",
"tracked-toolbox": "2.0.0",
Expand All @@ -165,5 +166,8 @@
"marked"
]
}
},
"dependencies": {
"fast-redact": "^3.3.0"
}
}
135 changes: 117 additions & 18 deletions pnpm-lock.yaml

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

0 comments on commit c6b3d9f

Please sign in to comment.