Skip to content
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

Merged
merged 3 commits into from
Aug 8, 2023

Conversation

darcythomas
Copy link
Contributor

@darcythomas darcythomas commented Aug 8, 2023

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.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is wrong here

Copy link
Collaborator

@Olwiba Olwiba left a 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

@darcythomas darcythomas requested a review from Olwiba August 8, 2023 22:34
Copy link
Collaborator

@Olwiba Olwiba left a 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 👍

@darcythomas darcythomas merged commit 8d78ba2 into master Aug 8, 2023
1 check passed
@darcythomas darcythomas deleted the darcy/withTags-as-a-function-fix branch August 8, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants