Add opt-in Matomo cid visitor IDs#212
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in configuration to send the configured visitor ID using Matomo’s cid request parameter instead of _id, enabling explicit visitor matching behavior while preserving the existing default.
Changes:
- Introduces
VisitorIdParameter(idvscid) and exposes it onMatomoTracker/initialize(...). - Updates request serialization (
MatomoAction.toMap) to emit either_idorcidbased on configuration. - Adds tests, README documentation, and changelog entry for the new option (including validation for
cidrequiring 16 hex chars).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/src/matomo_test.dart | Adds initialization and validation tests for visitorIdParameter: cid. |
| test/src/matomo_action_test.dart | Ensures tracking payload uses cid instead of _id when configured; updates mocks accordingly. |
| test/src/dispatch_settings_test.dart | Updates mocks to stub visitorIdParameter for non-nullable getter use. |
| test/ressources/utils/get_initialized_mamoto_tracker.dart | Adds visitorIdParameter plumbing to test initializer helper. |
| README.md | Documents how/when to use Matomo cid and its constraints. |
| lib/src/visitor.dart | Defines the VisitorIdParameter enum and updates visitor ID docs. |
| lib/src/matomo.dart | Adds visitorIdParameter to tracker initialization and validates cid IDs as 16-hex. |
| lib/src/matomo_action.dart | Switches the outgoing visitor-id query key between _id and cid. |
| CHANGELOG.md | Adds an “Unreleased” entry for cid support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _validateVisitorIdParameter( | ||
| visitorId: visitorId, | ||
| visitorIdParameter: visitorIdParameter, | ||
| ); |
|
@stefan01 thanks for the contribution, before reviewing it can you link the documentation from Matomo that says the
|
|
Thanks for raising this. The documentation does not explicitly use the wording that The Tracking API reference documents both parameters as visitor IDs:
Matomo’s tracker implementation makes their relationship clearer: I agree regarding The change is opt-in: I’m happy to adjust the wording in the PR further so it says that |
Optionally send the visitor id as
cidinstead of_id