optimizely-sdk 3.10.1 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +202 -202
- data/lib/optimizely/audience.rb +127 -97
- data/lib/optimizely/bucketer.rb +156 -156
- data/lib/optimizely/condition_tree_evaluator.rb +123 -123
- data/lib/optimizely/config/datafile_project_config.rb +539 -552
- data/lib/optimizely/config/proxy_config.rb +34 -34
- data/lib/optimizely/config_manager/async_scheduler.rb +95 -95
- data/lib/optimizely/config_manager/http_project_config_manager.rb +330 -329
- data/lib/optimizely/config_manager/project_config_manager.rb +24 -24
- data/lib/optimizely/config_manager/static_project_config_manager.rb +53 -52
- data/lib/optimizely/decide/optimizely_decide_option.rb +28 -28
- data/lib/optimizely/decide/optimizely_decision.rb +60 -60
- data/lib/optimizely/decide/optimizely_decision_message.rb +26 -26
- data/lib/optimizely/decision_service.rb +563 -563
- data/lib/optimizely/error_handler.rb +39 -39
- data/lib/optimizely/event/batch_event_processor.rb +235 -234
- data/lib/optimizely/event/entity/conversion_event.rb +44 -43
- data/lib/optimizely/event/entity/decision.rb +38 -38
- data/lib/optimizely/event/entity/event_batch.rb +86 -86
- data/lib/optimizely/event/entity/event_context.rb +50 -50
- data/lib/optimizely/event/entity/impression_event.rb +48 -47
- data/lib/optimizely/event/entity/snapshot.rb +33 -33
- data/lib/optimizely/event/entity/snapshot_event.rb +48 -48
- data/lib/optimizely/event/entity/user_event.rb +22 -22
- data/lib/optimizely/event/entity/visitor.rb +36 -35
- data/lib/optimizely/event/entity/visitor_attribute.rb +38 -37
- data/lib/optimizely/event/event_factory.rb +156 -155
- data/lib/optimizely/event/event_processor.rb +25 -25
- data/lib/optimizely/event/forwarding_event_processor.rb +44 -43
- data/lib/optimizely/event/user_event_factory.rb +88 -88
- data/lib/optimizely/event_builder.rb +221 -228
- data/lib/optimizely/event_dispatcher.rb +71 -71
- data/lib/optimizely/exceptions.rb +135 -139
- data/lib/optimizely/helpers/constants.rb +415 -397
- data/lib/optimizely/helpers/date_time_utils.rb +30 -30
- data/lib/optimizely/helpers/event_tag_utils.rb +132 -132
- data/lib/optimizely/helpers/group.rb +31 -31
- data/lib/optimizely/helpers/http_utils.rb +65 -64
- data/lib/optimizely/helpers/validator.rb +183 -183
- data/lib/optimizely/helpers/variable_type.rb +67 -67
- data/lib/optimizely/logger.rb +46 -45
- data/lib/optimizely/notification_center.rb +174 -176
- data/lib/optimizely/optimizely_config.rb +271 -272
- data/lib/optimizely/optimizely_factory.rb +181 -181
- data/lib/optimizely/optimizely_user_context.rb +204 -179
- data/lib/optimizely/params.rb +31 -31
- data/lib/optimizely/project_config.rb +99 -91
- data/lib/optimizely/semantic_version.rb +166 -166
- data/lib/optimizely/{custom_attribute_condition_evaluator.rb → user_condition_evaluator.rb} +391 -369
- data/lib/optimizely/user_profile_service.rb +35 -35
- data/lib/optimizely/version.rb +21 -21
- data/lib/optimizely.rb +1130 -1145
- metadata +15 -14
@@ -1,38 +1,38 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright 2019-2020, Optimizely and contributors
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
module Optimizely
|
19
|
-
class Decision
|
20
|
-
attr_reader :campaign_id, :experiment_id, :variation_id, :metadata
|
21
|
-
|
22
|
-
def initialize(campaign_id:, experiment_id:, variation_id:, metadata:)
|
23
|
-
@campaign_id = campaign_id
|
24
|
-
@experiment_id = experiment_id
|
25
|
-
@variation_id = variation_id
|
26
|
-
@metadata = metadata
|
27
|
-
end
|
28
|
-
|
29
|
-
def as_json
|
30
|
-
{
|
31
|
-
campaign_id: @campaign_id,
|
32
|
-
experiment_id: @experiment_id,
|
33
|
-
variation_id: @variation_id,
|
34
|
-
metadata: @metadata
|
35
|
-
}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2019-2020, Optimizely and contributors
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Optimizely
|
19
|
+
class Decision
|
20
|
+
attr_reader :campaign_id, :experiment_id, :variation_id, :metadata
|
21
|
+
|
22
|
+
def initialize(campaign_id:, experiment_id:, variation_id:, metadata:)
|
23
|
+
@campaign_id = campaign_id
|
24
|
+
@experiment_id = experiment_id
|
25
|
+
@variation_id = variation_id
|
26
|
+
@metadata = metadata
|
27
|
+
end
|
28
|
+
|
29
|
+
def as_json
|
30
|
+
{
|
31
|
+
campaign_id: @campaign_id,
|
32
|
+
experiment_id: @experiment_id,
|
33
|
+
variation_id: @variation_id,
|
34
|
+
metadata: @metadata
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,86 +1,86 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
module Optimizely
|
19
|
-
class EventBatch
|
20
|
-
attr_accessor :account_id, :project_id, :revision, :client_name, :client_version,
|
21
|
-
:anonymize_ip, :enrich_decisions, :visitors
|
22
|
-
|
23
|
-
def as_json
|
24
|
-
{
|
25
|
-
account_id: @account_id,
|
26
|
-
project_id: @project_id,
|
27
|
-
revision: @revision,
|
28
|
-
client_name: @client_name,
|
29
|
-
client_version: @client_version,
|
30
|
-
anonymize_ip: @anonymize_ip,
|
31
|
-
enrich_decisions: @enrich_decisions,
|
32
|
-
visitors: @visitors
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
class Builder
|
37
|
-
attr_reader :account_id, :project_id, :revision, :client_name, :client_version,
|
38
|
-
:anonymize_ip, :enrich_decisions, :visitors
|
39
|
-
|
40
|
-
def build
|
41
|
-
event_batch = EventBatch.new
|
42
|
-
event_batch.account_id = @account_id
|
43
|
-
event_batch.project_id = @project_id
|
44
|
-
event_batch.revision = @revision
|
45
|
-
event_batch.client_name = @client_name
|
46
|
-
event_batch.client_version = @client_version
|
47
|
-
event_batch.anonymize_ip = @anonymize_ip
|
48
|
-
event_batch.enrich_decisions = @enrich_decisions
|
49
|
-
event_batch.visitors = @visitors
|
50
|
-
event_batch
|
51
|
-
end
|
52
|
-
|
53
|
-
def with_account_id(account_id)
|
54
|
-
@account_id = account_id
|
55
|
-
end
|
56
|
-
|
57
|
-
def with_project_id(project_id)
|
58
|
-
@project_id = project_id
|
59
|
-
end
|
60
|
-
|
61
|
-
def with_revision(revision)
|
62
|
-
@revision = revision
|
63
|
-
end
|
64
|
-
|
65
|
-
def with_client_name(client_name)
|
66
|
-
@client_name = client_name
|
67
|
-
end
|
68
|
-
|
69
|
-
def with_client_version(client_version)
|
70
|
-
@client_version = client_version
|
71
|
-
end
|
72
|
-
|
73
|
-
def with_anonymize_ip(anonymize_ip)
|
74
|
-
@anonymize_ip = anonymize_ip
|
75
|
-
end
|
76
|
-
|
77
|
-
def with_enrich_decisions(enrich_decisions)
|
78
|
-
@enrich_decisions = enrich_decisions
|
79
|
-
end
|
80
|
-
|
81
|
-
def with_visitors(visitors)
|
82
|
-
@visitors = visitors
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2019, Optimizely and contributors
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Optimizely
|
19
|
+
class EventBatch
|
20
|
+
attr_accessor :account_id, :project_id, :revision, :client_name, :client_version,
|
21
|
+
:anonymize_ip, :enrich_decisions, :visitors
|
22
|
+
|
23
|
+
def as_json
|
24
|
+
{
|
25
|
+
account_id: @account_id,
|
26
|
+
project_id: @project_id,
|
27
|
+
revision: @revision,
|
28
|
+
client_name: @client_name,
|
29
|
+
client_version: @client_version,
|
30
|
+
anonymize_ip: @anonymize_ip,
|
31
|
+
enrich_decisions: @enrich_decisions,
|
32
|
+
visitors: @visitors
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
class Builder
|
37
|
+
attr_reader :account_id, :project_id, :revision, :client_name, :client_version,
|
38
|
+
:anonymize_ip, :enrich_decisions, :visitors
|
39
|
+
|
40
|
+
def build
|
41
|
+
event_batch = EventBatch.new
|
42
|
+
event_batch.account_id = @account_id
|
43
|
+
event_batch.project_id = @project_id
|
44
|
+
event_batch.revision = @revision
|
45
|
+
event_batch.client_name = @client_name
|
46
|
+
event_batch.client_version = @client_version
|
47
|
+
event_batch.anonymize_ip = @anonymize_ip
|
48
|
+
event_batch.enrich_decisions = @enrich_decisions
|
49
|
+
event_batch.visitors = @visitors
|
50
|
+
event_batch
|
51
|
+
end
|
52
|
+
|
53
|
+
def with_account_id(account_id)
|
54
|
+
@account_id = account_id
|
55
|
+
end
|
56
|
+
|
57
|
+
def with_project_id(project_id)
|
58
|
+
@project_id = project_id
|
59
|
+
end
|
60
|
+
|
61
|
+
def with_revision(revision)
|
62
|
+
@revision = revision
|
63
|
+
end
|
64
|
+
|
65
|
+
def with_client_name(client_name)
|
66
|
+
@client_name = client_name
|
67
|
+
end
|
68
|
+
|
69
|
+
def with_client_version(client_version)
|
70
|
+
@client_version = client_version
|
71
|
+
end
|
72
|
+
|
73
|
+
def with_anonymize_ip(anonymize_ip)
|
74
|
+
@anonymize_ip = anonymize_ip
|
75
|
+
end
|
76
|
+
|
77
|
+
def with_enrich_decisions(enrich_decisions)
|
78
|
+
@enrich_decisions = enrich_decisions
|
79
|
+
end
|
80
|
+
|
81
|
+
def with_visitors(visitors)
|
82
|
+
@visitors = visitors
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,50 +1,50 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
module Optimizely
|
19
|
-
class EventContext
|
20
|
-
attr_reader :account_id, :project_id, :anonymize_ip, :revision, :client_name,
|
21
|
-
:client_version
|
22
|
-
|
23
|
-
def initialize(
|
24
|
-
account_id:,
|
25
|
-
project_id:,
|
26
|
-
anonymize_ip:,
|
27
|
-
revision:,
|
28
|
-
client_name:,
|
29
|
-
client_version:
|
30
|
-
)
|
31
|
-
@account_id = account_id
|
32
|
-
@project_id = project_id
|
33
|
-
@anonymize_ip = anonymize_ip
|
34
|
-
@revision = revision
|
35
|
-
@client_name = client_name
|
36
|
-
@client_version = client_version
|
37
|
-
end
|
38
|
-
|
39
|
-
def as_json
|
40
|
-
{
|
41
|
-
account_id: @account_id,
|
42
|
-
project_id: @project_id,
|
43
|
-
anonymize_ip: @anonymize_ip,
|
44
|
-
revision: @revision,
|
45
|
-
client_name: @client_name,
|
46
|
-
client_version: @client_version
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2019, Optimizely and contributors
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Optimizely
|
19
|
+
class EventContext
|
20
|
+
attr_reader :account_id, :project_id, :anonymize_ip, :revision, :client_name,
|
21
|
+
:client_version
|
22
|
+
|
23
|
+
def initialize(
|
24
|
+
account_id:,
|
25
|
+
project_id:,
|
26
|
+
anonymize_ip:,
|
27
|
+
revision:,
|
28
|
+
client_name:,
|
29
|
+
client_version:
|
30
|
+
)
|
31
|
+
@account_id = account_id
|
32
|
+
@project_id = project_id
|
33
|
+
@anonymize_ip = anonymize_ip
|
34
|
+
@revision = revision
|
35
|
+
@client_name = client_name
|
36
|
+
@client_version = client_version
|
37
|
+
end
|
38
|
+
|
39
|
+
def as_json
|
40
|
+
{
|
41
|
+
account_id: @account_id,
|
42
|
+
project_id: @project_id,
|
43
|
+
anonymize_ip: @anonymize_ip,
|
44
|
+
revision: @revision,
|
45
|
+
client_name: @client_name,
|
46
|
+
client_version: @client_version
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,47 +1,48 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright 2019-2020, Optimizely and contributors
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
require_relative 'user_event'
|
19
|
-
require 'optimizely/helpers/date_time_utils'
|
20
|
-
module Optimizely
|
21
|
-
class ImpressionEvent < UserEvent
|
22
|
-
attr_reader :user_id, :experiment_layer_id, :experiment_id, :variation_id, :metadata,
|
23
|
-
:visitor_attributes, :bot_filtering
|
24
|
-
|
25
|
-
def initialize(
|
26
|
-
event_context:,
|
27
|
-
user_id:,
|
28
|
-
experiment_layer_id:,
|
29
|
-
experiment_id:,
|
30
|
-
variation_id:,
|
31
|
-
metadata:,
|
32
|
-
visitor_attributes:,
|
33
|
-
bot_filtering:
|
34
|
-
)
|
35
|
-
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
|
46
|
-
|
47
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2019-2020, 2022, Optimizely and contributors
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
require_relative 'user_event'
|
19
|
+
require 'optimizely/helpers/date_time_utils'
|
20
|
+
module Optimizely
|
21
|
+
class ImpressionEvent < UserEvent
|
22
|
+
attr_reader :user_id, :experiment_layer_id, :experiment_id, :variation_id, :metadata,
|
23
|
+
:visitor_attributes, :bot_filtering
|
24
|
+
|
25
|
+
def initialize(
|
26
|
+
event_context:,
|
27
|
+
user_id:,
|
28
|
+
experiment_layer_id:,
|
29
|
+
experiment_id:,
|
30
|
+
variation_id:,
|
31
|
+
metadata:,
|
32
|
+
visitor_attributes:,
|
33
|
+
bot_filtering:
|
34
|
+
)
|
35
|
+
super()
|
36
|
+
@event_context = event_context
|
37
|
+
@uuid = SecureRandom.uuid
|
38
|
+
@timestamp = Helpers::DateTimeUtils.create_timestamp
|
39
|
+
@user_id = user_id
|
40
|
+
@experiment_layer_id = experiment_layer_id
|
41
|
+
@experiment_id = experiment_id
|
42
|
+
@variation_id = variation_id
|
43
|
+
@metadata = metadata
|
44
|
+
@visitor_attributes = visitor_attributes
|
45
|
+
@bot_filtering = bot_filtering
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
module Optimizely
|
19
|
-
class Snapshot
|
20
|
-
attr_reader :events, :decisions
|
21
|
-
|
22
|
-
def initialize(events:, decisions: nil)
|
23
|
-
@decisions = decisions
|
24
|
-
@events = events
|
25
|
-
end
|
26
|
-
|
27
|
-
def as_json
|
28
|
-
hash = {events: @events}
|
29
|
-
hash[:decisions] = @decisions unless @decisions.nil?
|
30
|
-
hash
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2019, Optimizely and contributors
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Optimizely
|
19
|
+
class Snapshot
|
20
|
+
attr_reader :events, :decisions
|
21
|
+
|
22
|
+
def initialize(events:, decisions: nil)
|
23
|
+
@decisions = decisions
|
24
|
+
@events = events
|
25
|
+
end
|
26
|
+
|
27
|
+
def as_json
|
28
|
+
hash = {events: @events}
|
29
|
+
hash[:decisions] = @decisions unless @decisions.nil?
|
30
|
+
hash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,48 +1,48 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
module Optimizely
|
19
|
-
class SnapshotEvent
|
20
|
-
attr_reader :entity_id, :uuid, :key, :timestamp, :revenue, :value, :tags
|
21
|
-
|
22
|
-
def initialize(
|
23
|
-
entity_id:,
|
24
|
-
uuid:,
|
25
|
-
key:,
|
26
|
-
timestamp:,
|
27
|
-
revenue: nil,
|
28
|
-
value: nil,
|
29
|
-
tags: nil
|
30
|
-
)
|
31
|
-
@entity_id = entity_id
|
32
|
-
@uuid = uuid
|
33
|
-
@key = key
|
34
|
-
@timestamp = timestamp
|
35
|
-
@revenue = revenue
|
36
|
-
@value = value
|
37
|
-
@tags = tags
|
38
|
-
end
|
39
|
-
|
40
|
-
def as_json
|
41
|
-
hash = {entity_id: @entity_id, uuid: @uuid, key: @key, timestamp: @timestamp}
|
42
|
-
hash[:revenue] = @revenue unless @revenue.nil?
|
43
|
-
hash[:value] = @value unless @value.nil?
|
44
|
-
hash[:tags] = @tags unless @tags.nil?
|
45
|
-
hash
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2019, Optimizely and contributors
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Optimizely
|
19
|
+
class SnapshotEvent
|
20
|
+
attr_reader :entity_id, :uuid, :key, :timestamp, :revenue, :value, :tags
|
21
|
+
|
22
|
+
def initialize(
|
23
|
+
entity_id:,
|
24
|
+
uuid:,
|
25
|
+
key:,
|
26
|
+
timestamp:,
|
27
|
+
revenue: nil,
|
28
|
+
value: nil,
|
29
|
+
tags: nil
|
30
|
+
)
|
31
|
+
@entity_id = entity_id
|
32
|
+
@uuid = uuid
|
33
|
+
@key = key
|
34
|
+
@timestamp = timestamp
|
35
|
+
@revenue = revenue
|
36
|
+
@value = value
|
37
|
+
@tags = tags
|
38
|
+
end
|
39
|
+
|
40
|
+
def as_json
|
41
|
+
hash = {entity_id: @entity_id, uuid: @uuid, key: @key, timestamp: @timestamp}
|
42
|
+
hash[:revenue] = @revenue unless @revenue.nil?
|
43
|
+
hash[:value] = @value unless @value.nil?
|
44
|
+
hash[:tags] = @tags unless @tags.nil?
|
45
|
+
hash
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright 2019, Optimizely and contributors
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
module Optimizely
|
19
|
-
class UserEvent
|
20
|
-
attr_reader :event_context, :uuid, :timestamp
|
21
|
-
end
|
22
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2019, Optimizely and contributors
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Optimizely
|
19
|
+
class UserEvent
|
20
|
+
attr_reader :event_context, :uuid, :timestamp
|
21
|
+
end
|
22
|
+
end
|