21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/kameleoon/network/cookie/cookie_manager.rb', line 21
def get_or_add(cookies, default_visitor_code = nil)
return if cookies.nil?
Logging::KameleoonLogger.debug(
"CALL: CookieManager.get_or_add(cookies: %s, default_visitor_code: '%s')",
cookies, default_visitor_code
)
visitor_code = get_visitor_code_from_cookies(cookies)
unless visitor_code.nil?
Utils::VisitorCode.validate(visitor_code)
Logging::KameleoonLogger.debug("Read visitor code '%s' from cookies %s", visitor_code, cookies)
add(visitor_code, cookies) unless @data_manager.visitor_code_managed?
Logging::KameleoonLogger.debug(
"RETURN: CookieManager.get_or_add(cookies: %s, default_visitor_code: '%s') -> (visitor_code: '%s')",
cookies, default_visitor_code, visitor_code
)
return visitor_code
end
if default_visitor_code.nil?
visitor_code = Utils::VisitorCode.generate
Logging::KameleoonLogger.debug("Generated new visitor code '%s'", visitor_code)
add(visitor_code, cookies) unless @data_manager.visitor_code_managed?
Logging::KameleoonLogger.debug(
"RETURN: CookieManager.get_or_add(cookies: %s, default_visitor_code: '%s') -> (visitor_code: '%s')",
cookies, default_visitor_code, visitor_code
)
return visitor_code
end
visitor_code = default_visitor_code
Utils::VisitorCode.validate(visitor_code)
Logging::KameleoonLogger.debug("Used default visitor code '{%s}'", default_visitor_code)
add(visitor_code, cookies)
Logging::KameleoonLogger.debug(
"RETURN: CookieManager.get_or_add(cookies: %s, default_visitor_code: '%s') -> (visitor_code: '%s')",
cookies, default_visitor_code, visitor_code
)
visitor_code
end
|