Skip to content

Does this SDK works with browser extension ? #487

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

Closed
bt0r opened this issue Aug 13, 2020 · 8 comments
Closed

Does this SDK works with browser extension ? #487

bt0r opened this issue Aug 13, 2020 · 8 comments

Comments

@bt0r
Copy link

bt0r commented Aug 13, 2020

Hi there 👋🏻

In advance, thanks for your work 👏🏻
I'm actually trying to add your sdk inside a browser extension (in a content_script) but i stuck on 'logs.logger.info' not yet available, please call '.init()' first.

  • Is it supposed to work with browser extension ? if yes, is there is something special to do ?

Thanks

@bcaudan
Copy link
Contributor

bcaudan commented Aug 24, 2020

Hi @bt0r,

We are not actively supporting browser extension so some features could not work.
Could you share a repository where we could have a look at your issue?

@bt0r
Copy link
Author

bt0r commented Aug 24, 2020

Hi @bcaudan Thanks for your reply :)
Sure, you can check this one https://github.com/bt0r/noteflix , i didn't pushed a draft PR with datadog integration because its just a local test but if you need to go deeper, i can do it

@bcaudan
Copy link
Contributor

bcaudan commented Aug 24, 2020

If it does not bother you, it would be great

@bt0r
Copy link
Author

bt0r commented Aug 26, 2020

I pushed a branch with a litle test https://github.com/bt0r/NoteFlix/tree/draft/datadog-logs
To run the extension :

  • make install
  • make watch-firefox or make watch-chrome
  • Add the extension in your browser firefox or chrome
  • Open Netflix (needed to trigger the extension)

Index.js is the extension entrypoint, i simply added https://github.com/bt0r/NoteFlix/blob/draft/datadog-logs/src/index.js#L3-L20 to trigger the error (readable in console)
Screenshot_20200826_090040

If i can help you, just let me know ! i would be very happy to use datadog for this project

@bcaudan
Copy link
Contributor

bcaudan commented Aug 26, 2020

I've made a few tests, it works fine on chrome but it fails on firefox.

On firefox, I've got a TypeError: "fetch" is read-only which let me think that the extension execution context is stricter than the document one.
We use a fetch proxy to collect request errors, so disabling automatic error collection (forwardErrorsToLogs: false) should allow you to use the logger.

@bt0r
Copy link
Author

bt0r commented Aug 26, 2020

You're right ! The error seems out now but i cannot see any logs in Datadog, maybe i'm wrong but should it be somewhere else than in the Log explorer ? (i tried using 15 minutes and live tail to prevent a blacklist policy) Or maybe its not avalaible with the log managment free plan

There is a 403 replied (i tried differents token, buy a log managment plan but same goal)
Screenshot_20200826_160256

@bcaudan
Copy link
Contributor

bcaudan commented Aug 26, 2020

Unless the same request works from a different context (curl, browser debug console, integration in regular web page), it seems to me that this is a different issue not directly related to this repository.

If this is the case, you should ask Datadog support for help with it.

@bt0r
Copy link
Author

bt0r commented Aug 26, 2020

The bug is related to the "datacenter" attribute chosen in the init section https://github.com/bt0r/NoteFlix/blob/draft/datadog-logs/src/index.js#L11, i chose "eu" and now with "us" it's working fine, i close this issue.

Thanks you for you quick answers and help !

@bt0r bt0r closed this as completed Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants