wingify-fme-ruby-sdk 1.50.0
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 +7 -0
- data/lib/resources/debug_messages.json +21 -0
- data/lib/resources/error_messages.json +63 -0
- data/lib/resources/info_messages.json +43 -0
- data/lib/resources/warn_messages.json +1 -0
- data/lib/vwo.rb +40 -0
- data/lib/wingify/api/get_flag.rb +244 -0
- data/lib/wingify/api/set_attribute.rb +57 -0
- data/lib/wingify/api/track_event.rb +80 -0
- data/lib/wingify/constants/constants.rb +106 -0
- data/lib/wingify/decorators/storage_decorator.rb +82 -0
- data/lib/wingify/enums/api_enum.rb +23 -0
- data/lib/wingify/enums/campaign_type_enum.rb +19 -0
- data/lib/wingify/enums/debug_category_enum.rb +20 -0
- data/lib/wingify/enums/decision_types_enum.rb +18 -0
- data/lib/wingify/enums/event_enum.rb +22 -0
- data/lib/wingify/enums/headers_enum.rb +20 -0
- data/lib/wingify/enums/hooks_enum.rb +17 -0
- data/lib/wingify/enums/http_method_enum.rb +18 -0
- data/lib/wingify/enums/log_level_enum.rb +21 -0
- data/lib/wingify/enums/log_level_to_number.rb +27 -0
- data/lib/wingify/enums/status_enum.rb +19 -0
- data/lib/wingify/enums/storage_enum.rb +22 -0
- data/lib/wingify/enums/url_enum.rb +22 -0
- data/lib/wingify/models/campaign/campaign_model.rb +192 -0
- data/lib/wingify/models/campaign/feature_model.rb +111 -0
- data/lib/wingify/models/campaign/impact_campaign_model.rb +38 -0
- data/lib/wingify/models/campaign/metric_model.rb +44 -0
- data/lib/wingify/models/campaign/rule_model.rb +56 -0
- data/lib/wingify/models/campaign/variable_model.rb +51 -0
- data/lib/wingify/models/campaign/variation_model.rb +137 -0
- data/lib/wingify/models/gateway_service_model.rb +39 -0
- data/lib/wingify/models/schemas/settings_schema_validation.rb +104 -0
- data/lib/wingify/models/settings/settings_model.rb +101 -0
- data/lib/wingify/models/storage/storage_data_model.rb +44 -0
- data/lib/wingify/models/user/context_model.rb +154 -0
- data/lib/wingify/models/user/context_vwo_model.rb +38 -0
- data/lib/wingify/models/user/get_flag_response.rb +50 -0
- data/lib/wingify/models/vwo_options_model.rb +129 -0
- data/lib/wingify/packages/decision_maker/decision_maker.rb +60 -0
- data/lib/wingify/packages/logger/core/log_manager.rb +92 -0
- data/lib/wingify/packages/logger/core/transport_manager.rb +76 -0
- data/lib/wingify/packages/logger/log_message_builder.rb +70 -0
- data/lib/wingify/packages/logger/logger.rb +38 -0
- data/lib/wingify/packages/logger/transports/console_transport.rb +49 -0
- data/lib/wingify/packages/network_layer/client/network_client.rb +276 -0
- data/lib/wingify/packages/network_layer/handlers/request_handler.rb +37 -0
- data/lib/wingify/packages/network_layer/manager/network_manager.rb +145 -0
- data/lib/wingify/packages/network_layer/models/global_request_model.rb +105 -0
- data/lib/wingify/packages/network_layer/models/request_model.rb +179 -0
- data/lib/wingify/packages/network_layer/models/response_model.rb +62 -0
- data/lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb +77 -0
- data/lib/wingify/packages/segmentation_evaluator/enums/segment_operand_regex_enum.rb +29 -0
- data/lib/wingify/packages/segmentation_evaluator/enums/segment_operand_value_enum.rb +26 -0
- data/lib/wingify/packages/segmentation_evaluator/enums/segment_operator_value_enum.rb +33 -0
- data/lib/wingify/packages/segmentation_evaluator/evaluators/segment_evaluator.rb +218 -0
- data/lib/wingify/packages/segmentation_evaluator/evaluators/segment_operand_evaluator.rb +415 -0
- data/lib/wingify/packages/segmentation_evaluator/utils/segment_util.rb +44 -0
- data/lib/wingify/packages/storage/connector.rb +26 -0
- data/lib/wingify/packages/storage/storage.rb +47 -0
- data/lib/wingify/services/batch_event_queue.rb +179 -0
- data/lib/wingify/services/campaign_decision_service.rb +161 -0
- data/lib/wingify/services/hooks_service.rb +51 -0
- data/lib/wingify/services/logger_service.rb +114 -0
- data/lib/wingify/services/settings_service.rb +178 -0
- data/lib/wingify/services/storage_service.rb +66 -0
- data/lib/wingify/utils/batch_event_dispatcher_util.rb +178 -0
- data/lib/wingify/utils/brand_context.rb +33 -0
- data/lib/wingify/utils/brand_util.rb +53 -0
- data/lib/wingify/utils/campaign_util.rb +284 -0
- data/lib/wingify/utils/data_type_util.rb +105 -0
- data/lib/wingify/utils/debugger_service_util.rb +40 -0
- data/lib/wingify/utils/decision_util.rb +259 -0
- data/lib/wingify/utils/event_util.rb +55 -0
- data/lib/wingify/utils/function_util.rb +141 -0
- data/lib/wingify/utils/gateway_service_util.rb +101 -0
- data/lib/wingify/utils/impression_util.rb +66 -0
- data/lib/wingify/utils/log_message_util.rb +42 -0
- data/lib/wingify/utils/meg_util.rb +357 -0
- data/lib/wingify/utils/network_util.rb +503 -0
- data/lib/wingify/utils/rule_evaluation_util.rb +57 -0
- data/lib/wingify/utils/settings_util.rb +38 -0
- data/lib/wingify/utils/usage_stats_util.rb +119 -0
- data/lib/wingify/utils/uuid_util.rb +96 -0
- data/lib/wingify/wingify_builder.rb +261 -0
- data/lib/wingify/wingify_client.rb +227 -0
- data/lib/wingify.rb +117 -0
- metadata +327 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# Constants file for Ruby SDK
|
|
16
|
+
|
|
17
|
+
# Define the Constants module
|
|
18
|
+
module Constants
|
|
19
|
+
SDK_NAME = 'vwo-fme-ruby-sdk'.freeze
|
|
20
|
+
SDK_VERSION = '1.50.0'.freeze
|
|
21
|
+
|
|
22
|
+
# --- Brand-specific constants ---
|
|
23
|
+
|
|
24
|
+
# SDK gem names (sent in every network request as the sdk name identifier)
|
|
25
|
+
VWO_SDK_NAME = 'vwo-fme-ruby-sdk'.freeze
|
|
26
|
+
WINGIFY_SDK_NAME = 'wingify-fme-ruby-sdk'.freeze
|
|
27
|
+
|
|
28
|
+
# Settings fetch hostnames
|
|
29
|
+
VWO_HOST_NAME = 'dev.visualwebsiteoptimizer.com'.freeze
|
|
30
|
+
WINGIFY_SETTINGS_HOST_NAME = 'edge.wingify.net'.freeze
|
|
31
|
+
|
|
32
|
+
# Collect / events hostnames (used for ALL outbound POST calls)
|
|
33
|
+
WINGIFY_COLLECTION_HOST_NAME = 'collect.wingify.net'.freeze
|
|
34
|
+
# Note: VWO uses VWO_HOST_NAME for both settings and events
|
|
35
|
+
|
|
36
|
+
# Log prefixes shown in every log line
|
|
37
|
+
VWO_LOG_PREFIX = 'VWO-SDK'.freeze
|
|
38
|
+
WINGIFY_LOG_PREFIX = 'Wingify-SDK'.freeze
|
|
39
|
+
|
|
40
|
+
# Human-readable brand display names (used in log messages and error output)
|
|
41
|
+
VWO_BRAND_DISPLAY_NAME = 'VWO'.freeze
|
|
42
|
+
WINGIFY_BRAND_DISPLAY_NAME = 'Wingify'.freeze
|
|
43
|
+
|
|
44
|
+
MAX_TRAFFIC_PERCENT = 100
|
|
45
|
+
MAX_TRAFFIC_VALUE = 10_000
|
|
46
|
+
STATUS_RUNNING = 'RUNNING'.freeze
|
|
47
|
+
|
|
48
|
+
SEED_VALUE = 1
|
|
49
|
+
MAX_EVENTS_PER_REQUEST = 5_000
|
|
50
|
+
DEFAULT_REQUEST_TIME_INTERVAL = 600 # 10 minutes in seconds
|
|
51
|
+
DEFAULT_EVENTS_PER_REQUEST = 100
|
|
52
|
+
MIN_REQUEST_TIME_INTERVAL = 2
|
|
53
|
+
MIN_EVENTS_PER_REQUEST = 1
|
|
54
|
+
|
|
55
|
+
SEED_URL = 'https://vwo.com'.freeze # Define SEED_URL
|
|
56
|
+
WEB_UUID_REGEX = /\A[DJ][0-9A-Fa-f]{32}\z/.freeze
|
|
57
|
+
HTTP_PROTOCOL = 'http'.freeze
|
|
58
|
+
HTTPS_PROTOCOL = 'https'.freeze
|
|
59
|
+
|
|
60
|
+
SETTINGS = 'settings'.freeze
|
|
61
|
+
SETTINGS_EXPIRY = 10_000_000
|
|
62
|
+
SETTINGS_TIMEOUT = 50_000
|
|
63
|
+
POLLING_INTERVAL = 600_000 # 10 minutes in milliseconds
|
|
64
|
+
|
|
65
|
+
HOST_NAME = 'dev.visualwebsiteoptimizer.com'.freeze
|
|
66
|
+
SETTINGS_ENDPOINT = '/server-side/v2-settings'.freeze
|
|
67
|
+
WEBHOOK_SETTINGS_ENDPOINT = '/server-side/v2-pull'.freeze
|
|
68
|
+
LOCATION_ENDPOINT = '/getLocation'.freeze
|
|
69
|
+
|
|
70
|
+
VWO_FS_ENVIRONMENT = 'vwo_fs_environment'.freeze
|
|
71
|
+
|
|
72
|
+
RANDOM_ALGO = 1
|
|
73
|
+
|
|
74
|
+
API_VERSION = '1'.freeze
|
|
75
|
+
|
|
76
|
+
VWO_META_MEG_KEY = '_vwo_meta_meg_'.freeze
|
|
77
|
+
|
|
78
|
+
SHOULD_USE_THREADING = true
|
|
79
|
+
MAX_POOL_SIZE = 5
|
|
80
|
+
MAX_QUEUE_SIZE = 10000
|
|
81
|
+
|
|
82
|
+
PRODUCT_NAME = 'fme'.freeze
|
|
83
|
+
|
|
84
|
+
REQUEST_TIMEOUT = 10 # 10 seconds
|
|
85
|
+
|
|
86
|
+
# Retry mechanism constants
|
|
87
|
+
MAX_RETRIES = 3
|
|
88
|
+
INITIAL_RETRY_DELAY = 2 # seconds
|
|
89
|
+
RETRY_BACKOFF_FACTOR = 2
|
|
90
|
+
|
|
91
|
+
# Default retry configuration
|
|
92
|
+
DEFAULT_RETRY_CONFIG = {
|
|
93
|
+
should_retry: true,
|
|
94
|
+
initial_delay: 2,
|
|
95
|
+
max_retries: 3,
|
|
96
|
+
backoff_multiplier: 2
|
|
97
|
+
}.freeze
|
|
98
|
+
|
|
99
|
+
# debugger event constants
|
|
100
|
+
V2_SETTINGS = 'v2-settings'.freeze
|
|
101
|
+
POLLING = 'polling'.freeze
|
|
102
|
+
BATCH_EVENTS = 'batch-events'.freeze
|
|
103
|
+
NETWORK_CALL_FAILURE_AFTER_MAX_RETRIES = 'NETWORK_CALL_FAILURE_AFTER_MAX_RETRIES'.freeze
|
|
104
|
+
NETWORK_CALL_SUCCESS_WITH_RETRIES = 'NETWORK_CALL_SUCCESS_WITH_RETRIES'.freeze
|
|
105
|
+
IMPACT_ANALYSIS = 'IMPACT_ANALYSIS'.freeze
|
|
106
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require_relative '../enums/storage_enum'
|
|
16
|
+
require_relative '../models/campaign/feature_model'
|
|
17
|
+
require_relative '../models/campaign/variation_model'
|
|
18
|
+
require_relative '../services/storage_service'
|
|
19
|
+
require_relative '../models/user/context_model'
|
|
20
|
+
require_relative '../services/logger_service'
|
|
21
|
+
require_relative '../enums/log_level_enum'
|
|
22
|
+
class StorageDecorator
|
|
23
|
+
# Retrieves a feature from storage based on the feature key and user.
|
|
24
|
+
# @param feature_key [String] The key of the feature to retrieve.
|
|
25
|
+
# @param context [ContextModel] The user object.
|
|
26
|
+
# @param storage_service [StorageService] The storage service instance.
|
|
27
|
+
# @return [Hash, StorageEnum] The retrieved feature or relevant status.
|
|
28
|
+
def get_feature_from_storage(feature_key, context, storage_service)
|
|
29
|
+
campaign_map = storage_service.get_data_from_storage(feature_key, context)
|
|
30
|
+
|
|
31
|
+
case campaign_map
|
|
32
|
+
when StorageEnum::STORAGE_UNDEFINED, StorageEnum::NO_DATA_FOUND,
|
|
33
|
+
StorageEnum::CAMPAIGN_PAUSED, StorageEnum::WHITELISTED_VARIATION
|
|
34
|
+
nil # Return nil when there's no valid data
|
|
35
|
+
when StorageEnum::INCORRECT_DATA, StorageEnum::VARIATION_NOT_FOUND
|
|
36
|
+
campaign_map # Return the relevant error constant
|
|
37
|
+
else
|
|
38
|
+
campaign_map # Return valid stored data
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Sets data in storage based on the provided data object.
|
|
43
|
+
# @param data [Hash] The data to be stored, including feature key and user details.
|
|
44
|
+
# @param storage_service [StorageService] The storage service instance.
|
|
45
|
+
def set_data_in_storage(data, storage_service)
|
|
46
|
+
feature_key = data[:feature_key]
|
|
47
|
+
context = data[:context]
|
|
48
|
+
rollout_id = data[:rollout_id]
|
|
49
|
+
rollout_key = data[:rollout_key]
|
|
50
|
+
rollout_variation_id = data[:rollout_variation_id]
|
|
51
|
+
experiment_id = data[:experiment_id]
|
|
52
|
+
experiment_key = data[:experiment_key]
|
|
53
|
+
experiment_variation_id = data[:experiment_variation_id]
|
|
54
|
+
|
|
55
|
+
if feature_key.nil?
|
|
56
|
+
raise 'Feature key is missing'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
if context.nil? || context.id.nil?
|
|
60
|
+
raise 'Context ID is missing'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if rollout_key && !experiment_key && !rollout_variation_id
|
|
64
|
+
raise 'Invalid rollout variation'
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if experiment_key && !experiment_variation_id
|
|
68
|
+
raise 'Invalid experiment variation'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
storage_service.set_data_in_storage({
|
|
72
|
+
feature_key: feature_key,
|
|
73
|
+
user_id: context.id,
|
|
74
|
+
rollout_id: rollout_id,
|
|
75
|
+
rollout_key: rollout_key,
|
|
76
|
+
rollout_variation_id: rollout_variation_id,
|
|
77
|
+
experiment_id: experiment_id,
|
|
78
|
+
experiment_key: experiment_key,
|
|
79
|
+
experiment_variation_id: experiment_variation_id
|
|
80
|
+
}, context)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module ApiEnum
|
|
16
|
+
INIT = 'init'
|
|
17
|
+
GET_FLAG = 'getFlag'
|
|
18
|
+
TRACK_EVENT = 'trackEvent'
|
|
19
|
+
SET_ATTRIBUTE = 'setAttribute'
|
|
20
|
+
UPDATE_SETTINGS = 'updateSettings'
|
|
21
|
+
FLUSH_EVENTS = 'flushEvents'
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module CampaignTypeEnum
|
|
16
|
+
ROLLOUT = 'FLAG_ROLLOUT'
|
|
17
|
+
AB = 'FLAG_TESTING'
|
|
18
|
+
PERSONALIZE = 'FLAG_PERSONALIZE'
|
|
19
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module DebugCategoryEnum
|
|
16
|
+
DECISION = 'decision'
|
|
17
|
+
NETWORK = 'network'
|
|
18
|
+
RETRY = 'retry'
|
|
19
|
+
ERROR = 'error'
|
|
20
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module DecisionTypes
|
|
16
|
+
CAMPAIGN_DECISION = 'CAMPAIGN_DECISION'
|
|
17
|
+
end
|
|
18
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# Event types
|
|
16
|
+
module EventEnum
|
|
17
|
+
VARIATION_SHOWN = 'vwo_variationShown'
|
|
18
|
+
SYNC_VISITOR_PROP = 'vwo_syncVisitorProp'
|
|
19
|
+
DEBUGGER_EVENT = 'vwo_sdkDebug'
|
|
20
|
+
INIT_CALLED = 'vwo_fmeSdkInit'
|
|
21
|
+
USAGE_STATS = 'vwo_sdkUsageStats'
|
|
22
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# HTTP Headers
|
|
16
|
+
module HeadersEnum
|
|
17
|
+
USER_AGENT = 'X-Device-User-Agent'
|
|
18
|
+
IP = 'VWO-X-Forwarded-For'
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module HooksEnum
|
|
16
|
+
DECISION_TYPES = DecisionTypes
|
|
17
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module HttpMethodEnum
|
|
16
|
+
GET = 'GET'
|
|
17
|
+
POST = 'POST'
|
|
18
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module LogLevelEnum
|
|
16
|
+
TRACE = 'trace'
|
|
17
|
+
DEBUG = 'debug'
|
|
18
|
+
INFO = 'info'
|
|
19
|
+
WARN = 'warn'
|
|
20
|
+
ERROR = 'error'
|
|
21
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module LogLevelToNumber
|
|
16
|
+
LEVELS = {
|
|
17
|
+
'TRACE' => 0,
|
|
18
|
+
'DEBUG' => 1,
|
|
19
|
+
'INFO' => 2,
|
|
20
|
+
'WARN' => 3,
|
|
21
|
+
'ERROR' => 4
|
|
22
|
+
}.freeze
|
|
23
|
+
|
|
24
|
+
def self.to_number(level)
|
|
25
|
+
LEVELS[level.to_s.upcase] || 0
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module StatusEnum
|
|
16
|
+
PASSED = 'passed'
|
|
17
|
+
FAILED = 'failed'
|
|
18
|
+
end
|
|
19
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module StorageEnum
|
|
16
|
+
STORAGE_UNDEFINED = :storage_undefined
|
|
17
|
+
INCORRECT_DATA = :incorrect_data
|
|
18
|
+
NO_DATA_FOUND = :no_data_found
|
|
19
|
+
CAMPAIGN_PAUSED = :campaign_paused
|
|
20
|
+
VARIATION_NOT_FOUND = :variation_not_found
|
|
21
|
+
WHITELISTED_VARIATION = :whitelisted_variation
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module UrlEnum
|
|
16
|
+
BASE_URL = 'dev.visualwebsiteoptimizer.com'
|
|
17
|
+
SETTINGS_URL = '/server-side/settings'
|
|
18
|
+
EVENTS = '/events/t'
|
|
19
|
+
ATTRIBUTE_CHECK = '/check-attribute'
|
|
20
|
+
GET_USER_DATA = '/get-user-details'
|
|
21
|
+
BATCH_EVENTS = '/server-side/batch-events-v2'
|
|
22
|
+
end
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Copyright 2024-2026 Wingify Software Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require_relative 'metric_model'
|
|
16
|
+
require_relative 'variable_model'
|
|
17
|
+
require_relative 'variation_model'
|
|
18
|
+
|
|
19
|
+
class CampaignModel
|
|
20
|
+
attr_reader :id, :segments, :salt, :percent_traffic, :is_user_list_enabled, :key, :type, :name,
|
|
21
|
+
:is_forced_variation_enabled, :variations, :metrics, :variables, :variation_id,
|
|
22
|
+
:campaign_id, :rule_key
|
|
23
|
+
|
|
24
|
+
def initialize
|
|
25
|
+
@id = nil
|
|
26
|
+
@segments = {}
|
|
27
|
+
@salt = ''
|
|
28
|
+
@percent_traffic = 0
|
|
29
|
+
@is_user_list_enabled = false
|
|
30
|
+
@key = ''
|
|
31
|
+
@type = ''
|
|
32
|
+
@name = ''
|
|
33
|
+
@is_forced_variation_enabled = false
|
|
34
|
+
@variations = []
|
|
35
|
+
@metrics = []
|
|
36
|
+
@variables = []
|
|
37
|
+
@variation_id = nil
|
|
38
|
+
@campaign_id = nil
|
|
39
|
+
@rule_key = ''
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Copies campaign properties from another CampaignModel instance
|
|
43
|
+
def copy(campaign_model)
|
|
44
|
+
@metrics = campaign_model.metrics
|
|
45
|
+
@variations = campaign_model.variations
|
|
46
|
+
@variables = campaign_model.variables
|
|
47
|
+
process_campaign_keys(campaign_model)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Creates a model instance from a dictionary (hash) or CampaignModel
|
|
51
|
+
def model_from_dictionary(campaign)
|
|
52
|
+
if campaign.is_a?(Hash)
|
|
53
|
+
process_campaign_properties(campaign)
|
|
54
|
+
process_campaign_keys(campaign)
|
|
55
|
+
elsif campaign.is_a?(CampaignModel)
|
|
56
|
+
process_campaign_model(campaign)
|
|
57
|
+
end
|
|
58
|
+
self
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def get_id
|
|
62
|
+
@id
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def get_segments
|
|
66
|
+
@segments
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def get_salt
|
|
70
|
+
@salt
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def get_traffic
|
|
74
|
+
@percent_traffic
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def get_is_user_list_enabled
|
|
78
|
+
@is_user_list_enabled
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def get_key
|
|
82
|
+
@key
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def set_key(key)
|
|
86
|
+
@key = key
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def get_type
|
|
90
|
+
@type
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def get_name
|
|
94
|
+
@name
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def get_is_forced_variation_enabled
|
|
98
|
+
@is_forced_variation_enabled
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def get_variations
|
|
102
|
+
@variations
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def set_variations(variations)
|
|
106
|
+
@variations = variations
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def get_metrics
|
|
110
|
+
@metrics
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def get_variables
|
|
114
|
+
@variables
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def get_variation_id
|
|
118
|
+
@variation_id
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def get_campaign_id
|
|
122
|
+
@campaign_id
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def get_rule_key
|
|
126
|
+
@rule_key
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def set_rule_key(rule_key)
|
|
130
|
+
@rule_key = rule_key
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Process campaign properties (metrics, variations, variables)
|
|
134
|
+
def process_campaign_properties(campaign)
|
|
135
|
+
@variables = process_variables(campaign["variables"]) if campaign["variables"]
|
|
136
|
+
@variations = process_variations(campaign["variations"]) if campaign["variations"]
|
|
137
|
+
@metrics = process_metrics(campaign["metrics"]) if campaign["metrics"]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Process campaign keys
|
|
141
|
+
def process_campaign_keys(campaign)
|
|
142
|
+
@id = campaign["id"]
|
|
143
|
+
@percent_traffic = campaign["percentTraffic"]
|
|
144
|
+
@name = campaign["name"]
|
|
145
|
+
@variation_id = campaign["variationId"]
|
|
146
|
+
@campaign_id = campaign["campaignId"]
|
|
147
|
+
@rule_key = campaign["ruleKey"]
|
|
148
|
+
@is_forced_variation_enabled = campaign["isForcedVariationEnabled"]
|
|
149
|
+
@is_user_list_enabled = campaign["isUserListEnabled"]
|
|
150
|
+
@segments = campaign["segments"]
|
|
151
|
+
@key = campaign["key"]
|
|
152
|
+
@type = campaign["type"]
|
|
153
|
+
@salt = campaign["salt"]
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Process variables
|
|
157
|
+
def process_variables(variable_list)
|
|
158
|
+
return [] if variable_list.nil? || variable_list.is_a?(Hash) # Handle empty cases
|
|
159
|
+
variable_list.map { |variable| VariableModel.new.model_from_dictionary(variable) }
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Process variations
|
|
163
|
+
def process_variations(variation_list)
|
|
164
|
+
return [] if variation_list.nil? || variation_list.is_a?(Hash) # Handle empty cases
|
|
165
|
+
variation_list.map { |variation| VariationModel.new.model_from_dictionary(variation) }
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Process metrics
|
|
169
|
+
def process_metrics(metrics_list)
|
|
170
|
+
return [] if metrics_list.nil? || metrics_list.is_a?(Hash) # Handle empty cases
|
|
171
|
+
metrics_list.map { |metric| MetricModel.new.model_from_dictionary(metric) }
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Process campaign properties from CampaignModel instance
|
|
175
|
+
def process_campaign_model(campaign_model)
|
|
176
|
+
@variables = campaign_model.variables
|
|
177
|
+
@variations = campaign_model.variations
|
|
178
|
+
@metrics = campaign_model.metrics
|
|
179
|
+
@id = campaign_model.id
|
|
180
|
+
@percent_traffic = campaign_model.percent_traffic
|
|
181
|
+
@name = campaign_model.name
|
|
182
|
+
@variation_id = campaign_model.variation_id
|
|
183
|
+
@campaign_id = campaign_model.campaign_id
|
|
184
|
+
@rule_key = campaign_model.rule_key
|
|
185
|
+
@is_forced_variation_enabled = campaign_model.is_forced_variation_enabled
|
|
186
|
+
@is_user_list_enabled = campaign_model.is_user_list_enabled
|
|
187
|
+
@segments = campaign_model.segments
|
|
188
|
+
@key = campaign_model.key
|
|
189
|
+
@type = campaign_model.type
|
|
190
|
+
@salt = campaign_model.salt
|
|
191
|
+
end
|
|
192
|
+
end
|