diff --git a/lib/mixpanel-ruby/consumer.rb b/lib/mixpanel-ruby/consumer.rb index 3078f66..68baee4 100644 --- a/lib/mixpanel-ruby/consumer.rb +++ b/lib/mixpanel-ruby/consumer.rb @@ -108,6 +108,8 @@ def send!(type, message) if result['status'] != 1 raise ServerError.new("Could not write to Mixpanel, server responded with #{response_code} returning: '#{response_body}'") end + + [response_code, response_body] end # This method was deprecated in release 2.0.0, please use send! instead diff --git a/spec/mixpanel-ruby/consumer_spec.rb b/spec/mixpanel-ruby/consumer_spec.rb index 941f256..cb9aa32 100644 --- a/spec/mixpanel-ruby/consumer_spec.rb +++ b/spec/mixpanel-ruby/consumer_spec.rb @@ -68,6 +68,12 @@ expect(WebMock).to have_requested(:post, 'https://api.mixpanel.com/track'). with(:body => {'data' => 'IlRFU1QgRVZFTlQgTUVTU0FHRSI=', 'verbose' => '1' }) end + + it 'should return the response status and body' do + stub_request(:any, 'https://api.mixpanel.com/track').to_return({:body => '{"status": 1, "error": null}'}) + expect(subject.send!(:event, {'data' => 'TEST EVENT MESSAGE'}.to_json)) + .to eq(['200', '{"status": 1, "error": null}']) + end end context 'raw consumer' do