amplitude-api 0.0.2 → 0.0.3
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/.yardopts +2 -0
- data/lib/amplitude-api/event.rb +2 -2
- data/lib/amplitude-api/version.rb +1 -1
- data/readme.md +6 -0
- data/spec/lib/amplitude_api_spec.rb +20 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69388981ec7465494e2f8894a0f8d324430d8280
|
4
|
+
data.tar.gz: 8a97fd8316f0581b18a0420ab5c6a455094626d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17936fe48ef36da5ced4833c86a64f57f0df31e8d06909a0d60d55a2ecf2fe2a26b2692d675d6c015d36ed71d7d87ea14bd08ab0034384dbe035a8b81ae98b4
|
7
|
+
data.tar.gz: c4b6ed7af9745f5a75647080c08f9a7ee952977b03d305409f36d285d752da3fdf65830574e7b091deaa72df9242346060d34e403e14270e08119c9840f48324
|
data/.yardopts
ADDED
data/lib/amplitude-api/event.rb
CHANGED
@@ -15,14 +15,14 @@ class AmplitudeAPI
|
|
15
15
|
# @param [ String ] user_id a user_id to associate with the event
|
16
16
|
# @param [ String ] event_type a name for the event
|
17
17
|
# @param [ Hash ] event_properties various properties to attach to the event
|
18
|
-
def initialize(user_id: , event_type: , event_properties: {})
|
18
|
+
def initialize(user_id: "" , event_type: "", event_properties: {})
|
19
19
|
self.user_id = user_id
|
20
20
|
self.event_type = event_type
|
21
21
|
self.event_properties = event_properties
|
22
22
|
end
|
23
23
|
|
24
24
|
def user_id=(value)
|
25
|
-
@user_id =
|
25
|
+
@user_id =
|
26
26
|
if value.respond_to?(:id)
|
27
27
|
value.id
|
28
28
|
else
|
data/readme.md
CHANGED
@@ -27,11 +27,17 @@ event = AmplitudeAPI::Event.new({
|
|
27
27
|
AmplitudeAPI.track(event)
|
28
28
|
```
|
29
29
|
|
30
|
+
Currently, we are using this in Rails and using ActiveJob to dispatch events asynchronously. I plan on moving background/asynchronous support into this gem.
|
31
|
+
|
30
32
|
## What's Next
|
31
33
|
|
32
34
|
* Thread support for background dispatching in bulk
|
33
35
|
* `device_id` support as an alternative to `user_id`
|
34
36
|
* Configurable default account to use when no `user_id` present
|
37
|
+
|
38
|
+
## Other useful resources
|
39
|
+
* [Amplitude HTTP Api Documentation](https://amplitude.zendesk.com/hc/en-us/articles/204771828)
|
40
|
+
* [Segment.io Amplitude integration](https://segment.com/docs/integrations/amplitude/)
|
35
41
|
|
36
42
|
## Contributing
|
37
43
|
|
@@ -30,6 +30,26 @@ describe AmplitudeAPI do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe ".initializer " do
|
34
|
+
it "initializes event without parameter" do
|
35
|
+
event = AmplitudeAPI::Event.new()
|
36
|
+
expect(event.to_hash).to eq({
|
37
|
+
event_type: "",
|
38
|
+
user_id: "",
|
39
|
+
event_properties: {}
|
40
|
+
})
|
41
|
+
end
|
42
|
+
|
43
|
+
it "initializes event with parameter" do
|
44
|
+
event = AmplitudeAPI::Event.new(user_id: 123, event_type: "test_event", event_properties: {test_property: 1})
|
45
|
+
expect(event.to_hash).to eq({
|
46
|
+
event_type: "test_event",
|
47
|
+
user_id: 123,
|
48
|
+
event_properties: {test_property: 1}
|
49
|
+
})
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
33
53
|
describe ".send_event" do
|
34
54
|
it "sends an event to AmplitudeAPI" do
|
35
55
|
event = AmplitudeAPI::Event.new(user_id: @user, event_type: "test_event", event_properties: {test_property: 1})
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rakoczy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- ".gitignore"
|
89
89
|
- ".rspec"
|
90
90
|
- ".travis.yml"
|
91
|
+
- ".yardopts"
|
91
92
|
- Gemfile
|
92
93
|
- Gemfile.lock
|
93
94
|
- LICENSE
|
@@ -128,4 +129,3 @@ test_files:
|
|
128
129
|
- spec/lib/amplitude-api/event_spec.rb
|
129
130
|
- spec/lib/amplitude_api_spec.rb
|
130
131
|
- spec/spec_helper.rb
|
131
|
-
has_rdoc:
|