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

Add return of event in track method #569

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ahoy/database_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def track_event(data)
event.time = visit.started_at if event.time < visit.started_at
begin
event.save!
event
rescue => e
raise e unless unique_exception?(e)
end
Expand Down
1 change: 0 additions & 1 deletion lib/ahoy/tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def track(name, properties = {}, options = {})

@store.track_event(data)
end
true
rescue => e
report_exception(e)
end
Expand Down
6 changes: 6 additions & 0 deletions test/tracker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def test_user_option
assert_equal user.id, event.user_id
end

def test_track_return_value
ahoy = Ahoy::Tracker.new
event = ahoy.track("Some event", some_prop: true)
assert_instance_of Ahoy::Event, event
end

def test_user_option_in_store
user = Struct.new(:id, :user_prop).new(123, 42)
ahoy = Ahoy::Tracker.new(user: user)
Expand Down