mixpanel_client 4.0.1 → 4.1.0
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.
- checksums.yaml +4 -4
- data/changelog.md +5 -0
- data/lib/mixpanel/client.rb +23 -12
- data/lib/mixpanel/version.rb +1 -1
- data/readme.md +2 -3
- data/spec/mixpanel_client/mixpanel_client_spec.rb +0 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2064a32d2001e146ea1f47b5b9ac83744c683a60
|
4
|
+
data.tar.gz: 3033df250915740f19205d9c2864773b61acfc65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab6d79cdf8270ad2a721c95d690cc28bfb83562fc1519752c4e70206132bcb69f770a0eab04e2c490949272c01c504d7076a7f0079d3e3a8eaa5a9e2240d3552
|
7
|
+
data.tar.gz: 34ea6268f37da906c193476b089bfa810dd1cd1bbcdd7d4659abd8120efee99b1086fc83990f6422c2622412e518f13bc55162103daf8f847ea88fa3f5241d51
|
data/changelog.md
CHANGED
data/lib/mixpanel/client.rb
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
module Mixpanel
|
10
10
|
# Return metrics from Mixpanel Data API
|
11
11
|
class Client
|
12
|
-
BASE_URI
|
13
|
-
DATA_URI
|
12
|
+
BASE_URI = 'https://mixpanel.com/api/2.0'
|
13
|
+
DATA_URI = 'https://data.mixpanel.com/api/2.0'
|
14
14
|
IMPORT_URI = 'https://api.mixpanel.com'
|
15
15
|
|
16
16
|
attr_reader :uri
|
@@ -24,9 +24,9 @@ module Mixpanel
|
|
24
24
|
#
|
25
25
|
# @param [Hash] config consisting of an 'api_key' and an 'api_secret'
|
26
26
|
def initialize(config)
|
27
|
-
@api_key = config[:api_key]
|
28
|
-
@api_secret = config[:api_secret]
|
29
|
-
@parallel = config[:parallel] ||
|
27
|
+
@api_key = config[:api_key]
|
28
|
+
@api_secret = config[:api_secret]
|
29
|
+
@parallel = config[:parallel] || false
|
30
30
|
|
31
31
|
fail ConfigurationError if @api_key.nil? || @api_secret.nil?
|
32
32
|
end
|
@@ -56,6 +56,7 @@ module Mixpanel
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def make_parallel_request
|
59
|
+
require 'typhoeus'
|
59
60
|
parallel_request = prepare_parallel_request
|
60
61
|
hydra.queue parallel_request
|
61
62
|
parallel_request
|
@@ -105,10 +106,10 @@ module Mixpanel
|
|
105
106
|
elsif response.timed_out?
|
106
107
|
fail TimeoutError
|
107
108
|
elsif response.code == 0
|
108
|
-
# Could not get an http response, something's wrong
|
109
|
+
# Could not get an http response, something's wrong
|
109
110
|
fail HTTPError, response.curl_error_message
|
110
111
|
else
|
111
|
-
# Received a non-successful http response
|
112
|
+
# Received a non-successful http response
|
112
113
|
if response.body && response.body != ''
|
113
114
|
error_message = JSON.parse(response.body)['error']
|
114
115
|
else
|
@@ -139,11 +140,21 @@ module Mixpanel
|
|
139
140
|
# signature
|
140
141
|
def normalize_options(options)
|
141
142
|
normalized_options = options.dup
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
|
144
|
+
normalized_options
|
145
|
+
.merge!(
|
146
|
+
format: @format,
|
147
|
+
api_key: @api_key,
|
148
|
+
expire: request_expires_at(normalized_options)
|
149
|
+
)
|
150
|
+
.merge!(
|
151
|
+
sig: Utils.generate_signature(normalized_options, @api_secret)
|
152
|
+
)
|
153
|
+
end
|
154
|
+
|
155
|
+
def request_expires_at(options)
|
156
|
+
ten_minutes_from_now = Time.now.to_i + 600
|
157
|
+
options[:expire] ? options[:expire].to_i : ten_minutes_from_now
|
147
158
|
end
|
148
159
|
|
149
160
|
def self.base_uri_for_resource(resource)
|
data/lib/mixpanel/version.rb
CHANGED
data/readme.md
CHANGED
@@ -9,7 +9,7 @@ Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.
|
|
9
9
|
## Installation
|
10
10
|
|
11
11
|
gem install mixpanel_client
|
12
|
-
|
12
|
+
|
13
13
|
or if you use a Gemfile
|
14
14
|
|
15
15
|
gem 'mixpanel_client'
|
@@ -50,8 +50,7 @@ or if you use a Gemfile
|
|
50
50
|
limit: 5
|
51
51
|
)
|
52
52
|
|
53
|
-
|
54
|
-
# use the import API, which allows one to specify a time in the past, unlike the track API.
|
53
|
+
# Use the import API, which allows one to specify a time in the past, unlike the track API.
|
55
54
|
# note that you need to include your api token in the data. More details at:
|
56
55
|
# https://mixpanel.com/docs/api-documentation/importing-events-older-than-31-days
|
57
56
|
data_to_import = {'event' => 'firstLogin', 'properties' => {'distinct_id' => guid, 'time' => time_as_integer_seconds_since_epoch, 'token' => api_token}}
|
@@ -11,13 +11,6 @@ describe Mixpanel::Client do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'when initializing a new Mixpanel::Client' do
|
14
|
-
it 'should not raise an exception if a hash is given' do
|
15
|
-
Mixpanel::Client.new(
|
16
|
-
'api_key' => 'test_key',
|
17
|
-
'api_secret' => 'test_secret'
|
18
|
-
).should_not { raise_error }
|
19
|
-
end
|
20
|
-
|
21
14
|
it 'should set a parallel option as false by default' do
|
22
15
|
Mixpanel::Client.new(
|
23
16
|
api_key: 'test_key',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixpanel_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keolo Keagy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|