kameleoon-client-ruby 3.16.0 → 3.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 602844d249763c9165d740e924c71b8d98efbfdb77c8f70ef4cd0ad361dfb86f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1a9ee1ce8a3b3548f38ba19f21d3f0de86aeba513549405870bcd3150a617608
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8988b718fac058005be7ac57bc7519c9cc8ad4e6dd95d03e2505e3210eea483fc619362959b8af6788d5ee5f06045f52941b27cbca57f0b11b82c45e63e92612
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 41c1a2c1c2a7903dd352b5fe3a515d4f2639656eb05de89a19791e2d50ae0c4ef5b4336649491e2dc358dd55c51e92ab1e411132a7c7b1cd9784735c6bae3e81
         
     | 
| 
         @@ -10,6 +10,8 @@ module Kameleoon 
     | 
|
| 
       10 
10 
     | 
    
         
             
              class CustomData < DuplicationUnsafeData
         
     | 
| 
       11 
11 
     | 
    
         
             
                attr_reader :index, :name, :values, :overwrite
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
                UNDEFINED_INDEX = -1
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       13 
15 
     | 
    
         
             
                def to_s
         
     | 
| 
       14 
16 
     | 
    
         
             
                  "CustomData{index:#{@index},name:'#{@name}',values:#{@values},overwrite:#{@overwrite}}"
         
     | 
| 
       15 
17 
     | 
    
         
             
                end
         
     | 
| 
         @@ -35,13 +37,13 @@ module Kameleoon 
     | 
|
| 
       35 
37 
     | 
    
         
             
                    index = hash['index'] || hash['id']
         
     | 
| 
       36 
38 
     | 
    
         
             
                    name = hash['name']
         
     | 
| 
       37 
39 
     | 
    
         
             
                    if index.nil? && name.nil?
         
     | 
| 
       38 
     | 
    
         
            -
                      raise  
     | 
| 
      
 40 
     | 
    
         
            +
                      raise Exception::NotFound.new('index/id/name'), '"index/id/name" is mandatory'
         
     | 
| 
       39 
41 
     | 
    
         
             
                    end
         
     | 
| 
       40 
42 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                    @index = index ||  
     | 
| 
      
 43 
     | 
    
         
            +
                    @index = index || CustomData::UNDEFINED_INDEX
         
     | 
| 
       42 
44 
     | 
    
         
             
                    @name = name
         
     | 
| 
       43 
45 
     | 
    
         
             
                    values = hash['values']
         
     | 
| 
       44 
     | 
    
         
            -
                    raise  
     | 
| 
      
 46 
     | 
    
         
            +
                    raise Exception::NotFound.new('values'), '"values" is mandatory' if values.nil?
         
     | 
| 
       45 
47 
     | 
    
         | 
| 
       46 
48 
     | 
    
         
             
                    @values = values.is_a?(Array) ? values.dup : [values]
         
     | 
| 
       47 
49 
     | 
    
         
             
                    @overwrite = hash.fetch('overwrite', true)
         
     | 
| 
         @@ -50,10 +52,10 @@ module Kameleoon 
     | 
|
| 
       50 
52 
     | 
    
         
             
                    when Integer
         
     | 
| 
       51 
53 
     | 
    
         
             
                      @index = arg0
         
     | 
| 
       52 
54 
     | 
    
         
             
                    when String
         
     | 
| 
       53 
     | 
    
         
            -
                      @index =  
     | 
| 
      
 55 
     | 
    
         
            +
                      @index = CustomData::UNDEFINED_INDEX
         
     | 
| 
       54 
56 
     | 
    
         
             
                      @name = arg0
         
     | 
| 
       55 
57 
     | 
    
         
             
                    else
         
     | 
| 
       56 
     | 
    
         
            -
                      raise  
     | 
| 
      
 58 
     | 
    
         
            +
                      raise Exception.new('Unexpected arg0 type'), 'Unexpected arg0 type'
         
     | 
| 
       57 
59 
     | 
    
         
             
                    end
         
     | 
| 
       58 
60 
     | 
    
         
             
                    @values = args
         
     | 
| 
       59 
61 
     | 
    
         
             
                    @overwrite = overwrite
         
     | 
| 
         @@ -62,7 +64,7 @@ module Kameleoon 
     | 
|
| 
       62 
64 
     | 
    
         
             
                  return if @index.is_a?(Integer)
         
     | 
| 
       63 
65 
     | 
    
         | 
| 
       64 
66 
     | 
    
         
             
                  Logging::KameleoonLogger.warning("CustomData field 'index' must be of 'Integer' type")
         
     | 
| 
       65 
     | 
    
         
            -
                  @index = @index.is_a?(String) ? @index.to_i :  
     | 
| 
      
 67 
     | 
    
         
            +
                  @index = @index.is_a?(String) ? @index.to_i : CustomData::UNDEFINED_INDEX
         
     | 
| 
       66 
68 
     | 
    
         
             
                end
         
     | 
| 
       67 
69 
     | 
    
         
             
                # rubocop:enable Metrics/MethodLength
         
     | 
| 
       68 
70 
     | 
    
         | 
| 
         @@ -92,7 +94,7 @@ module Kameleoon 
     | 
|
| 
       92 
94 
     | 
    
         
             
                    overwrite: @overwrite,
         
     | 
| 
       93 
95 
     | 
    
         
             
                    nonce: nonce
         
     | 
| 
       94 
96 
     | 
    
         
             
                  }
         
     | 
| 
       95 
     | 
    
         
            -
                   
     | 
| 
      
 97 
     | 
    
         
            +
                  Network::UriHelper.encode_query(params)
         
     | 
| 
       96 
98 
     | 
    
         
             
                end
         
     | 
| 
       97 
99 
     | 
    
         
             
              end
         
     | 
| 
       98 
100 
     | 
    
         
             
            end
         
     | 
| 
         @@ -6,13 +6,6 @@ module Kameleoon 
     | 
|
| 
       6 
6 
     | 
    
         
             
                # DataArrayStorage is a readonly accessor to a sequntial storage of specific visitor data.
         
     | 
| 
       7 
7 
     | 
    
         
             
                # It is thread-safe
         
     | 
| 
       8 
8 
     | 
    
         
             
                class DataArrayStorage
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  def to_s
         
     | 
| 
       11 
     | 
    
         
            -
                    values = []
         
     | 
| 
       12 
     | 
    
         
            -
                    enumerate { |v| values << v }
         
     | 
| 
       13 
     | 
    
         
            -
                    "DataArrayStorage{values:#{values.join(',')}}"
         
     | 
| 
       14 
     | 
    
         
            -
                  end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
9 
     | 
    
         
             
                  def initialize(mutex, array)
         
     | 
| 
       17 
10 
     | 
    
         
             
                    @mutex = mutex
         
     | 
| 
       18 
11 
     | 
    
         
             
                    @array = array
         
     | 
| 
         @@ -45,6 +38,12 @@ module Kameleoon 
     | 
|
| 
       45 
38 
     | 
    
         
             
                    end
         
     | 
| 
       46 
39 
     | 
    
         
             
                    value
         
     | 
| 
       47 
40 
     | 
    
         
             
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 43 
     | 
    
         
            +
                    values = []
         
     | 
| 
      
 44 
     | 
    
         
            +
                    enumerate { |v| values << v }
         
     | 
| 
      
 45 
     | 
    
         
            +
                    "DataArrayStorage{values:#{values.join(',')}}"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
       48 
47 
     | 
    
         
             
                end
         
     | 
| 
       49 
48 
     | 
    
         
             
              end
         
     | 
| 
       50 
49 
     | 
    
         
             
            end
         
     | 
| 
         @@ -3,6 +3,8 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'concurrent'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'rufus/scheduler'
         
     | 
| 
       5 
5 
     | 
    
         
             
            require 'kameleoon/configuration/custom_data_info'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'kameleoon/data/conversion'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'kameleoon/data/custom_data'
         
     | 
| 
       6 
8 
     | 
    
         
             
            require 'kameleoon/data/mapping_identifier'
         
     | 
| 
       7 
9 
     | 
    
         
             
            require 'kameleoon/data/manager/visitor'
         
     | 
| 
       8 
10 
     | 
    
         
             
            require 'kameleoon/logging/kameleoon_logger'
         
     | 
| 
         @@ -71,15 +73,21 @@ module Kameleoon 
     | 
|
| 
       71 
73 
     | 
    
         
             
                  end
         
     | 
| 
       72 
74 
     | 
    
         | 
| 
       73 
75 
     | 
    
         
             
                  def add_data(visitor_code, *args, overwrite: true)
         
     | 
| 
       74 
     | 
    
         
            -
                    Logging::KameleoonLogger.debug( 
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
                    Logging::KameleoonLogger.debug(
         
     | 
| 
      
 77 
     | 
    
         
            +
                      "CALL: VisitorManager.add_data(visitor_code: '%s', args: %s, overwrite: %s)",
         
     | 
| 
      
 78 
     | 
    
         
            +
                      visitor_code, args, overwrite
         
     | 
| 
      
 79 
     | 
    
         
            +
                    )
         
     | 
| 
       76 
80 
     | 
    
         
             
                    visitor = get_or_create_visitor(visitor_code)
         
     | 
| 
       77 
81 
     | 
    
         
             
                    cdi = @data_manager.data_file.custom_data_info
         
     | 
| 
       78 
82 
     | 
    
         
             
                    args.size.times do |i|
         
     | 
| 
       79 
     | 
    
         
            -
                       
     | 
| 
       80 
     | 
    
         
            -
                       
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 83 
     | 
    
         
            +
                      data = args[i]
         
     | 
| 
      
 84 
     | 
    
         
            +
                      case data
         
     | 
| 
      
 85 
     | 
    
         
            +
                      when CustomData
         
     | 
| 
      
 86 
     | 
    
         
            +
                        data = process_custom_data(cdi, visitor_code, visitor, data)
         
     | 
| 
      
 87 
     | 
    
         
            +
                      when Conversion
         
     | 
| 
      
 88 
     | 
    
         
            +
                        data = process_conversion(data, cdi)
         
     | 
| 
       82 
89 
     | 
    
         
             
                      end
         
     | 
| 
      
 90 
     | 
    
         
            +
                      args[i] = data
         
     | 
| 
       83 
91 
     | 
    
         
             
                    end
         
     | 
| 
       84 
92 
     | 
    
         
             
                    visitor.add_data(*args, overwrite: overwrite)
         
     | 
| 
       85 
93 
     | 
    
         
             
                    Logging::KameleoonLogger.debug(
         
     | 
| 
         @@ -92,12 +100,13 @@ module Kameleoon 
     | 
|
| 
       92 
100 
     | 
    
         
             
                  private
         
     | 
| 
       93 
101 
     | 
    
         | 
| 
       94 
102 
     | 
    
         
             
                  def process_custom_data(cdi, visitor_code, visitor, custom_data)
         
     | 
| 
       95 
     | 
    
         
            -
                     
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                       
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                      custom_data = custom_data.named_to_indexed(cd_index)
         
     | 
| 
      
 103 
     | 
    
         
            +
                    mapped_cd = try_map_custom_data_index_by_name(custom_data, cdi)
         
     | 
| 
      
 104 
     | 
    
         
            +
                    if mapped_cd.nil?
         
     | 
| 
      
 105 
     | 
    
         
            +
                      Logging::KameleoonLogger.error('%s is invalid and will be ignored', custom_data)
         
     | 
| 
      
 106 
     | 
    
         
            +
                      return nil
         
     | 
| 
       100 
107 
     | 
    
         
             
                    end
         
     | 
| 
      
 108 
     | 
    
         
            +
                    custom_data = mapped_cd
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
       101 
110 
     | 
    
         
             
                    # We shouldn't send custom data with local only type
         
     | 
| 
       102 
111 
     | 
    
         
             
                    custom_data.mark_as_sent if cdi.local_only?(custom_data.index)
         
     | 
| 
       103 
112 
     | 
    
         
             
                    # If mappingIdentifier is passed, we should link anonymous visitor with real unique userId.
         
     | 
| 
         @@ -115,6 +124,23 @@ module Kameleoon 
     | 
|
| 
       115 
124 
     | 
    
         
             
                    custom_data
         
     | 
| 
       116 
125 
     | 
    
         
             
                  end
         
     | 
| 
       117 
126 
     | 
    
         | 
| 
      
 127 
     | 
    
         
            +
                  def process_conversion(conversion, cdi)
         
     | 
| 
      
 128 
     | 
    
         
            +
                    conversion.metadata&.each_index do |i|
         
     | 
| 
      
 129 
     | 
    
         
            +
                      cd = try_map_custom_data_index_by_name(conversion.metadata[i], cdi)
         
     | 
| 
      
 130 
     | 
    
         
            +
                      Logging::KameleoonLogger.warning('Conversion metadata %s is invalid', conversion.metadata[i]) if cd.nil?
         
     | 
| 
      
 131 
     | 
    
         
            +
                      conversion.metadata[i] = cd
         
     | 
| 
      
 132 
     | 
    
         
            +
                    end
         
     | 
| 
      
 133 
     | 
    
         
            +
                    conversion
         
     | 
| 
      
 134 
     | 
    
         
            +
                  end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                  def try_map_custom_data_index_by_name(custom_data, cdi)
         
     | 
| 
      
 137 
     | 
    
         
            +
                    return custom_data if custom_data.index != CustomData::UNDEFINED_INDEX
         
     | 
| 
      
 138 
     | 
    
         
            +
                    return nil if custom_data.name.nil?
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                    cd_index = cdi.get_custom_data_index_by_name(custom_data.name)
         
     | 
| 
      
 141 
     | 
    
         
            +
                    cd_index.nil? ? nil : custom_data.named_to_indexed(cd_index)
         
     | 
| 
      
 142 
     | 
    
         
            +
                  end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
       118 
144 
     | 
    
         
             
                  def purge
         
     | 
| 
       119 
145 
     | 
    
         
             
                    Logging::KameleoonLogger.debug('CALL: VisitorManager.purge')
         
     | 
| 
       120 
146 
     | 
    
         
             
                    expired_time = Time.new.to_i - @expiration_period
         
     | 
    
        data/lib/kameleoon/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: kameleoon-client-ruby
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 3.16. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.16.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Kameleoon
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2025- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-10-31 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: em-http-request
         
     |