Skip to content

Require SDK ^2.0.0-beta.2 and use the PayloadContext enum - #58

Merged
loevgaard merged 1 commit into
masterfrom
fix/sdk-2.0-beta.2
Sep 21, 2026
Merged

loevgaard merged 1 commit into
masterfrom
fix/sdk-2.0-beta.2

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Problem

A fresh install of v1.0.0-alpha.1 is broken, and so is any existing install that runs composer update.

v2.0.0-beta.2 of the SDK replaced Parameters::PAYLOAD_CONTEXT_BROWSER with the PayloadContext enum. It is called out there as a breaking change within the beta series. The bundle uses that constant in one place, AddEventToTagBagSubscriber, when it renders the fbq('init', …) call.

Nothing keeps beta.2 out: the bundle requires ^2.0.0-alpha.3, and the install command in the release notes uses ^2.0@alpha. Both match a beta, so Composer resolves to beta.2. The result is an undefined constant Error thrown from a listener on ConversionsApiEventRaised, which propagates into the controller: a 500 on every page that raises an event with client side tracking enabled. Server side only setups are not affected, and neither is an install that stays locked on alpha.3.

Found by installing beta.2 on master and running the suite: 4 errors, 2 failures, and PHPStan flagging the same line.

Change

  • getPayload(Parameters::PAYLOAD_CONTEXT_BROWSER) becomes getPayload(PayloadContext::Browser).
  • The constraint floor moves to ^2.0.0-beta.2, the first release that has the enum. --prefer-lowest resolves to it.
  • UPGRADE.md tells consumers to allow ^2.0@beta rather than @alpha.

The two failures were tests, not behaviour. v2.0.0-beta.1 accepts a subdomain index above 2, which is what Meta writes for a cookie set on a deeper domain such as a.b.example.co.uk. Two tests asserted that fb.3.… is rejected. They now use an index with a leading zero, which beta.2 still rejects (checked, not assumed), and fb.3.… is added as a value that must parse, for both _fbc and _fbp. The bundle benefits from that change without any code of its own.

Nothing else in the two betas touches the bundle: it does not subclass Event, so the getMapping() signature change does not apply.

After merging

This needs a new pre-release of the bundle. v1.0.0-alpha.1 cannot be repaired, since a published tag's composer.json is fixed, but fixing forward is enough: ^1.0@alpha resolves to the newest pre-release, so anyone installing gets the working one.

One thing to weigh, because this is the second time in a day an SDK pre-release broke a caret range (alpha.2's exception model was the first): the SDK's notes say its API "may still change", and a caret on a pre-release trusts that it will not. Pinning the SDK exactly until 2.0 is stable would make each bundle release work with precisely what it was tested against, at the cost of a bundle release per SDK pre-release. Not done here; the constraint stays a caret, as before.

Verified on PHP 8.1 and 8.4, with --prefer-lowest and highest, plus PHPStan, ECS, Rector, the dependency analyser, composer validate and composer normalize. 174 tests.

beta.2 of the SDK replaced Parameters::PAYLOAD_CONTEXT_BROWSER with the
PayloadContext enum. The bundle used the constant when rendering the
fbq() init call, and its ^2.0.0-alpha.3 constraint also matches a beta,
so a fresh install resolved to beta.2 and threw an undefined constant
Error from an event listener, i.e. a 500 on every page that raises an
event with client side tracking enabled.

Use PayloadContext::Browser and move the constraint floor to beta.2,
the first release that has the enum.

beta.1 also accepts a subdomain index above 2, which Meta writes for a
cookie set on a deeper domain. Two tests asserted that such a value is
rejected; they now use an index with a leading zero, which still is,
and a deeper domain is covered as a value that must parse.
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.95%. Comparing base (06dcc17) to head (503dc53).

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #58   +/-   ##
=========================================
  Coverage     97.95%   97.95%           
  Complexity      156      156           
=========================================
  Files            32       32           
  Lines           489      489           
=========================================
  Hits            479      479           
  Misses           10       10           
Files with missing lines Coverage Δ
src/EventSubscriber/AddEventToTagBagSubscriber.php 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@loevgaard
loevgaard merged commit 5c66e80 into master Sep 21, 2026
91 checks passed
@loevgaard
loevgaard deleted the fix/sdk-2.0-beta.2 branch September 21, 2026 13:10
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.

1 participant