@driveflux/reporter 6.0.0 → 6.0.2

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.
@@ -1,215 +1,33 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
1
+ import * as Sentry from '@sentry/nextjs';
2
+ export class SentryNextJSDriver {
3
+ config;
4
+ constructor(config) {
5
+ this.config = config;
6
+ if (!this.config) {
7
+ throw new Error('Sentry is not configured');
8
+ }
8
9
  }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
10
+ getSentry() {
11
+ return Sentry;
13
12
  }
14
- }
15
- function _async_to_generator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
13
+ async reportError(err, metadata) {
14
+ Sentry.captureException(err, {
15
+ contexts: {
16
+ metadata,
17
+ },
27
18
  });
28
- };
29
- }
30
- function _class_call_check(instance, Constructor) {
31
- if (!(instance instanceof Constructor)) {
32
- throw new TypeError("Cannot call a class as a function");
33
- }
34
- }
35
- function _defineProperties(target, props) {
36
- for(var i = 0; i < props.length; i++){
37
- var descriptor = props[i];
38
- descriptor.enumerable = descriptor.enumerable || false;
39
- descriptor.configurable = true;
40
- if ("value" in descriptor) descriptor.writable = true;
41
- Object.defineProperty(target, descriptor.key, descriptor);
42
19
  }
43
- }
44
- function _create_class(Constructor, protoProps, staticProps) {
45
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46
- if (staticProps) _defineProperties(Constructor, staticProps);
47
- return Constructor;
48
- }
49
- function _define_property(obj, key, value) {
50
- if (key in obj) {
51
- Object.defineProperty(obj, key, {
52
- value: value,
53
- enumerable: true,
54
- configurable: true,
55
- writable: true
20
+ async reportProblem(problem) {
21
+ Sentry.captureException(problem.privateMetadata?.error ||
22
+ new Error(problem.message || problem.code), {
23
+ contexts: {
24
+ metadata: problem.metadata,
25
+ privateMetadata: problem.privateMetadata,
26
+ },
56
27
  });
57
- } else {
58
- obj[key] = value;
59
28
  }
60
- return obj;
61
- }
62
- function _ts_generator(thisArg, body) {
63
- var f, y, t, _ = {
64
- label: 0,
65
- sent: function() {
66
- if (t[0] & 1) throw t[1];
67
- return t[1];
68
- },
69
- trys: [],
70
- ops: []
71
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
72
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
73
- return this;
74
- }), g;
75
- function verb(n) {
76
- return function(v) {
77
- return step([
78
- n,
79
- v
80
- ]);
81
- };
82
- }
83
- function step(op) {
84
- if (f) throw new TypeError("Generator is already executing.");
85
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
86
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
87
- if (y = 0, t) op = [
88
- op[0] & 2,
89
- t.value
90
- ];
91
- switch(op[0]){
92
- case 0:
93
- case 1:
94
- t = op;
95
- break;
96
- case 4:
97
- _.label++;
98
- return {
99
- value: op[1],
100
- done: false
101
- };
102
- case 5:
103
- _.label++;
104
- y = op[1];
105
- op = [
106
- 0
107
- ];
108
- continue;
109
- case 7:
110
- op = _.ops.pop();
111
- _.trys.pop();
112
- continue;
113
- default:
114
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
115
- _ = 0;
116
- continue;
117
- }
118
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
119
- _.label = op[1];
120
- break;
121
- }
122
- if (op[0] === 6 && _.label < t[1]) {
123
- _.label = t[1];
124
- t = op;
125
- break;
126
- }
127
- if (t && _.label < t[2]) {
128
- _.label = t[2];
129
- _.ops.push(op);
130
- break;
131
- }
132
- if (t[2]) _.ops.pop();
133
- _.trys.pop();
134
- continue;
135
- }
136
- op = body.call(thisArg, _);
137
- } catch (e) {
138
- op = [
139
- 6,
140
- e
141
- ];
142
- y = 0;
143
- } finally{
144
- f = t = 0;
145
- }
146
- if (op[0] & 5) throw op[1];
147
- return {
148
- value: op[0] ? op[1] : void 0,
149
- done: true
150
- };
29
+ setReporterPayload(payload) {
30
+ Sentry.setContext('reporterPayload', payload);
151
31
  }
152
32
  }
153
- import * as Sentry from '@sentry/nextjs';
154
- export var SentryNextJSDriver = /*#__PURE__*/ function() {
155
- "use strict";
156
- function SentryNextJSDriver(config) {
157
- _class_call_check(this, SentryNextJSDriver);
158
- _define_property(this, "config", void 0);
159
- this.config = config;
160
- if (!this.config) {
161
- throw new Error('Sentry is not configured');
162
- }
163
- }
164
- _create_class(SentryNextJSDriver, [
165
- {
166
- key: "getSentry",
167
- value: function getSentry() {
168
- return Sentry;
169
- }
170
- },
171
- {
172
- key: "reportError",
173
- value: function reportError(err, metadata) {
174
- return _async_to_generator(function() {
175
- return _ts_generator(this, function(_state) {
176
- Sentry.captureException(err, {
177
- contexts: {
178
- metadata: metadata
179
- }
180
- });
181
- return [
182
- 2
183
- ];
184
- });
185
- })();
186
- }
187
- },
188
- {
189
- key: "reportProblem",
190
- value: function reportProblem(problem) {
191
- return _async_to_generator(function() {
192
- var _problem_privateMetadata;
193
- return _ts_generator(this, function(_state) {
194
- Sentry.captureException(((_problem_privateMetadata = problem.privateMetadata) === null || _problem_privateMetadata === void 0 ? void 0 : _problem_privateMetadata.error) || new Error(problem.message || problem.code), {
195
- contexts: {
196
- metadata: problem.metadata,
197
- privateMetadata: problem.privateMetadata
198
- }
199
- });
200
- return [
201
- 2
202
- ];
203
- });
204
- })();
205
- }
206
- },
207
- {
208
- key: "setReporterPayload",
209
- value: function setReporterPayload(payload) {
210
- Sentry.setContext('reporterPayload', payload);
211
- }
212
- }
213
- ]);
214
- return SentryNextJSDriver;
215
- }();
33
+ //# sourceMappingURL=sentry-nextjs.js.map