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

Commit c6b3d9f

Browse files
committed
feat: sentry integration
1 parent 912db0f commit c6b3d9f

File tree

4 files changed

+198
-21
lines changed

4 files changed

+198
-21
lines changed

app/app.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,61 @@
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+
if (config["@sentry/ember"]) {
26+
const sentryConfig = config["@sentry/ember"].sentry;
27+
Sentry.init({
28+
...sentryConfig,
29+
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
30+
beforeSend(_event, hint) {
31+
const event = redact(_event);
32+
// ignore this differentiation in dev environment
33+
if (event.environment === "production") {
34+
if (window.location.hostname === "test.timed.adfinis.com") {
35+
event.environment = "staging";
36+
}
37+
}
38+
39+
const exception = hint.originalException;
40+
if (
41+
exception &&
42+
Array.isArray(exception.errors) &&
43+
exception.errors.every((e) => e.status === 401)
44+
) {
45+
event.level = "info";
46+
}
47+
48+
if (
49+
config.SENTRY_IGNORE &&
50+
config.SENTRY_IGNORE.includes(hint.originalException.name)
51+
) {
52+
return null;
53+
}
54+
return event;
55+
},
56+
});
57+
}
58+
1159
if (!window.ResizeObserver) {
1260
window.ResizeObserver = ResizeObserver;
1361
}

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)