amplitude-api 0.0.6 → 0.0.7
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/Gemfile +1 -1
- data/Gemfile.lock +5 -5
- data/amplitude-api.gemspec +1 -1
- data/lib/amplitude_api.rb +3 -3
- data/lib/amplitude_api/event.rb +12 -6
- data/lib/amplitude_api/version.rb +1 -1
- data/readme.md +2 -1
- data/spec/lib/amplitude_api_spec.rb +10 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 233332597b10167395db959e0066e1f8b2adf1ad
|
4
|
+
data.tar.gz: 574f6162547e34a3e2003abf0410146064de2279
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 860998aada7dc9516f451d1e83d1c92abc1247eab787eb67ed186efa63c30e650f94e6e31afe422119a1f55da6c058d606df6a5b3529ad669f32781f3bb33b11
|
7
|
+
data.tar.gz: 22b4a53df0df781db7f2efeac562481546b8551bee4e31b2be1918189a8b5cb145cb14e2eb70b366965dd56b27310ef95832d73125bdcb7ffa157818382a1ba6
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,9 +4,9 @@ GEM
|
|
4
4
|
ast (2.2.0)
|
5
5
|
coderay (1.1.1)
|
6
6
|
diff-lcs (1.2.5)
|
7
|
-
ethon (0.
|
7
|
+
ethon (0.9.0)
|
8
8
|
ffi (>= 1.3.0)
|
9
|
-
ffi (1.9.
|
9
|
+
ffi (1.9.14)
|
10
10
|
method_source (0.8.2)
|
11
11
|
parser (2.3.0.6)
|
12
12
|
ast (~> 2.2)
|
@@ -39,8 +39,8 @@ GEM
|
|
39
39
|
rubocop-rspec (1.4.0)
|
40
40
|
ruby-progressbar (1.7.5)
|
41
41
|
slop (3.6.0)
|
42
|
-
typhoeus (0.
|
43
|
-
ethon (>= 0.
|
42
|
+
typhoeus (1.0.2)
|
43
|
+
ethon (>= 0.9.0)
|
44
44
|
unicode-display_width (0.3.1)
|
45
45
|
|
46
46
|
PLATFORMS
|
@@ -52,7 +52,7 @@ DEPENDENCIES
|
|
52
52
|
rspec (>= 2.99.0)
|
53
53
|
rubocop (~> 0.37.2)
|
54
54
|
rubocop-rspec
|
55
|
-
typhoeus (~> 0.
|
55
|
+
typhoeus (~> 1.0.2)
|
56
56
|
|
57
57
|
BUNDLED WITH
|
58
58
|
1.10.6
|
data/amplitude-api.gemspec
CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'rspec', '~> 2.99', '>= 2.99.0'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0', '>= 10.0'
|
23
23
|
spec.add_development_dependency 'pry', '~> 0.9.12.6'
|
24
|
-
spec.add_dependency 'typhoeus', '~> 0.
|
24
|
+
spec.add_dependency 'typhoeus', '~> 1.0.2'
|
25
25
|
spec.required_ruby_version = '~> 2.0'
|
26
26
|
end
|
data/lib/amplitude_api.rb
CHANGED
@@ -28,12 +28,12 @@ class AmplitudeAPI
|
|
28
28
|
# and contains user properties to be associated with the user
|
29
29
|
#
|
30
30
|
# @return [ Typhoeus::Response ]
|
31
|
-
def send_event(event_name, user,
|
31
|
+
def send_event(event_name, user, options = {})
|
32
32
|
event = AmplitudeAPI::Event.new(
|
33
33
|
user_id: user,
|
34
34
|
event_type: event_name,
|
35
|
-
event_properties: event_properties,
|
36
|
-
user_properties: user_properties
|
35
|
+
event_properties: options.fetch(:event_properties, {}),
|
36
|
+
user_properties: options.fetch(:user_properties, {})
|
37
37
|
)
|
38
38
|
track(event)
|
39
39
|
end
|
data/lib/amplitude_api/event.rb
CHANGED
@@ -16,6 +16,9 @@ class AmplitudeAPI
|
|
16
16
|
# @!attribute [ rw ] time
|
17
17
|
# @return [ Time ] Time that the event occurred (defaults to now)
|
18
18
|
attr_accessor :time
|
19
|
+
# @!attribute [ rw ] ip
|
20
|
+
# @return [ String ] IP address of the user
|
21
|
+
attr_accessor :ip
|
19
22
|
|
20
23
|
# Create a new Event
|
21
24
|
#
|
@@ -23,12 +26,14 @@ class AmplitudeAPI
|
|
23
26
|
# @param [ String ] event_type a name for the event
|
24
27
|
# @param [ Hash ] event_properties various properties to attach to the event
|
25
28
|
# @param [ Time ] Time that the event occurred (defaults to now)
|
26
|
-
|
27
|
-
|
28
|
-
self.
|
29
|
-
self.
|
30
|
-
self.
|
31
|
-
self.
|
29
|
+
# @param [ String ] IP address of the user
|
30
|
+
def initialize(options = {})
|
31
|
+
self.user_id = options.fetch(:user_id, '')
|
32
|
+
self.event_type = options.fetch(:event_type, '')
|
33
|
+
self.event_properties = options.fetch(:event_properties, {})
|
34
|
+
self.user_properties = options.fetch(:user_properties, {})
|
35
|
+
self.time = options[:time]
|
36
|
+
self.ip = options.fetch(:ip, '')
|
32
37
|
end
|
33
38
|
|
34
39
|
def user_id=(value)
|
@@ -50,6 +55,7 @@ class AmplitudeAPI
|
|
50
55
|
serialized_event[:event_properties] = event_properties
|
51
56
|
serialized_event[:user_properties] = user_properties
|
52
57
|
serialized_event[:time] = formatted_time if time
|
58
|
+
serialized_event[:ip] = ip if ip
|
53
59
|
serialized_event
|
54
60
|
end
|
55
61
|
|
data/readme.md
CHANGED
@@ -11,7 +11,7 @@ gem install amplitude-api
|
|
11
11
|
|
12
12
|
## Basic Usage
|
13
13
|
|
14
|
-
The following code snippet will immediately track an event to the Amplitude API.
|
14
|
+
The following code snippet will immediately track an event to the Amplitude API.
|
15
15
|
|
16
16
|
```ruby
|
17
17
|
# Configure your Amplitude API key
|
@@ -20,6 +20,7 @@ AmplitudeAPI.api_key = "abcdef123456"
|
|
20
20
|
event = AmplitudeAPI::Event.new({
|
21
21
|
user_id: "123",
|
22
22
|
event_type: "clicked on home",
|
23
|
+
time: Time.now,
|
23
24
|
event_properties: {
|
24
25
|
cause: "button",
|
25
26
|
arbitrary: "properties"
|
@@ -99,7 +99,8 @@ describe AmplitudeAPI do
|
|
99
99
|
event_type: '',
|
100
100
|
user_id: '',
|
101
101
|
event_properties: {},
|
102
|
-
user_properties: {}
|
102
|
+
user_properties: {},
|
103
|
+
ip: ''
|
103
104
|
)
|
104
105
|
end
|
105
106
|
|
@@ -109,13 +110,15 @@ describe AmplitudeAPI do
|
|
109
110
|
event_type: 'test_event',
|
110
111
|
event_properties: {
|
111
112
|
test_property: 1
|
112
|
-
}
|
113
|
+
},
|
114
|
+
ip: '8.8.8.8'
|
113
115
|
)
|
114
116
|
expect(event.to_hash).to eq(
|
115
117
|
event_type: 'test_event',
|
116
118
|
user_id: 123,
|
117
119
|
event_properties: { test_property: 1 },
|
118
|
-
user_properties: {}
|
120
|
+
user_properties: {},
|
121
|
+
ip: '8.8.8.8'
|
119
122
|
)
|
120
123
|
end
|
121
124
|
end
|
@@ -243,7 +246,8 @@ describe AmplitudeAPI do
|
|
243
246
|
},
|
244
247
|
user_properties: {
|
245
248
|
abc: '123'
|
246
|
-
}
|
249
|
+
},
|
250
|
+
ip: '8.8.8.8'
|
247
251
|
)
|
248
252
|
body = described_class.track_body(event)
|
249
253
|
|
@@ -257,7 +261,8 @@ describe AmplitudeAPI do
|
|
257
261
|
},
|
258
262
|
user_properties: {
|
259
263
|
abc: '123'
|
260
|
-
}
|
264
|
+
},
|
265
|
+
ip: '8.8.8.8'
|
261
266
|
}
|
262
267
|
]
|
263
268
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amplitude-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rakoczy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 0.
|
73
|
+
version: 1.0.2
|
74
74
|
type: :runtime
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0.
|
80
|
+
version: 1.0.2
|
81
81
|
description: Provides an integration for sending events to Amplitude
|
82
82
|
email:
|
83
83
|
- arakoczy@gmail.com
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.5.1
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Send events to the Amplitude API
|