Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Event Logger Utilization #14

Merged
merged 2 commits into from Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
absmartly-sdk (1.0.6)
absmartly-sdk (1.0.7)
arraybuffer (~> 0.0.6)
faraday (~> 1.10.3)
murmurhash3 (~> 0.1.7)
Expand Down
2 changes: 1 addition & 1 deletion lib/absmartly/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Absmartly
VERSION = "1.0.6"
VERSION = "1.0.7"
end
6 changes: 3 additions & 3 deletions lib/json/attribute.rb
Expand Up @@ -22,9 +22,9 @@ def hash_code

def to_s
"Attribute{" +
"name='" + @name + "'" +
", value=" + @value +
", setAt=" + @set_at +
"name='#{@name}'" +
", value=#{@value}" +
", setAt=#{@set_at}" +
"}"
end
end
30 changes: 15 additions & 15 deletions lib/json/experiment.rb
Expand Up @@ -63,21 +63,21 @@ def hash_code

def to_s
"ContextExperiment{" +
"id=" + @id +
", name='" + @name + "'" +
", unitType='" + @unit_type + "'" +
", iteration=" + @iteration +
", seedHi=" + @seed_hi +
", seedLo=" + @seed_lo +
", split=" + @split.join +
", trafficSeedHi=" + @traffic_seed_hi +
", trafficSeedLo=" + @traffic_seed_lo +
", trafficSplit=" + @traffic_split.join +
", fullOnVariant=" + @full_on_variant +
", applications=" + @applications.join +
", variants=" + @variants.join +
", audienceStrict=" + @audience_strict +
", audience='" + @audience + "'" +
"id= #{@id}"+
", name='#{@name}'" +
", unitType='#{@unit_type}'" +
", iteration=#{@iteration}" +
", seedHi=#{@seed_hi}" +
", seedLo=#{@seed_lo}" +
", split=#{@split.join}" +
", trafficSeedHi=#{@traffic_seed_hi}" +
", trafficSeedLo=#{@traffic_seed_lo}" +
", trafficSplit=#{@traffic_split.join}" +
", fullOnVariant=#{@full_on_variant}" +
", applications=#{@applications.join}" +
", variants=#{@variants.join}" +
", audienceStrict=#{@audience_strict}" +
", audience='#{@audience}'" +
"}"
end
end
4 changes: 2 additions & 2 deletions lib/json/experiment_variant.rb
Expand Up @@ -22,8 +22,8 @@ def hash_code

def to_s
"ExperimentVariant{" +
"name='" + @name + "'" +
", config='" + @config + "'" +
"name='#{@name}'" +
", config='#{@config}'" +
"}"
end
end
22 changes: 11 additions & 11 deletions lib/json/exposure.rb
Expand Up @@ -44,17 +44,17 @@ def hash_code

def to_s
"Exposure{" +
"id=" + @id +
"name='" + @name + "'" +
", unit=" + @unit +
", variant=" + @variant +
", exposed_at=" + @exposed_at +
", assigned=" + @assigned +
", eligible=" + @eligible +
", overridden=" + @overridden +
", full_on=" + @full_on +
", custom=" + @custom +
", audience_mismatch=" + @audience_mismatch +
"id=#{@id}" +
"name='#{@name}'" +
", unit=#{@unit}" +
", variant=#{@variant}" +
", exposed_at=#{@exposed_at}" +
", assigned=#{@assigned}" +
", eligible=#{@eligible}" +
", overridden=#{@overridden}" +
", full_on=#{@full_on}" +
", custom=#{@custom}" +
", audience_mismatch=#{@audience_mismatch}" +
"}"
end
end
6 changes: 3 additions & 3 deletions lib/json/goal_achievement.rb
Expand Up @@ -24,9 +24,9 @@ def hash_code

def to_s
"GoalAchievement{" +
"name='" + @name + "'" +
", achieved_at='" + @achieved_at + "'" +
", properties='" + @properties.inspect + "'" +
"name='#{@name}'" +
", achieved_at='#{@achieved_at}'" +
", properties='#{@properties.inspect}'" +
"}"
end
end
12 changes: 6 additions & 6 deletions lib/json/publish_event.rb
Expand Up @@ -31,12 +31,12 @@ def hash_code

def to_s
"PublishEvent{" +
"hashedUnits=" + @hashed +
", units=" + @units.inspect +
", publishedAt=" + @published_at +
", exposures=" + @exposures.inspect +
", goals=" + @goals.inspect +
", attributes=" + @attributes.join +
"hashedUnits=#{@hashed}" +
", units=#{@units.inspect}" +
", publishedAt=#{@published_at}" +
", exposures=#{@exposures.inspect}" +
", goals=#{@goals.inspect}" +
", attributes=#{@attributes!=nil ? @attributes.join : ""}" +
"}"
end
end
9 changes: 7 additions & 2 deletions spec/context_spec.rb
Expand Up @@ -12,6 +12,7 @@
require "scheduled_executor_service"
require "audience_matcher"
require "json/unit"
require "logger"

RSpec.describe Context do
let(:units) {
Expand Down Expand Up @@ -106,7 +107,7 @@
end
let(:event_logger) do
event_logger = MockContextEventLoggerProxy.new
allow(event_logger).to receive(:handle_event).and_return(nil)
allow(event_logger).to receive(:handle_event).and_call_original
event_logger
end
let(:variable_parser) { DefaultVariableParser.new }
Expand Down Expand Up @@ -1081,16 +1082,20 @@ def faraday_response(content)


class MockContextEventLoggerProxy < ContextEventLogger
attr_accessor :called, :events
attr_accessor :called, :events, :logger

def initialize
@called = 0
@events = []
@logger = Logger.new(STDOUT)
end

def handle_event(event, data)
@called += 1
@events << { event: event, data: data }

@logger.debug "event: #{event}"
@logger.debug "data: #{data}"
end

def clear
Expand Down