@commercetools-frontend/sentry 22.2.1 → 22.3.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.
|
@@ -48,54 +48,44 @@ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construc
|
|
|
48
48
|
var _pt__default = /*#__PURE__*/_interopDefault(_pt);
|
|
49
49
|
|
|
50
50
|
// NOTE: This string will be replaced on build time with the package version.
|
|
51
|
-
var version = "22.
|
|
51
|
+
var version = "22.3.1";
|
|
52
52
|
|
|
53
53
|
const makeErrorToCapture = error => {
|
|
54
54
|
if (error instanceof Error) return error;
|
|
55
55
|
if (error instanceof ErrorEvent) return new Error(error.message);
|
|
56
56
|
return new Error(_JSON$stringify__default["default"](error.reason || 'Unhandled rejection without a reason'));
|
|
57
57
|
};
|
|
58
|
-
|
|
59
58
|
const sendErrorToSentry = error => {
|
|
60
59
|
if (typeof error === 'string') return Sentry__namespace.captureMessage(error);
|
|
61
60
|
const errorToCapture = makeErrorToCapture(error);
|
|
62
61
|
return Sentry__namespace.captureException(errorToCapture);
|
|
63
62
|
};
|
|
64
|
-
|
|
65
63
|
const replaceEventValues = (source, replacements) => {
|
|
66
64
|
const replaceEventValue = prop => {
|
|
67
65
|
source[prop] = replacements[prop];
|
|
68
66
|
};
|
|
69
|
-
|
|
70
67
|
for (const prop in source) {
|
|
71
68
|
if (Object.prototype.hasOwnProperty.call(source, prop)) {
|
|
72
69
|
var _context;
|
|
73
|
-
|
|
74
70
|
const hasPropReplacement = _includesInstanceProperty__default["default"](_context = _Object$keys__default["default"](replacements)).call(_context, prop);
|
|
75
|
-
|
|
76
71
|
switch (typeof source[prop]) {
|
|
77
72
|
case 'string':
|
|
78
73
|
if (hasPropReplacement) {
|
|
79
74
|
replaceEventValue(prop);
|
|
80
75
|
}
|
|
81
|
-
|
|
82
76
|
break;
|
|
83
|
-
|
|
84
77
|
case 'object':
|
|
85
78
|
if (hasPropReplacement) {
|
|
86
79
|
replaceEventValue(prop);
|
|
87
80
|
} else {
|
|
88
81
|
replaceEventValues(source[prop], replacements);
|
|
89
82
|
}
|
|
90
|
-
|
|
91
83
|
break;
|
|
92
84
|
}
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
|
-
|
|
96
87
|
return source;
|
|
97
88
|
};
|
|
98
|
-
|
|
99
89
|
const redactUnsafeEventFields = event => {
|
|
100
90
|
return replaceEventValues(event, {
|
|
101
91
|
firstName: '[Redacted]',
|
|
@@ -106,7 +96,6 @@ const redactUnsafeEventFields = event => {
|
|
|
106
96
|
const boot = () => {
|
|
107
97
|
if (window.app.trackingSentry && window.app.trackingSentry !== 'null') {
|
|
108
98
|
var _context2;
|
|
109
|
-
|
|
110
99
|
Sentry__namespace.init({
|
|
111
100
|
dsn: window.app.trackingSentry,
|
|
112
101
|
release: window.app.revision,
|
|
@@ -127,27 +116,21 @@ const boot = () => {
|
|
|
127
116
|
// we can implement the `tracesSampler` function.
|
|
128
117
|
// https://docs.sentry.io/platforms/javascript/guides/react/configuration/sampling/#sampling-transaction-events
|
|
129
118
|
tracesSampleRate: 0.05,
|
|
130
|
-
|
|
131
119
|
beforeSend(event) {
|
|
132
120
|
return redactUnsafeEventFields(event);
|
|
133
121
|
}
|
|
134
|
-
|
|
135
122
|
});
|
|
136
123
|
Sentry__namespace.configureScope(scope => {
|
|
137
124
|
scope.setTag('role', 'frontend');
|
|
138
125
|
});
|
|
139
126
|
}
|
|
140
127
|
};
|
|
141
|
-
|
|
142
128
|
const isExtraAsObject = extrasOrExtra => typeof extrasOrExtra === 'object';
|
|
143
|
-
|
|
144
129
|
const reportErrorToSentry = (error, extraInfo, getIsEnabled) => {
|
|
145
130
|
const isEnabled = getIsEnabled ? getIsEnabled() : Boolean(window.app.trackingSentry);
|
|
146
|
-
|
|
147
131
|
if (typeof error === 'string' && !isEnabled) {
|
|
148
132
|
console.warn('[SENTRY]: You called "reportErrorToSentry" with a string argument. ' + '"Error" objects should be preferred so that a stack-trace can be made available in Sentry. ' + 'See: https://docs.sentry.io/clients/javascript/usage/#try-catch');
|
|
149
133
|
}
|
|
150
|
-
|
|
151
134
|
if (isEnabled) {
|
|
152
135
|
if (extraInfo !== null && extraInfo !== void 0 && extraInfo.extra) {
|
|
153
136
|
if (isExtraAsObject(extraInfo.extra)) {
|
|
@@ -156,61 +139,49 @@ const reportErrorToSentry = (error, extraInfo, getIsEnabled) => {
|
|
|
156
139
|
} else {
|
|
157
140
|
Sentry__namespace.setExtra('extra', extraInfo.extra);
|
|
158
141
|
}
|
|
159
|
-
}
|
|
160
|
-
|
|
142
|
+
}
|
|
143
|
+
// Generate a unique ID referring to the last generated Sentry error
|
|
144
|
+
const errorId = sendErrorToSentry(error);
|
|
161
145
|
|
|
162
|
-
|
|
146
|
+
// The error stack should be available in Sentry, so there is no
|
|
163
147
|
// need to print it in the console as well.
|
|
164
148
|
// We just notify that an error occurred and provide the error ID.
|
|
165
|
-
|
|
166
149
|
console.error("[SENTRY]: An error occured (ID: ".concat(errorId, ")."));
|
|
167
150
|
return errorId;
|
|
168
151
|
}
|
|
169
|
-
|
|
170
152
|
console.error('[SENTRY]:', error);
|
|
171
153
|
return undefined;
|
|
172
154
|
};
|
|
173
155
|
|
|
174
156
|
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
175
|
-
|
|
176
157
|
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
177
|
-
|
|
178
158
|
/**
|
|
179
159
|
* This component will let sentry know if any information about the user has
|
|
180
160
|
* changed.
|
|
181
161
|
*/
|
|
182
162
|
let SentryUserTracker = /*#__PURE__*/function (_PureComponent) {
|
|
183
163
|
_inherits(SentryUserTracker, _PureComponent);
|
|
184
|
-
|
|
185
164
|
var _super = _createSuper$1(SentryUserTracker);
|
|
186
|
-
|
|
187
165
|
function SentryUserTracker() {
|
|
188
166
|
var _this;
|
|
189
|
-
|
|
190
167
|
_classCallCheck(this, SentryUserTracker);
|
|
191
|
-
|
|
192
168
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
193
169
|
args[_key] = arguments[_key];
|
|
194
170
|
}
|
|
195
|
-
|
|
196
171
|
_this = _super.call(this, ...args);
|
|
197
|
-
|
|
198
172
|
_this.syncUser = () => {
|
|
199
173
|
if (_this.props.user && window.app.trackingSentry) {
|
|
200
174
|
// to avoid sending personal data to sentry we anonymize the email address
|
|
201
175
|
// by only sending the domain part or the email
|
|
202
176
|
const emailTld = _this.props.user.email.split('@')[1];
|
|
203
|
-
|
|
204
177
|
Sentry__namespace.setUser({
|
|
205
178
|
email: "xxx@".concat(emailTld),
|
|
206
179
|
id: _this.props.user.id
|
|
207
180
|
});
|
|
208
181
|
}
|
|
209
182
|
};
|
|
210
|
-
|
|
211
183
|
return _this;
|
|
212
184
|
}
|
|
213
|
-
|
|
214
185
|
_createClass(SentryUserTracker, [{
|
|
215
186
|
key: "componentDidMount",
|
|
216
187
|
value: function componentDidMount() {
|
|
@@ -229,10 +200,8 @@ let SentryUserTracker = /*#__PURE__*/function (_PureComponent) {
|
|
|
229
200
|
return null;
|
|
230
201
|
}
|
|
231
202
|
}]);
|
|
232
|
-
|
|
233
203
|
return SentryUserTracker;
|
|
234
204
|
}(react.PureComponent);
|
|
235
|
-
|
|
236
205
|
SentryUserTracker.displayName = 'SentryUserTracker';
|
|
237
206
|
SentryUserTracker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
238
207
|
user: _pt__default["default"].shape({
|
|
@@ -242,20 +211,14 @@ SentryUserTracker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
242
211
|
} : {};
|
|
243
212
|
|
|
244
213
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
245
|
-
|
|
246
214
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
247
|
-
|
|
248
215
|
let SentryUserLogoutTracker = /*#__PURE__*/function (_Component) {
|
|
249
216
|
_inherits(SentryUserLogoutTracker, _Component);
|
|
250
|
-
|
|
251
217
|
var _super = _createSuper(SentryUserLogoutTracker);
|
|
252
|
-
|
|
253
218
|
function SentryUserLogoutTracker() {
|
|
254
219
|
_classCallCheck(this, SentryUserLogoutTracker);
|
|
255
|
-
|
|
256
220
|
return _super.apply(this, arguments);
|
|
257
221
|
}
|
|
258
|
-
|
|
259
222
|
_createClass(SentryUserLogoutTracker, [{
|
|
260
223
|
key: "componentDidMount",
|
|
261
224
|
value: function componentDidMount() {
|
|
@@ -273,10 +236,8 @@ let SentryUserLogoutTracker = /*#__PURE__*/function (_Component) {
|
|
|
273
236
|
return null;
|
|
274
237
|
}
|
|
275
238
|
}]);
|
|
276
|
-
|
|
277
239
|
return SentryUserLogoutTracker;
|
|
278
240
|
}(react.Component);
|
|
279
|
-
|
|
280
241
|
SentryUserLogoutTracker.displayName = 'SentryUserLogoutTracker';
|
|
281
242
|
|
|
282
243
|
exports.SentryUserLogoutTracker = SentryUserLogoutTracker;
|
|
@@ -47,54 +47,44 @@ var history__default = /*#__PURE__*/_interopDefault(history);
|
|
|
47
47
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
48
48
|
|
|
49
49
|
// NOTE: This string will be replaced on build time with the package version.
|
|
50
|
-
var version = "22.
|
|
50
|
+
var version = "22.3.1";
|
|
51
51
|
|
|
52
52
|
const makeErrorToCapture = error => {
|
|
53
53
|
if (error instanceof Error) return error;
|
|
54
54
|
if (error instanceof ErrorEvent) return new Error(error.message);
|
|
55
55
|
return new Error(_JSON$stringify__default["default"](error.reason || 'Unhandled rejection without a reason'));
|
|
56
56
|
};
|
|
57
|
-
|
|
58
57
|
const sendErrorToSentry = error => {
|
|
59
58
|
if (typeof error === 'string') return Sentry__namespace.captureMessage(error);
|
|
60
59
|
const errorToCapture = makeErrorToCapture(error);
|
|
61
60
|
return Sentry__namespace.captureException(errorToCapture);
|
|
62
61
|
};
|
|
63
|
-
|
|
64
62
|
const replaceEventValues = (source, replacements) => {
|
|
65
63
|
const replaceEventValue = prop => {
|
|
66
64
|
source[prop] = replacements[prop];
|
|
67
65
|
};
|
|
68
|
-
|
|
69
66
|
for (const prop in source) {
|
|
70
67
|
if (Object.prototype.hasOwnProperty.call(source, prop)) {
|
|
71
68
|
var _context;
|
|
72
|
-
|
|
73
69
|
const hasPropReplacement = _includesInstanceProperty__default["default"](_context = _Object$keys__default["default"](replacements)).call(_context, prop);
|
|
74
|
-
|
|
75
70
|
switch (typeof source[prop]) {
|
|
76
71
|
case 'string':
|
|
77
72
|
if (hasPropReplacement) {
|
|
78
73
|
replaceEventValue(prop);
|
|
79
74
|
}
|
|
80
|
-
|
|
81
75
|
break;
|
|
82
|
-
|
|
83
76
|
case 'object':
|
|
84
77
|
if (hasPropReplacement) {
|
|
85
78
|
replaceEventValue(prop);
|
|
86
79
|
} else {
|
|
87
80
|
replaceEventValues(source[prop], replacements);
|
|
88
81
|
}
|
|
89
|
-
|
|
90
82
|
break;
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
85
|
}
|
|
94
|
-
|
|
95
86
|
return source;
|
|
96
87
|
};
|
|
97
|
-
|
|
98
88
|
const redactUnsafeEventFields = event => {
|
|
99
89
|
return replaceEventValues(event, {
|
|
100
90
|
firstName: '[Redacted]',
|
|
@@ -105,7 +95,6 @@ const redactUnsafeEventFields = event => {
|
|
|
105
95
|
const boot = () => {
|
|
106
96
|
if (window.app.trackingSentry && window.app.trackingSentry !== 'null') {
|
|
107
97
|
var _context2;
|
|
108
|
-
|
|
109
98
|
Sentry__namespace.init({
|
|
110
99
|
dsn: window.app.trackingSentry,
|
|
111
100
|
release: window.app.revision,
|
|
@@ -126,27 +115,21 @@ const boot = () => {
|
|
|
126
115
|
// we can implement the `tracesSampler` function.
|
|
127
116
|
// https://docs.sentry.io/platforms/javascript/guides/react/configuration/sampling/#sampling-transaction-events
|
|
128
117
|
tracesSampleRate: 0.05,
|
|
129
|
-
|
|
130
118
|
beforeSend(event) {
|
|
131
119
|
return redactUnsafeEventFields(event);
|
|
132
120
|
}
|
|
133
|
-
|
|
134
121
|
});
|
|
135
122
|
Sentry__namespace.configureScope(scope => {
|
|
136
123
|
scope.setTag('role', 'frontend');
|
|
137
124
|
});
|
|
138
125
|
}
|
|
139
126
|
};
|
|
140
|
-
|
|
141
127
|
const isExtraAsObject = extrasOrExtra => typeof extrasOrExtra === 'object';
|
|
142
|
-
|
|
143
128
|
const reportErrorToSentry = (error, extraInfo, getIsEnabled) => {
|
|
144
129
|
const isEnabled = getIsEnabled ? getIsEnabled() : Boolean(window.app.trackingSentry);
|
|
145
|
-
|
|
146
130
|
if (typeof error === 'string' && !isEnabled) {
|
|
147
131
|
console.warn('[SENTRY]: You called "reportErrorToSentry" with a string argument. ' + '"Error" objects should be preferred so that a stack-trace can be made available in Sentry. ' + 'See: https://docs.sentry.io/clients/javascript/usage/#try-catch');
|
|
148
132
|
}
|
|
149
|
-
|
|
150
133
|
if (isEnabled) {
|
|
151
134
|
if (extraInfo !== null && extraInfo !== void 0 && extraInfo.extra) {
|
|
152
135
|
if (isExtraAsObject(extraInfo.extra)) {
|
|
@@ -155,61 +138,49 @@ const reportErrorToSentry = (error, extraInfo, getIsEnabled) => {
|
|
|
155
138
|
} else {
|
|
156
139
|
Sentry__namespace.setExtra('extra', extraInfo.extra);
|
|
157
140
|
}
|
|
158
|
-
}
|
|
159
|
-
|
|
141
|
+
}
|
|
142
|
+
// Generate a unique ID referring to the last generated Sentry error
|
|
143
|
+
const errorId = sendErrorToSentry(error);
|
|
160
144
|
|
|
161
|
-
|
|
145
|
+
// The error stack should be available in Sentry, so there is no
|
|
162
146
|
// need to print it in the console as well.
|
|
163
147
|
// We just notify that an error occurred and provide the error ID.
|
|
164
|
-
|
|
165
148
|
console.error("[SENTRY]: An error occured (ID: ".concat(errorId, ")."));
|
|
166
149
|
return errorId;
|
|
167
150
|
}
|
|
168
|
-
|
|
169
151
|
console.error('[SENTRY]:', error);
|
|
170
152
|
return undefined;
|
|
171
153
|
};
|
|
172
154
|
|
|
173
155
|
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
174
|
-
|
|
175
156
|
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
176
|
-
|
|
177
157
|
/**
|
|
178
158
|
* This component will let sentry know if any information about the user has
|
|
179
159
|
* changed.
|
|
180
160
|
*/
|
|
181
161
|
let SentryUserTracker = /*#__PURE__*/function (_PureComponent) {
|
|
182
162
|
_inherits(SentryUserTracker, _PureComponent);
|
|
183
|
-
|
|
184
163
|
var _super = _createSuper$1(SentryUserTracker);
|
|
185
|
-
|
|
186
164
|
function SentryUserTracker() {
|
|
187
165
|
var _this;
|
|
188
|
-
|
|
189
166
|
_classCallCheck(this, SentryUserTracker);
|
|
190
|
-
|
|
191
167
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
192
168
|
args[_key] = arguments[_key];
|
|
193
169
|
}
|
|
194
|
-
|
|
195
170
|
_this = _super.call(this, ...args);
|
|
196
|
-
|
|
197
171
|
_this.syncUser = () => {
|
|
198
172
|
if (_this.props.user && window.app.trackingSentry) {
|
|
199
173
|
// to avoid sending personal data to sentry we anonymize the email address
|
|
200
174
|
// by only sending the domain part or the email
|
|
201
175
|
const emailTld = _this.props.user.email.split('@')[1];
|
|
202
|
-
|
|
203
176
|
Sentry__namespace.setUser({
|
|
204
177
|
email: "xxx@".concat(emailTld),
|
|
205
178
|
id: _this.props.user.id
|
|
206
179
|
});
|
|
207
180
|
}
|
|
208
181
|
};
|
|
209
|
-
|
|
210
182
|
return _this;
|
|
211
183
|
}
|
|
212
|
-
|
|
213
184
|
_createClass(SentryUserTracker, [{
|
|
214
185
|
key: "componentDidMount",
|
|
215
186
|
value: function componentDidMount() {
|
|
@@ -228,28 +199,20 @@ let SentryUserTracker = /*#__PURE__*/function (_PureComponent) {
|
|
|
228
199
|
return null;
|
|
229
200
|
}
|
|
230
201
|
}]);
|
|
231
|
-
|
|
232
202
|
return SentryUserTracker;
|
|
233
203
|
}(react.PureComponent);
|
|
234
|
-
|
|
235
204
|
SentryUserTracker.displayName = 'SentryUserTracker';
|
|
236
205
|
SentryUserTracker.propTypes = {};
|
|
237
206
|
|
|
238
207
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
239
|
-
|
|
240
208
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
241
|
-
|
|
242
209
|
let SentryUserLogoutTracker = /*#__PURE__*/function (_Component) {
|
|
243
210
|
_inherits(SentryUserLogoutTracker, _Component);
|
|
244
|
-
|
|
245
211
|
var _super = _createSuper(SentryUserLogoutTracker);
|
|
246
|
-
|
|
247
212
|
function SentryUserLogoutTracker() {
|
|
248
213
|
_classCallCheck(this, SentryUserLogoutTracker);
|
|
249
|
-
|
|
250
214
|
return _super.apply(this, arguments);
|
|
251
215
|
}
|
|
252
|
-
|
|
253
216
|
_createClass(SentryUserLogoutTracker, [{
|
|
254
217
|
key: "componentDidMount",
|
|
255
218
|
value: function componentDidMount() {
|
|
@@ -267,10 +230,8 @@ let SentryUserLogoutTracker = /*#__PURE__*/function (_Component) {
|
|
|
267
230
|
return null;
|
|
268
231
|
}
|
|
269
232
|
}]);
|
|
270
|
-
|
|
271
233
|
return SentryUserLogoutTracker;
|
|
272
234
|
}(react.Component);
|
|
273
|
-
|
|
274
235
|
SentryUserLogoutTracker.displayName = 'SentryUserLogoutTracker';
|
|
275
236
|
|
|
276
237
|
exports.SentryUserLogoutTracker = SentryUserLogoutTracker;
|
|
@@ -15,54 +15,44 @@ import _pt from 'prop-types';
|
|
|
15
15
|
import { PureComponent, Component } from 'react';
|
|
16
16
|
|
|
17
17
|
// NOTE: This string will be replaced on build time with the package version.
|
|
18
|
-
var version = "22.
|
|
18
|
+
var version = "22.3.1";
|
|
19
19
|
|
|
20
20
|
const makeErrorToCapture = error => {
|
|
21
21
|
if (error instanceof Error) return error;
|
|
22
22
|
if (error instanceof ErrorEvent) return new Error(error.message);
|
|
23
23
|
return new Error(_JSON$stringify(error.reason || 'Unhandled rejection without a reason'));
|
|
24
24
|
};
|
|
25
|
-
|
|
26
25
|
const sendErrorToSentry = error => {
|
|
27
26
|
if (typeof error === 'string') return Sentry.captureMessage(error);
|
|
28
27
|
const errorToCapture = makeErrorToCapture(error);
|
|
29
28
|
return Sentry.captureException(errorToCapture);
|
|
30
29
|
};
|
|
31
|
-
|
|
32
30
|
const replaceEventValues = (source, replacements) => {
|
|
33
31
|
const replaceEventValue = prop => {
|
|
34
32
|
source[prop] = replacements[prop];
|
|
35
33
|
};
|
|
36
|
-
|
|
37
34
|
for (const prop in source) {
|
|
38
35
|
if (Object.prototype.hasOwnProperty.call(source, prop)) {
|
|
39
36
|
var _context;
|
|
40
|
-
|
|
41
37
|
const hasPropReplacement = _includesInstanceProperty(_context = _Object$keys(replacements)).call(_context, prop);
|
|
42
|
-
|
|
43
38
|
switch (typeof source[prop]) {
|
|
44
39
|
case 'string':
|
|
45
40
|
if (hasPropReplacement) {
|
|
46
41
|
replaceEventValue(prop);
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
break;
|
|
50
|
-
|
|
51
44
|
case 'object':
|
|
52
45
|
if (hasPropReplacement) {
|
|
53
46
|
replaceEventValue(prop);
|
|
54
47
|
} else {
|
|
55
48
|
replaceEventValues(source[prop], replacements);
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
break;
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
53
|
}
|
|
62
|
-
|
|
63
54
|
return source;
|
|
64
55
|
};
|
|
65
|
-
|
|
66
56
|
const redactUnsafeEventFields = event => {
|
|
67
57
|
return replaceEventValues(event, {
|
|
68
58
|
firstName: '[Redacted]',
|
|
@@ -73,7 +63,6 @@ const redactUnsafeEventFields = event => {
|
|
|
73
63
|
const boot = () => {
|
|
74
64
|
if (window.app.trackingSentry && window.app.trackingSentry !== 'null') {
|
|
75
65
|
var _context2;
|
|
76
|
-
|
|
77
66
|
Sentry.init({
|
|
78
67
|
dsn: window.app.trackingSentry,
|
|
79
68
|
release: window.app.revision,
|
|
@@ -94,27 +83,21 @@ const boot = () => {
|
|
|
94
83
|
// we can implement the `tracesSampler` function.
|
|
95
84
|
// https://docs.sentry.io/platforms/javascript/guides/react/configuration/sampling/#sampling-transaction-events
|
|
96
85
|
tracesSampleRate: 0.05,
|
|
97
|
-
|
|
98
86
|
beforeSend(event) {
|
|
99
87
|
return redactUnsafeEventFields(event);
|
|
100
88
|
}
|
|
101
|
-
|
|
102
89
|
});
|
|
103
90
|
Sentry.configureScope(scope => {
|
|
104
91
|
scope.setTag('role', 'frontend');
|
|
105
92
|
});
|
|
106
93
|
}
|
|
107
94
|
};
|
|
108
|
-
|
|
109
95
|
const isExtraAsObject = extrasOrExtra => typeof extrasOrExtra === 'object';
|
|
110
|
-
|
|
111
96
|
const reportErrorToSentry = (error, extraInfo, getIsEnabled) => {
|
|
112
97
|
const isEnabled = getIsEnabled ? getIsEnabled() : Boolean(window.app.trackingSentry);
|
|
113
|
-
|
|
114
98
|
if (typeof error === 'string' && !isEnabled) {
|
|
115
99
|
console.warn('[SENTRY]: You called "reportErrorToSentry" with a string argument. ' + '"Error" objects should be preferred so that a stack-trace can be made available in Sentry. ' + 'See: https://docs.sentry.io/clients/javascript/usage/#try-catch');
|
|
116
100
|
}
|
|
117
|
-
|
|
118
101
|
if (isEnabled) {
|
|
119
102
|
if (extraInfo !== null && extraInfo !== void 0 && extraInfo.extra) {
|
|
120
103
|
if (isExtraAsObject(extraInfo.extra)) {
|
|
@@ -123,61 +106,49 @@ const reportErrorToSentry = (error, extraInfo, getIsEnabled) => {
|
|
|
123
106
|
} else {
|
|
124
107
|
Sentry.setExtra('extra', extraInfo.extra);
|
|
125
108
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
109
|
+
}
|
|
110
|
+
// Generate a unique ID referring to the last generated Sentry error
|
|
111
|
+
const errorId = sendErrorToSentry(error);
|
|
128
112
|
|
|
129
|
-
|
|
113
|
+
// The error stack should be available in Sentry, so there is no
|
|
130
114
|
// need to print it in the console as well.
|
|
131
115
|
// We just notify that an error occurred and provide the error ID.
|
|
132
|
-
|
|
133
116
|
console.error("[SENTRY]: An error occured (ID: ".concat(errorId, ")."));
|
|
134
117
|
return errorId;
|
|
135
118
|
}
|
|
136
|
-
|
|
137
119
|
console.error('[SENTRY]:', error);
|
|
138
120
|
return undefined;
|
|
139
121
|
};
|
|
140
122
|
|
|
141
123
|
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
142
|
-
|
|
143
124
|
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
144
|
-
|
|
145
125
|
/**
|
|
146
126
|
* This component will let sentry know if any information about the user has
|
|
147
127
|
* changed.
|
|
148
128
|
*/
|
|
149
129
|
let SentryUserTracker = /*#__PURE__*/function (_PureComponent) {
|
|
150
130
|
_inherits(SentryUserTracker, _PureComponent);
|
|
151
|
-
|
|
152
131
|
var _super = _createSuper$1(SentryUserTracker);
|
|
153
|
-
|
|
154
132
|
function SentryUserTracker() {
|
|
155
133
|
var _this;
|
|
156
|
-
|
|
157
134
|
_classCallCheck(this, SentryUserTracker);
|
|
158
|
-
|
|
159
135
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
160
136
|
args[_key] = arguments[_key];
|
|
161
137
|
}
|
|
162
|
-
|
|
163
138
|
_this = _super.call(this, ...args);
|
|
164
|
-
|
|
165
139
|
_this.syncUser = () => {
|
|
166
140
|
if (_this.props.user && window.app.trackingSentry) {
|
|
167
141
|
// to avoid sending personal data to sentry we anonymize the email address
|
|
168
142
|
// by only sending the domain part or the email
|
|
169
143
|
const emailTld = _this.props.user.email.split('@')[1];
|
|
170
|
-
|
|
171
144
|
Sentry.setUser({
|
|
172
145
|
email: "xxx@".concat(emailTld),
|
|
173
146
|
id: _this.props.user.id
|
|
174
147
|
});
|
|
175
148
|
}
|
|
176
149
|
};
|
|
177
|
-
|
|
178
150
|
return _this;
|
|
179
151
|
}
|
|
180
|
-
|
|
181
152
|
_createClass(SentryUserTracker, [{
|
|
182
153
|
key: "componentDidMount",
|
|
183
154
|
value: function componentDidMount() {
|
|
@@ -196,10 +167,8 @@ let SentryUserTracker = /*#__PURE__*/function (_PureComponent) {
|
|
|
196
167
|
return null;
|
|
197
168
|
}
|
|
198
169
|
}]);
|
|
199
|
-
|
|
200
170
|
return SentryUserTracker;
|
|
201
171
|
}(PureComponent);
|
|
202
|
-
|
|
203
172
|
SentryUserTracker.displayName = 'SentryUserTracker';
|
|
204
173
|
SentryUserTracker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
205
174
|
user: _pt.shape({
|
|
@@ -209,20 +178,14 @@ SentryUserTracker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
209
178
|
} : {};
|
|
210
179
|
|
|
211
180
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
212
|
-
|
|
213
181
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
214
|
-
|
|
215
182
|
let SentryUserLogoutTracker = /*#__PURE__*/function (_Component) {
|
|
216
183
|
_inherits(SentryUserLogoutTracker, _Component);
|
|
217
|
-
|
|
218
184
|
var _super = _createSuper(SentryUserLogoutTracker);
|
|
219
|
-
|
|
220
185
|
function SentryUserLogoutTracker() {
|
|
221
186
|
_classCallCheck(this, SentryUserLogoutTracker);
|
|
222
|
-
|
|
223
187
|
return _super.apply(this, arguments);
|
|
224
188
|
}
|
|
225
|
-
|
|
226
189
|
_createClass(SentryUserLogoutTracker, [{
|
|
227
190
|
key: "componentDidMount",
|
|
228
191
|
value: function componentDidMount() {
|
|
@@ -240,10 +203,8 @@ let SentryUserLogoutTracker = /*#__PURE__*/function (_Component) {
|
|
|
240
203
|
return null;
|
|
241
204
|
}
|
|
242
205
|
}]);
|
|
243
|
-
|
|
244
206
|
return SentryUserLogoutTracker;
|
|
245
207
|
}(Component);
|
|
246
|
-
|
|
247
208
|
SentryUserLogoutTracker.displayName = 'SentryUserLogoutTracker';
|
|
248
209
|
|
|
249
210
|
export { SentryUserLogoutTracker, SentryUserTracker, boot, redactUnsafeEventFields, reportErrorToSentry, version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/sentry",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.3.1",
|
|
4
4
|
"description": "Components to set up Sentry for a MC application",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -9,26 +9,40 @@
|
|
|
9
9
|
"directory": "packages/sentry"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://docs.commercetools.com/custom-applications",
|
|
12
|
-
"keywords": [
|
|
12
|
+
"keywords": [
|
|
13
|
+
"javascript",
|
|
14
|
+
"frontend",
|
|
15
|
+
"react",
|
|
16
|
+
"toolkit"
|
|
17
|
+
],
|
|
13
18
|
"license": "MIT",
|
|
14
19
|
"publishConfig": {
|
|
15
20
|
"access": "public"
|
|
16
21
|
},
|
|
17
22
|
"main": "dist/commercetools-frontend-sentry.cjs.js",
|
|
18
23
|
"module": "dist/commercetools-frontend-sentry.esm.js",
|
|
19
|
-
"files": [
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
20
30
|
"dependencies": {
|
|
21
31
|
"@babel/runtime": "^7.20.13",
|
|
22
32
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
23
|
-
"@commercetools-frontend/browser-history": "22.
|
|
24
|
-
"@commercetools-frontend/constants": "22.
|
|
25
|
-
"@sentry/react": "7.
|
|
26
|
-
"@sentry/
|
|
33
|
+
"@commercetools-frontend/browser-history": "22.3.1",
|
|
34
|
+
"@commercetools-frontend/constants": "22.3.1",
|
|
35
|
+
"@sentry/react": "7.51.2",
|
|
36
|
+
"@sentry/types": "7.51.2",
|
|
37
|
+
"@sentry/tracing": "7.51.2",
|
|
27
38
|
"@types/prop-types": "^15.7.5",
|
|
28
39
|
"@types/react": "^17.0.53",
|
|
29
40
|
"prop-types": "15.8.1"
|
|
30
41
|
},
|
|
31
42
|
"devDependencies": {
|
|
43
|
+
"@emotion/react": "11.11.0",
|
|
44
|
+
"@types/jest": "^29.5.1",
|
|
45
|
+
"jest": "29.5.0",
|
|
32
46
|
"react": "17.0.2",
|
|
33
47
|
"sentry-testkit": "5.0.5",
|
|
34
48
|
"wait-for-expect": "3.0.2"
|
|
@@ -36,4 +50,4 @@
|
|
|
36
50
|
"peerDependencies": {
|
|
37
51
|
"react": "17.x"
|
|
38
52
|
}
|
|
39
|
-
}
|
|
53
|
+
}
|