@akinon/next 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/sentry/index.ts +27 -0
- package/utils/log.ts +20 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/sentry/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as Sentry from '@sentry/nextjs';
|
|
2
|
+
|
|
3
|
+
const SENTRY_DSN: string =
|
|
4
|
+
process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
|
|
5
|
+
|
|
6
|
+
export const initSentry = (
|
|
7
|
+
type: 'Server' | 'Client' | 'Edge',
|
|
8
|
+
options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {}
|
|
9
|
+
) => {
|
|
10
|
+
// TODO: Handle options with ESLint rules
|
|
11
|
+
|
|
12
|
+
// TODO: Remove Zero Project DSN
|
|
13
|
+
|
|
14
|
+
Sentry.init({
|
|
15
|
+
dsn:
|
|
16
|
+
SENTRY_DSN ||
|
|
17
|
+
'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
|
|
18
|
+
initialScope: {
|
|
19
|
+
tags: {
|
|
20
|
+
APP_TYPE: 'ProjectZeroNext',
|
|
21
|
+
TYPE: type
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
tracesSampleRate: 1.0,
|
|
25
|
+
integrations: []
|
|
26
|
+
});
|
|
27
|
+
};
|
package/utils/log.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Sentry from '@sentry/nextjs';
|
|
2
|
+
|
|
1
3
|
enum LogLevel {
|
|
2
4
|
TRACE = 'trace',
|
|
3
5
|
DEBUG = 'debug',
|
|
@@ -92,6 +94,15 @@ const error: LoggerFn = (message, payload) => {
|
|
|
92
94
|
message,
|
|
93
95
|
payload
|
|
94
96
|
});
|
|
97
|
+
|
|
98
|
+
Sentry.withScope(function (scope) {
|
|
99
|
+
scope.setLevel('error');
|
|
100
|
+
|
|
101
|
+
Sentry.captureException({
|
|
102
|
+
message,
|
|
103
|
+
extra: payload
|
|
104
|
+
});
|
|
105
|
+
});
|
|
95
106
|
};
|
|
96
107
|
|
|
97
108
|
const warn: LoggerFn = (message, payload) => {
|
|
@@ -100,6 +111,15 @@ const warn: LoggerFn = (message, payload) => {
|
|
|
100
111
|
message,
|
|
101
112
|
payload
|
|
102
113
|
});
|
|
114
|
+
|
|
115
|
+
Sentry.withScope(function (scope) {
|
|
116
|
+
scope.setLevel('warning');
|
|
117
|
+
|
|
118
|
+
Sentry.captureEvent({
|
|
119
|
+
message,
|
|
120
|
+
extra: payload
|
|
121
|
+
});
|
|
122
|
+
});
|
|
103
123
|
};
|
|
104
124
|
|
|
105
125
|
const debug: LoggerFn = (message, payload) => {
|