promoted-ruby-client 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/dev.md +1 -1
- data/lib/promoted/ruby/client/request_builder.rb +9 -2
- data/lib/promoted/ruby/client/version.rb +1 -1
- data/lib/promoted/ruby/client.rb +16 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 526e2104c5f4658b67b971a1a2f19639ea383ddcee8556dd496c906c7aed8d86
|
4
|
+
data.tar.gz: f3e6afce46a2995b8497f8426d7fcccda89e9a0c533d270a55dd72598c6a0287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3b5e39490f8ceac8c261cfd6a7b3c9264980b98306bf7ac520fcc4f4855600329f43fc1eee55a22f4c8968c1d44eaa1ae47fa1ed737d61fbce6b8e5064eabb8
|
7
|
+
data.tar.gz: 94fe93237603bc0be26b54a5a7ecbd39f45065d2e878610e240079a946ecde5697b39894a6c7b2fd2817b51fdc60462d5edc66c279be3038e79618e14c9e6deb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -49,6 +49,7 @@ Name | Type | Description
|
|
49
49
|
```:perform_checks``` | Boolean | Whether or not to perform detailed input validation, defaults to true but may be disabled for performance
|
50
50
|
```:logger``` | Ruby Logger-compatible logger | Defaults to nil (no logging). Example: ```Logger.new(STDERR, :progname => 'promotedai')```
|
51
51
|
```:shadow_traffic_delivery_percent``` | Number between 0 and 1 | % of ```prepare_for_logging``` traffic that gets directed to Delivery API as "shadow traffic". Defaults to 0 (no shadow traffic).
|
52
|
+
```:send_shadow_traffic_for_control``` | Boolean | If true, the ```deliver``` method will send shadow traffic for users in the CONTROL arm of an experiment. Defaults to true.
|
52
53
|
```:default_request_headers``` | Hash | Additional headers to send on the request beyond ```x-api-key```. Defaults to {}
|
53
54
|
```:default_only_log``` | Boolean | If true, the ```deliver``` method will not direct traffic to Delivery API but rather return a request suitable for logging. Defaults to false.
|
54
55
|
```:should_apply_treatment_func``` | Proc | Called during delivery, accepts an experiment and returns a Boolean indicating whether the request should be considered part of the control group (false) or in the experiment (true). If nil, the default behavior of checking the experiement ```:arm``` is applied.
|
data/dev.md
CHANGED
@@ -4,5 +4,5 @@
|
|
4
4
|
2. Get credentials for deployment from 1password.
|
5
5
|
3. Modify `promoted-ruby-client.gemspec`'s push block.
|
6
6
|
4. Run `gem build promoted-ruby-client.gemspec` to generate `gem`.
|
7
|
-
5. Run (using new output) `gem push promoted-ruby-client-0.1.
|
7
|
+
5. Run (using new output) `gem push promoted-ruby-client-0.1.21.gem`
|
8
8
|
6. Update README with new version.
|
@@ -57,7 +57,7 @@ module Promoted
|
|
57
57
|
params = {
|
58
58
|
user_info: user_info,
|
59
59
|
timing: timing,
|
60
|
-
client_info:
|
60
|
+
client_info: merge_client_info_defaults,
|
61
61
|
device: @device,
|
62
62
|
platform_id: @platform_id,
|
63
63
|
view_id: @view_id,
|
@@ -104,7 +104,7 @@ module Promoted
|
|
104
104
|
params = {
|
105
105
|
user_info: user_info,
|
106
106
|
timing: timing,
|
107
|
-
client_info:
|
107
|
+
client_info: merge_client_info_defaults,
|
108
108
|
device: @device
|
109
109
|
}
|
110
110
|
|
@@ -193,6 +193,13 @@ module Promoted
|
|
193
193
|
|
194
194
|
private
|
195
195
|
|
196
|
+
def merge_client_info_defaults
|
197
|
+
return @client_info.merge({
|
198
|
+
:client_type => Promoted::Ruby::Client::CLIENT_TYPE['PLATFORM_SERVER'],
|
199
|
+
:traffic_type => Promoted::Ruby::Client::TRAFFIC_TYPE['PRODUCTION']
|
200
|
+
})
|
201
|
+
end
|
202
|
+
|
196
203
|
def add_missing_ids_on_insertions! request, insertions
|
197
204
|
insertions.each do |insertion|
|
198
205
|
insertion[:insertion_id] = @id_generator.newID if not insertion[:insertion_id]
|
data/lib/promoted/ruby/client.rb
CHANGED
@@ -19,7 +19,8 @@ module Promoted
|
|
19
19
|
class Error < StandardError; end
|
20
20
|
|
21
21
|
attr_reader :perform_checks, :default_only_log, :delivery_timeout_millis, :metrics_timeout_millis, :should_apply_treatment_func,
|
22
|
-
:default_request_headers, :http_client, :logger, :shadow_traffic_delivery_percent, :async_shadow_traffic
|
22
|
+
:default_request_headers, :http_client, :logger, :shadow_traffic_delivery_percent, :async_shadow_traffic,
|
23
|
+
:send_shadow_traffic_for_control
|
23
24
|
|
24
25
|
attr_accessor :request_logging_on, :enabled
|
25
26
|
|
@@ -79,6 +80,11 @@ module Promoted
|
|
79
80
|
@async_shadow_traffic = params[:async_shadow_traffic] || false
|
80
81
|
end
|
81
82
|
|
83
|
+
@send_shadow_traffic_for_control = true
|
84
|
+
if params[:send_shadow_traffic_for_control] != nil
|
85
|
+
@send_shadow_traffic_for_control = params[:send_shadow_traffic_for_control] || false
|
86
|
+
end
|
87
|
+
|
82
88
|
@pool = nil
|
83
89
|
if @async_shadow_traffic
|
84
90
|
# Thread pool to process delivery of shadow traffic. Will silently drop excess requests beyond the queue
|
@@ -161,9 +167,8 @@ module Promoted
|
|
161
167
|
cohort_membership_to_log = delivery_request_builder.new_cohort_membership_to_log
|
162
168
|
|
163
169
|
if should_apply_treatment(cohort_membership_to_log)
|
164
|
-
|
165
|
-
|
166
|
-
# Call Delivery API
|
170
|
+
# Call Delivery API to get insertions to use
|
171
|
+
delivery_request_params = delivery_request_builder.delivery_request_params
|
167
172
|
begin
|
168
173
|
response = send_request(delivery_request_params, @delivery_endpoint, @delivery_timeout_millis, @delivery_api_key, headers)
|
169
174
|
rescue StandardError => err
|
@@ -172,11 +177,14 @@ module Promoted
|
|
172
177
|
deliver_err = true
|
173
178
|
@logger.error("Error calling delivery: " + err.message) if @logger
|
174
179
|
end
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
response && response[:insertion] || [])
|
180
|
+
elsif @send_shadow_traffic_for_control
|
181
|
+
# Call Delivery API to send shadow traffic. This will create the request params with traffic type set.
|
182
|
+
deliver_shadow_traffic args, headers
|
179
183
|
end
|
184
|
+
|
185
|
+
insertions_from_delivery = (response != nil && !deliver_err);
|
186
|
+
response_insertions = delivery_request_builder.fill_details_from_response(
|
187
|
+
response && response[:insertion] || [])
|
180
188
|
end
|
181
189
|
|
182
190
|
request_to_log = nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promoted-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- scottmcmaster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|