mixpanel_client 2.0.1 → 2.0.2

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.
data/README.md CHANGED
@@ -7,6 +7,10 @@ Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.
7
7
  ## Installation
8
8
 
9
9
  gem install mixpanel_client
10
+
11
+ or if you use a Gemfile
12
+
13
+ gem 'mixpanel_client'
10
14
 
11
15
  ## Usage
12
16
 
@@ -17,15 +21,21 @@ Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.
17
21
  client = Mixpanel::Client.new(config)
18
22
 
19
23
  data = client.request do
20
- resource 'events/properties'
21
- event '["test-event"]'
22
- name 'hello'
23
- values '["uno", "dos"]'
24
- type 'general'
25
- unit 'hour'
26
- interval 24
27
- limit 5
28
- bucket 'contents'
24
+ # Available options
25
+ resource 'events/properties'
26
+ event '["test-event"]'
27
+ name 'hello'
28
+ values '["uno", "dos"]'
29
+ type 'general'
30
+ unit 'hour'
31
+ interval 24
32
+ limit 5
33
+ bucket 'contents'
34
+ from_date '2011-08-11'
35
+ to_date '2011-08-12'
36
+ on 'properties["product_id"]'
37
+ where '1 in properties["product_id"]'
38
+ buckets '5'
29
39
  end
30
40
 
31
41
  puts data.inspect
@@ -16,7 +16,7 @@ module Mixpanel
16
16
 
17
17
  # Availalbe options for a Mixpanel API request
18
18
  OPTIONS = [:resource, :event, :funnel, :name, :type, :unit, :interval, :limit, :format, :bucket,
19
- :values, :from_date, :to_date, :on, :where, :buckets]
19
+ :values, :from_date, :to_date, :on, :where, :buckets, :timezone]
20
20
 
21
21
  # Dynamically define accessor methods for each option
22
22
  OPTIONS.each do |option|
@@ -8,5 +8,7 @@
8
8
  # See LICENSE for details
9
9
  module Mixpanel
10
10
  # URI related exceptions
11
- class URI::HTTPError < StandardError; end
11
+ class Error < StandardError; end
12
+ class HTTPError < Error; end
13
+ class ParseError < Error; end
12
14
  end
@@ -25,7 +25,11 @@ module Mixpanel
25
25
  if format == 'csv'
26
26
  data
27
27
  else
28
- JSON.parse(data)
28
+ begin
29
+ JSON.parse(data)
30
+ rescue JSON::ParserError => error
31
+ raise ParseError, error
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -10,6 +10,6 @@ module Mixpanel
10
10
  # Return metrics from Mixpanel Data API
11
11
  class Client
12
12
  # Mixpanel::Client library version
13
- VERSION = '2.0.1'
13
+ VERSION = '2.0.2'
14
14
  end
15
15
  end
@@ -16,7 +16,7 @@ describe 'External calls to mixpanel' do
16
16
  resource 'events'
17
17
  end
18
18
  }
19
- data.should raise_error(Mixpanel::URI::HTTPError)
19
+ data.should raise_error(Mixpanel::HTTPError)
20
20
  end
21
21
 
22
22
  it 'should return events' do
@@ -87,6 +87,7 @@ describe Mixpanel::Client do
87
87
  stub_request(:get, /^#{@uri}.*/).to_return(:body => '{"events": [], "type": "general"}')
88
88
 
89
89
  @client.request do
90
+ # This is not a real request. It just lists all possible options.
90
91
  resource 'events'
91
92
  event '["test-event"]'
92
93
  funnel 'down-the-rabbit-hole'
@@ -98,7 +99,7 @@ describe Mixpanel::Client do
98
99
  format 'csv'
99
100
  bucket 'list'
100
101
  values '["tiger", "blood"]'
101
- #below options only in segmentation events
102
+ timezone '-8'
102
103
  from_date '2011-08-11'
103
104
  to_date '2011-08-12'
104
105
  on 'properties["product_id"]'
@@ -16,7 +16,7 @@ describe 'External calls to mixpanel' do
16
16
  resource 'properties'
17
17
  end
18
18
  }
19
- data.should raise_error(Mixpanel::URI::HTTPError)
19
+ data.should raise_error(Mixpanel::HTTPError)
20
20
  end
21
21
 
22
22
  it 'should return events' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixpanel_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 1
10
- version: 2.0.1
9
+ - 2
10
+ version: 2.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Keolo Keagy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-15 00:00:00 -07:00
18
+ date: 2011-11-22 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency