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

Commit 9246536

Browse files
authored
Merge pull request #1166 from MitanOmar/sentry-integration
feat: sentry integration
2 parents 4b83b9a + 0206f40 commit 9246536

File tree

4 files changed

+199
-21
lines changed

4 files changed

+199
-21
lines changed

app/app.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,62 @@
11
import Application from "@ember/application";
2+
import * as Sentry from "@sentry/ember";
23
import loadInitializers from "ember-load-initializers";
34
import Resolver from "ember-resolver";
5+
import fastRedact from "fast-redact";
46
import ResizeObserver from "resize-observer-polyfill";
57
import config from "timed/config/environment";
68
// simplebar setup
79
// see components/scroll-container for further usage
810
import "simplebar";
911
import "simplebar/dist/simplebar.css";
1012

13+
const redact = fastRedact({
14+
paths: [
15+
"user.email",
16+
"user.family_name",
17+
"user.given_name",
18+
"user.address",
19+
"user.postalCode",
20+
"user.city",
21+
],
22+
serialize: false,
23+
});
24+
25+
/* istanbul ignore if */
26+
if (config["@sentry/ember"]) {
27+
const sentryConfig = config["@sentry/ember"].sentry;
28+
Sentry.init({
29+
...sentryConfig,
30+
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
31+
beforeSend(_event, hint) {
32+
const event = redact(_event);
33+
// ignore this differentiation in dev environment
34+
if (event.environment === "production") {
35+
if (window.location.hostname === "test.timed.adfinis.com") {
36+
event.environment = "staging";
37+
}
38+
}
39+
40+
const exception = hint.originalException;
41+
if (
42+
exception &&
43+
Array.isArray(exception.errors) &&
44+
exception.errors.every((e) => e.status === 401)
45+
) {
46+
event.level = "info";
47+
}
48+
49+
if (
50+
config.SENTRY_IGNORE &&
51+
config.SENTRY_IGNORE.includes(hint.originalException.name)
52+
) {
53+
return null;
54+
}
55+
return event;
56+
},
57+
});
58+
}
59+
1160
if (!window.ResizeObserver) {
1261
window.ResizeObserver = ResizeObserver;
1362
}

config/environment.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* jshint node: true */
2-
32
module.exports = function (environment) {
43
const ENV = {
54
modulePrefix: "timed",
@@ -62,6 +61,33 @@ module.exports = function (environment) {
6261
},
6362
};
6463

64+
if (process.env.SENTRY_DSN) {
65+
ENV["@sentry/ember"] = {
66+
// Will silence Ember.onError warning without the need of using Ember debugging tools.
67+
ignoreEmberOnErrorWarning: false,
68+
69+
// All runloop queue durations will be added as spans.
70+
minimumRunloopQueueDuration: 0,
71+
72+
// Will disable automatic instrumentation for components.
73+
// disableInstrumentComponents: true,
74+
75+
// All (non-glimmer) component render durations will be added as spans.
76+
minimumComponentRenderDuration: 0,
77+
78+
// All component definitions will be added as spans.
79+
enableComponentDefinition: true,
80+
sentry: {
81+
environment,
82+
dsn: process.env.SENTRY_DSN,
83+
debug: environment !== "production",
84+
tracesSampleRate: 0.01,
85+
maxBreadcrumbs: 20,
86+
},
87+
};
88+
ENV.SENTRY_IGNORE = ["TransitionAborted"];
89+
}
90+
6591
if (environment === "development") {
6692
ENV["ember-simple-auth-oidc"].host =
6793
"http://timed.local/auth/realms/timed/protocol/openid-connect";

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@html-next/vertical-collection": "4.0.2",
6262
"@semantic-release/changelog": "^6.0.3",
6363
"@semantic-release/git": "^10.0.1",
64+
"@sentry/ember": "^7.98.0",
6465
"broccoli-asset-rev": "3.0.0",
6566
"broccoli-funnel": "^3.0.8",
6667
"downloadjs": "1.4.7",
@@ -88,7 +89,7 @@
8889
"ember-cli-update": "1.0.1",
8990
"ember-component-css": "0.8.1",
9091
"ember-composable-helpers": "5.0.0",
91-
"ember-concurrency": "2.3.4",
92+
"ember-concurrency": "^2.3.7",
9293
"ember-data": "4.4.0",
9394
"ember-decorators": "6.1.1",
9495
"ember-event-helpers": "^0.1.1",
@@ -139,7 +140,7 @@
139140
"resize-observer-polyfill": "^1.5.1",
140141
"sass": "1.58.3",
141142
"semantic-release": "21.0.7",
142-
"shepherd.js": "^11.1.1",
143+
"shepherd.js": "^11.2.0",
143144
"simplebar": "^6.2.5",
144145
"tracked-built-ins": "3.1.1",
145146
"tracked-toolbox": "2.0.0",
@@ -165,5 +166,8 @@
165166
"marked"
166167
]
167168
}
169+
},
170+
"dependencies": {
171+
"fast-redact": "^3.3.0"
168172
}
169173
}

pnpm-lock.yaml

Lines changed: 117 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)