Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #51 +/- ##
============================================
+ Coverage 97.95% 98.07% +0.12%
- Complexity 151 158 +7
============================================
Files 32 33 +1
Lines 488 519 +31
============================================
+ Hits 478 509 +31
Misses 10 10
🚀 New features to boost your workflow:
|
eb5e4ab to
4bb3064
Compare
3f605cd to
d692d8b
Compare
4bb3064 to
0cb43bc
Compare
d692d8b to
17decfb
Compare
0cb43bc to
11986eb
Compare
17decfb to
8132598
Compare
11986eb to
25b8339
Compare
8132598 to
1b315b0
Compare
25b8339 to
9040b2c
Compare
1b315b0 to
2844117
Compare
9040b2c to
1752b17
Compare
2844117 to
c939840
Compare
1752b17 to
97ab8f5
Compare
c939840 to
e7e75f9
Compare
97ab8f5 to
3a3a2e3
Compare
e7e75f9 to
cf58c0c
Compare
3a3a2e3 to
659351d
Compare
cf58c0c to
c7e08ee
Compare
659351d to
176bc4b
Compare
c7e08ee to
8e1ec90
Compare
176bc4b to
749cb00
Compare
8e1ec90 to
c5e3b32
Compare
749cb00 to
6a31353
Compare
c5e3b32 to
4c4083c
Compare
Meta writes the fbp and fbc cookies on the registrable domain and encodes that level in the value. The bundle wrote host-only cookies while always claiming level 1, so apex and www got different cookies whose values disagreed with where they were set. Add cookies.domain and cookies.lifetime, and derive the subdomain index from the domain the cookie is actually written on. Fixes #29
6a31353 to
0fb55dd
Compare
4c4083c to
af4b440
Compare
|
Closing without merging. The The remaining part, deriving the subdomain index from the host so the value agrees with where the cookie was set, is correct but small, and there is no evidence Meta rejects the mismatch. If the SDK adopts the The branch is deleted here; the work is kept locally if any of it is ever wanted. |
Fixes #29
Problem
Meta writes
_fbpand_fbcon the registrable domain and encodes the level it used in the second segment of the value:fb.1.meansexample.com,fb.2.meanswww.example.com,fb.0.means a single label host.The bundle created host-only cookies, because no domain was ever passed to
Cookie::create(), while the SDK value objects default the subdomain index to 1. So onwww.example.comthe cookie was scoped to that host but its value claimed it was set on the registrable domain. A visitor moving between the apex,wwwand a checkout subdomain got different cookies, and the browser pixel could write its own domain cookie alongside the server's host-only one, giving one person two_fbpvalues.Change
New options:
A new
Cookie\CookieDomainservice answers two questions: which domain to write on, and what subdomain index goes with it. The index is the number of dots in the domain the cookie actually ends up on, which is exactly how Meta's own parameter builder computes it:It is capped at 2, since the SDK asserts the value is 0, 1 or 2.
Crucially the index is applied where the value is created, in
GeneratedFbpContextandQueryBasedFbcContext, not where the cookie is written. That keeps the value in the cookie and the value sent to Meta identical. A value parsed from an existing cookie keeps the index it already had.Tests
Ten unit tests for
CookieDomaincovering configured domains, a leading dot, a capped deep subdomain, the request host fallback and the no-request case, plus two new tests each forGeneratedFbpContext,QueryBasedFbcContextandStoreFbpSubscriberasserting the index and the written domain line up.