You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Meta ships facebook/capi-param-builder-php, which implements the _fbp and _fbc semantics this bundle currently reimplements. It already arrives transitively through facebook/php-business-sdk (1.3.1 at the time of writing).
getClientIpAddress() and getEventSourceUrl() on top.
processRequest($host, $queries, $cookies, $referer, $xForwardedFor, $remoteAddress) takes explicit arguments, so nothing reads $_GET or $_SERVER. It autoloads cleanly.
Adopting it would supersede most of #20, #28 and #29.
What it costs
It becomes a direct require instead of a transitive one, so we own its version constraint.
It targets PHP 7.4 and declares no parameter or return types. At PHPStan level max every call site needs narrowing.
It is a whole-request abstraction: one call computes fbc, fbp, ip and source url together and returns the cookies to set. The bundle's Context classes are small decorators that a user can replace one at a time, which is a documented extension point.
It deals in strings, not the SDK's Fbc/Fbp value objects. User::$fbc accepts string|Fbc|null so that works, but FbcContextInterface::getFbc(): ?Fbc and FbpContextInterface::getFbp(): Fbp would have to change.
Suggested approach
Decide whether the decorator based Context extension point is worth keeping. If it is, wrap the builder in a single ParamBuilderFbcContext / ParamBuilderFbpContext pair and leave the interfaces alone, converting the strings back into Fbc/Fbp.
If it is not, collapse Context/Fbc, Context/Fbp, StoreFbcSubscriber and StoreFbpSubscriber into one subscriber driving the builder, and change the interfaces to return strings.
Either way, add the direct require and confirm PHPStan stays clean at level max.
Worth checking against a live browser session first: whether fbevents.js writes the same five segment shape the builder does, so that a cookie written by one is read correctly by the other.
Raised from review feedback on #39.
Meta ships
facebook/capi-param-builder-php, which implements the_fbpand_fbcsemantics this bundle currently reimplements. It already arrives transitively throughfacebook/php-business-sdk(1.3.1 at the time of writing).What it gives us
Run against the vendored copy:
getClientIpAddress()andgetEventSourceUrl()on top.processRequest($host, $queries, $cookies, $referer, $xForwardedFor, $remoteAddress)takes explicit arguments, so nothing reads$_GETor$_SERVER. It autoloads cleanly.Adopting it would supersede most of #20, #28 and #29.
What it costs
requireinstead of a transitive one, so we own its version constraint.Contextclasses are small decorators that a user can replace one at a time, which is a documented extension point.Fbc/Fbpvalue objects.User::$fbcacceptsstring|Fbc|nullso that works, butFbcContextInterface::getFbc(): ?FbcandFbpContextInterface::getFbp(): Fbpwould have to change.Suggested approach
Contextextension point is worth keeping. If it is, wrap the builder in a singleParamBuilderFbcContext/ParamBuilderFbpContextpair and leave the interfaces alone, converting the strings back intoFbc/Fbp.Context/Fbc,Context/Fbp,StoreFbcSubscriberandStoreFbpSubscriberinto one subscriber driving the builder, and change the interfaces to return strings.requireand confirm PHPStan stays clean at level max.Worth checking against a live browser session first: whether
fbevents.jswrites the same five segment shape the builder does, so that a cookie written by one is read correctly by the other.