Commit Graph

180 Commits

Author SHA1 Message Date
Artur Pata a204c89066
Stop trying to compile detector and verifier on CE (#5857) 2025-11-03 09:22:55 +00:00
apata 2ad3c18f76 Released tracker script version 0.4.4 2025-10-31 08:01:23 +00:00
Artur Pata c9cbea7cd8
Add JSDoc types (#5842)
* Enhance TypeScript definitions for Plausible tracking library

Updated the plausible.d.ts file to improve documentation by adding JSDoc comments for all functions and properties. This enhances clarity and usability for developers integrating the tracking library.

* Update CHANGELOG.md to reflect changes in TypeScript definition comments for improved IDE integration

* Format

* Remove subtitle from changelog

---------

Co-authored-by: Ahmed Hassanein <eng.a7mad.gamal@gmail.com>
2025-10-31 07:56:01 +00:00
Artur Pata 2a6720cbfa
Update deps (#5837)
* Update playwright to 1.56.1

* chore: Bump tracker_script_version to 33

* Run audit fix for /assets

---------

Co-authored-by: apata <apata@users.noreply.github.com>
2025-10-28 08:44:42 +00:00
RobertJoonas a83b4f3583
Clean up legacy verification code and script v2 flag (#5824)
* add module name to service_error when check times out

Otherwise, it can sometimes remain unclear in the diagnostics, whether
it was InstallationV2 or InstallationV2CacheBust that timed out.

* Remove duplicate timeout logic

The current production logs show two types of verification timeouts:

* service_error: "Unhandled Browserless response status: 408" (vast
  majority of cases)
* service_error: :timeout (only a few cases)

The latter happens when we hit the Req receive_timeout
(endpoint_timeout + 2s). I've seen Browserless not respect the timeout
param from time to time, so it's better to keep the timeout logic
"in-house" only.

* make service_error into a map with code and extra

* interpret temporary service errors

...but still consider them "unhandled" for telemetry, also notifying Sentry
and logging the warning.

* separate sentry messages (verification)

* make Verification.ChecksTest more DRY

* organize tests into describe blocks

* test verification telemetry and logging

* fix codespell

* get rid of legacy verification

* rename Checks.InstallationV2 -> Checks.VerifyInstallation

* delete Live.Installation and rename Live.InstallationV2 -> Live.Installation

* rename installationv2 (live) files as well

* delete old change-domain routes

Also rename current liveview modules and routes, removing the v2 suffix

* rename domain_change_v2 files, removing v2 suffix

* remove legacy JS verifier code

Also fix dockerignore and elixir.yml referencing a wrong priv path

* rename verification_v2_test -> verification_test

* remove v2 prefix from logs and sentry messages

* clean up duplicate external_sites_controller_test.exs tests

* remove flag

* fix typespec

* pass timeout as query param to Browserless too

* Fixup external sites controller test module (#5826)

* fix test description

---------

Co-authored-by: Artur Pata <artur.pata@gmail.com>
2025-10-27 09:39:41 +00:00
Artur Pata 6b1821362f
Start passing official installs that are using legacy .compat script (#5812)
* Start passing official installs that are using legacy .compat installation

* Pass the first domain for verifying legacy compat installs

* Fix variable access issue

* Fix non-existent function call

* Comment why split domainString
2025-10-16 15:53:18 +00:00
Artur Pata 7b4d86f4bc
Retry on 408 timeout from Browserless.io (#5800)
* Retry on 408 timeout from Browserless.io

* Make Browserless retries configurable

* Override ignoring events

* Refactor
2025-10-14 12:17:51 +00:00
Artur Pata 3eeab00273
Make sure undefined callbackResult (ignored event) is visible in logs (#5802) 2025-10-14 08:54:20 +00:00
Artur Pata b03569d762
Update tests transformRequest tests (#5687) 2025-09-16 05:39:17 +00:00
apata aceef2d6d3 Released tracker script version 0.4.3 2025-09-15 11:25:59 +00:00
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 f7acb068d4
Script v2: Change priority of CSP related error for verifying manual installations (#5707)
* Add logic to find Plausible script tag

* Clarify where cookies fixtures come from

* Add case for snippet not found

* Fix issue with installation type not propagating to diagnostics

* Better struct definition

* Refactor verification tests to be more comprehensive

* Fix compile error related to Test.Support.DNS

* Fix DNS imports for CE

* Refactor when tracker is in HTML is detected
2025-09-11 06:59:03 +00:00
Artur Pata 88fccb6972
Script v2: Show "Plausible not detected" errors with installation type specific recommendations (#5693)
* Show Plausible not detected errors with installation type specific recommendations

* Update diagnostics and diagnostics tests for verification

* Format

* Stop calling statuses between 200..299 as errors

* Remove function that populates diagnostics randomly
2025-09-04 06:24:37 +00:00
apata ddc98670db Released tracker script version 0.4.2 2025-09-04 05:00:50 +00:00
Artur Pata 757cf95070
Script v2: Adds linter and prettier, satisfies linter (#5691)
* Install deps and create config

* Satisfy linter in tests

* Silence redeclare warnings

* Remove shadowed/redeclared variables

* Update changelog
2025-09-04 04:56:42 +00:00
apata 91e60fe148 Released tracker script version 0.4.1 2025-09-01 05:59:11 +00:00
Artur Pata af06df806b
Script v2: Verifier accepts cookies (#5669)
* Accept cookies (WIP)

* Make resolving Plausible function call a priority

* Update tracker script version

* Remove cookieBannerLikely, replace with debug-only cookiesConsentResult

* Use compact rules

* Make verifier tests less flaky

* Add fixtures for accepting cookies

* Limit CMPs

* Fix dep position
2025-09-01 05:54:19 +00:00
Karl-Aksel Puulmann 619a9ed57b
ScriptV2: Use async instead of defer, new snippet (#5655)
* async -> defer

* Run legacy tests using async instead of defer
2025-08-25 07:12:11 +00:00
Karl-Aksel Puulmann b36a92fb45
ScriptV2: snippet structure change (#5662)
* Remove dead code

* Use a new snippet style

* Allow plausible to be on window
2025-08-25 05:35:06 +00:00
Karl-Aksel Puulmann bcf8b422e1
ScriptV2: Domain change refinement (#5657)
* Improve "back to settings" button

* Dark mode support for change domain

* Purge CDN cache on domain change

* Allow npm installation_type

* Detect npm installation type in detector

* Support npm installation type in onboarding

* Show warning in change domain flow for npm

* Make CE tests happy

* Cleanup

* npm_likely -> npm

* Cleanup
2025-08-21 09:25:39 +00:00
Artur Pata 276f95cda2
Script v2: Make detection take less time (#5635)
* Add fast failing dns check to verification

* Convert Detection to a checks pipeline

* Convert detection to checks pipeline

* Unify browserless checks, set retry policy, timeouts

* Fix spelling

* Update change domain v2

* Fix issue with handling errors with detection

* Include timeoutMs in detector function args

* Allow saving npm installation type (#5639)

* small code style/comment improvements

---------

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2025-08-19 10:16:27 +00:00
Karl-Aksel Puulmann 428d9893e3
ScriptV2: Allow customizing lib passed from init (#5641)
* Allow customizing lib passed from init

Going to be used by GTM (and possibly wordpress) to make it easier to detect what source was used for install

* chore: Bump tracker_script_version to 28
2025-08-18 09:06:15 +00:00
Karl-Aksel Puulmann e52e9882c9
Bump eslint-plugin-playwright, add tracker-release: none label (#5645)
* Add support for `tracker release: none` label

* Update eslint-plugin-playwright

* Fix conditional

* chore: Bump tracker_script_version to 28
2025-08-18 09:02:01 +00:00
macobo 224ed8ed21 Released tracker script version 0.4.0 2025-08-12 06:58:32 +00:00
Karl-Aksel Puulmann a457ec5008
ScriptV2: Move tracker package under @plausible-analytics organization (#5627)
* Move tracker package under @plausible-analytics organization

* Remove notice
2025-08-12 06:52:54 +00:00
Artur Pata a2df9a986c
Script v2: Add more diagnostics cases to verifier v2, more tests for verifier v2 (#5620)
* Add more diagnostics cases to verifier v2, more tests for verifier v2

* Remove extraneous text from CSP in tests
2025-08-11 10:43:59 +00:00
dependabot[bot] ddba753710
Bump actions/download-artifact from 4 to 5 (#5626)
* Bump actions/download-artifact from 4 to 5

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update arch to get tracker CI to run

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Artur Pata <artur.pata@gmail.com>
2025-08-11 09:44:19 +00:00
Artur Pata 5807878a18
Script v2: Handle verifying sites where there's an immediate JS redirect (#5619)
* Handle canceled execution context when verifying v2 installs

* Show diagnostics even on verification success for superadmins

* Add check for scriptv2 user to support branching off to v2 site verification better
2025-08-07 07:51:22 +00:00
apata 24ddb486e8 Released tracker script version 0.3.6 2025-08-04 10:31:30 +00:00
Artur Pata a533116444
Fix unexpected config switch from calling init twice with plausible web (#5601) 2025-08-04 10:26:40 +00:00
apata fb4e2aa9a0 Released tracker script version 0.3.5 2025-08-04 10:13:55 +00:00
Artur Pata 9c35a0f47c
Script v2: Handle exceptions on clicks on links within svgs (#5538)
* Access href attribute more defensively to avoid uncaught errors

WIP

chore: Bump tracker_script_version to 22

Try accept limitation

Clarify issue with tagged link clicks within svgs

Fix potential error chain accessing object

Revert fixes about tagged events props

* Refactor script tests
2025-08-04 10:10:08 +00:00
Artur Pata 51647b323d
Shard playwright tests, cache tracker npm deps and browsers (#5603) 2025-08-04 09:49:10 +00:00
Artur Pata bb17a17e5a
Script v2: Allow verifying that tracker installed correctly (1st iteration) (#5572)
* Sketch out verification for v2 installs

* WIP

* Fix naming

* Implement CSP check, refactor what test event output looks like

* Update error matcher

* Better typedefs

* Unify error format

* WIP diagnostics

* Delete superfluos doc

* Remove prettierrc

* Fix type

* Remove superfluous error file

* Remove foobar.md

* Fix format and variable names, ensure compliance for errors

* Add cache bust check, fix success diagnostics

* Fix v2 verifier spec and add moduledocs

* Make test not dependent on tracker script version

* Make verifier less CPU intensive

* Change the signature of checkDisallowedByCSP

* Fix unused service_errror matcher

* Refactor data_domain to expected_domain

* Ignore request URL

* Add case for for succeeding after cache bust

* Fix infinite recursion

* Relax CSP error interpretation

* Fix sentry message, ignore plausible.s
2025-07-31 08:10:44 +00:00
RobertJoonas c5adbc6af0
Detector.js - detect v1 and technologies used on the website (#5591)
* fix comment on localhost dogfood tracking

* improve detector script and integrate into Elixir

* wait for window.plausible.l instead of window.plausible

* do not touch source files during compilation

* stop referencing compiler hint module attr
2025-07-29 06:17:16 +00:00
apata c82bc94019 Released tracker script version 0.3.4 2025-07-23 13:05:02 +00:00
Artur Pata 57400ab90b
Fix order of setting window.plausible.l = true (#5588)
* Fix order of setting window.plausible.l = true

* chore: Bump tracker_script_version to 25

---------

Co-authored-by: apata <apata@users.noreply.github.com>
2025-07-23 13:00:26 +00:00
RobertJoonas d8065557ef Released tracker script version 0.3.3 2025-07-22 10:11:28 +00:00
RobertJoonas 9be0b71233
Add `window.plausible` to NPM + `window.plausible.v2` (#5580)
* setWindowFlag

* bindToWindow

* set window.plausiuble.v2 flag

* chore: Bump tracker_script_version to 24

* fix billing test

* tracker changlog

* Update tracker/test/plausible-npm.spec.js

Co-authored-by: Artur Pata <artur.pata@gmail.com>

* update npm tracker changelog

* flattened window.plausible fields with more info

* remove unused function + readme update

---------

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
Co-authored-by: RobertJoonas <RobertJoonas@users.noreply.github.com>
Co-authored-by: Artur Pata <artur.pata@gmail.com>
2025-07-22 10:06:46 +00:00
RobertJoonas 97dcc3fe7c
Refactor Verification module structure (#5570)
* detector.js

* refactor: organize modules better

* Renaming (Elixir + JS)

* lib/plausible/verification -> lib/plausible/installation_support
* test/plausible/verification -> test/plausible/installation_support
* priv/tracker/verifier -> priv/tracker/installation_support
* tracker/verifier -> tracker/installation_support
* tracker/test/verifier -> tracker/test/installation-support

* rename remaining test modules

* add documentation

* dialyzer: remove module refs that do not exist yet

* Fix CI

* fix tracker CI

* fix tracker CI for good
2025-07-15 10:50:34 +00:00
RobertJoonas b76996b3a4
Verification v2 (#5549)
* new verifier script with tests + telemetry

* dataDomainMismatch tests

* more tests for callbackStatus and plausibleInstalled

* create priv/verifier subfolder + fix Elixir CI

* bump CI cache version

* organize verifier tests

* Remove accidentally committed verifier

* Rework compilation: Make it a variant, always return new verifier code in tests

* Make priv/tracker/verifier/ exist

* Handle static checks with grace

* Fix paths

* Fix paths

* Add some tests

* Add one more test

* split up the JS

* proxyLikely + code structure refactor + unit tests

* fix telemetry fields

* move most telemetry to logs

* run verifier tests only on chromium

* detect wordpressPlugin and wordpressLikely

* detect GTM

* rename JS checks

* detect cookiebot

* include new fields in logs

* different logs for browserless request vs js failures

* detect manual extension

* detect unknown attrs + fix logging

* stick to Elixir checks for snippet detection

* fix codespell

* fix IO.inspect

* remove unnecessary fields from test mock

* cookiebot doc

* move test into verifier subfolder

* do not duplicate ts types

* comma -> semicolon in log

* test dynamically loaded snippet

* improve logging on Browserless error

---------

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2025-07-14 14:32:21 +00:00
apata c92e0afc17 Released tracker script version 0.3.2 2025-07-14 08:43:43 +00:00
Artur Pata 3bdbe83383
Script v2: Sync event.props.path for special path-based events from event.pathname (#5559)
* Sync pathname to event.props.path for special path-based goals

* Stop adding event.props.path for 'Form: Submission' events

* Update tracker script version

* Fix test expectations

* Fix format

* Simplify maybe_put_props_path with 'with'

* Add specs, fix factory

* Update tracker changelog

* Update EE/CE changelog

* Remove business logic from factory

* Refactor event.props.path sync result to be validated with the rest of the custom props

* Clarify doctests and update function name
2025-07-14 08:39:25 +00:00
apata e12579f13f Released tracker script version 0.3.1 2025-07-08 08:08:18 +00:00
Artur Pata 04f455cbfc
Script v2: Do not send Form: Submission events for tagged forms (#5546)
* Do not send duplicate tagged form events

* Update changelog

* chore: Bump tracker_script_version to 22

* Share HTML fixture

---------

Co-authored-by: apata <apata@users.noreply.github.com>
2025-07-08 08:01:14 +00:00
apata 627db388c9 Released tracker script version 0.3.0 2025-06-27 12:17:00 +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
macobo c19ca2ec60 Released tracker script version 0.2.4 2025-06-19 08:51:53 +00:00
Karl-Aksel Puulmann 1f86ae55ef
ScriptV2: `callback`, file downloads and `logging` changes (#5514)
* Make logging in tracker script configurable

* Improved callbacks

* Improved fileDownloads

* Export DEFAULT_FILE_TYPES

* Cross-browser compatibility

* Rename

* Rename a test

* chore: Bump tracker_script_version to 20
2025-06-19 08:45:20 +00:00
apata 9256f4ff9c Released tracker script version 0.2.3 2025-06-17 10:17:07 +00:00