Commit 7d16f93
Enable ParamBuilder.processRequestFromContext now that 1.3.0 is pinned
Summary:
# Problem
`Event#setRequestContext` constructed a `ParamBuilder` but deliberately
did NOT call `paramBuilder.processRequestFromContext(context)`, because
that method was not in the Maven Central release the SDK pinned
(`1.1.1`) — calling it would have been a `NoSuchMethodError`. With the
call deferred, `ParamBuilder` was never given the request context, so
`applyParamBuilderDefaults()` was a runtime no-op: fbc / fbp /
event_source_url / referrer_url were never extracted from the request,
even though the wiring exists. The `1.3.0` bump (D106968654) now pins a
Maven Central release that publishes `processRequestFromContext`,
`getEventSourceUrl`, and `getReferrerUrl`, so the call can be enabled.
# Solution
- `Event#setRequestContext` now calls
`this.paramBuilder.processRequestFromContext(context)` (the deferral
NOTE is removed). Extraction into `UserData` / `Event` still happens
in `applyParamBuilderDefaults()` at send time, so call order with
`setUserData` is unchanged.
- The real-builder guardrail `testRealParamBuilderExposesMethodsTheSdkCalls`
now also asserts `processRequestFromContext(Object)`,
`getEventSourceUrl()`, and `getReferrerUrl()` exist on the pinned
artifact (in addition to `getFbc`/`getFbp`), so a future upstream API
shift fails CI loudly.
- Replaced the deferred no-op test
`testSetRequestContextStoresParamBuilderWithoutContextProcessing`
with an end-to-end test
`testSetRequestContextPopulatesFbpFromCookieEndToEnd` that drives a
real (non-mocked) `ParamBuilder` and asserts `fbp` is auto-populated
from the `_fbp` cookie.
The new test uses the Java `RequestContextAdaptor` Map strategy's flat
CGI/environ-style keys (`HTTP_HOST`, `HTTP_COOKIE`) — NOT the nested
`{"headers": {...}}` shape the old deferred test used, which the
adaptor does not read. `ParamBuilder` appends an appendix token to a
4-segment fbp, so the assertion uses `startsWith` rather than exact
equality.
The mocked tests are unaffected: `MockedConstruction` intercepts
`new ParamBuilder()`, and `processRequestFromContext` on the mock is a
no-op, so the stubbed `getFbc` / `getFbp` / `getEventSourceUrl` /
`getReferrerUrl` values still drive `applyParamBuilderDefaults`.
Differential Revision: D106975772
fbshipit-source-id: e52ec5576def6a4356bee2508ad16f7bd2d56c351 parent 5441573 commit 7d16f93
2 files changed
Lines changed: 29 additions & 40 deletions
File tree
- src
- main/java/com/facebook/ads/sdk/serverside
- test/java/com/facebook/ads/sdk/serverside
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
| 664 | + | |
671 | 665 | | |
672 | 666 | | |
673 | 667 | | |
| |||
Lines changed: 28 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
412 | 410 | | |
413 | 411 | | |
| 412 | + | |
414 | 413 | | |
415 | 414 | | |
| 415 | + | |
| 416 | + | |
416 | 417 | | |
417 | | - | |
418 | | - | |
419 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
420 | 421 | | |
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
424 | 425 | | |
425 | 426 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
433 | 432 | | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
444 | 438 | | |
445 | 439 | | |
446 | 440 | | |
447 | 441 | | |
448 | | - | |
| 442 | + | |
449 | 443 | | |
450 | 444 | | |
451 | | - | |
452 | 445 | | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
457 | 452 | | |
458 | 453 | | |
0 commit comments