Store the partner id in the client metadata of setono/client-bundle instead of a plugin cookie - #61
Open
loevgaard wants to merge 1 commit into
Open
Store the partner id in the client metadata of setono/client-bundle instead of a plugin cookie#61loevgaard wants to merge 1 commit into
loevgaard wants to merge 1 commit into
Conversation
The plugin no longer sets a cookie of its own. The partner id captured from the affiliate link is stored in the metadata of the visitor's client (setono/client-bundle), which recognises returning visitors through its own cookie and persists changed metadata itself at the end of the request. A small PartnerIdStorageInterface keeps the subscribers independent of the bundle and makes the storage swappable. The attribution window stays configurable in days (attribution_window, default 40) and becomes the metadata key's TTL. The legacy 2.x cookie is not imported; UPGRADE.md says so. Claude-Session: https://claude.ai/code/session_01Mt12J8vdGwwWg4V23uoEf9
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.x #61 +/- ##
============================================
- Coverage 84.85% 84.24% -0.62%
+ Complexity 101 99 -2
============================================
Files 21 21
Lines 535 514 -21
============================================
- Hits 454 433 -21
Misses 81 81 ☔ 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.
What changed
The plugin no longer owns a cookie. The partner id captured from an affiliate link is stored in the metadata of the visitor's client provided by setono/client-bundle (v1.2), which recognises returning visitors through its own
setono_client_idcookie and persists changed metadata itself atkernel.finish_request.PartnerIdStorage\PartnerIdStorageInterface(store(int),get(): ?int) withClientMetadataPartnerIdStorage: writes the id under the namespaced keysetono_sylius_partner_ads.partner_idwith the attribution window as TTL; on read it re-validates throughPartnerIdParserand deliberately never removes an invalid value (a write at checkout would make the bundle flush during checkout). Same pattern asSyliusGoogleAdsPlugin.EventListener\CapturePartnerIdSubscriber(replacesSetCookieSubscriber) onkernel.request: same guards and validation as before, thenstore(). Last click wins.CreateConversionSubscriberreads through the storage; theRequestStackdependency is gone. Its docblock now explains the checkout-time cost: one lazy SELECT by the bundle, no writes (an expired key is pruned and persisted by the bundle after the order is committed).cookienode (name,expire) is removed;attribution_window(days, default 40, min 1) replacescookie.expire.setono/client-bundle ^1.2andsetono/client ^1.1.2added;symfony/http-foundationno longer required directly. The test application registersSetonoClientBundle.Breaking changes
CookieHandler\CookieHandler,CookieHandler\CookieHandlerInterface,EventListener\SetCookieSubscriber(the BC job flags exactly these — expected on3.x).cookie.*removed;attribution_windowadded.SetonoClientBundleand migrate (setono_client__metadata).All of this is in
UPGRADE.md; the README gained the bundle registration step, an attribution-window step and a "Consent and privacy" section (consent via the bundle'sPreStoreCookieEvent);CLAUDE.mdis updated accordingly.Tests
ClientMetadataPartnerIdStorageTest(TTL arithmetic, overwrite/restart, expiry, invalid stored values remain untouched),CapturePartnerIdSubscriberTest, a kernel-bootPartnerIdStorageTestproving bundle registration and wiring (no database needed);CreateConversionSubscriberTest,ConfigurationTest(incl. rejecting the removedcookienode) and the extension test updated; cookie tests removed.lint:container,doctrine:schema:validate(withsetono_client__metadatacreated), 172 tests, and Infection at 100% on the changed files all pass locally.Closes #53 once merged: the plugin sets no cookie any more; consent and the IP disclosure are documented. The
Secureflag question now concerns the bundle's cookie.