absmartly-sdk 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a63e1c39032b6a7427c760d5b657d69bcee386e66f9bf4f809e1638d0224251
4
- data.tar.gz: e8e2acb8a335ce2705aa22e72d000cde80e9a089daa16a4f096ebb3a4bdee88a
3
+ metadata.gz: 8a43518b761dda2ac2d8c0297e39c9b0ce83c48c7f8a173206148d4e28f7db3d
4
+ data.tar.gz: f770928ce488617ce4381e67a5d12df3bfdfd07fa05bb04e5144dcd186bdfd0d
5
5
  SHA512:
6
- metadata.gz: 8d7876ef4191d0da54a36aabb7b1c0da583182316ba618bb13cd5674c75063aae212d25cfd35761c29966c8d58c91187466fbab04e50cdabd6f051d5443dba97
7
- data.tar.gz: 2fff9f84a10749f2bd9a65a505590e029364a21a20ea2622fd6a8de41c4b91cf11105b5a4aa5c42a163474ddbd7ea4d82aa768c6eeac39dbf73ffc23723293d6
6
+ metadata.gz: a5d3b4c6d70f2893a291192e85a2bccd8a9be25381d2a4d7c870d77a8c46853b4249dcbc80c04688204384024be6f505c3e946b75ca54998812ed232a7783f15
7
+ data.tar.gz: ec9681200650e472a496c36930a2332224d305a5304d2bea53398d12563071762afc9efdfce763b5412a5a10eac20e98d0bfafdac70eae3821464790043fc18e
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
- gem "arraybuffer"
10
9
  gem "murmurhash3"
11
10
  gem "faraday"
12
11
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- absmartly-sdk (1.1.0)
5
- arraybuffer (~> 0.0.6)
4
+ absmartly-sdk (1.1.2)
6
5
  faraday (~> 2.0)
7
6
  faraday-retry (~> 2.0)
8
7
  murmurhash3 (~> 0.1.7)
@@ -10,7 +9,6 @@ PATH
10
9
  GEM
11
10
  remote: https://rubygems.org/
12
11
  specs:
13
- arraybuffer (0.0.6)
14
12
  ast (2.4.2)
15
13
  byebug (11.1.3)
16
14
  diff-lcs (1.5.0)
@@ -33,7 +31,8 @@ GEM
33
31
  regexp_parser (2.5.0)
34
32
  reline (0.1.5)
35
33
  io-console (~> 0.5)
36
- rexml (3.2.5)
34
+ rexml (3.2.8)
35
+ strscan (>= 3.0.9)
37
36
  rspec (3.11.0)
38
37
  rspec-core (~> 3.11.0)
39
38
  rspec-expectations (~> 3.11.0)
@@ -61,6 +60,7 @@ GEM
61
60
  parser (>= 3.1.1.0)
62
61
  ruby-progressbar (1.11.0)
63
62
  ruby2_keywords (0.0.5)
63
+ strscan (3.1.0)
64
64
  unicode-display_width (2.2.0)
65
65
 
66
66
  PLATFORMS
@@ -69,7 +69,6 @@ PLATFORMS
69
69
 
70
70
  DEPENDENCIES
71
71
  absmartly-sdk!
72
- arraybuffer
73
72
  byebug
74
73
  faraday
75
74
  irb
data/absmartly.gemspec CHANGED
@@ -35,7 +35,6 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency "faraday", "~> 2.0"
36
36
  spec.add_dependency "faraday-retry", "~> 2.0"
37
37
  spec.add_dependency "murmurhash3", "~> 0.1.7"
38
- spec.add_dependency "arraybuffer", "~> 0.0.6"
39
38
 
40
39
  # For more information and examples about making a new gem, check out our
41
40
  # guide at: https://bundler.io/guides/creating_gem.html
data/example/example.rb CHANGED
@@ -48,3 +48,38 @@ properties = {
48
48
  ctx.track("payment", properties)
49
49
 
50
50
  ctx.close
51
+
52
+ context_data = Absmartly.context_data
53
+ ctx2 = Absmartly.create_context_with(context_config, context_data)
54
+
55
+ treatment = ctx2.treatment("exp_test_ab")
56
+ puts(treatment) # 0
57
+ treatment1 = ctx2.treatment("net_seasons")
58
+ puts(treatment1) # 1
59
+ treatment2 = ctx2.treatment("Experimento!")
60
+ puts(treatment2) # 1
61
+ treatment3 = ctx2.treatment("test")
62
+ puts(treatment3) # 1
63
+
64
+ ctx2.set_unit("db_user_id", 1000013)
65
+ ctx2.set_units(db_user_id2: 1000013, session_id2: 12311)
66
+
67
+ ctx2.set_attribute("user_agent", "Chrome 2022")
68
+ ctx2.set_attributes(
69
+ customer_age: "new_customer",
70
+ customer_point: 20,
71
+ )
72
+
73
+ ctx2.set_override("new_exp", 3)
74
+ ctx2.set_overrides(
75
+ exp_test_experiment: 1,
76
+ exp_another_experiment: 0,
77
+ )
78
+ ctx2.publish
79
+ properties = {
80
+ value: 125,
81
+ fee: 125
82
+ }
83
+ ctx2.track("payment", properties)
84
+
85
+ ctx2.close
data/lib/a_b_smartly.rb CHANGED
@@ -64,7 +64,7 @@ class ABSmartly
64
64
  end
65
65
 
66
66
  def create_context_with(config, data)
67
- Context.create(get_utc_format, config, scheduler, data,
67
+ Context.create(get_utc_format, config, data,
68
68
  @context_data_provider, @context_event_handler, @context_event_logger, @variable_parser,
69
69
  AudienceMatcher.new(@audience_deserializer))
70
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Absmartly
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.2"
5
5
  end
data/lib/absmartly.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "absmartly/version"
4
- require_relative "absmartly/variant_assigner"
5
- require_relative "absmartly/md5"
6
4
  require_relative "a_b_smartly"
7
5
  require_relative "a_b_smartly_config"
8
6
  require_relative "client"
@@ -34,6 +32,14 @@ module Absmartly
34
32
  sdk.create_context(context_config)
35
33
  end
36
34
 
35
+ def create_context_with(context_config, data)
36
+ sdk.create_context_with(context_config, data)
37
+ end
38
+
39
+ def context_data
40
+ sdk.context_data
41
+ end
42
+
37
43
  private
38
44
  def client_config
39
45
  @client_config = ClientConfig.create
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: absmartly-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - absmartly
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-29 00:00:00.000000000 Z
11
+ date: 2024-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.7
55
- - !ruby/object:Gem::Dependency
56
- name: arraybuffer
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.0.6
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.0.6
69
55
  description: Absmartly gem
70
56
  email:
71
57
  - sdks@absmartly.com
@@ -89,8 +75,6 @@ files:
89
75
  - lib/a_b_smartly.rb
90
76
  - lib/a_b_smartly_config.rb
91
77
  - lib/absmartly.rb
92
- - lib/absmartly/md5.rb
93
- - lib/absmartly/variant_assigner.rb
94
78
  - lib/absmartly/version.rb
95
79
  - lib/audience_deserializer.rb
96
80
  - lib/audience_matcher.rb
@@ -172,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
156
  - !ruby/object:Gem::Version
173
157
  version: '0'
174
158
  requirements: []
175
- rubygems_version: 3.4.10
159
+ rubygems_version: 3.5.11
176
160
  signing_key:
177
161
  specification_version: 4
178
162
  summary: Absmartly gem
data/lib/absmartly/md5.rb DELETED
@@ -1,178 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "arraybuffer"
4
-
5
- module Absmartly
6
- class Md5
7
- def self.cmn (q, a, b, x, s, t)
8
- a = a + q + (x >> 0) + t # TODO >>>
9
- ((a << s) | (a >> (32 - s))) + b # TODO >>>
10
- end
11
-
12
- def self.ff(a, b, c, d, x, s, t)
13
- cmn((b & c) | (~b & d), a, b, x, s, t)
14
- end
15
-
16
- def self.gg(a, b, c, d, x, s, t)
17
- cmn((b & d) | (c & ~d), a, b, x, s, t)
18
- end
19
-
20
- def self.hh(a, b, c, d, x, s, t)
21
- cmn(b ^ c ^ d, a, b, x, s, t)
22
- end
23
-
24
- def self.ii(a, b, c, d, x, s, t)
25
- cmn(c ^ (b | ~d), a, b, x, s, t)
26
- end
27
-
28
- def self.md5_cycle(x, k)
29
- a = x[0]
30
- b = x[1]
31
- c = x[2]
32
- d = x[3]
33
-
34
- a = ff(a, b, c, d, k[0], 7, -680876936)
35
- d = ff(d, a, b, c, k[1], 12, -389564586)
36
- c = ff(c, d, a, b, k[2], 17, 606105819)
37
- b = ff(b, c, d, a, k[3], 22, -1044525330)
38
- a = ff(a, b, c, d, k[4], 7, -176418897)
39
- d = ff(d, a, b, c, k[5], 12, 1200080426)
40
- c = ff(c, d, a, b, k[6], 17, -1473231341)
41
- b = ff(b, c, d, a, k[7], 22, -45705983)
42
- a = ff(a, b, c, d, k[8], 7, 1770035416)
43
- d = ff(d, a, b, c, k[9], 12, -1958414417)
44
- c = ff(c, d, a, b, k[10], 17, -42063)
45
- b = ff(b, c, d, a, k[11], 22, -1990404162)
46
- a = ff(a, b, c, d, k[12], 7, 1804603682)
47
- d = ff(d, a, b, c, k[13], 12, -40341101)
48
- c = ff(c, d, a, b, k[14], 17, -1502002290)
49
- b = ff(b, c, d, a, k[15], 22, 1236535329)
50
-
51
- a = gg(a, b, c, d, k[1], 5, -165796510)
52
- d = gg(d, a, b, c, k[6], 9, -1069501632)
53
- c = gg(c, d, a, b, k[11], 14, 643717713)
54
- b = gg(b, c, d, a, k[0], 20, -373897302)
55
- a = gg(a, b, c, d, k[5], 5, -701558691)
56
- d = gg(d, a, b, c, k[10], 9, 38016083)
57
- c = gg(c, d, a, b, k[15], 14, -660478335)
58
- b = gg(b, c, d, a, k[4], 20, -405537848)
59
- a = gg(a, b, c, d, k[9], 5, 568446438)
60
- d = gg(d, a, b, c, k[14], 9, -1019803690)
61
- c = gg(c, d, a, b, k[3], 14, -187363961)
62
- b = gg(b, c, d, a, k[8], 20, 1163531501)
63
- a = gg(a, b, c, d, k[13], 5, -1444681467)
64
- d = gg(d, a, b, c, k[2], 9, -51403784)
65
- c = gg(c, d, a, b, k[7], 14, 1735328473)
66
- b = gg(b, c, d, a, k[12], 20, -1926607734)
67
-
68
- a = hh(a, b, c, d, k[5], 4, -378558)
69
- d = hh(d, a, b, c, k[8], 11, -2022574463)
70
- c = hh(c, d, a, b, k[11], 16, 1839030562)
71
- b = hh(b, c, d, a, k[14], 23, -35309556)
72
- a = hh(a, b, c, d, k[1], 4, -1530992060)
73
- d = hh(d, a, b, c, k[4], 11, 1272893353)
74
- c = hh(c, d, a, b, k[7], 16, -155497632)
75
- b = hh(b, c, d, a, k[10], 23, -1094730640)
76
- a = hh(a, b, c, d, k[13], 4, 681279174)
77
- d = hh(d, a, b, c, k[0], 11, -358537222)
78
- c = hh(c, d, a, b, k[3], 16, -722521979)
79
- b = hh(b, c, d, a, k[6], 23, 76029189)
80
- a = hh(a, b, c, d, k[9], 4, -640364487)
81
- d = hh(d, a, b, c, k[12], 11, -421815835)
82
- c = hh(c, d, a, b, k[15], 16, 530742520)
83
- b = hh(b, c, d, a, k[2], 23, -995338651)
84
-
85
- a = ii(a, b, c, d, k[0], 6, -198630844)
86
- d = ii(d, a, b, c, k[7], 10, 1126891415)
87
- c = ii(c, d, a, b, k[14], 15, -1416354905)
88
- b = ii(b, c, d, a, k[5], 21, -57434055)
89
- a = ii(a, b, c, d, k[12], 6, 1700485571)
90
- d = ii(d, a, b, c, k[3], 10, -1894986606)
91
- c = ii(c, d, a, b, k[10], 15, -1051523)
92
- b = ii(b, c, d, a, k[1], 21, -2054922799)
93
- a = ii(a, b, c, d, k[8], 6, 1873313359)
94
- d = ii(d, a, b, c, k[15], 10, -30611744)
95
- c = ii(c, d, a, b, k[6], 15, -1560198380)
96
- b = ii(b, c, d, a, k[13], 21, 1309151649)
97
- a = ii(a, b, c, d, k[4], 6, -145523070)
98
- d = ii(d, a, b, c, k[11], 10, -1120210379)
99
- c = ii(c, d, a, b, k[2], 15, 718787259)
100
- b = ii(b, c, d, a, k[9], 21, -343485551)
101
-
102
- x[0] = (a + x[0]) >> 0 # TODO >>>
103
- x[1] = (b + x[1]) >> 0 # TODO >>>
104
- x[2] = (c + x[2]) >> 0 # TODO >>>
105
- x[3] = (d + x[3]) >> 0 # TODO >>>
106
- end
107
-
108
- def self.process(new_bytes_buffer)
109
- key = DataView.new new_bytes_buffer, 0, new_bytes_buffer.length
110
-
111
- l = new_bytes_buffer.length
112
- n = l & ~63
113
- i = 0
114
- block = ArrayBuffer.new(16)
115
- state = ArrayBuffer.new(4)
116
-
117
- [1732584193, -271733879, -1732584194, 271733878].each_with_index do |el, index|
118
- state[index] = el
119
- end
120
-
121
- (0...n).step(64).each do |val|
122
- (0...16).each do |w|
123
- block[w] = key.getU32(val + (w << 2))
124
- end
125
-
126
- md5_cycle(state, block)
127
-
128
- i += 64
129
- end
130
-
131
- w = 0
132
- m = l & ~3
133
-
134
- (i...m).step(4).each do |val|
135
- block[w] = key.getU32(val)
136
- w += 1
137
- end
138
-
139
- p = l & 3
140
-
141
- case p
142
- when 3
143
- block[w] = 0x80000000 | key.getU8(i) | (key.getU8(i + 1) << 8) | (key.getU8(i + 2) << 16)
144
- w += 1
145
- when 2
146
- block[w] = 0x800000 | key.getUint8(i) | (key.getUint8(i + 1) << 8)
147
- w += 1
148
-
149
- when 1
150
- block[w] = 0x8000 | key.getUint8(i)
151
- w += 1
152
-
153
- else
154
- block[w] = 0x80
155
- w += 1
156
-
157
- end
158
-
159
- if w > 14
160
- (w...16).each do |v|
161
- block[v] = 0
162
- end
163
-
164
- md5_cycle(state, block)
165
- w = 0
166
- end
167
-
168
- (w...16).each do |v|
169
- block[v] = 0
170
- end
171
-
172
- block[14] = l << 3
173
- md5_cycle(state, block)
174
-
175
- state
176
- end
177
- end
178
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "arraybuffer"
4
- require "murmurhash3"
5
-
6
- module Absmartly
7
- # VariantAssigner
8
- class VariantAssigner
9
- def initialize(_unit)
10
- # this._unitHash = murmur3_32(stringToUint8Array(unit).buffer);
11
- end
12
-
13
- def assign(split, seed_hi, seed_lo)
14
- prob = probability(seed_hi, seed_lo)
15
- chooseVariant(split, prob)
16
- end
17
-
18
- # private
19
-
20
- # def chooseVariant(split, prob)
21
- #
22
- # end
23
- #
24
- # def probability(seedHi, seedLo)
25
- # const key = this._unitHash;
26
- # const buffer = new ArrayBuffer(12)
27
- # const view = new DataView(buffer)
28
- # view.setUint32(0, seedLo, true)
29
- # view.setUint32(4, seedHi, true)
30
- # view.setUint32(8, key, true)
31
- #
32
- # murmur3_32(buffer) * (1.0 / 0xffffffff)
33
- # end
34
- end
35
- end
36
- # DataView.new(new_bytes_buffer, src_offset, new_bytes.length)