mixpanel_client 2.2.0 → 2.2.1
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 +9 -0
- data/lib/mixpanel/client.rb +7 -1
- data/lib/mixpanel/uri.rb +2 -1
- data/lib/mixpanel/version.rb +1 -1
- data/spec/mixpanel_client/uri_spec.rb +4 -0
- metadata +3 -3
data/README.md
CHANGED
|
@@ -74,6 +74,13 @@ Create tag v2.0.2 and build and push mixpanel_client-2.0.2.gem to Rubygems
|
|
|
74
74
|
|
|
75
75
|
## Changelog
|
|
76
76
|
|
|
77
|
+
### v.2.2.1
|
|
78
|
+
* Added support for the raw data export API.
|
|
79
|
+
|
|
80
|
+
### v2.2.0
|
|
81
|
+
* BASE_URI is now https.
|
|
82
|
+
* Changed funnel to funnel_id.
|
|
83
|
+
|
|
77
84
|
### v2.1.0
|
|
78
85
|
* Updated json dependency to 1.6.
|
|
79
86
|
|
|
@@ -105,6 +112,8 @@ Create tag v2.0.2 and build and push mixpanel_client-2.0.2.gem to Rubygems
|
|
|
105
112
|
libraries. [a710a84e8ba4b6f018b7](https://github.com/keolo/mixpanel_client/commit/a710a84e8ba4b6f018b7404ab9fabc8f08b4a4f3)
|
|
106
113
|
|
|
107
114
|
## Collaborators and Maintainers
|
|
115
|
+
Feel free to add your name and link here.
|
|
116
|
+
|
|
108
117
|
[Keolo Keagy](http://github.com/keolo) (Author)
|
|
109
118
|
[Jason Logsdon](https://github.com/jasonlogsdon)
|
|
110
119
|
[James R](https://github.com/Cev)
|
data/lib/mixpanel/client.rb
CHANGED
|
@@ -10,11 +10,12 @@ module Mixpanel
|
|
|
10
10
|
# Return metrics from Mixpanel Data API
|
|
11
11
|
class Client
|
|
12
12
|
BASE_URI = 'https://mixpanel.com/api/2.0'
|
|
13
|
+
DATA_URI = 'https://data.mixpanel.com/api/2.0'
|
|
13
14
|
|
|
14
15
|
attr_reader :uri
|
|
15
16
|
attr_accessor :api_key, :api_secret
|
|
16
17
|
|
|
17
|
-
#
|
|
18
|
+
# Available options for a Mixpanel API request
|
|
18
19
|
OPTIONS = [:resource, :event, :funnel_id, :name, :type, :unit, :interval, :limit, :format, :bucket,
|
|
19
20
|
:values, :from_date, :to_date, :on, :where, :buckets, :timezone]
|
|
20
21
|
|
|
@@ -61,6 +62,7 @@ module Mixpanel
|
|
|
61
62
|
instance_eval(&options)
|
|
62
63
|
@uri = URI.mixpanel(resource, normalize_params(params))
|
|
63
64
|
response = URI.get(@uri)
|
|
65
|
+
response = %Q|[#{response.split("\n").join(',')}]| if resource == 'export'
|
|
64
66
|
Utils.to_hash(response, @format)
|
|
65
67
|
end
|
|
66
68
|
|
|
@@ -94,5 +96,9 @@ module Mixpanel
|
|
|
94
96
|
:expire => Time.now.to_i + 600 # Grant this request 10 minutes
|
|
95
97
|
).merge!(:sig => Utils.generate_signature(params, @api_secret))
|
|
96
98
|
end
|
|
99
|
+
|
|
100
|
+
def self.base_uri_for_resource(resource)
|
|
101
|
+
resource == 'export' ? DATA_URI : BASE_URI
|
|
102
|
+
end
|
|
97
103
|
end
|
|
98
104
|
end
|
data/lib/mixpanel/uri.rb
CHANGED
|
@@ -10,7 +10,8 @@ module Mixpanel
|
|
|
10
10
|
# Utilities to assist generating and requesting URIs
|
|
11
11
|
class URI
|
|
12
12
|
def self.mixpanel(resource, params)
|
|
13
|
-
|
|
13
|
+
base = Mixpanel::Client.base_uri_for_resource(resource)
|
|
14
|
+
"#{File.join([base, resource.to_s])}?#{self.encode(params)}"
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
def self.encode(params)
|
data/lib/mixpanel/version.rb
CHANGED
|
@@ -11,6 +11,10 @@ describe Mixpanel::URI do
|
|
|
11
11
|
resource, params = ['events/top', {:c => 'see', :a => 'ey'}]
|
|
12
12
|
Mixpanel::URI.mixpanel(resource, params).should == "#{Mixpanel::Client::BASE_URI}/events/top?a=ey&c=see"
|
|
13
13
|
end
|
|
14
|
+
it 'should return a uri with a different endpoint when doing a raw data export' do
|
|
15
|
+
resource, params = ['export', {:c => 'see', :a => 'ey'}]
|
|
16
|
+
Mixpanel::URI.mixpanel(resource, params).should == "#{Mixpanel::Client::DATA_URI}/export?a=ey&c=see"
|
|
17
|
+
end
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
describe '.encode' 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:
|
|
4
|
+
hash: 5
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 2
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 2.2.
|
|
9
|
+
- 1
|
|
10
|
+
version: 2.2.1
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Keolo Keagy
|