Upgrade to the Meta Conversions API bundle 1.0 and SDK 2.0 - #89
Merged
Merged
Conversation
Events are now sent to Graph API v26.0 instead of v14.0. Meta retired everything up to and including v20.0 on 24 September 2026. Two things in the plugin had to follow, and neither fails loudly when it is missing: the event is just dropped. - The bundle's service ids are FQCNs now, so the compiler pass aliases PixelProviderInterface instead of the removed setono_meta_conversions_api.pixel_provider.default. With the old id the bundle fell back to the pixels from its own configuration, i.e. none. - The bundle asks the pixel provider for the access tokens again when an event is sent, which may be in a Messenger worker where there is no request and hence no channel. The provider returns every enabled pixel then, through the new PixelRepositoryInterface::findEnabled(). The tokens are matched by pixel id, so this never adds a pixel to an event.
The test application's http client gets a mock response factory that records the requests, so the functional tests can assert on the pixel, the access token and the Graph API version of what would be sent, both for an event raised during a request and for one sent by a worker. It also means that no test can send anything to Meta.
The readme explains how to allow the pre-releases, replaces the http client step, which a Sylius application does not need, with how to send the events asynchronously, and describes the test event code. The upgrade guide lists what a shop has to do, first of all to let the Messenger transport drain before deploying.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.x #89 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 110 113 +3
===========================================
Files 25 25
Lines 400 410 +10
===========================================
+ Hits 400 410 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #88.
Moves the plugin to
setono/meta-conversions-api-bundle^1.0@alpha(was~0.1.5) andsetono/meta-conversions-api-php-sdk^2.0@alpha(was~0.2.4). Events are sent to Graph API v26.0 instead of v14.0. Meta retires everything up to and including v20.0 on 24 September 2026.Why this is more than a version bump
With only the constraints changed,
lint:containerpassed and all unit tests were green, while every event was dropped. Nothing in the chain fails loudly when the plugin is wired wrongly.OverrideDefaultPixelProviderPassaliasedsetono_meta_conversions_api.pixel_provider.default, which no longer exists, soPixelProviderInterfacekept pointing at the bundle's configuration based provider, i.e. at no pixels. It aliasesPixelProviderInterface::classnow.DoctrineBasedPixelProviderasked Sylius for the channel there and got aChannelNotFoundExceptionin a shop with more than one channel. It now takes theRequestStack: with a request it returns the enabled pixels of the current channel, as before, and without one it returns every enabled pixel, through the newPixelRepositoryInterface::findEnabled(). The tokens are matched by pixel id against the pixels the event was raised for, so this never adds a pixel to an event.Tests
PixelProviderTest(functional): the container resolvesPixelProviderInterfaceto the plugin's provider, and the provider returns the right pixels with and without a request.ServerSideTrackingTest(functional): the whole way fromConversionsApiEventRaisedto the request, with a recording mock response factory on the test application's http client. It asserts the pixel, the restored access token and that the Graph API version is at least 21, for an event raised during a request and for one sent outside of one. No test can send anything to Meta anymore.Docs
php-http/discoveryplugin, sending the events asynchronously instead of the http client step (a Sylius application already ships withsymfony/http-clientandnyholm/psr7), and the test event code, which only works whenkernel.debugis true now.SendEventchanged shape.Worth knowing when reviewing
DoctrineBasedPixelProvider::__construct()got a third argument andPixelRepositoryInterfacegotfindEnabled(). Both are needed for the worker case and are described in UPGRADE.md.SendEventon the default bus, which issylius.command_busin a Sylius application, with thevalidationanddoctrine_transactionmiddleware. Every event the plugin raises comes from a shop controller, never from inside another handler or an open transaction, so this is safe, and the plugin keeps the bundle's default.setono_meta_conversions_api.server_side.message_busis documented for those who want another bus.Verified locally (PHP 8.3)
composer validate --strict,composer normalize --dry-run, ECS, PHPStan, Rector,lint:container,lint:yaml, 76 unit and 15 functional tests, Infection at 87% (threshold 87; 164 of 188 killed, single threaded). Smoke test on the dev server: the pages return 200, only the enabled pixel of the channel is initialised,ViewContentis rendered client side, and server side the request reached Meta, which rejected the dummy access token of the dev database. That was logged on thesetono_meta_conversions_apichannel and did not break the page.