optimizely-sdk 3.6.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/optimizely.rb +50 -10
- data/lib/optimizely/config/datafile_project_config.rb +2 -0
- data/lib/optimizely/decision_service.rb +1 -0
- data/lib/optimizely/event/entity/decision.rb +6 -4
- data/lib/optimizely/event/entity/impression_event.rb +4 -2
- data/lib/optimizely/event/event_factory.rb +4 -3
- data/lib/optimizely/event/user_event_factory.rb +4 -3
- data/lib/optimizely/project_config.rb +2 -0
- data/lib/optimizely/version.rb +1 -1
- 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: 84b914d98655786586e8f691c82529bb3a8f074a6c157aceff6c2ef0ab4a4e3e
|
4
|
+
data.tar.gz: 484164de6c112f23adc94568371a33f564a99dba714c3141cf156783cb638a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b56b571c9aed79bdf0fdce664fa8ae24c152e52ac6804f3621c1597701a0293e4e105e0ce2db482d75640e81d7c8d9d1db085d70d0aa8827290277c87c280f68
|
7
|
+
data.tar.gz: a68af4ec2b0f7d02411e543aae1ca8e141d0be7a992e2d57ac6cd3c40e54ed3437ff39df312907914a679c7b75853902d4ab016b562428ae543f0af50730cabf
|
data/lib/optimizely.rb
CHANGED
@@ -140,7 +140,10 @@ module Optimizely
|
|
140
140
|
|
141
141
|
# Create and dispatch impression event
|
142
142
|
experiment = config.get_experiment_from_key(experiment_key)
|
143
|
-
send_impression(
|
143
|
+
send_impression(
|
144
|
+
config, experiment, variation_key, '', experiment_key, true,
|
145
|
+
Optimizely::DecisionService::DECISION_SOURCES['EXPERIMENT'], user_id, attributes
|
146
|
+
)
|
144
147
|
|
145
148
|
variation_key
|
146
149
|
end
|
@@ -316,14 +319,23 @@ module Optimizely
|
|
316
319
|
experiment_key: decision.experiment['key'],
|
317
320
|
variation_key: variation['key']
|
318
321
|
}
|
319
|
-
# Send event if Decision came from
|
320
|
-
send_impression(
|
321
|
-
|
322
|
-
|
323
|
-
|
322
|
+
# Send event if Decision came from a feature test.
|
323
|
+
send_impression(
|
324
|
+
config, decision.experiment, variation['key'], feature_flag_key, decision.experiment['key'], feature_enabled, source_string, user_id, attributes
|
325
|
+
)
|
326
|
+
elsif decision.source == Optimizely::DecisionService::DECISION_SOURCES['ROLLOUT'] && config.send_flag_decisions
|
327
|
+
send_impression(
|
328
|
+
config, decision.experiment, variation['key'], feature_flag_key, decision.experiment['key'], feature_enabled, source_string, user_id, attributes
|
329
|
+
)
|
324
330
|
end
|
325
331
|
end
|
326
332
|
|
333
|
+
if decision.nil? && config.send_flag_decisions
|
334
|
+
send_impression(
|
335
|
+
config, nil, '', feature_flag_key, '', feature_enabled, source_string, user_id, attributes
|
336
|
+
)
|
337
|
+
end
|
338
|
+
|
327
339
|
@notification_center.send_notifications(
|
328
340
|
NotificationCenter::NOTIFICATION_TYPES[:DECISION],
|
329
341
|
Helpers::Constants::DECISION_NOTIFICATION_TYPES['FEATURE'],
|
@@ -867,15 +879,43 @@ module Optimizely
|
|
867
879
|
raise InvalidInputError, 'event_dispatcher'
|
868
880
|
end
|
869
881
|
|
870
|
-
def send_impression(config, experiment, variation_key, user_id, attributes = nil)
|
882
|
+
def send_impression(config, experiment, variation_key, flag_key, rule_key, enabled, rule_type, user_id, attributes = nil)
|
883
|
+
if experiment.nil?
|
884
|
+
experiment = {
|
885
|
+
'id' => '',
|
886
|
+
'key' => '',
|
887
|
+
'layerId' => '',
|
888
|
+
'status' => '',
|
889
|
+
'variations' => [],
|
890
|
+
'trafficAllocation' => [],
|
891
|
+
'audienceIds' => [],
|
892
|
+
'audienceConditions' => [],
|
893
|
+
'forcedVariations' => {}
|
894
|
+
}
|
895
|
+
end
|
896
|
+
|
871
897
|
experiment_key = experiment['key']
|
872
|
-
|
873
|
-
|
898
|
+
|
899
|
+
variation_id = ''
|
900
|
+
variation_id = config.get_variation_id_from_key(experiment_key, variation_key) if experiment_key != ''
|
901
|
+
|
902
|
+
metadata = {
|
903
|
+
flag_key: flag_key,
|
904
|
+
rule_key: rule_key,
|
905
|
+
rule_type: rule_type,
|
906
|
+
variation_key: variation_key,
|
907
|
+
enabled: enabled
|
908
|
+
}
|
909
|
+
|
910
|
+
user_event = UserEventFactory.create_impression_event(config, experiment, variation_id, metadata, user_id, attributes)
|
874
911
|
@event_processor.process(user_event)
|
875
912
|
return unless @notification_center.notification_count(NotificationCenter::NOTIFICATION_TYPES[:ACTIVATE]).positive?
|
876
913
|
|
877
914
|
@logger.log(Logger::INFO, "Activating user '#{user_id}' in experiment '#{experiment_key}'.")
|
878
|
-
|
915
|
+
|
916
|
+
experiment = nil if experiment_key == ''
|
917
|
+
variation = nil
|
918
|
+
variation = config.get_variation_from_id(experiment_key, variation_id) unless experiment.nil?
|
879
919
|
log_event = EventFactory.create_log_event(user_event, @logger)
|
880
920
|
@notification_center.send_notifications(
|
881
921
|
NotificationCenter::NOTIFICATION_TYPES[:ACTIVATE],
|
@@ -40,6 +40,7 @@ module Optimizely
|
|
40
40
|
attr_reader :revision
|
41
41
|
attr_reader :rollouts
|
42
42
|
attr_reader :version
|
43
|
+
attr_reader :send_flag_decisions
|
43
44
|
|
44
45
|
attr_reader :attribute_key_map
|
45
46
|
attr_reader :audience_id_map
|
@@ -83,6 +84,7 @@ module Optimizely
|
|
83
84
|
@bot_filtering = config['botFiltering']
|
84
85
|
@revision = config['revision']
|
85
86
|
@rollouts = config.fetch('rollouts', [])
|
87
|
+
@send_flag_decisions = config.fetch('sendFlagDecisions', false)
|
86
88
|
|
87
89
|
# Json type is represented in datafile as a subtype of string for the sake of backwards compatibility.
|
88
90
|
# Converting it to a first-class json type while creating Project Config
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
4
|
+
# Copyright 2019-2020, Optimizely and contributors
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -17,19 +17,21 @@
|
|
17
17
|
#
|
18
18
|
module Optimizely
|
19
19
|
class Decision
|
20
|
-
attr_reader :campaign_id, :experiment_id, :variation_id
|
20
|
+
attr_reader :campaign_id, :experiment_id, :variation_id, :metadata
|
21
21
|
|
22
|
-
def initialize(campaign_id:, experiment_id:, variation_id:)
|
22
|
+
def initialize(campaign_id:, experiment_id:, variation_id:, metadata:)
|
23
23
|
@campaign_id = campaign_id
|
24
24
|
@experiment_id = experiment_id
|
25
25
|
@variation_id = variation_id
|
26
|
+
@metadata = metadata
|
26
27
|
end
|
27
28
|
|
28
29
|
def as_json
|
29
30
|
{
|
30
31
|
campaign_id: @campaign_id,
|
31
32
|
experiment_id: @experiment_id,
|
32
|
-
variation_id: @variation_id
|
33
|
+
variation_id: @variation_id,
|
34
|
+
metadata: @metadata
|
33
35
|
}
|
34
36
|
end
|
35
37
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
4
|
+
# Copyright 2019-2020, Optimizely and contributors
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -19,7 +19,7 @@ require_relative 'user_event'
|
|
19
19
|
require 'optimizely/helpers/date_time_utils'
|
20
20
|
module Optimizely
|
21
21
|
class ImpressionEvent < UserEvent
|
22
|
-
attr_reader :user_id, :experiment_layer_id, :experiment_id, :variation_id,
|
22
|
+
attr_reader :user_id, :experiment_layer_id, :experiment_id, :variation_id, :metadata,
|
23
23
|
:visitor_attributes, :bot_filtering
|
24
24
|
|
25
25
|
def initialize(
|
@@ -28,6 +28,7 @@ module Optimizely
|
|
28
28
|
experiment_layer_id:,
|
29
29
|
experiment_id:,
|
30
30
|
variation_id:,
|
31
|
+
metadata:,
|
31
32
|
visitor_attributes:,
|
32
33
|
bot_filtering:
|
33
34
|
)
|
@@ -38,6 +39,7 @@ module Optimizely
|
|
38
39
|
@experiment_layer_id = experiment_layer_id
|
39
40
|
@experiment_id = experiment_id
|
40
41
|
@variation_id = variation_id
|
42
|
+
@metadata = metadata
|
41
43
|
@visitor_attributes = visitor_attributes
|
42
44
|
@bot_filtering = bot_filtering
|
43
45
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
4
|
+
# Copyright 2019-2020, Optimizely and contributors
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -101,10 +101,11 @@ module Optimizely
|
|
101
101
|
private
|
102
102
|
|
103
103
|
def create_impression_event_visitor(impression_event)
|
104
|
-
decision =
|
104
|
+
decision = Decision.new(
|
105
105
|
campaign_id: impression_event.experiment_layer_id,
|
106
106
|
experiment_id: impression_event.experiment_id,
|
107
|
-
variation_id: impression_event.variation_id
|
107
|
+
variation_id: impression_event.variation_id,
|
108
|
+
metadata: impression_event.metadata
|
108
109
|
)
|
109
110
|
|
110
111
|
snapshot_event = Optimizely::SnapshotEvent.new(
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
4
|
+
# Copyright 2019-2020, Optimizely and contributors
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -22,7 +22,7 @@ require_relative 'event_factory'
|
|
22
22
|
module Optimizely
|
23
23
|
class UserEventFactory
|
24
24
|
# UserEventFactory builds ImpressionEvent and ConversionEvent objects from a given user_event.
|
25
|
-
def self.create_impression_event(project_config, experiment, variation_id, user_id, user_attributes)
|
25
|
+
def self.create_impression_event(project_config, experiment, variation_id, metadata, user_id, user_attributes)
|
26
26
|
# Create impression Event to be sent to the logging endpoint.
|
27
27
|
#
|
28
28
|
# project_config - Instance of ProjectConfig
|
@@ -42,13 +42,14 @@ module Optimizely
|
|
42
42
|
).as_json
|
43
43
|
|
44
44
|
visitor_attributes = Optimizely::EventFactory.build_attribute_list(user_attributes, project_config)
|
45
|
-
experiment_layer_id =
|
45
|
+
experiment_layer_id = experiment['layerId']
|
46
46
|
Optimizely::ImpressionEvent.new(
|
47
47
|
event_context: event_context,
|
48
48
|
user_id: user_id,
|
49
49
|
experiment_layer_id: experiment_layer_id,
|
50
50
|
experiment_id: experiment['id'],
|
51
51
|
variation_id: variation_id,
|
52
|
+
metadata: metadata,
|
52
53
|
visitor_attributes: visitor_attributes,
|
53
54
|
bot_filtering: project_config.bot_filtering
|
54
55
|
)
|
data/lib/optimizely/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optimizely-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Optimizely
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|