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

Sentry recording errors with beacon #22

Closed
Jivings opened this issue Jan 23, 2022 · 4 comments
Closed

Sentry recording errors with beacon #22

Jivings opened this issue Jan 23, 2022 · 4 comments

Comments

@Jivings
Copy link

Jivings commented Jan 23, 2022

My Sentry is showing errors thrown in the SA script, looks like it's this line:

nav[sendBeaconText](

Here's a link to the Sentry issue:

https://sentry.io/share/issue/20005bc054fb4e48a65b8c01209ae3d2/

image

@Jivings
Copy link
Author

Jivings commented Jan 23, 2022

I think it's because you can't use the navigator object as a reference without binding it's scope. So you should be invoking it with call or apply.

nav[sendBeaconText].call(
  nav, 
  fullApiUrl + "/append",
  stringify(assign(payload, append))
);

So for example this doesn't work:

image

But this does:

image

@adriaandotcom
Copy link
Collaborator

adriaandotcom commented Jan 23, 2022

Thanks for investigating this! Will update the script when I'm back from my holiday.

Maybe a better solution would be using sendBeacon directly:

nav.sendBeacon(
  fullApiUrl + "/append",
  stringify(assign(payload, append))
);

We don't need to size optimization if we need apply or call anyway.

@Jivings
Copy link
Author

Jivings commented Jan 24, 2022

Yes that should be fine.

adriaandotcom added a commit that referenced this issue Mar 26, 2022
@adriaandotcom adriaandotcom mentioned this issue Mar 26, 2022
Merged
6 tasks
@adriaandotcom
Copy link
Collaborator

Fixed in #29

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

No branches or pull requests

2 participants