matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.31k stars 2.59k forks source link

[Bug] Opt out not compatible with some older browsers #22215

Open tsteur opened 1 month ago

tsteur commented 1 month ago

What happened?

We offer the ability to embed a Tracking Opt Out see https://matomo.org/faq/general/faq_20000/

seeing https://github.com/matomo-org/matomo/pull/22210/files there is a const in the opt out code which makes me think the opt out is not functional on some older browsers such as IE 10. I didn't specifically test it but would assume this is the case.

In terms of tracking code we support also older browsers see text at the bottom in https://matomo.org/faq/new-to-piwik/faq_20541/

What should happen?

Make Opt out work with older browsers.

Or maybe the opt out iframe still works there and docs can be adjusted to make this clear?

How can this be reproduced?

Embed opt out in IE 10

Matomo version

5.0.0

PHP version

No response

Server operating system

No response

What browsers are you seeing the problem on?

Other

Computer operating system

No response

Relevant log output

No response

Validations

sgiehl commented 1 month ago

I've created a PR to fix the problem with const only, as that clearly breaks on older browsers. But we still need to do some testing on older browsers to see if everything else works correctly for the opt out. As part of this issue we should also consider adding tests for some older browsers, as we are currently only running test with latest chrome and will not see such problems early enough.

michalkleiner commented 1 month ago

As part of this work, it would great to define what older browsers we want to support for the tracker and/or what does 'on best effort basis' mean. With "we try to support as much as we can" there's no boundary and someone can always say "this doesn't work for me" or "we can't use that". Based on https://caniuse.com/const const is available to 97% percent of users.

rr-it commented 1 week ago

In this case the JS code is generated by PHP.

In general by using Closure Compiler it would be possible to define a target language spec like ECMAScript: ECMA-262, edition 3 and thereby ensure Browser Compatibility. java -jar closure-compiler-v20230502.jar --language_in ECMASCRIPT3 --language_out ECMASCRIPT3

See https://github.com/google/closure-compiler/wiki/Flags-and-Options#basic-usage

--language_out VAL Sets the language spec to which output should conform. Options: ECMASCRIPT3, ECMASCRIPT5, ECMASCRIPT_2015, ECMASCRIPT_2016, ECMASCRIPT_2017, ECMASCRIPT_2018, ECMASCRIPT_2019, ECMASCRIPT_2020, ECMASCRIPT_2021, STABLE, ECMASCRIPT_NEXT (latest features supported) (default: ECMASCRIPT_NEXT)