@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Refactor Sentry configs
8
+
3
9
  ## 1.1.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -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) => {