-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Darcy/with tags as a function fix #498
Conversation
src/raygun.js
Outdated
@@ -952,9 +952,16 @@ var raygunFactory = function(window, $, undefined) { | |||
payload.Details.GroupingKey = _groupingKeyCallback(payload, stackTrace, options); | |||
} | |||
|
|||
var clonedPayload = (!!window.structuredClone ? window.structuredClone(payload): payload); //clone in supported browsers (everything but IE) | |||
var clonedPayload = payload; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is wrong here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you able to provide a more details explanation of the changes in the PR description?
the code changes look fine but hard to understand how the order of operations have changed at a glance and would prefer to approve understanding this rather than just looking at the code changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the extra details, change looks good to me 👍
Prevent errors on structured clone from propagating
raygun.js has this line:
var clonedData = (!!window.structuredClone ? window.structuredClone(data): data); //clone in supported browsers (everything but IE)
but
window.structuredClone
throws if it encounters a function (https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#things_that_dont_work_with_structured_clone).When using
rg4js('withTags', getCustomTags); ( [Documentation] (https://raygun.com/documentation/language-guides/javascript/advanced-setup/#withtags) ), this is causing an error to be thrown, because
data..eventData[].Tags` can be a function.The fix here is to attempt to perform a structured clone, but fall back to the original behaviour is that is not possible.