Comments (11)
Hi,
We have modified the SDK to be Web Worker friendly with the latest release (23.12.0). Currently, it seems to be working with non-Module Workers. However, as you also mentioned in your implementation, automatic tracking is not working (like for sessions, views, clicks, etc) as it depends on the window object.
Also, we extended the storage methods so you can provide your own. If you encounter any issues, please let us know.
Current documentation on the topic: https://support.count.ly/hc/en-us/articles/360037441932-Web-analytics-JavaScript-#h_01HH1BABFQ48FKWGJCX9HFMKW8
from countly-sdk-web.
Hello. Which features are you using in your integration?
The window
object is used for many things in the SDK so it might not be removed even if the SDK was tree-shakable.
If I understand correctly, the main problem in your case is that there is no window
object in the context that you want to run the SDK in? Would your problem be solved if there was some kind of "switch" in the SDK that would make the SDK not use the window
object?
from countly-sdk-web.
Thanks @ArtursKadikis, if there was a switch that would be a nice short-term fix, whether it meets the expectation can only be validated in the webworker context. WebWorkers also don't allow XMLHttpRequest
i.e. only fetch
would work.
The reason this will be short-term fix is because it will still bloat the bundles with all the unreachable code. So the ideal solution would be some sort of modularization that would allow for tree-shaking all unreachable code.
from countly-sdk-web.
Also @ArtursKadikis, just so it's clear, any Countly users who use Countly within browser extensions are going to hit this same issue with the MV3 migration that is underway in the Chromium ecosystem. Addressing this issue will be a benefit beyond @whizzzkid and the ipfs-companion project. Thanks a lot.
from countly-sdk-web.
@ArtursKadikis : is there any sense of timeline for addressing this? Some info (even if rough) is better than none. For example would this happen in a month, in 2023Q2, by end of the year?
I'm asking so we can plan our work accordingly. I'd ideally like to be staying on countly SDKs but given the last shared dates in March of Chrome webstore rejecting extensions that aren't MV3 compatible, we may have to roll our own client SDK.
from countly-sdk-web.
@ArtursKadikis the main thing I think many users would like to see is a version of the countly sdk that works in both node and the web. i.e. an ESM module, that doesn't include side-effects (not kicking off the IIFE).
However, for the sake of getting this resolved; Simply removing the IIFE, and using dependency injection should resolve many of our current problems as well as future issues without being too much of a burden on your team.
from countly-sdk-web.
@SgtPooki I'm not sure if that helps your specific usecase, but we already have a SDK that targets specifically NodeJS:
https://github.com/Countly/countly-sdk-nodejs
@BigLep on the timelines this currently seems more of a Q2 - Q3 kind of thing. This would include taking care of the window
object and XMLHttpRequest
that we currently use. This probably would not include any kind of tree-shaking type of functionality. That would probably require a more involved rework of the SDK which would break backwards compatibility in major ways.
from countly-sdk-web.
@ArtursKadikis any update on the removal of the window object and making the web SDK more webworker friendly?
from countly-sdk-web.
@SgtPooki Unfortunately, other priorities took over, and we did not have time to focus on web SDK for a while. Currently, we are looking into creating a new JS SDK that would be able to work in broader contexts.
Which features are you currently using?
from countly-sdk-web.
@turtledreams thanks for your feedback, I patched the sdk like so: https://github.com/ipfs/ipfs-companion/pull/1232/files#diff-a05913488f8fc1e2aa8f1c8f051438b7f05e9dca1ad8d185b793d48dfa6099cb
This seems to be able to ship metrics to countly. What doesn't work:
- anything related to
window
/document
- auto-track
- instrumentation logic.
And, that's fine, because what we need is building blocks for shipping metrics, the other functionality is nice to have or not needed in the webworker context.
As @SgtPooki mentioned before: Simply removing the IIFE, and using dependency injection should resolve many of our current problems
would be a good start, but if you want to plan for the future, you can publish this as an ESM and add the features as additional plugins.
from countly-sdk-web.
Hello,
Looks like it should be working in a web worker context. Will be closing this for now.
We can reopen in case there are any issues related to it.
from countly-sdk-web.
Related Issues (20)
- Do you offer a notification service for web HOT 2
- Element is Not Defined With React Integrations HOT 1
- Countly installs a non-compliant polyfill for Element.closest HOT 8
- Lighthouse error "Registers an unload listener" from the tracking script HOT 1
- Pass user agent with all requests HOT 1
- [Security Issue] Semi-persistent DOM XSS HOT 2
- How to integrate this sdk with βAnt Design Proβ? HOT 2
- Bug: Countly doesn't correctly remove consent for custom groups. HOT 3
- version inconsistencies HOT 2
- It is not possible to cancel the timed event HOT 5
- Session duration issues HOT 2
- Device ID not used for the queued queries when disabling offline mode HOT 1
- Can not work when the salt on Countly server is set HOT 5
- China map is displayed incorrectly HOT 1
- Recommendation: Any plan on modularising the application/splitting into multiple files and also any plan of converting to typescipt. HOT 6
- send json string to countly HOT 2
- Source maps
- Uncaught TypeError: Converting circular structure to JSON HOT 4
- CORS issue with Next.js and countly-sdk-web HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from countly-sdk-web.