Commit 5441573
Add Event.referrer_url and auto-populate from CAPI ParamBuilder
Summary:
# Problem
`com.facebook.capi.sdk:capi-param-builder` 1.3.0 (D106968654) exposes
`ParamBuilder.getReferrerUrl()`, and the Java SDK's `Preference`
already has the `is_referrer_url_allowed` gate. What is still missing
is (1) a `referrer_url` field on `Event` to land the value in, and (2)
the wiring in `Event.applyParamBuilderDefaults()` that consults the
ParamBuilder when `setRequestContext(...)` is used. This mirrors the
Node.js change in D106967695, the PHP change in D106908330, the Ruby
change in D106704554, and the Python change in D106700660.
# Solution
Add `referrer_url` to `Event`, following the shape of
`event_source_url`:
- New `SerializedName("referrer_url")` field `referrerUrl` (gson
serializes it on the wire automatically; null is omitted).
- `referrerUrl` appended as the last parameter of the all-args
constructor (with `param` doc + assignment), matching how every prior
field was added to this constructor — e.g. `originalEventData` /
`attributionData` were appended in place in D59667901. This is
source- and binary-incompatible for callers of the positional
`new Event(...)` constructor, consistent with the SDK's established
pattern of growing that constructor per release. Callers using the
fluent `new Event()` builder are unaffected, and no in-repo caller
uses the positional form (all 42 sites use the fluent builder).
- Fluent `referrerUrl(String)`, getter `getReferrerUrl()`, and plain
`setReferrerUrl(...)`, adjacent to the `eventSourceUrl` accessors.
- `equals`, `hashCode`, and `toString` updated to include the new
field.
Extend `Event.applyParamBuilderDefaults()` so that after the
`event_source_url` handling it also reads
`paramBuilder.getReferrerUrl()` and assigns it to the event's
`referrerUrl` when:
- `preference.isReferrerUrlAllowed()` is `true` (default), AND
- `referrerUrl` is currently null or empty (caller-supplied values
always win, matching the precedence rule for fbc/fbp/event_source_url),
AND
- the builder returned a non-empty URL.
As with the fbc/fbp/event_source_url handling, this is wired and
unit-tested via a mocked `ParamBuilder` but is a runtime no-op until
the deferred `processRequestFromContext` call in `setRequestContext`
is re-enabled (see the NOTE there) — kept in lock-step with the other
fields rather than changing that behavior here.
Differential Revision: D106972893
fbshipit-source-id: 70f9ad280ca530c00a489d14a4f65b096b9040141 parent 21cf543 commit 5441573
2 files changed
Lines changed: 105 additions & 4 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 | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
113 | | - | |
114 | | - | |
| 117 | + | |
| 118 | + | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
| |||
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
220 | 254 | | |
221 | 255 | | |
222 | 256 | | |
| |||
674 | 708 | | |
675 | 709 | | |
676 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
677 | 718 | | |
678 | 719 | | |
679 | 720 | | |
| |||
725 | 766 | | |
726 | 767 | | |
727 | 768 | | |
728 | | - | |
| 769 | + | |
| 770 | + | |
729 | 771 | | |
730 | 772 | | |
731 | 773 | | |
732 | 774 | | |
733 | 775 | | |
734 | | - | |
| 776 | + | |
735 | 777 | | |
736 | 778 | | |
737 | 779 | | |
| |||
742 | 784 | | |
743 | 785 | | |
744 | 786 | | |
| 787 | + | |
745 | 788 | | |
746 | 789 | | |
747 | 790 | | |
| |||
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| |||
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
| 224 | + | |
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
| |||
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
282 | 340 | | |
283 | 341 | | |
284 | 342 | | |
| |||
0 commit comments