Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions app/services/frontend_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ def initialize(analytics:, event_map:)

def track_event(name, attributes)
if (analytics_method = event_map[name])
if analytics_method.is_a?(Proc)
analytics_method.call(analytics, **attributes)
else
analytics_method.bind_call(
analytics,
**hash_from_method_kwargs(attributes, analytics_method),
)
end
analytics_method.bind_call(analytics, **hash_from_method_kwargs(attributes, analytics_method))
else
analytics.track_event("Frontend: #{name}", attributes)
end
Expand Down
12 changes: 0 additions & 12 deletions spec/services/frontend_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ class ExampleAnalytics < FakeAnalytics
end

let(:analytics) { ExampleAnalytics.new }
let(:proc_handler) { proc {} }
let(:event_map) do
{
'proc' => proc_handler,
'method' => ExampleAnalyticsEvents.instance_method(:example_method_handler),
}
end
Expand All @@ -37,16 +35,6 @@ class ExampleAnalytics < FakeAnalytics
end
end

context 'with proc event handler' do
let(:name) { 'proc' }

it 'calls proc with analytics instance' do
expect(proc_handler).to receive(:call).with(analytics, attributes)

call
end
end

context 'with method handler' do
let(:name) { 'method' }

Expand Down