From 02fc7d032a3c08f84de1b0f64e5b1ab91c220054 Mon Sep 17 00:00:00 2001 From: Abbas-khaliq Date: Wed, 23 Feb 2022 19:40:50 +0530 Subject: [PATCH] refactor(sdk): add support to send tracking calls to the configured location --- CHANGELOG.md | 7 ++++ LICENSE | 2 +- NOTICE | 2 +- README.md | 2 +- git-hooks/pre-push | 4 +- lib/vwo.rb | 5 ++- lib/vwo/constants.rb | 4 +- lib/vwo/core/bucketer.rb | 2 +- lib/vwo/core/variation_decider.rb | 2 +- lib/vwo/enums.rb | 2 +- lib/vwo/logger.rb | 2 +- lib/vwo/schemas/settings_file.rb | 5 ++- lib/vwo/services/batch_events_dispatcher.rb | 6 ++- lib/vwo/services/batch_events_queue.rb | 2 +- lib/vwo/services/event_dispatcher.rb | 6 ++- lib/vwo/services/hooks_manager.rb | 2 +- lib/vwo/services/operand_evaluator.rb | 2 +- lib/vwo/services/segment_evaluator.rb | 2 +- lib/vwo/services/settings_file_manager.rb | 2 +- lib/vwo/services/settings_file_processor.rb | 2 +- lib/vwo/services/usage_stats.rb | 2 +- lib/vwo/user_storage.rb | 2 +- lib/vwo/utils/campaign.rb | 2 +- lib/vwo/utils/custom_dimensions.rb | 4 +- lib/vwo/utils/data_location_manager.rb | 46 +++++++++++++++++++++ lib/vwo/utils/feature.rb | 2 +- lib/vwo/utils/function.rb | 2 +- lib/vwo/utils/impression.rb | 7 ++-- lib/vwo/utils/request.rb | 2 +- lib/vwo/utils/segment.rb | 2 +- lib/vwo/utils/utility.rb | 10 ++++- lib/vwo/utils/uuid.rb | 2 +- lib/vwo/utils/validations.rb | 2 +- tests/test_all_tests.rb | 2 +- tests/test_bucketer.rb | 2 +- tests/test_event_dispatcher.rb | 2 +- tests/test_helper.rb | 2 +- tests/test_impression.rb | 2 +- tests/test_logger.rb | 2 +- tests/test_mutually_exclusive.rb | 2 +- tests/test_segment_evaluator.rb | 2 +- tests/test_settings_file_manager.rb | 2 +- tests/test_user_storage.rb | 2 +- tests/test_utility.rb | 17 +++++++- tests/test_variation_decider.rb | 2 +- tests/test_vwo.rb | 2 +- 46 files changed, 137 insertions(+), 52 deletions(-) create mode 100644 lib/vwo/utils/data_location_manager.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d8dcba..9aced9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.29.0] - 2022-02-23 + +### Changed + +- Tracking data for the `Data Residency` enabled VWO accounts will be sent to the configured location +- Update year in all the copyright and liense headers + ## [1.28.1] - 2022-01-23 ### Changed diff --git a/LICENSE b/LICENSE index a950ee5..fddb2be 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2019-2021 Wingify Software Pvt. Ltd. + Copyright 2019-2022 Wingify Software Pvt. Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE b/NOTICE index ba8742c..09b23aa 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,4 @@ -Copyright 2019-2021 Wingify Software Pvt. Ltd. +Copyright 2019-2022 Wingify Software Pvt. Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 7b31f46..311c113 100644 --- a/README.md +++ b/README.md @@ -214,4 +214,4 @@ Please go through our [contributing guidelines](https://github.com/wingify/vwo-r [Apache License, Version 2.0](https://github.com/wingify/vwo-ruby-sdk/blob/master/LICENSE) -Copyright 2019-2021 Wingify Software Pvt. Ltd. +Copyright 2019-2022 Wingify Software Pvt. Ltd. diff --git a/git-hooks/pre-push b/git-hooks/pre-push index 70ac82d..edee115 100644 --- a/git-hooks/pre-push +++ b/git-hooks/pre-push @@ -1,7 +1,7 @@ #!/usr/bin/env node /** - * Copyright 2019-2021 Wingify Software Pvt. Ltd. + * Copyright 2019-2022 Wingify Software Pvt. Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -248,7 +248,7 @@ let checkLicenseUtil = { console.time('Execution time for License and Copyright'); console.log(`${AnsiColorEnum.CYAN}\nVerifying License and Copyright${AnsiColorEnum.RESET}\n`); const isSuccess = checkLicenseUtil.checkLicenseAndCopyright({ - year: `2019-2021`, + year: `2019-2022`, author: 'Wingify Software Pvt. Ltd.', paths: 'lib,tests', stoppingCriteria: '\\*\\/', diff --git a/lib/vwo.rb b/lib/vwo.rb index cc5c954..43c88b5 100644 --- a/lib/vwo.rb +++ b/lib/vwo.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ require_relative 'vwo/utils/feature' require_relative 'vwo/utils/custom_dimensions' require_relative 'vwo/utils/utility' +require_relative 'vwo/utils/data_location_manager' require_relative 'vwo/constants' require_relative 'vwo/core/variation_decider' require_relative 'vwo/services/batch_events_dispatcher' @@ -41,6 +42,7 @@ class VWO include Utils::Campaign include Utils::Impression include Utils::Utility + include VWO::Utils include CONSTANTS FILE = FileNameEnum::VWO @@ -123,6 +125,7 @@ def initialize( # Process the settings file @config.process_settings_file @settings_file = @config.get_settings_file + DataLocationManager.get_instance().set_settings(@settings_file) @usage_stats = VWO::Services::UsageStats.new(usage_stats, @is_development_mode) diff --git a/lib/vwo/constants.rb b/lib/vwo/constants.rb index 45e2afd..0456545 100644 --- a/lib/vwo/constants.rb +++ b/lib/vwo/constants.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ module CONSTANTS HTTP_PROTOCOL = 'http://' HTTPS_PROTOCOL = 'https://' URL_NAMESPACE = '6ba7b811-9dad-11d1-80b4-00c04fd430c8' - SDK_VERSION = '1.28.1' + SDK_VERSION = '1.29.0' SDK_NAME = 'ruby' VWO_DELIMITER = '_vwo_' MAX_EVENTS_PER_REQUEST = 5000 diff --git a/lib/vwo/core/bucketer.rb b/lib/vwo/core/bucketer.rb index 0feda53..f8c6e46 100644 --- a/lib/vwo/core/bucketer.rb +++ b/lib/vwo/core/bucketer.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/core/variation_decider.rb b/lib/vwo/core/variation_decider.rb index 1e593a4..a7ae319 100644 --- a/lib/vwo/core/variation_decider.rb +++ b/lib/vwo/core/variation_decider.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/enums.rb b/lib/vwo/enums.rb index 94d1802..1446659 100644 --- a/lib/vwo/enums.rb +++ b/lib/vwo/enums.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/logger.rb b/lib/vwo/logger.rb index fd4db6e..d52c824 100644 --- a/lib/vwo/logger.rb +++ b/lib/vwo/logger.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/schemas/settings_file.rb b/lib/vwo/schemas/settings_file.rb index f2410b8..d380b00 100644 --- a/lib/vwo/schemas/settings_file.rb +++ b/lib/vwo/schemas/settings_file.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,9 @@ module Schema isEventArchEnabled: { type: ['boolean'] }, + collectionPrefix: { + type: ['string'] + }, campaigns: { if: { type: 'array' diff --git a/lib/vwo/services/batch_events_dispatcher.rb b/lib/vwo/services/batch_events_dispatcher.rb index 3067406..c2624b6 100644 --- a/lib/vwo/services/batch_events_dispatcher.rb +++ b/lib/vwo/services/batch_events_dispatcher.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,10 +15,12 @@ require_relative '../logger' require_relative '../enums' require_relative '../utils/request' +require_relative '../utils/utility' class VWO module Services class BatchEventsDispatcher include VWO::Enums + include VWO::Utils::Utility # Initialize the BatchEventDispatcher with logger and development mode # # @param [Boolean] : To specify whether the request @@ -36,7 +38,7 @@ def initialize # @return[Boolean] # def dispatch(impression, callback, query_params) - url = CONSTANTS::HTTPS_PROTOCOL + CONSTANTS::ENDPOINTS::BASE_URL + CONSTANTS::ENDPOINTS::BATCH_EVENTS + url = CONSTANTS::HTTPS_PROTOCOL + get_url(CONSTANTS::ENDPOINTS::BATCH_EVENTS) account_id = query_params[:a] resp = VWO::Utils::Request.post(url, query_params, impression) if resp.code == '200' diff --git a/lib/vwo/services/batch_events_queue.rb b/lib/vwo/services/batch_events_queue.rb index 596e343..da7b302 100644 --- a/lib/vwo/services/batch_events_queue.rb +++ b/lib/vwo/services/batch_events_queue.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/services/event_dispatcher.rb b/lib/vwo/services/event_dispatcher.rb index a05f59b..d182a9f 100644 --- a/lib/vwo/services/event_dispatcher.rb +++ b/lib/vwo/services/event_dispatcher.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ require_relative '../logger' require_relative '../enums' require_relative '../utils/request' +require_relative '../utils/utility' require_relative '../constants' class VWO @@ -22,6 +23,7 @@ module Services class EventDispatcher include VWO::Enums include VWO::CONSTANTS + include Utils::Utility EXCLUDE_KEYS = ['url'].freeze @@ -69,7 +71,7 @@ def dispatch(impression) def dispatch_event_arch_post(params, post_data) return true if @is_development_mode - url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL + ENDPOINTS::EVENTS + url = HTTPS_PROTOCOL + get_url(ENDPOINTS::EVENTS) resp = VWO::Utils::Request.event_post(url, params, post_data, SDK_NAME) if resp.code == '200' @logger.log( diff --git a/lib/vwo/services/hooks_manager.rb b/lib/vwo/services/hooks_manager.rb index 94c2b6d..d71b854 100644 --- a/lib/vwo/services/hooks_manager.rb +++ b/lib/vwo/services/hooks_manager.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/services/operand_evaluator.rb b/lib/vwo/services/operand_evaluator.rb index 71680ea..a1e6e45 100644 --- a/lib/vwo/services/operand_evaluator.rb +++ b/lib/vwo/services/operand_evaluator.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/services/segment_evaluator.rb b/lib/vwo/services/segment_evaluator.rb index 58e693a..63e4241 100644 --- a/lib/vwo/services/segment_evaluator.rb +++ b/lib/vwo/services/segment_evaluator.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/services/settings_file_manager.rb b/lib/vwo/services/settings_file_manager.rb index 2c6a5c8..d1b4205 100644 --- a/lib/vwo/services/settings_file_manager.rb +++ b/lib/vwo/services/settings_file_manager.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/services/settings_file_processor.rb b/lib/vwo/services/settings_file_processor.rb index 9c1732c..c90e653 100644 --- a/lib/vwo/services/settings_file_processor.rb +++ b/lib/vwo/services/settings_file_processor.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/services/usage_stats.rb b/lib/vwo/services/usage_stats.rb index 827c017..bb92cac 100644 --- a/lib/vwo/services/usage_stats.rb +++ b/lib/vwo/services/usage_stats.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/user_storage.rb b/lib/vwo/user_storage.rb index bf9cb03..a4bb3b6 100644 --- a/lib/vwo/user_storage.rb +++ b/lib/vwo/user_storage.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/utils/campaign.rb b/lib/vwo/utils/campaign.rb index 633de82..f7e60f0 100644 --- a/lib/vwo/utils/campaign.rb +++ b/lib/vwo/utils/campaign.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/utils/custom_dimensions.rb b/lib/vwo/utils/custom_dimensions.rb index 1382b71..5e49ad1 100644 --- a/lib/vwo/utils/custom_dimensions.rb +++ b/lib/vwo/utils/custom_dimensions.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ module CustomDimensions include VWO::Utils::Utility def get_url_params(settings_file, tag_key, tag_value, user_id, sdk_key) - url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL + ENDPOINTS::PUSH + url = HTTPS_PROTOCOL + get_url(ENDPOINTS::PUSH) tag = { 'u' => {} } tag['u'][tag_key] = tag_value diff --git a/lib/vwo/utils/data_location_manager.rb b/lib/vwo/utils/data_location_manager.rb new file mode 100644 index 0000000..92f43a5 --- /dev/null +++ b/lib/vwo/utils/data_location_manager.rb @@ -0,0 +1,46 @@ +# Copyright 2019-2022 Wingify Software Pvt. Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +require_relative '../constants' + +# Utility module for generating uuid +class VWO + module Utils + class DataLocationManager + + @@instance = nil + + def self.get_instance + if @@instance.nil? + @@instance = self.new + end + @@instance + end + + + def get_data_location + url = VWO::CONSTANTS::ENDPOINTS::BASE_URL + if @settings.key?("collectionPrefix") + url = url + '/' + @settings["collectionPrefix"] + end + url + end + + def set_settings(settings) + @settings = settings + end + end + end +end diff --git a/lib/vwo/utils/feature.rb b/lib/vwo/utils/feature.rb index 911446c..5e6508d 100644 --- a/lib/vwo/utils/feature.rb +++ b/lib/vwo/utils/feature.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/utils/function.rb b/lib/vwo/utils/function.rb index f65ac97..cd8fbd1 100644 --- a/lib/vwo/utils/function.rb +++ b/lib/vwo/utils/function.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/utils/impression.rb b/lib/vwo/utils/impression.rb index 83b56b1..1338c52 100644 --- a/lib/vwo/utils/impression.rb +++ b/lib/vwo/utils/impression.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -67,12 +67,11 @@ def create_impression(settings_file, campaign_id, variation_id, user_id, sdk_key impression = usage_stats.merge(impression) - url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL logger = VWO::Logger.get_instance if is_track_user_api impression['ed'] = JSON.generate(p: 'server') - impression['url'] = "#{url}#{ENDPOINTS::TRACK_USER}" + impression['url'] = HTTPS_PROTOCOL + get_url(ENDPOINTS::TRACK_USER) logger.log( LogLevelEnum::DEBUG, format( @@ -82,7 +81,7 @@ def create_impression(settings_file, campaign_id, variation_id, user_id, sdk_key ) ) else - impression['url'] = url + ENDPOINTS::TRACK_GOAL + impression['url'] = HTTPS_PROTOCOL + get_url(ENDPOINTS::TRACK_GOAL) impression['goal_id'] = goal_id impression['r'] = revenue if revenue logger.log( diff --git a/lib/vwo/utils/request.rb b/lib/vwo/utils/request.rb index 49d7db3..e97cbaf 100644 --- a/lib/vwo/utils/request.rb +++ b/lib/vwo/utils/request.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/utils/segment.rb b/lib/vwo/utils/segment.rb index b8de2dd..aca77a4 100644 --- a/lib/vwo/utils/segment.rb +++ b/lib/vwo/utils/segment.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/utils/utility.rb b/lib/vwo/utils/utility.rb index 2654f0a..f21538f 100644 --- a/lib/vwo/utils/utility.rb +++ b/lib/vwo/utils/utility.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,12 +14,16 @@ require 'json' require_relative './validations' +require_relative './data_location_manager' +require_relative '../constants' # Generic utility module class VWO module Utils module Utility include Validations + include VWO::Utils + include VWO::CONSTANTS # converting hash with keys as strings into hash with keys as strings # @param[Hash] @@ -42,6 +46,10 @@ def remove_sensitive_properties(properties) properties.delete("env".to_sym) JSON.generate(properties) end + + def get_url(endpoint) + return DataLocationManager.get_instance().get_data_location + endpoint + end end end end diff --git a/lib/vwo/utils/uuid.rb b/lib/vwo/utils/uuid.rb index a0b845a..effb6a7 100644 --- a/lib/vwo/utils/uuid.rb +++ b/lib/vwo/utils/uuid.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/vwo/utils/validations.rb b/lib/vwo/utils/validations.rb index ac9e444..3a70f97 100644 --- a/lib/vwo/utils/validations.rb +++ b/lib/vwo/utils/validations.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_all_tests.rb b/tests/test_all_tests.rb index 0721733..84bf57e 100644 --- a/tests/test_all_tests.rb +++ b/tests/test_all_tests.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_bucketer.rb b/tests/test_bucketer.rb index d181491..cf7b2f7 100644 --- a/tests/test_bucketer.rb +++ b/tests/test_bucketer.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_event_dispatcher.rb b/tests/test_event_dispatcher.rb index 3f9530e..c158cae 100644 --- a/tests/test_event_dispatcher.rb +++ b/tests/test_event_dispatcher.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_helper.rb b/tests/test_helper.rb index 4ff179b..cce94cc 100644 --- a/tests/test_helper.rb +++ b/tests/test_helper.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_impression.rb b/tests/test_impression.rb index 507c10d..ec87083 100644 --- a/tests/test_impression.rb +++ b/tests/test_impression.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_logger.rb b/tests/test_logger.rb index d83bc77..88ccf8e 100644 --- a/tests/test_logger.rb +++ b/tests/test_logger.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_mutually_exclusive.rb b/tests/test_mutually_exclusive.rb index 4df6c31..434ed39 100644 --- a/tests/test_mutually_exclusive.rb +++ b/tests/test_mutually_exclusive.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_segment_evaluator.rb b/tests/test_segment_evaluator.rb index 8bc734b..2b66d75 100644 --- a/tests/test_segment_evaluator.rb +++ b/tests/test_segment_evaluator.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_settings_file_manager.rb b/tests/test_settings_file_manager.rb index a32b489..c382d94 100644 --- a/tests/test_settings_file_manager.rb +++ b/tests/test_settings_file_manager.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_user_storage.rb b/tests/test_user_storage.rb index ceb04ab..6dc6863 100644 --- a/tests/test_user_storage.rb +++ b/tests/test_user_storage.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_utility.rb b/tests/test_utility.rb index f77605b..d997e11 100644 --- a/tests/test_utility.rb +++ b/tests/test_utility.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,10 +14,13 @@ require 'json' require_relative '../lib/vwo/utils/utility' +require_relative '../lib/vwo/utils/data_location_manager' +require_relative '../lib/vwo/constants' require 'test/unit' class UtilityTest < Test::Unit::TestCase include VWO::Utils::Utility + include VWO::CONSTANTS def test_convert_to_symbol_hash_with_valid_hash hashObject = { 'name': 'CUSTOM' } @@ -40,4 +43,16 @@ def test_convert_to_symbol_hash_with_nil assert_equal(expectation, result) end + def test_get_url_without + settings = {} + DataLocationManager.get_instance().set_settings(settings) + assert_equal(ENDPOINTS::BASE_URL, get_url('')) + end + + def test_get_url_with_data + settings = {"collectionPrefix" => "eu"} + DataLocationManager.get_instance().set_settings(settings) + assert_equal(ENDPOINTS::BASE_URL+"/eu", get_url('')) + end + end diff --git a/tests/test_variation_decider.rb b/tests/test_variation_decider.rb index c36863c..b96f9dc 100644 --- a/tests/test_variation_decider.rb +++ b/tests/test_variation_decider.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/test_vwo.rb b/tests/test_vwo.rb index f21e225..c683b60 100644 --- a/tests/test_vwo.rb +++ b/tests/test_vwo.rb @@ -1,4 +1,4 @@ -# Copyright 2019-2021 Wingify Software Pvt. Ltd. +# Copyright 2019-2022 Wingify Software Pvt. Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.