vwo-sdk 1.14.1 → 1.23.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 +4 -4
- data/lib/vwo/constants.rb +5 -2
- data/lib/vwo/core/bucketer.rb +33 -5
- data/lib/vwo/core/variation_decider.rb +422 -133
- data/lib/vwo/enums.rb +6 -1
- data/lib/vwo/logger.rb +4 -2
- data/lib/vwo/schemas/settings_file.rb +32 -1
- data/lib/vwo/services/operand_evaluator.rb +2 -3
- data/lib/vwo/services/segment_evaluator.rb +4 -2
- data/lib/vwo/utils/campaign.rb +60 -2
- data/lib/vwo/utils/feature.rb +2 -0
- data/lib/vwo/utils/utility.rb +40 -0
- data/lib/vwo.rb +204 -190
- metadata +15 -9
    
        data/lib/vwo.rb
    CHANGED
    
    | @@ -23,6 +23,7 @@ require_relative 'vwo/utils/campaign' | |
| 23 23 | 
             
            require_relative 'vwo/utils/impression'
         | 
| 24 24 | 
             
            require_relative 'vwo/utils/feature'
         | 
| 25 25 | 
             
            require_relative 'vwo/utils/custom_dimensions'
         | 
| 26 | 
            +
            require_relative 'vwo/utils/utility'
         | 
| 26 27 | 
             
            require_relative 'vwo/constants'
         | 
| 27 28 | 
             
            require_relative 'vwo/core/variation_decider'
         | 
| 28 29 | 
             
            require_relative 'vwo/services/batch_events_dispatcher'
         | 
| @@ -39,6 +40,7 @@ class VWO | |
| 39 40 | 
             
              include Utils::CustomDimensions
         | 
| 40 41 | 
             
              include Utils::Campaign
         | 
| 41 42 | 
             
              include Utils::Impression
         | 
| 43 | 
            +
              include Utils::Utility
         | 
| 42 44 | 
             
              include CONSTANTS
         | 
| 43 45 |  | 
| 44 46 | 
             
              FILE = FileNameEnum::VWO
         | 
| @@ -62,6 +64,7 @@ class VWO | |
| 62 64 | 
             
                settings_file = nil,
         | 
| 63 65 | 
             
                options = {}
         | 
| 64 66 | 
             
              )
         | 
| 67 | 
            +
                options = convert_to_symbol_hash(options)
         | 
| 65 68 | 
             
                @account_id = account_id
         | 
| 66 69 | 
             
                @sdk_key = sdk_key
         | 
| 67 70 | 
             
                @user_storage = user_storage
         | 
| @@ -295,9 +298,10 @@ class VWO | |
| 295 298 | 
             
                  return
         | 
| 296 299 | 
             
                end
         | 
| 297 300 |  | 
| 301 | 
            +
                options = convert_to_symbol_hash(options)
         | 
| 298 302 | 
             
                # Retrieve custom variables
         | 
| 299 | 
            -
                custom_variables = options[ | 
| 300 | 
            -
                variation_targeting_variables = options[ | 
| 303 | 
            +
                custom_variables = options[:custom_variables]
         | 
| 304 | 
            +
                variation_targeting_variables = options[:variation_targeting_variables]
         | 
| 301 305 |  | 
| 302 306 | 
             
                should_track_returning_user = get_should_track_returning_user(options)
         | 
| 303 307 | 
             
                # Validate input parameters
         | 
| @@ -413,7 +417,6 @@ class VWO | |
| 413 417 | 
             
                      )
         | 
| 414 418 | 
             
                    end
         | 
| 415 419 | 
             
                  end
         | 
| 416 | 
            -
                  variation['name']
         | 
| 417 420 | 
             
                else
         | 
| 418 421 | 
             
                  @logger.log(
         | 
| 419 422 | 
             
                    LogLevelEnum::INFO,
         | 
| @@ -425,8 +428,8 @@ class VWO | |
| 425 428 | 
             
                      api_name: ApiMethods::ACTIVATE
         | 
| 426 429 | 
             
                    )
         | 
| 427 430 | 
             
                  )
         | 
| 428 | 
            -
                  nil
         | 
| 429 431 | 
             
                end
         | 
| 432 | 
            +
                variation['name']
         | 
| 430 433 | 
             
              rescue StandardError => e
         | 
| 431 434 | 
             
                @logger.log(
         | 
| 432 435 | 
             
                  LogLevelEnum::ERROR,
         | 
| @@ -437,7 +440,7 @@ class VWO | |
| 437 440 | 
             
                    exception: e
         | 
| 438 441 | 
             
                  )
         | 
| 439 442 | 
             
                )
         | 
| 440 | 
            -
                 | 
| 443 | 
            +
                e
         | 
| 441 444 | 
             
              end
         | 
| 442 445 |  | 
| 443 446 | 
             
              # This API method: Gets the variation name assigned for the
         | 
| @@ -469,9 +472,10 @@ class VWO | |
| 469 472 | 
             
                  )
         | 
| 470 473 | 
             
                  return
         | 
| 471 474 | 
             
                end
         | 
| 475 | 
            +
                options = convert_to_symbol_hash(options)
         | 
| 472 476 | 
             
                # Retrieve custom variables
         | 
| 473 | 
            -
                custom_variables = options[ | 
| 474 | 
            -
                variation_targeting_variables = options[ | 
| 477 | 
            +
                custom_variables = options[:custom_variables]
         | 
| 478 | 
            +
                variation_targeting_variables = options[:variation_targeting_variables]
         | 
| 475 479 |  | 
| 476 480 | 
             
                # Validate input parameters
         | 
| 477 481 | 
             
                unless valid_string?(campaign_key) && valid_string?(user_id) && (custom_variables.nil? || valid_hash?(custom_variables)) &&
         | 
| @@ -580,9 +584,10 @@ class VWO | |
| 580 584 | 
             
                  return false
         | 
| 581 585 | 
             
                end
         | 
| 582 586 |  | 
| 583 | 
            -
                 | 
| 584 | 
            -
                 | 
| 585 | 
            -
                 | 
| 587 | 
            +
                options = convert_to_symbol_hash(options)
         | 
| 588 | 
            +
                revenue_value = options[:revenue_value]
         | 
| 589 | 
            +
                custom_variables = options[:custom_variables]
         | 
| 590 | 
            +
                variation_targeting_variables = options[:variation_targeting_variables]
         | 
| 586 591 | 
             
                should_track_returning_user = get_should_track_returning_user(options)
         | 
| 587 592 | 
             
                goal_type_to_track = get_goal_type_to_track(options)
         | 
| 588 593 |  | 
| @@ -611,147 +616,149 @@ class VWO | |
| 611 616 |  | 
| 612 617 | 
             
                result = {}
         | 
| 613 618 | 
             
                campaigns.each do |campaign|
         | 
| 614 | 
            -
                   | 
| 619 | 
            +
                  begin
         | 
| 620 | 
            +
                    campaign_type = campaign['type']
         | 
| 615 621 |  | 
| 616 | 
            -
             | 
| 617 | 
            -
                    @logger.log(
         | 
| 618 | 
            -
                      LogLevelEnum::ERROR,
         | 
| 619 | 
            -
                      format(
         | 
| 620 | 
            -
                        LogMessageEnum::ErrorMessages::INVALID_API,
         | 
| 621 | 
            -
                        file: FILE,
         | 
| 622 | 
            -
                        api_name: ApiMethods::TRACK,
         | 
| 623 | 
            -
                        user_id: user_id,
         | 
| 624 | 
            -
                        campaign_key: campaign['key'],
         | 
| 625 | 
            -
                        campaign_type: campaign_type
         | 
| 626 | 
            -
                      )
         | 
| 627 | 
            -
                    )
         | 
| 628 | 
            -
                    result[campaign['key']] = false
         | 
| 629 | 
            -
                    next
         | 
| 630 | 
            -
                  end
         | 
| 631 | 
            -
             | 
| 632 | 
            -
                  variation = @variation_decider.get_variation(user_id, campaign, ApiMethods::TRACK, campaign['key'], custom_variables, variation_targeting_variables, goal_identifier)
         | 
| 633 | 
            -
             | 
| 634 | 
            -
                  if variation
         | 
| 635 | 
            -
                    goal = get_campaign_goal(campaign, goal_identifier)
         | 
| 636 | 
            -
                    if goal.nil? || !goal["id"]
         | 
| 622 | 
            +
                    if campaign_type == CampaignTypes::FEATURE_ROLLOUT
         | 
| 637 623 | 
             
                      @logger.log(
         | 
| 638 624 | 
             
                        LogLevelEnum::ERROR,
         | 
| 639 625 | 
             
                        format(
         | 
| 640 | 
            -
                          LogMessageEnum::ErrorMessages:: | 
| 626 | 
            +
                          LogMessageEnum::ErrorMessages::INVALID_API,
         | 
| 641 627 | 
             
                          file: FILE,
         | 
| 642 | 
            -
                           | 
| 628 | 
            +
                          api_name: ApiMethods::TRACK,
         | 
| 643 629 | 
             
                          user_id: user_id,
         | 
| 644 630 | 
             
                          campaign_key: campaign['key'],
         | 
| 645 | 
            -
                           | 
| 631 | 
            +
                          campaign_type: campaign_type
         | 
| 646 632 | 
             
                        )
         | 
| 647 633 | 
             
                      )
         | 
| 648 634 | 
             
                      result[campaign['key']] = false
         | 
| 649 635 | 
             
                      next
         | 
| 650 | 
            -
                    elsif goal['type'] == GoalTypes::REVENUE && !valid_value?(revenue_value)
         | 
| 651 | 
            -
                      @logger.log(
         | 
| 652 | 
            -
                        LogLevelEnum::ERROR,
         | 
| 653 | 
            -
                        format(
         | 
| 654 | 
            -
                          LogMessageEnum::ErrorMessages::TRACK_API_REVENUE_NOT_PASSED_FOR_REVENUE_GOAL,
         | 
| 655 | 
            -
                          file: FILE,
         | 
| 656 | 
            -
                          user_id: user_id,
         | 
| 657 | 
            -
                          goal_identifier: goal_identifier,
         | 
| 658 | 
            -
                          campaign_key: campaign['key'],
         | 
| 659 | 
            -
                          api_name: ApiMethods::TRACK
         | 
| 660 | 
            -
                        )
         | 
| 661 | 
            -
                      )
         | 
| 662 | 
            -
                      result[campaign['key']] = false
         | 
| 663 | 
            -
                      next
         | 
| 664 | 
            -
                    elsif goal['type'] == GoalTypes::CUSTOM
         | 
| 665 | 
            -
                      revenue_value = nil
         | 
| 666 636 | 
             
                    end
         | 
| 667 637 |  | 
| 668 | 
            -
                     | 
| 669 | 
            -
                      identifiers = variation['goal_identifier'].split(VWO_DELIMITER)
         | 
| 670 | 
            -
                    else
         | 
| 671 | 
            -
                      variation['goal_identifier'] = ''
         | 
| 672 | 
            -
                      identifiers = []
         | 
| 673 | 
            -
                    end
         | 
| 638 | 
            +
                    variation = @variation_decider.get_variation(user_id, campaign, ApiMethods::TRACK, campaign['key'], custom_variables, variation_targeting_variables, goal_identifier)
         | 
| 674 639 |  | 
| 675 | 
            -
                    if  | 
| 676 | 
            -
                       | 
| 677 | 
            -
                       | 
| 678 | 
            -
             | 
| 679 | 
            -
             | 
| 680 | 
            -
             | 
| 681 | 
            -
             | 
| 682 | 
            -
             | 
| 683 | 
            -
             | 
| 684 | 
            -
             | 
| 685 | 
            -
             | 
| 686 | 
            -
             | 
| 687 | 
            -
                           | 
| 688 | 
            -
                          goal_identifier: goal_identifier,
         | 
| 689 | 
            -
                          api_name: ApiMethods::TRACK
         | 
| 640 | 
            +
                    if variation
         | 
| 641 | 
            +
                      goal = get_campaign_goal(campaign, goal_identifier)
         | 
| 642 | 
            +
                      if goal.nil? || !goal["id"]
         | 
| 643 | 
            +
                        @logger.log(
         | 
| 644 | 
            +
                          LogLevelEnum::ERROR,
         | 
| 645 | 
            +
                          format(
         | 
| 646 | 
            +
                            LogMessageEnum::ErrorMessages::TRACK_API_GOAL_NOT_FOUND,
         | 
| 647 | 
            +
                            file: FILE,
         | 
| 648 | 
            +
                            goal_identifier: goal_identifier,
         | 
| 649 | 
            +
                            user_id: user_id,
         | 
| 650 | 
            +
                            campaign_key: campaign['key'],
         | 
| 651 | 
            +
                            api_name: ApiMethods::TRACK
         | 
| 652 | 
            +
                          )
         | 
| 690 653 | 
             
                        )
         | 
| 691 | 
            -
             | 
| 692 | 
            -
             | 
| 693 | 
            -
                       | 
| 694 | 
            -
                    end
         | 
| 695 | 
            -
             | 
| 696 | 
            -
                    if defined?(@batch_events)
         | 
| 697 | 
            -
                      impression = create_bulk_event_impression(
         | 
| 698 | 
            -
                        @settings_file,
         | 
| 699 | 
            -
                        campaign['id'],
         | 
| 700 | 
            -
                        variation['id'],
         | 
| 701 | 
            -
                        user_id,
         | 
| 702 | 
            -
                        goal['id'],
         | 
| 703 | 
            -
                        revenue_value
         | 
| 704 | 
            -
                      )
         | 
| 705 | 
            -
                      @batch_events_queue.enqueue(impression)
         | 
| 706 | 
            -
                    else
         | 
| 707 | 
            -
                      impression = create_impression(
         | 
| 708 | 
            -
                        @settings_file,
         | 
| 709 | 
            -
                        campaign['id'],
         | 
| 710 | 
            -
                        variation['id'],
         | 
| 711 | 
            -
                        user_id,
         | 
| 712 | 
            -
                        @sdk_key,
         | 
| 713 | 
            -
                        goal['id'],
         | 
| 714 | 
            -
                        revenue_value
         | 
| 715 | 
            -
                      )
         | 
| 716 | 
            -
                      if @event_dispatcher.dispatch(impression)
         | 
| 654 | 
            +
                        result[campaign['key']] = false
         | 
| 655 | 
            +
                        next
         | 
| 656 | 
            +
                      elsif goal['type'] == GoalTypes::REVENUE && !valid_value?(revenue_value)
         | 
| 717 657 | 
             
                        @logger.log(
         | 
| 718 | 
            -
                          LogLevelEnum:: | 
| 658 | 
            +
                          LogLevelEnum::ERROR,
         | 
| 719 659 | 
             
                          format(
         | 
| 720 | 
            -
                            LogMessageEnum:: | 
| 660 | 
            +
                            LogMessageEnum::ErrorMessages::TRACK_API_REVENUE_NOT_PASSED_FOR_REVENUE_GOAL,
         | 
| 721 661 | 
             
                            file: FILE,
         | 
| 722 | 
            -
                             | 
| 723 | 
            -
                             | 
| 724 | 
            -
                             | 
| 725 | 
            -
                             | 
| 726 | 
            -
                            end_point: EVENTS::TRACK_GOAL
         | 
| 662 | 
            +
                            user_id: user_id,
         | 
| 663 | 
            +
                            goal_identifier: goal_identifier,
         | 
| 664 | 
            +
                            campaign_key: campaign['key'],
         | 
| 665 | 
            +
                            api_name: ApiMethods::TRACK
         | 
| 727 666 | 
             
                          )
         | 
| 728 667 | 
             
                        )
         | 
| 668 | 
            +
                        result[campaign['key']] = false
         | 
| 669 | 
            +
                        next
         | 
| 670 | 
            +
                      elsif goal['type'] == GoalTypes::CUSTOM
         | 
| 671 | 
            +
                        revenue_value = nil
         | 
| 672 | 
            +
                      end
         | 
| 673 | 
            +
             | 
| 674 | 
            +
                      if variation['goal_identifier']
         | 
| 675 | 
            +
                        identifiers = variation['goal_identifier'].split(VWO_DELIMITER)
         | 
| 676 | 
            +
                      else
         | 
| 677 | 
            +
                        variation['goal_identifier'] = ''
         | 
| 678 | 
            +
                        identifiers = []
         | 
| 679 | 
            +
                      end
         | 
| 680 | 
            +
             | 
| 681 | 
            +
                      if !identifiers.include? goal_identifier
         | 
| 682 | 
            +
                        updated_goal_identifier = variation['goal_identifier']
         | 
| 683 | 
            +
                        updated_goal_identifier += VWO_DELIMITER + goal_identifier
         | 
| 684 | 
            +
                        @variation_decider.save_user_storage(user_id, campaign['key'], campaign['name'], variation['name'], updated_goal_identifier) if variation['name']
         | 
| 685 | 
            +
                        # set variation at user storage
         | 
| 686 | 
            +
                      elsif !should_track_returning_user
         | 
| 729 687 | 
             
                        @logger.log(
         | 
| 730 688 | 
             
                          LogLevelEnum::INFO,
         | 
| 731 689 | 
             
                          format(
         | 
| 732 | 
            -
                            LogMessageEnum::InfoMessages:: | 
| 690 | 
            +
                            LogMessageEnum::InfoMessages::GOAL_ALREADY_TRACKED,
         | 
| 733 691 | 
             
                            file: FILE,
         | 
| 734 | 
            -
                             | 
| 735 | 
            -
                             | 
| 736 | 
            -
                             | 
| 737 | 
            -
                             | 
| 692 | 
            +
                            user_id: user_id,
         | 
| 693 | 
            +
                            campaign_key: campaign['key'],
         | 
| 694 | 
            +
                            goal_identifier: goal_identifier,
         | 
| 695 | 
            +
                            api_name: ApiMethods::TRACK
         | 
| 738 696 | 
             
                          )
         | 
| 739 697 | 
             
                        )
         | 
| 698 | 
            +
                        result[campaign['key']] = false
         | 
| 699 | 
            +
                        next
         | 
| 740 700 | 
             
                      end
         | 
| 701 | 
            +
             | 
| 702 | 
            +
                      if defined?(@batch_events)
         | 
| 703 | 
            +
                        impression = create_bulk_event_impression(
         | 
| 704 | 
            +
                          @settings_file,
         | 
| 705 | 
            +
                          campaign['id'],
         | 
| 706 | 
            +
                          variation['id'],
         | 
| 707 | 
            +
                          user_id,
         | 
| 708 | 
            +
                          goal['id'],
         | 
| 709 | 
            +
                          revenue_value
         | 
| 710 | 
            +
                        )
         | 
| 711 | 
            +
                        @batch_events_queue.enqueue(impression)
         | 
| 712 | 
            +
                      else
         | 
| 713 | 
            +
                        impression = create_impression(
         | 
| 714 | 
            +
                          @settings_file,
         | 
| 715 | 
            +
                          campaign['id'],
         | 
| 716 | 
            +
                          variation['id'],
         | 
| 717 | 
            +
                          user_id,
         | 
| 718 | 
            +
                          @sdk_key,
         | 
| 719 | 
            +
                          goal['id'],
         | 
| 720 | 
            +
                          revenue_value
         | 
| 721 | 
            +
                        )
         | 
| 722 | 
            +
                        if @event_dispatcher.dispatch(impression)
         | 
| 723 | 
            +
                          @logger.log(
         | 
| 724 | 
            +
                            LogLevelEnum::INFO,
         | 
| 725 | 
            +
                            format(
         | 
| 726 | 
            +
                              LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS,
         | 
| 727 | 
            +
                              file: FILE,
         | 
| 728 | 
            +
                              sdk_key: @sdk_key,
         | 
| 729 | 
            +
                              account_id: @account_id,
         | 
| 730 | 
            +
                              campaign_id: campaign['id'],
         | 
| 731 | 
            +
                              variation_id: variation['id'],
         | 
| 732 | 
            +
                              end_point: EVENTS::TRACK_GOAL
         | 
| 733 | 
            +
                            )
         | 
| 734 | 
            +
                          )
         | 
| 735 | 
            +
                          @logger.log(
         | 
| 736 | 
            +
                            LogLevelEnum::INFO,
         | 
| 737 | 
            +
                            format(
         | 
| 738 | 
            +
                              LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
         | 
| 739 | 
            +
                              file: FILE,
         | 
| 740 | 
            +
                              sdk_key: @sdk_key,
         | 
| 741 | 
            +
                              campaign_id: impression[:experiment_id],
         | 
| 742 | 
            +
                              account_id: impression[:account_id],
         | 
| 743 | 
            +
                              variation_id: impression[:combination]
         | 
| 744 | 
            +
                            )
         | 
| 745 | 
            +
                          )
         | 
| 746 | 
            +
                        end
         | 
| 747 | 
            +
                      end
         | 
| 748 | 
            +
                      result[campaign['key']] = true
         | 
| 749 | 
            +
                      next
         | 
| 741 750 | 
             
                    end
         | 
| 742 | 
            -
                    result[campaign['key']] =  | 
| 743 | 
            -
             | 
| 744 | 
            -
             | 
| 745 | 
            -
             | 
| 746 | 
            -
             | 
| 747 | 
            -
             | 
| 748 | 
            -
             | 
| 749 | 
            -
             | 
| 750 | 
            -
                       | 
| 751 | 
            -
                      file: FILE,
         | 
| 752 | 
            -
                      exception: e
         | 
| 751 | 
            +
                    result[campaign['key']] = false
         | 
| 752 | 
            +
                  rescue StandardError => e
         | 
| 753 | 
            +
                    @logger.log(
         | 
| 754 | 
            +
                      LogLevelEnum::ERROR,
         | 
| 755 | 
            +
                      format(
         | 
| 756 | 
            +
                        e.message,
         | 
| 757 | 
            +
                        file: FILE,
         | 
| 758 | 
            +
                        exception: e
         | 
| 759 | 
            +
                      )
         | 
| 753 760 | 
             
                    )
         | 
| 754 | 
            -
                   | 
| 761 | 
            +
                  end
         | 
| 755 762 | 
             
                end
         | 
| 756 763 |  | 
| 757 764 | 
             
                if result.length() == 0
         | 
| @@ -798,9 +805,10 @@ class VWO | |
| 798 805 | 
             
                  return false
         | 
| 799 806 | 
             
                end
         | 
| 800 807 |  | 
| 808 | 
            +
                options = convert_to_symbol_hash(options)
         | 
| 801 809 | 
             
                # Retrieve custom variables
         | 
| 802 | 
            -
                custom_variables = options[ | 
| 803 | 
            -
                variation_targeting_variables = options[ | 
| 810 | 
            +
                custom_variables = options[:custom_variables]
         | 
| 811 | 
            +
                variation_targeting_variables = options[:variation_targeting_variables]
         | 
| 804 812 | 
             
                should_track_returning_user = get_should_track_returning_user(options)
         | 
| 805 813 | 
             
                @logger.log(
         | 
| 806 814 | 
             
                  LogLevelEnum::INFO,
         | 
| @@ -868,80 +876,85 @@ class VWO | |
| 868 876 | 
             
                return false unless variation
         | 
| 869 877 |  | 
| 870 878 | 
             
                # if campaign type is feature_test Send track call to server
         | 
| 871 | 
            -
                if campaign_type == CampaignTypes::FEATURE_TEST
         | 
| 872 | 
            -
                  if is_eligible_to_send_impression(should_track_returning_user)
         | 
| 873 | 
            -
                    if defined?(@batch_events)
         | 
| 874 | 
            -
                      impression = create_bulk_event_impression(
         | 
| 875 | 
            -
                        @settings_file,
         | 
| 876 | 
            -
                        campaign['id'],
         | 
| 877 | 
            -
                        variation['id'],
         | 
| 878 | 
            -
                        user_id
         | 
| 879 | 
            -
                      )
         | 
| 880 | 
            -
                      @batch_events_queue.enqueue(impression)
         | 
| 881 | 
            -
                    else
         | 
| 882 | 
            -
                      impression = create_impression(
         | 
| 883 | 
            -
                        @settings_file,
         | 
| 884 | 
            -
                        campaign['id'],
         | 
| 885 | 
            -
                        variation['id'],
         | 
| 886 | 
            -
                        user_id,
         | 
| 887 | 
            -
                        @sdk_key,
         | 
| 888 | 
            -
                        goal_id: nil,
         | 
| 889 | 
            -
                        revenue: nil,
         | 
| 890 | 
            -
                        usage_stats: @usage_stats.usage_stats
         | 
| 891 | 
            -
                      )
         | 
| 892 879 |  | 
| 893 | 
            -
             | 
| 894 | 
            -
             | 
| 895 | 
            -
             | 
| 896 | 
            -
             | 
| 897 | 
            -
             | 
| 898 | 
            -
             | 
| 899 | 
            -
             | 
| 900 | 
            -
             | 
| 901 | 
            -
             | 
| 902 | 
            -
                          variation_id: impression[:combination]
         | 
| 903 | 
            -
                        )
         | 
| 904 | 
            -
                      )
         | 
| 905 | 
            -
                    end
         | 
| 906 | 
            -
                    result = variation['isFeatureEnabled']
         | 
| 907 | 
            -
                    if result
         | 
| 908 | 
            -
                      @logger.log(
         | 
| 909 | 
            -
                        LogLevelEnum::INFO,
         | 
| 910 | 
            -
                        format(
         | 
| 911 | 
            -
                          LogMessageEnum::InfoMessages::FEATURE_ENABLED_FOR_USER,
         | 
| 912 | 
            -
                          file: FILE,
         | 
| 913 | 
            -
                          user_id: user_id,
         | 
| 914 | 
            -
                          feature_key: campaign_key,
         | 
| 915 | 
            -
                          api_name: ApiMethods::IS_FEATURE_ENABLED
         | 
| 916 | 
            -
                        )
         | 
| 917 | 
            -
                      )
         | 
| 918 | 
            -
                    else
         | 
| 919 | 
            -
                      @logger.log(
         | 
| 920 | 
            -
                        LogLevelEnum::INFO,
         | 
| 921 | 
            -
                        format(
         | 
| 922 | 
            -
                          LogMessageEnum::InfoMessages::FEATURE_NOT_ENABLED_FOR_USER,
         | 
| 923 | 
            -
                          file: FILE,
         | 
| 924 | 
            -
                          user_id: user_id,
         | 
| 925 | 
            -
                          feature_key: campaign_key,
         | 
| 926 | 
            -
                          api_name: ApiMethods::IS_FEATURE_ENABLED
         | 
| 927 | 
            -
                        )
         | 
| 928 | 
            -
                      )
         | 
| 929 | 
            -
                    end
         | 
| 930 | 
            -
                    return result
         | 
| 880 | 
            +
                if is_eligible_to_send_impression(should_track_returning_user)
         | 
| 881 | 
            +
                  if defined?(@batch_events)
         | 
| 882 | 
            +
                    impression = create_bulk_event_impression(
         | 
| 883 | 
            +
                      @settings_file,
         | 
| 884 | 
            +
                      campaign['id'],
         | 
| 885 | 
            +
                      variation['id'],
         | 
| 886 | 
            +
                      user_id
         | 
| 887 | 
            +
                    )
         | 
| 888 | 
            +
                    @batch_events_queue.enqueue(impression)
         | 
| 931 889 | 
             
                  else
         | 
| 890 | 
            +
                    impression = create_impression(
         | 
| 891 | 
            +
                      @settings_file,
         | 
| 892 | 
            +
                      campaign['id'],
         | 
| 893 | 
            +
                      variation['id'],
         | 
| 894 | 
            +
                      user_id,
         | 
| 895 | 
            +
                      @sdk_key,
         | 
| 896 | 
            +
                      nil,
         | 
| 897 | 
            +
                      nil,
         | 
| 898 | 
            +
                      usage_stats: @usage_stats.usage_stats
         | 
| 899 | 
            +
                    )
         | 
| 900 | 
            +
             | 
| 901 | 
            +
                    @event_dispatcher.dispatch(impression)
         | 
| 932 902 | 
             
                    @logger.log(
         | 
| 933 903 | 
             
                      LogLevelEnum::INFO,
         | 
| 934 904 | 
             
                      format(
         | 
| 935 | 
            -
                        LogMessageEnum::InfoMessages:: | 
| 905 | 
            +
                        LogMessageEnum::InfoMessages::MAIN_KEYS_FOR_IMPRESSION,
         | 
| 936 906 | 
             
                        file: FILE,
         | 
| 937 | 
            -
                         | 
| 938 | 
            -
                         | 
| 939 | 
            -
                         | 
| 907 | 
            +
                        campaign_id: impression[:experiment_id],
         | 
| 908 | 
            +
                        sdk_key: @sdk_key,
         | 
| 909 | 
            +
                        account_id: impression[:account_id],
         | 
| 910 | 
            +
                        variation_id: impression[:combination]
         | 
| 940 911 | 
             
                      )
         | 
| 941 912 | 
             
                    )
         | 
| 942 913 | 
             
                  end
         | 
| 914 | 
            +
             | 
| 915 | 
            +
                else
         | 
| 916 | 
            +
                  @logger.log(
         | 
| 917 | 
            +
                    LogLevelEnum::INFO,
         | 
| 918 | 
            +
                    format(
         | 
| 919 | 
            +
                      LogMessageEnum::InfoMessages::USER_ALREADY_TRACKED,
         | 
| 920 | 
            +
                      file: FILE,
         | 
| 921 | 
            +
                      user_id: user_id,
         | 
| 922 | 
            +
                      campaign_key: campaign_key,
         | 
| 923 | 
            +
                      api_name: ApiMethods::IS_FEATURE_ENABLED
         | 
| 924 | 
            +
                    )
         | 
| 925 | 
            +
                  )
         | 
| 943 926 | 
             
                end
         | 
| 944 | 
            -
                 | 
| 927 | 
            +
                if campaign_type == CampaignTypes::FEATURE_ROLLOUT
         | 
| 928 | 
            +
                  result = true
         | 
| 929 | 
            +
                else
         | 
| 930 | 
            +
                  result = variation['isFeatureEnabled']
         | 
| 931 | 
            +
                end
         | 
| 932 | 
            +
             | 
| 933 | 
            +
                if result
         | 
| 934 | 
            +
                  @logger.log(
         | 
| 935 | 
            +
                    LogLevelEnum::INFO,
         | 
| 936 | 
            +
                    format(
         | 
| 937 | 
            +
                      LogMessageEnum::InfoMessages::FEATURE_ENABLED_FOR_USER,
         | 
| 938 | 
            +
                      file: FILE,
         | 
| 939 | 
            +
                      user_id: user_id,
         | 
| 940 | 
            +
                      feature_key: campaign_key,
         | 
| 941 | 
            +
                      api_name: ApiMethods::IS_FEATURE_ENABLED
         | 
| 942 | 
            +
                    )
         | 
| 943 | 
            +
                  )
         | 
| 944 | 
            +
                else
         | 
| 945 | 
            +
                  @logger.log(
         | 
| 946 | 
            +
                    LogLevelEnum::INFO,
         | 
| 947 | 
            +
                    format(
         | 
| 948 | 
            +
                      LogMessageEnum::InfoMessages::FEATURE_NOT_ENABLED_FOR_USER,
         | 
| 949 | 
            +
                      file: FILE,
         | 
| 950 | 
            +
                      user_id: user_id,
         | 
| 951 | 
            +
                      feature_key: campaign_key,
         | 
| 952 | 
            +
                      api_name: ApiMethods::IS_FEATURE_ENABLED
         | 
| 953 | 
            +
                    )
         | 
| 954 | 
            +
                  )
         | 
| 955 | 
            +
                end
         | 
| 956 | 
            +
             | 
| 957 | 
            +
                result
         | 
| 945 958 | 
             
              rescue StandardError => e
         | 
| 946 959 | 
             
                @logger.log(
         | 
| 947 960 | 
             
                  LogLevelEnum::ERROR,
         | 
| @@ -987,9 +1000,10 @@ class VWO | |
| 987 1000 | 
             
                  return
         | 
| 988 1001 | 
             
                end
         | 
| 989 1002 |  | 
| 1003 | 
            +
                options = convert_to_symbol_hash(options)
         | 
| 990 1004 | 
             
                # Retrieve custom variables
         | 
| 991 | 
            -
                custom_variables = options[ | 
| 992 | 
            -
                variation_targeting_variables = options[ | 
| 1005 | 
            +
                custom_variables = options[:custom_variables]
         | 
| 1006 | 
            +
                variation_targeting_variables = options[:variation_targeting_variables]
         | 
| 993 1007 |  | 
| 994 1008 | 
             
                unless valid_string?(campaign_key) && valid_string?(variable_key) && valid_string?(user_id) &&
         | 
| 995 1009 | 
             
                  (custom_variables.nil? || valid_hash?(custom_variables)) && (variation_targeting_variables.nil? || valid_hash?(variation_targeting_variables))
         | 
    
        metadata
    CHANGED
    
    | @@ -1,29 +1,29 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: vwo-sdk
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.23.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - VWO
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-10-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name:  | 
| 14 | 
            +
              name: codecov
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 0. | 
| 19 | 
            +
                    version: 0.4.3
         | 
| 20 20 | 
             
              type: :development
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 0. | 
| 26 | 
            +
                    version: 0.4.3
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: rubocop
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -80,7 +80,7 @@ dependencies: | |
| 80 80 | 
             
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '0.1'
         | 
| 83 | 
            -
            description:  | 
| 83 | 
            +
            description: Ruby SDK for VWO FullStack testing.
         | 
| 84 84 | 
             
            email:
         | 
| 85 85 | 
             
            - dev@wingify.com
         | 
| 86 86 | 
             
            executables: []
         | 
| @@ -111,12 +111,18 @@ files: | |
| 111 111 | 
             
            - lib/vwo/utils/impression.rb
         | 
| 112 112 | 
             
            - lib/vwo/utils/request.rb
         | 
| 113 113 | 
             
            - lib/vwo/utils/segment.rb
         | 
| 114 | 
            +
            - lib/vwo/utils/utility.rb
         | 
| 114 115 | 
             
            - lib/vwo/utils/uuid.rb
         | 
| 115 116 | 
             
            - lib/vwo/utils/validations.rb
         | 
| 116 117 | 
             
            homepage: https://vwo.com/fullstack/server-side-testing/
         | 
| 117 118 | 
             
            licenses:
         | 
| 118 119 | 
             
            - Apache-2.0
         | 
| 119 | 
            -
            metadata: | 
| 120 | 
            +
            metadata:
         | 
| 121 | 
            +
              bug_tracker_uri: https://github.com/wingify/vwo-ruby-sdk/issues
         | 
| 122 | 
            +
              changelog_uri: https://github.com/wingify/vwo-ruby-sdk/blob/master/CHANGELOG.md
         | 
| 123 | 
            +
              documentation_uri: https://developers.vwo.com/docs/ruby-sdk-reference
         | 
| 124 | 
            +
              homepage_uri: https://github.com/wingify/vwo-ruby-sdk
         | 
| 125 | 
            +
              source_code_uri: https://github.com/wingify/vwo-ruby-sdk
         | 
| 120 126 | 
             
            post_install_message:
         | 
| 121 127 | 
             
            rdoc_options: []
         | 
| 122 128 | 
             
            require_paths:
         | 
| @@ -125,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 125 131 | 
             
              requirements:
         | 
| 126 132 | 
             
              - - ">="
         | 
| 127 133 | 
             
                - !ruby/object:Gem::Version
         | 
| 128 | 
            -
                  version:  | 
| 134 | 
            +
                  version: 2.2.10
         | 
| 129 135 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 130 136 | 
             
              requirements:
         | 
| 131 137 | 
             
              - - ">="
         | 
| @@ -135,5 +141,5 @@ requirements: [] | |
| 135 141 | 
             
            rubygems_version: 3.0.6
         | 
| 136 142 | 
             
            signing_key:
         | 
| 137 143 | 
             
            specification_version: 4
         | 
| 138 | 
            -
            summary: Ruby SDK for VWO  | 
| 144 | 
            +
            summary: Ruby SDK for VWO FullStack testing
         | 
| 139 145 | 
             
            test_files: []
         |