@prezly/theme-kit-nextjs 10.16.2 → 10.16.3
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.
|
@@ -37,11 +37,23 @@ function addedScript(colno) {
|
|
|
37
37
|
in_app: true
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
// The OneTrust script, as the Sentry SDK reports it after it replaces `https://cdn.cookielaw.org` with `app://`.
|
|
42
|
+
function oneTrust(version, colno) {
|
|
43
|
+
return {
|
|
44
|
+
filename: "app:///scripttemplates/".concat(version, "/otBannerSdk.js"),
|
|
45
|
+
lineno: 7,
|
|
46
|
+
colno,
|
|
47
|
+
in_app: true
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
var EVENT_TARGET_OF_UNDEFINED = "Cannot read properties of undefined (reading 'target')";
|
|
40
51
|
function error(message, frames) {
|
|
52
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'TypeError';
|
|
41
53
|
return {
|
|
42
54
|
exception: {
|
|
43
55
|
values: [{
|
|
44
|
-
type
|
|
56
|
+
type,
|
|
45
57
|
value: message,
|
|
46
58
|
stacktrace: frames ? {
|
|
47
59
|
frames
|
|
@@ -94,6 +106,28 @@ describe('buildSentryClientConfig', () => {
|
|
|
94
106
|
};
|
|
95
107
|
expect(send(config, event)).toBe(event);
|
|
96
108
|
});
|
|
109
|
+
describe('OneTrust links called without a click event', () => {
|
|
110
|
+
// Frames from real events in Sentry issue THEMES-NEXTJS-68D (DEV-25110).
|
|
111
|
+
it.each([['"List of cookies" link, OneTrust 202405.1.0 (Telenet)', oneTrust('202405.1.0', 275943)], ['"IAB vendors" link, OneTrust 202609.1.0 (otomoto.pl)', oneTrust('202609.1.0', 322959)]])('drops the error from the %s', (_link, frame) => {
|
|
112
|
+
expect(send(config, error(EVENT_TARGET_OF_UNDEFINED, [SENTRY_WRAPPER, frame]))).toBeNull();
|
|
113
|
+
});
|
|
114
|
+
it.each([['Safari', "undefined is not an object (evaluating 'e.target')"], ['Firefox', 'can\'t access property "target", e is undefined']])('drops the same error as %s reports it', (_browser, message) => {
|
|
115
|
+
var event = error(message, [SENTRY_WRAPPER, oneTrust('202610.1.0', 1)]);
|
|
116
|
+
expect(send(config, event)).toBeNull();
|
|
117
|
+
});
|
|
118
|
+
it('keeps the same error when theme code throws it', () => {
|
|
119
|
+
var event = error(EVENT_TARGET_OF_UNDEFINED, [SENTRY_WRAPPER, THEME_CODE]);
|
|
120
|
+
expect(send(config, event)).toBe(event);
|
|
121
|
+
});
|
|
122
|
+
it('keeps the same error when theme code called by OneTrust throws it', () => {
|
|
123
|
+
var event = error(EVENT_TARGET_OF_UNDEFINED, [oneTrust('202609.1.0', 322959), THEME_CODE]);
|
|
124
|
+
expect(send(config, event)).toBe(event);
|
|
125
|
+
});
|
|
126
|
+
it.each([['the banner loop (DEV-24553)', 'RangeError', 'Maximum call stack size exceeded.'], ['missing OneTrust data', 'TypeError', "Cannot read properties of undefined (reading 'DomainData')"], ['reading `target` from null', 'TypeError', "Cannot read properties of null (reading 'target')"], ['the same message with another type', 'Error', EVENT_TARGET_OF_UNDEFINED]])('keeps other OneTrust errors: %s', (_case, type, message) => {
|
|
127
|
+
var event = error(message, [SENTRY_WRAPPER, oneTrust('202609.1.0', 100)], type);
|
|
128
|
+
expect(send(config, event)).toBe(event);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
97
131
|
});
|
|
98
132
|
describe('buildSentryServerConfig', () => {
|
|
99
133
|
it('keeps errors from `<anonymous>` code with a line number', () => {
|
|
@@ -35,11 +35,23 @@ function addedScript(colno) {
|
|
|
35
35
|
in_app: true
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
// The OneTrust script, as the Sentry SDK reports it after it replaces `https://cdn.cookielaw.org` with `app://`.
|
|
40
|
+
function oneTrust(version, colno) {
|
|
41
|
+
return {
|
|
42
|
+
filename: "app:///scripttemplates/".concat(version, "/otBannerSdk.js"),
|
|
43
|
+
lineno: 7,
|
|
44
|
+
colno,
|
|
45
|
+
in_app: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var EVENT_TARGET_OF_UNDEFINED = "Cannot read properties of undefined (reading 'target')";
|
|
38
49
|
function error(message, frames) {
|
|
50
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'TypeError';
|
|
39
51
|
return {
|
|
40
52
|
exception: {
|
|
41
53
|
values: [{
|
|
42
|
-
type
|
|
54
|
+
type,
|
|
43
55
|
value: message,
|
|
44
56
|
stacktrace: frames ? {
|
|
45
57
|
frames
|
|
@@ -92,6 +104,28 @@ describe('buildSentryClientConfig', () => {
|
|
|
92
104
|
};
|
|
93
105
|
expect(send(config, event)).toBe(event);
|
|
94
106
|
});
|
|
107
|
+
describe('OneTrust links called without a click event', () => {
|
|
108
|
+
// Frames from real events in Sentry issue THEMES-NEXTJS-68D (DEV-25110).
|
|
109
|
+
it.each([['"List of cookies" link, OneTrust 202405.1.0 (Telenet)', oneTrust('202405.1.0', 275943)], ['"IAB vendors" link, OneTrust 202609.1.0 (otomoto.pl)', oneTrust('202609.1.0', 322959)]])('drops the error from the %s', (_link, frame) => {
|
|
110
|
+
expect(send(config, error(EVENT_TARGET_OF_UNDEFINED, [SENTRY_WRAPPER, frame]))).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
it.each([['Safari', "undefined is not an object (evaluating 'e.target')"], ['Firefox', 'can\'t access property "target", e is undefined']])('drops the same error as %s reports it', (_browser, message) => {
|
|
113
|
+
var event = error(message, [SENTRY_WRAPPER, oneTrust('202610.1.0', 1)]);
|
|
114
|
+
expect(send(config, event)).toBeNull();
|
|
115
|
+
});
|
|
116
|
+
it('keeps the same error when theme code throws it', () => {
|
|
117
|
+
var event = error(EVENT_TARGET_OF_UNDEFINED, [SENTRY_WRAPPER, THEME_CODE]);
|
|
118
|
+
expect(send(config, event)).toBe(event);
|
|
119
|
+
});
|
|
120
|
+
it('keeps the same error when theme code called by OneTrust throws it', () => {
|
|
121
|
+
var event = error(EVENT_TARGET_OF_UNDEFINED, [oneTrust('202609.1.0', 322959), THEME_CODE]);
|
|
122
|
+
expect(send(config, event)).toBe(event);
|
|
123
|
+
});
|
|
124
|
+
it.each([['the banner loop (DEV-24553)', 'RangeError', 'Maximum call stack size exceeded.'], ['missing OneTrust data', 'TypeError', "Cannot read properties of undefined (reading 'DomainData')"], ['reading `target` from null', 'TypeError', "Cannot read properties of null (reading 'target')"], ['the same message with another type', 'Error', EVENT_TARGET_OF_UNDEFINED]])('keeps other OneTrust errors: %s', (_case, type, message) => {
|
|
125
|
+
var event = error(message, [SENTRY_WRAPPER, oneTrust('202609.1.0', 100)], type);
|
|
126
|
+
expect(send(config, event)).toBe(event);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
95
129
|
});
|
|
96
130
|
describe('buildSentryServerConfig', () => {
|
|
97
131
|
it('keeps errors from `<anonymous>` code with a line number', () => {
|
package/build/sentry/common.cjs
CHANGED
|
@@ -44,6 +44,42 @@ function shouldExceptionBeIgnored(exception) {
|
|
|
44
44
|
* Note: the Sentry SDK fills in `filename` in the browser, not `abs_path`.
|
|
45
45
|
*/
|
|
46
46
|
function isThrownByScriptWithoutUrl(exception) {
|
|
47
|
+
var _findThrowingFrame;
|
|
48
|
+
return ((_findThrowingFrame = findThrowingFrame(exception)) === null || _findThrowingFrame === void 0 ? void 0 : _findThrowingFrame.filename) === '<anonymous>';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The OneTrust script. The Sentry SDK replaces the domain of every script URL with `app://`
|
|
53
|
+
* before `beforeSend`, so the file name is matched, not `cdn.cookielaw.org`.
|
|
54
|
+
*/
|
|
55
|
+
var ONETRUST_BANNER_SCRIPT = /\/otBannerSdk\.js(?:$|[?#])/;
|
|
56
|
+
|
|
57
|
+
/** How Chrome, Safari and Firefox report reading `target` from an event that is `undefined`. */
|
|
58
|
+
var EVENT_TARGET_OF_UNDEFINED = /^(?:Cannot read properties of undefined \(reading 'target'\)|undefined is not an object \(evaluating '[\w$]+\.target'\)|can't access property "target", [\w$]+ is undefined)$/;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* In the OneTrust cookie settings panel, the "List of cookies" and "IAB vendors" links
|
|
62
|
+
* wait a moment after a click, then read `event.target`. A real click always passes the event.
|
|
63
|
+
* Automated security scanners call these handlers without an event, so the delayed code throws.
|
|
64
|
+
* See DEV-25110 and Sentry issue THEMES-NEXTJS-68D.
|
|
65
|
+
*
|
|
66
|
+
* Only this error is dropped. Other errors from the OneTrust script are still reported, because
|
|
67
|
+
* our OneTrust integration can cause them (for example the banner loop in DEV-24553).
|
|
68
|
+
*/
|
|
69
|
+
function isOneTrustLinkCalledWithoutEvent(exception) {
|
|
70
|
+
var _exception$value, _findThrowingFrame2;
|
|
71
|
+
if (exception.type !== 'TypeError' || !EVENT_TARGET_OF_UNDEFINED.test((_exception$value = exception.value) !== null && _exception$value !== void 0 ? _exception$value : '')) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
var filename = (_findThrowingFrame2 = findThrowingFrame(exception)) === null || _findThrowingFrame2 === void 0 ? void 0 : _findThrowingFrame2.filename;
|
|
75
|
+
return filename !== undefined && ONETRUST_BANNER_SCRIPT.test(filename);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns the frame where the error was thrown. Frames without a line number are browser
|
|
80
|
+
* built-in functions, such as `Array.map`, and are skipped.
|
|
81
|
+
*/
|
|
82
|
+
function findThrowingFrame(exception) {
|
|
47
83
|
var _exception$stacktrace, _exception$stacktrace2;
|
|
48
84
|
var frames = (_exception$stacktrace = (_exception$stacktrace2 = exception.stacktrace) === null || _exception$stacktrace2 === void 0 ? void 0 : _exception$stacktrace2.frames) !== null && _exception$stacktrace !== void 0 ? _exception$stacktrace : [];
|
|
49
85
|
|
|
@@ -51,10 +87,10 @@ function isThrownByScriptWithoutUrl(exception) {
|
|
|
51
87
|
for (var index = frames.length - 1; index >= 0; index -= 1) {
|
|
52
88
|
var frame = frames[index];
|
|
53
89
|
if (typeof frame.lineno === 'number') {
|
|
54
|
-
return frame
|
|
90
|
+
return frame;
|
|
55
91
|
}
|
|
56
92
|
}
|
|
57
|
-
return
|
|
93
|
+
return undefined;
|
|
58
94
|
}
|
|
59
95
|
function buildSentryConfig(dsn, themeName) {
|
|
60
96
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
@@ -85,6 +121,9 @@ function buildSentryConfig(dsn, themeName) {
|
|
|
85
121
|
if (ignoreScriptsWithoutUrl && exceptions !== null && exceptions !== void 0 && exceptions.length && exceptions.every(isThrownByScriptWithoutUrl)) {
|
|
86
122
|
return null;
|
|
87
123
|
}
|
|
124
|
+
if (exceptions !== null && exceptions !== void 0 && exceptions.length && exceptions.every(isOneTrustLinkCalledWithoutEvent)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
88
127
|
return event;
|
|
89
128
|
},
|
|
90
129
|
// Attach theme tag to each event
|
package/build/sentry/common.mjs
CHANGED
|
@@ -38,6 +38,42 @@ function shouldExceptionBeIgnored(exception) {
|
|
|
38
38
|
* Note: the Sentry SDK fills in `filename` in the browser, not `abs_path`.
|
|
39
39
|
*/
|
|
40
40
|
function isThrownByScriptWithoutUrl(exception) {
|
|
41
|
+
var _findThrowingFrame;
|
|
42
|
+
return ((_findThrowingFrame = findThrowingFrame(exception)) === null || _findThrowingFrame === void 0 ? void 0 : _findThrowingFrame.filename) === '<anonymous>';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The OneTrust script. The Sentry SDK replaces the domain of every script URL with `app://`
|
|
47
|
+
* before `beforeSend`, so the file name is matched, not `cdn.cookielaw.org`.
|
|
48
|
+
*/
|
|
49
|
+
var ONETRUST_BANNER_SCRIPT = /\/otBannerSdk\.js(?:$|[?#])/;
|
|
50
|
+
|
|
51
|
+
/** How Chrome, Safari and Firefox report reading `target` from an event that is `undefined`. */
|
|
52
|
+
var EVENT_TARGET_OF_UNDEFINED = /^(?:Cannot read properties of undefined \(reading 'target'\)|undefined is not an object \(evaluating '[\w$]+\.target'\)|can't access property "target", [\w$]+ is undefined)$/;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* In the OneTrust cookie settings panel, the "List of cookies" and "IAB vendors" links
|
|
56
|
+
* wait a moment after a click, then read `event.target`. A real click always passes the event.
|
|
57
|
+
* Automated security scanners call these handlers without an event, so the delayed code throws.
|
|
58
|
+
* See DEV-25110 and Sentry issue THEMES-NEXTJS-68D.
|
|
59
|
+
*
|
|
60
|
+
* Only this error is dropped. Other errors from the OneTrust script are still reported, because
|
|
61
|
+
* our OneTrust integration can cause them (for example the banner loop in DEV-24553).
|
|
62
|
+
*/
|
|
63
|
+
function isOneTrustLinkCalledWithoutEvent(exception) {
|
|
64
|
+
var _exception$value, _findThrowingFrame2;
|
|
65
|
+
if (exception.type !== 'TypeError' || !EVENT_TARGET_OF_UNDEFINED.test((_exception$value = exception.value) !== null && _exception$value !== void 0 ? _exception$value : '')) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
var filename = (_findThrowingFrame2 = findThrowingFrame(exception)) === null || _findThrowingFrame2 === void 0 ? void 0 : _findThrowingFrame2.filename;
|
|
69
|
+
return filename !== undefined && ONETRUST_BANNER_SCRIPT.test(filename);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns the frame where the error was thrown. Frames without a line number are browser
|
|
74
|
+
* built-in functions, such as `Array.map`, and are skipped.
|
|
75
|
+
*/
|
|
76
|
+
function findThrowingFrame(exception) {
|
|
41
77
|
var _exception$stacktrace, _exception$stacktrace2;
|
|
42
78
|
var frames = (_exception$stacktrace = (_exception$stacktrace2 = exception.stacktrace) === null || _exception$stacktrace2 === void 0 ? void 0 : _exception$stacktrace2.frames) !== null && _exception$stacktrace !== void 0 ? _exception$stacktrace : [];
|
|
43
79
|
|
|
@@ -45,10 +81,10 @@ function isThrownByScriptWithoutUrl(exception) {
|
|
|
45
81
|
for (var index = frames.length - 1; index >= 0; index -= 1) {
|
|
46
82
|
var frame = frames[index];
|
|
47
83
|
if (typeof frame.lineno === 'number') {
|
|
48
|
-
return frame
|
|
84
|
+
return frame;
|
|
49
85
|
}
|
|
50
86
|
}
|
|
51
|
-
return
|
|
87
|
+
return undefined;
|
|
52
88
|
}
|
|
53
89
|
export function buildSentryConfig(dsn, themeName) {
|
|
54
90
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
@@ -79,6 +115,9 @@ export function buildSentryConfig(dsn, themeName) {
|
|
|
79
115
|
if (ignoreScriptsWithoutUrl && exceptions !== null && exceptions !== void 0 && exceptions.length && exceptions.every(isThrownByScriptWithoutUrl)) {
|
|
80
116
|
return null;
|
|
81
117
|
}
|
|
118
|
+
if (exceptions !== null && exceptions !== void 0 && exceptions.length && exceptions.every(isOneTrustLinkCalledWithoutEvent)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
82
121
|
return event;
|
|
83
122
|
},
|
|
84
123
|
// Attach theme tag to each event
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-nextjs",
|
|
3
|
-
"version": "10.16.
|
|
3
|
+
"version": "10.16.3",
|
|
4
4
|
"description": "Data layer and utility library for developing Prezly themes with NextJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.mjs",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"json-stable-stringify": "^1.2.1",
|
|
80
80
|
"redis": "^4.7.0",
|
|
81
81
|
"url-pattern": "^1.0.3",
|
|
82
|
-
"@prezly/theme-kit-
|
|
83
|
-
"@prezly/theme-kit-
|
|
84
|
-
"@prezly/theme-kit-
|
|
82
|
+
"@prezly/theme-kit-core": "^10.16.3",
|
|
83
|
+
"@prezly/theme-kit-intl": "^10.16.3",
|
|
84
|
+
"@prezly/theme-kit-react": "^10.16.3"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@sentry/nextjs": "7.120.4"
|