Commit Graph

7 Commits

Author SHA1 Message Date
Artur Pata cc5ca4b752
Script v2: Apply prettier (#5718)
* Apply prettier

* Fix issue with quotes in test setup

* Fix other issues with customSubmitHandlerStub

* Fix format with cookies fixtures
2025-09-15 11:21:27 +00:00
Artur Pata 74dddc241c
Script v2: Remove delays except when using .compat extension (#5465)
* Make delays conditional on COMPILE_COMPAT, otherwise rely on keepalive fetch

* Add tests

* Fix webkit related test file-download feature tests issues

* Remove ternaries for scriptConfig in tests

* Make sure .compat scripts don't contain unreachable code blocks

* Test legacy .compat extension in a separate block

* Tests for tagged events

* Remove extraneous tests, add needed tests

* Add tests for v2 features overlap and outbound link clicks

* Add changelog, add current behaviour test for outbound links

* Remove mockRequest, unify API

* Fix coverage of legacy compat navigation, add back interactive event test

* chore: Bump tracker_script_version to 21

* Update specs

* Fix issues with _ variable

* Fix args

* Types and formatting cleanup

---------

Co-authored-by: apata <apata@users.noreply.github.com>
2025-06-27 12:10:02 +00:00
Karl-Aksel Puulmann 7265d04a8c
ScriptV2: Improved tracker compile.js (#5363)
* Add CLI arguments to compile.js and logging

* Rename folder

* Extract compile code, es modules

* Add a progress bar

* Remove handlebars

* Update report-sizes

* Remove debug code

* inline

* More generous split

* Allow positional arguments for compiling

* Add watch option to compile

* Add compileFile logic

* Most tests run under playwright

* All tests runnable

* Update playwright, remove hack

Note that upgrading to latest failed due to a new test failure. This
might be due to a chrome update.

* Compile script on the fly for tests

* Minor refactor for compileAll

* es module for generate-variants.js

* Allow passing suffix to compilation script - this can be used to generate separate files for comparison

* Fix positionals

* Switch from 2 passes to 1 pass

Did some data analysis on this data:
- Compared to master, 1 pass increased brotli size by 0.7%, 2 passes 0.4%.

Given the change is insignificant enough, we can ignore it for now

The increase is likely due to order of operations in compilation and
some inlined functions getting lost.

* Move customEvents.js to plausible.js

* Clean up API

* Suffix default

* Rework variants.json, globals stored there

* Add more variants under test

* Distribute work across multiple worker threads

Compile time went on my machine from 60s -> 30s

* Fixup server

* Update canSkipCompile

* chore: Bump tracker_script_version to 7

* Update scripts

* Update node-version

* Experiment with adding a small delay to page

* Casing

* rename variable

* Update help text

* features -> compileIds, backport functionality from other branch
2025-05-08 07:05:09 +00:00
RobertJoonas f262bea316
Average Scroll Depth Metric: Track custom props on pageleaves (#4964)
* improve tracker test util to handle custom props

* track pageleave props

* make test util more powerful

* also test with pageview-props extension

* add test for sending props on hash navigation

* simplify tracker logic around currentPageLeaveURL

* clarify the intent of a timeout by extracting a fn

* bugfix: stop sending pageleaves from ignored pages

+ fix the test to actually fail if this doesn't work.

* refactor: drop expectCustomEvent in favour of the new test util

* add test for pageleave props ingestion

* add query tests

* improve test util readability
2025-01-16 15:06:19 +00:00
RobertJoonas 2a7d02b6f0
Average Scroll Depth Metric: extracted tracker changes (#4826)
* (cherry-pick) implement scroll depth tracking under pageleave variant

* drop unnecessary vars

* remove unused require

* add scroll depth tests

* improve error messages in test util

* reevaluate currentDocumentHeight on page load

* account for dynamically loaded content when initializing documnent height

* remove all semicolons from tracker specs

* allow window and document globals in tracker eslint

* tweak global tracker dir eslint rules

* update comment

* reevaluate document height on scroll

* add test

* remove unneccessary timeout
2024-11-21 14:29:52 +00:00
RobertJoonas 37116a2b12
Add tests for the pageleave script (#4744)
* move util function to util module

* move playwright config file to tracker dir root

* update Playwright + add gitignores

* Playwright: enable reuseExistingServer (non-CI env)

* store tracker src copies to avoid re-compilation in dev env

* test pageleave on simple navigation

* fix test util fn

* rename local_test npm script

* make test util able to expect multiple requests

* test pageleaves in SPAs

* test pageleave with manual URL

* test pageleave not sent in manual when pageview not triggered

* extend util fn to refute event requests

* test pageleaves not sent in excluded hash pages

* store hashes instead of file copies to detect /tracker/src changes

* drop async

* speed up test suite
2024-10-28 15:30:03 +00:00
RobertJoonas af94f01310
Fix experimental pageleaves script (SPAs) (#4667)
* bugfix: make sure to send pageleave with current URL

* another bugfix: avoid triggering pageleaves in SPAs unless listeningPageLeave is true

* revert behavioural change in manual extension

* test manual script extension
2024-10-14 09:34:47 +00:00