Tidy the public API before 1.0 - #57
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| $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']); |
There was a problem hiding this comment.
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
b740807 to
e87c757
Compare
Fixes #27. Replaces #52, which was merged into its base branch
fix/29-cookie-domainrather than intomaster, so its changes never reachedmaster. Same single commit, now based directly onmasteras 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::$contextis 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 inREADME.md, and it gained thegetContext(string $key, mixed $default = null)accessor it was missing next tohasContext().CommandInterfaceis 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::$eventand::$contextarereadonly. TheEventobject stays mutable, which is what enrichment listeners need, but the properties can no longer be swapped.Removed
setono_meta_conversions_api.client_side.enabledand.server_side.enabledcontainer 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-lowestand highest.