@@ -21,8 +21,10 @@ final class ParamBuilder
2121 private $ domain_list ;
2222
2323 // appendix info
24- private $ appendix_new ;
25- private $ appendix_normal ;
24+ private $ appendix_net_new ;
25+ private $ appendix_modified_new ;
26+ private $ appendix_general_new ;
27+ private $ appendix_no_change ;
2628
2729 // captured values
2830 private $ fbc = null ;
@@ -45,8 +47,14 @@ public function __construct(
4547 new FbcParamConfig (FBCLID , '' , CLICK_ID_STRING )
4648 );
4749
48- $ this ->appendix_new = AppendixProvider::getAppendix (true );
49- $ this ->appendix_normal = AppendixProvider::getAppendix (false );
50+ $ this ->appendix_general_new =
51+ AppendixProvider::getAppendix (APPENDIX_GENERAL_NEW );
52+ $ this ->appendix_net_new =
53+ AppendixProvider::getAppendix (APPENDIX_NET_NEW );
54+ $ this ->appendix_modified_new =
55+ AppendixProvider::getAppendix (APPENDIX_MODIFIED_NEW );
56+ $ this ->appendix_no_change =
57+ AppendixProvider::getAppendix (APPENDIX_NO_CHANGE );
5058
5159 if ($ params instanceof ETLDPlus1Resolver) {
5260 $ this ->etld_plus1_resolver = $ params ;
@@ -101,7 +109,7 @@ private function preProcess($cookie, $cookie_name, $host)
101109 $ contains_extra_dot = empty ($ slices [MIN_PAYLOAD_SPLIT_LENGTH - 1 ]);
102110 $ updated_cookie = $ cookie_value
103111 . ($ contains_extra_dot ? '' : '. ' )
104- . $ this ->appendix_normal ;
112+ . $ this ->appendix_no_change ;
105113 }
106114
107115 // Cookie exist, contains language token. Validate it
@@ -239,11 +247,14 @@ public function processRequest(
239247 if (ParamBuilder::shouldUpdateFbc ($ new_fbc_payload )) {
240248 $ this ->computeETLDPlus1ForHost ($ host );
241249 $ drop_ts = round (microtime (true ) * 1000 );
250+ $ is_net_new = empty ($ this ->fbc );
242251 $ this ->fbc = FB_PREFIX .
243252 '. ' . $ this ->sub_domain_index .
244253 '. ' . $ drop_ts .
245254 '. ' . $ new_fbc_payload .
246- '. ' . $ this ->appendix_new ;
255+ '. ' . ($ is_net_new
256+ ? $ this ->appendix_net_new
257+ : $ this ->appendix_modified_new );
247258 $ this ->cookies_to_set [FBC_NAME ] = new CookieSettings (
248259 FBC_NAME ,
249260 $ this ->fbc ,
@@ -261,7 +272,7 @@ public function processRequest(
261272 '. ' . $ this ->sub_domain_index .
262273 '. ' . $ drop_ts .
263274 '. ' . $ new_fbp_payload .
264- '. ' . $ this ->appendix_new ;
275+ '. ' . $ this ->appendix_net_new ;
265276 $ this ->cookies_to_set [FBP_NAME ] = new CookieSettings (
266277 FBP_NAME ,
267278 $ this ->fbp ,
@@ -549,6 +560,10 @@ private static function getClientIp(
549560 $ client_ip_from_request
550561 );
551562
563+ $ client_ip_appendix = $ client_ip_from_request_is_public_ip
564+ ? AppendixProvider::getAppendix (APPENDIX_MODIFIED_NEW )
565+ : AppendixProvider::getAppendix (APPENDIX_NET_NEW );
566+
552567 // Prioritize: IPv6 over IPv4, public over private,
553568 // and cookie-sourced IPs over request-sourced IPs.
554569 if (
@@ -559,13 +574,14 @@ private static function getClientIp(
559574 (
560575 $ client_ip_language_token_from_cookie
561576 ? $ client_ip_language_token_from_cookie
562- : AppendixProvider:: getAppendix ( true )
577+ : $ client_ip_appendix
563578 );
564579 } else if (
565580 $ client_ip_from_request_is_IPv6 &&
566581 $ client_ip_from_request_is_public_ip
567582 ) {
568- $ best_client_ip = $ client_ip_from_request . '. ' . AppendixProvider::getAppendix (false );
583+ $ best_client_ip = $ client_ip_from_request . '. ' .
584+ AppendixProvider::getAppendix (APPENDIX_NO_CHANGE );
569585 } else if (
570586 $ client_ip_from_cookie_is_IPv4 &&
571587 $ client_ip_from_cookie_is_public_ip
@@ -574,13 +590,14 @@ private static function getClientIp(
574590 (
575591 $ client_ip_language_token_from_cookie
576592 ? $ client_ip_language_token_from_cookie
577- : AppendixProvider:: getAppendix ( true )
593+ : $ client_ip_appendix
578594 );
579595 } else if (
580596 $ client_ip_from_request_is_IPv4 &&
581597 $ client_ip_from_request_is_public_ip
582598 ) {
583- $ best_client_ip = $ client_ip_from_request . '. ' . AppendixProvider::getAppendix (false );
599+ $ best_client_ip = $ client_ip_from_request . '. ' .
600+ AppendixProvider::getAppendix (APPENDIX_NO_CHANGE );
584601 }
585602
586603 return $ best_client_ip ;
0 commit comments