benvinegar / counterscale

Scalable web analytics you run yourself on Cloudflare
https://counterscale.dev
MIT License
1.34k stars 61 forks source link

Transitioning from Google Analytics to Counterscale: Implementing OSS Analytics Across Android, iOS, and PWA #64

Open xuelink opened 6 months ago

xuelink commented 6 months ago

I'm interested in transitioning from Google Analytics to an open-source solution, and Counterscale seems to meet my requirements. However, I have three clients: Android, iOS, and a Progressive Web App (PWA) for our OSS project. And we have discussed here about counterscale in our DG server if you are intetested in: invitation

Eventually we have decided to implement it and test it: https://github.com/langxapp/langx/issues/653

For the PWA (web app), implementing Counterscale should be relatively straightforward. However, I've previously integrated Google Analytics into my native Android and iOS apps by importing the 'google-analytics.plist' file or similar resources as data sources.

My concern is how to replace this setup with Counterscale. Is it feasible to collect data from native iOS and Android devices using Counterscale? If so, what would be the process? Do you have any documentation, references, or examples that could guide me through this?

benvinegar commented 6 months ago

That's exciting – just a note about this disclaimer in the README:

NOTE: Counterscale is currently in very early development and shouldn't be used in any actual production setting.

I just want to highlight that this isn't version 1.0 yet. I think it's "stable" in the sense that the infrastructure will stay up just fine and not cause you any maintenance burden from general operation. But the software will change.

My concern is how to replace this setup with Counterscale. Is it feasible to collect data from native iOS and Android devices using Counterscale? If so, what would be the process? Do you have any documentation, references, or examples that could guide me through this?

Counterscale has a single HTTP ingestion endpoint that processes the analytics data emitted from the client (tracker.js).

I'd be happy to document the endpoint in the README. But you'd have to figure out how to populate the endpoint with the relevant data from these different environments. I'm afraid I don't have any real iOS or Android experience that would be helpful, and I should add I didn't build this with any consideration for it being used outside of a web context (though I imagine it could).

xuelink commented 6 months ago

@benvinegar, I appreciate your kind and detailed explanation. No worries, I'll take a stab at sharing my experiences. It might yield some useful feedback!

Today, i forked this repo and implemented for several projects today: https://insight.langx.io/dashboard 1- https://langx.io tagged as website 2- https://token.langx.io tagged as token-website 3- https://insight.langx.io tagged as insight 4- web-app, ios and android tagged as app

Let's see how it reacts but the initial impression is that the dashboard opening is slow. If everything is ok then i should upgrade my free tier in CF because of following screenshot

Screenshot_2024-04-12_at_11 51 18_PM
benvinegar commented 6 months ago

Let's see how it reacts but the initial impression is that the dashboard opening is slow.

I'm feeling that too on counterscale.dev. It basically queues up like 8 simultaneous queries (in parallel) and if any of them are slow the whole thing will wait.

I think this recent change is affecting things negatively: 956163c653a1fb129e7dd3a472a4ea831927ec04

Going to do some more analysis and figure out if it's the cause, and if so, revert.

benvinegar commented 6 months ago

Perf issues documented in #68

Playing around, I don't feel 956163c is the cause. Even queries with low intervals (e.g. 7 days) can randomly just take 10 seconds.