You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
countly-web-sdk ships as an iife which bundles everything, including dependence on window object and implements XMLHttpRequest. Both of these are blockers for implement countly in webworkers (companion background worker and service workers)
Proposed Fix:
Since not all APIs are used by ignite-metrics, it's possible to write a minimal set of function calls that can call countly endpoints from within the webworker.
APIs Needed:
Authentication Flow
Session Create Flow
Push Event Flow
Other considerations:
We already implement an eventAccumulator
We will need a batching mechanism to not overwhelm the endpoint.
Limitations:
webworkers don't have access to DOM, window, XMLHttpRequest and localStorage, so:
use fetch to open connections to countly endpoints
use indexedDB for storage needs. The browser API is awful to use, but projects like Dexie provide a decent API to work with indexedDB.
Shipping:
Since webpack supports webworker build target as of v5. We can simply provide an export target without changing a lot of things.
Other Thoughts
If countly can implement a modular SDK, we might be able to treeshake most of unreachable code and shim window if still needed.
In the short term this can help unblock and have light and sane way of communicating with countly.
@BigLep It's about a week worth of effort. I talked with @whizzzkid about this and I believe I could get this done before EOW in a way that works for us, though it would be somewhat hacky.
Blocks: ipfs/ipfs-companion#1127
Related: Countly/countly-sdk-web#382
The issue:
countly-web-sdk
ships as an iife which bundles everything, including dependence onwindow
object and implementsXMLHttpRequest
. Both of these are blockers for implement countly in webworkers (companion background worker and service workers)Proposed Fix:
DOM
,window
,XMLHttpRequest
andlocalStorage
, so:fetch
to open connections to countly endpointsindexedDB
for storage needs. The browser API is awful to use, but projects likeDexie
provide a decent API to work withindexedDB
.webworker
build target as of v5. We can simply provide an export target without changing a lot of things.Other Thoughts
window
if still needed.CC: @SgtPooki
The text was updated successfully, but these errors were encountered: