ihucos / counter.dev

Web Analytics made simple
https://counter.dev
GNU Affero General Public License v3.0
914 stars 39 forks source link

Tracking JavaScript not compatible with every browser - IE not tracked. #5

Open ihucos opened 3 years ago

ihucos commented 3 years ago

A user noted that his browser does not support URLSearchParams and that for some browses like IE and older browsers fetch is not supported.

Each of this features are independently from each others supported by ~95% percent of all browsers.[1] With IE not supporting these two features at all and therefore not being tracked.

Not tracking IE is of course undesirable since it could be interesting for users to know how many of it's users are using IE in order to better evaluate if supporting it is worth it. Additionally I know there are potential users where a considerable percentage of users could be IE - for example internal webpages for corporations or governments where most users have to use IE.

On the other hand, we have that one of the design decisions of SWA is to not have a separate javascript file that is included but instead the tracking javascript embedded into the source. This is done like this for security reasons and because it's cheaper and SWA is a free service that is privacy friendly.

Having the embedded inline script not use fetch and URLSearchParams may be possible, but would make it longer and more complex.

Weighting this, my current opinion is that having a shorter and more legible tracking code and the transparency with that is more valuable than supporting more browsers and track IE. With time this issue may become more and more irrelevant.

I am very open to other opinions, a discussion or a concrete suggestion how the tracking code could look like so more browsers are supported :-)

[1] https://caniuse.com/#search=fetch https://caniuse.com/#search=URLSearchParams

jcubic commented 3 years ago

If you care about this you can add documentation that the one that want to use IE can add polyfill. There is even free service that add polyfills anyone can include that with the tracking code. to support fetch and URLSearchParams. https://polyfill.io/v3/

If you want I can create polyfill for both APIs (implementations most likely already exists) that can be put into documentation if anyone want to support older browsers.

jcubic commented 3 years ago

This is minfied implementation for Polyfill I've found. but I didn't test it though.

counter.min.txt

the code is based on

Unfetch is some old version I had in my other project and url-search param is just minimum that make the constructor work, I hope.

2kB of data if someone would like. I can test on BrowserStack where I have access to Windows machine.

jcubic commented 3 years ago

Just an idea, you can create server script that serve this data like polyfil.io user will include this script that will give output only for IE.

ihucos commented 3 years ago

Thats a really cool idea. Did not think of it. I will leave it open until more people ask for this. Currently there is no real documentation where this could go in.

hello-smile6 commented 2 years ago

Please add this!