Skip to content

Tidy the public API before 1.0 - #57

Merged
loevgaard merged 1 commit into
masterfrom
fix/27-public-api
Sep 14, 2026
Merged

loevgaard merged 1 commit into
masterfrom
fix/27-public-api

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Fixes #27. Replaces #52, which was merged into its base branch fix/29-cookie-domain rather than into master, so its changes never reached master. Same single commit, now based directly on master as requested.

Problem

The Roave BC check will lock the public surface in at 1.0, and a few things were public but unused, undocumented, or both.

Change

Kept and documented

  • ConversionsApiEventRaised::$context is the way to hand your own listeners data that must never reach Meta, such as the order the event was raised for. It now says so in the docblock and in README.md, and it gained the getContext(string $key, mixed $default = null) accessor it was missing next to hasContext().
  • CommandInterface is genuinely useful for routing every command the bundle dispatches as a group. The docblock now shows the routing snippet, and the README mentions it.

Tightened

  • ConversionsApiEventRaised::$event and ::$context are readonly. The Event object stays mutable, which is what enrichment listeners need, but the properties can no longer be swapped.

Removed

  • The setono_meta_conversions_api.client_side.enabled and .server_side.enabled container parameters. No service read them once the subscribers became conditional, and whether a side is on is already visible from whether its services exist.

Tests

A test for getContext() including the default, and the extension test drops its assertions on the two removed parameters.

Note

The rest of the series (#49, #50, #51, #53, #54, #55, #56) has been re-chained to sit behind this one, so merging this first is the intended order. Each was re-verified on PHP 8.1 and 8.4, with --prefer-lowest and highest.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.93%. Comparing base (df977e6) to head (e87c757).

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #57   +/-   ##
=========================================
  Coverage     81.93%   81.93%           
- Complexity      148      149    +1     
=========================================
  Files            31       31           
  Lines           487      487           
=========================================
  Hits            399      399           
  Misses           88       88           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines -37 to -38
$container->setParameter('setono_meta_conversions_api.client_side.enabled', $config['client_side']['enabled']);
$container->setParameter('setono_meta_conversions_api.server_side.enabled', $config['server_side']['enabled']);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because nothing reads them any more. Every other parameter the extension sets is consumed by a service definition:

%setono_meta_conversions_api.consent.category%
%setono_meta_conversions_api.consent.enabled%
%setono_meta_conversions_api.filters.user_agent%
%setono_meta_conversions_api.pixels%
%setono_meta_conversions_api.test_event_code.query_parameter%
%setono_meta_conversions_api.test_event_code.value%

These two are not, in src/, in any of the XML files, or in the tests. They went dead earlier in this 1.0 series: the subscribers for each side used to be registered unconditionally and check a flag at runtime, so they needed the parameter. Now the extension only loads services/conditional/client_side.xml and services/conditional/server_side.xml when the corresponding side is enabled, so whether a side is on is visible from whether its services exist.

The argument for keeping them, which is why this is your call rather than mine: a parameter is the only convenient way for your application, or another bundle, to ask at runtime whether a side is enabled. $container->has(DispatchOnCommandBusSubscriber::class) only works at compile time, and once 1.0 is tagged the BC check makes putting them back a minor release rather than a free change.

Say the word and I will restore both and document them in the README as public flags instead. Otherwise the removal stands as described in UPGRADE.md.

The Roave BC check will lock this surface in, so decide on the parts
that were public but unused.

Keep the event context and document it as the way to pass data to your
own listeners, adding a getContext() accessor; keep CommandInterface and
document routing by interface; make the event properties readonly; and
drop the two container parameters no service reads.

Fixes #27
@loevgaard
loevgaard merged commit 0c26905 into master Sep 14, 2026
47 checks passed
@loevgaard
loevgaard deleted the fix/27-public-api branch September 14, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove or document unused public API before 1.0

1 participant