matomo-org / matomo-java-tracker

Official Java implementation of the Matomo Tracking HTTP API.
https://matomo-org.github.io/matomo-java-tracker/
BSD 3-Clause "New" or "Revised" License
69 stars 52 forks source link

Update Matomo Java Tracker for Singular Parameters #163

Closed dheid closed 12 months ago

dheid commented 1 year ago

Currently, the Matomo Java Tracker application allows for the same query parameter to be added multiple times using the additionalParameters method. However, this behavior is not consistent with the Matomo Tracking HTTP API, as it allows only one occurrence of a parameter.

Proposed Solution:

Modify the Matomo Java Tracker code to enforce a singular occurrence of each parameter in the URL when using the additionalParameters method. This adjustment aligns with common URL parameter practices and helps prevent potential confusion or unexpected behavior.

Additional Information:

  1. Current Behavior: The additionalParameters method allows the same parameter name to be added multiple times, resulting in duplicate parameters in the URL.

  2. Proposed Behavior: Update the code to ensure that only one occurrence of each parameter is allowed in the URL when using the additionalParameters method.

  3. Rationale: Having multiple occurrences of the same parameter in a URL can lead to confusion and is not a standard practice. The proposed modification aims to enhance consistency and adherence to established conventions.

Steps to Reproduce:

  1. Use the additionalParameters method to add the same parameter multiple times.
  2. Note the resulting URL with duplicate parameters.

Expected Result: The Matomo Java Tracker should restrict the addition of duplicate parameters, ensuring only one occurrence of each parameter in the generated URL.

Additional Comments: This change will improve the overall usability and conformity of the Matomo Java Tracker, aligning it with widely accepted URL parameter practices.