[ 
https://issues.apache.org/jira/browse/UNOMI-1023?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Serge Huber updated UNOMI-1023:
-------------------------------
    Description: 
h3. Summary

Websites that load the published tracker file directly get no tracking at all, 
and nothing tells the site owner. The tracker bundled with Unomi is not 
affected.

Technical detail: the UMD build throws "Buffer is not defined" in browsers, 
because es6-crawler-detect calls Buffer.byteLength. Also true of 1.5.0 and of 
es6-crawler-detect 4.x.

h3. Approach
* When Buffer exists, call the library as today.
* Otherwise, give it a Buffer.byteLength for that one synchronous call; nothing 
is left on window.
* No library upgrade on 1.x.

h3. How to test
* Unit tests: same byte count as Buffer.byteLength, same result with and 
without Buffer.
* yarn test:servers: works without a polyfill; requests identical to 1.5.0.

  was:
h3. Summary

A website that adds the Unomi tracker to its pages by loading the tracker file 
directly gets no tracking at all: no visitor data reaches Unomi and no 
personalisation is shown. Nothing visible tells the site owner that it is not 
working. The tracker bundled with the Unomi server is not affected, but sites 
that use the published tracker file are.

Technical detail: the UMD build (dist/apache-unomi-tracker.umd.js, the package 
"browser" entry) throws "Buffer is not defined" in a browser, so the tracker 
never starts. The crawler detection library es6-crawler-detect calls 
Buffer.byteLength in isCrawler(), which startTracker() always runs. Buffer is a 
Node API that browsers do not have. This is also true of the published 1.5.0, 
and of es6-crawler-detect 4.x. The tracker bundled with Unomi 
(extensions/web-tracker) works only because its build adds Node polyfills. 
Bundlers that add no Node polyfills (Vite, webpack 5) probably fail too.

The goal of this ticket is that the tracker builds run in a browser without any 
polyfill, without changing anything for the sites that work today.

h3. Decided approach
* When Buffer exists (Node, or a bundler polyfill such as the one in Unomi's 
bundled tracker), es6-crawler-detect is called exactly as today, so those sites 
see no change.
* When it does not exist, the library gets a Buffer.byteLength, with the same 
UTF-8 byte count as Node's, for the duration of the call only. The call is 
synchronous, so no other code on the page can see it, and nothing is left on 
window (some libraries change behaviour when they find a Buffer).
* No upgrade of es6-crawler-detect on the 1.x line, so crawler detection stays 
exactly the same there.
* The tracker sends the same requests as before.

h3. How to test
* Unit tests: the byte count matches Buffer.byteLength on edge-case strings 
(emoji, unpaired surrogates, the 4096-byte limit); crawler detection gives the 
same result with and without Buffer, and leaves no Buffer behind.
* yarn test:servers: the test page loads the tracker with no polyfill, against 
every supported server.
* yarn test:servers compare-1.5.0: the requests are identical to those of the 
published 1.5.0.



> Websites that load the Unomi tracker file directly get no tracking at all
> -------------------------------------------------------------------------
>
>                 Key: UNOMI-1023
>                 URL: https://issues.apache.org/jira/browse/UNOMI-1023
>             Project: Apache Unomi
>          Issue Type: Bug
>          Components: unomi-tracker
>    Affects Versions: unomi-tracker-1.5.0
>            Reporter: Serge Huber
>            Priority: Major
>             Fix For: unomi-tracker-1.6.0, unomi-tracker-2.0.0
>
>
> h3. Summary
> Websites that load the published tracker file directly get no tracking at 
> all, and nothing tells the site owner. The tracker bundled with Unomi is not 
> affected.
> Technical detail: the UMD build throws "Buffer is not defined" in browsers, 
> because es6-crawler-detect calls Buffer.byteLength. Also true of 1.5.0 and of 
> es6-crawler-detect 4.x.
> h3. Approach
> * When Buffer exists, call the library as today.
> * Otherwise, give it a Buffer.byteLength for that one synchronous call; 
> nothing is left on window.
> * No library upgrade on 1.x.
> h3. How to test
> * Unit tests: same byte count as Buffer.byteLength, same result with and 
> without Buffer.
> * yarn test:servers: works without a polyfill; requests identical to 1.5.0.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to