Class: ParamBuilder
- Inherits:
-
Object
- Object
- ParamBuilder
- Defined in:
- lib/capi_param_builder.rb
Constant Summary collapse
- FBC_NAME =
"_fbc"- FBP_NAME =
"_fbp"- DEFAULT_1PC_AGE =
90 * 24 * 3600
- LANGUAGE_TOKEN =
"BQ"- SUPPORTED_LANGUAGE_TOKENS =
["AQ", "Ag", "Aw", "BA", "BQ", "Bg"]
- MIN_PAYLOAD_SPLIT_LENGTH =
4- MAX_PAYLOAD_WITH_LANGUAGE_TOKEN_LENGTH =
5- IPV4_REGEX =
/\A(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\z/- IPV6_REGEX =
/\A(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\z|\A(?:[0-9a-fA-F]{1,4}:){1,7}:\z|\A(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}\z|\A(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}\z|\A(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}\z|\A(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}\z|\A(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}\z|\A[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}\z|\A:(?::[0-9a-fA-F]{1,4}){1,7}\z|\A::\z|\A(?:[0-9a-fA-F]{1,4}:){6}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\z/
Instance Method Summary collapse
- #get_cookies_to_set ⇒ Object
- #get_fbc ⇒ Object
- #get_fbp ⇒ Object
-
#initialize(input = nil) ⇒ ParamBuilder
constructor
A new instance of ParamBuilder.
- #process_request(host, queries, cookies, referer = nil) ⇒ Object
Constructor Details
#initialize(input = nil) ⇒ ParamBuilder
Returns a new instance of ParamBuilder.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/capi_param_builder.rb', line 25 def initialize(input = nil) @fbc_params_configs = [FbcParamConfigs.new("fbclid", "", "clickID")] if input.nil? return end if input.is_a?(Array) @domain_list = [] input.each do |domain_item| @domain_list.push(extract_host_from_http_host(domain_item.downcase)) end elsif input.is_a?(EtldPlusOneResolver) @etld_plus_one_resolver = input end end |
Instance Method Details
#get_cookies_to_set ⇒ Object
134 135 136 |
# File 'lib/capi_param_builder.rb', line 134 def () return @cookie_to_set end |
#get_fbc ⇒ Object
138 139 140 |
# File 'lib/capi_param_builder.rb', line 138 def get_fbc() return @fbc end |
#get_fbp ⇒ Object
142 143 144 |
# File 'lib/capi_param_builder.rb', line 142 def get_fbp() return @fbp end |
#process_request(host, queries, cookies, referer = nil) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/capi_param_builder.rb', line 108 def process_request(host, queries, , referer=nil) compute_etld_plus_one_for_host(host) @cookie_to_set_dict = {} @cookie_to_set = Set.new() @fbc = (, FBC_NAME) @fbp = (, FBP_NAME) # Get new fbc payload new_fbc_payload = get_new_fbc_payload_from_url(queries, referer) # fbc update = (@fbc, new_fbc_payload) if !.nil? @cookie_to_set_dict[FBC_NAME] = @fbc = .value end # fbp update = (@fbp) if !.nil? @cookie_to_set_dict[FBP_NAME] = @fbp = .value end @cookie_to_set = Set.new(@cookie_to_set_dict.values) return @cookie_to_set end |