fluent-plugin-amplitude 0.0.8 → 0.0.9
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/fluent-plugin-amplitude.gemspec +1 -1
- data/lib/fluent/plugin/out_amplitude.rb +14 -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: a2df4393337ff57bd66d8282d7d27d00e18fd11f
|
4
|
+
data.tar.gz: 0bb12c933cdfed442fdec1c8cde1fe66e06712b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3a3f198523457df7d57b82ee7eb6bb75536be0665a8c4ef9e027118878fa09459988092d78913377eaae44251e29d4b70d92cd79a665172dda71e8c57b7dec
|
7
|
+
data.tar.gz: 08ac45b1b9eea96014545ff9c9e9c11b05f524c7de17541125410ca3e323fcc36049df41bdf17b163a9a9641bbf89122d917cdcc466ba50a81a6d486cf8a1eea
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'fluent-plugin-amplitude'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.9'
|
8
8
|
spec.authors = ['Vijay Ramesh']
|
9
9
|
spec.email = ['vijay@change.org']
|
10
10
|
spec.summary = 'Fluentd plugin to output event data to Amplitude'
|
@@ -57,7 +57,9 @@ module Fluent
|
|
57
57
|
if verify_user_and_device(record)
|
58
58
|
records << AmplitudeAPI::Event.new(record)
|
59
59
|
else
|
60
|
-
log.info(
|
60
|
+
log.info(
|
61
|
+
"Error: either user_id or device_id must be set for tag #{tag}"
|
62
|
+
)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
@@ -93,7 +95,7 @@ module Fluent
|
|
93
95
|
def verify_user_and_device(amplitude_hash)
|
94
96
|
user_id = amplitude_hash[:user_id]
|
95
97
|
device_id = amplitude_hash[:device_id]
|
96
|
-
|
98
|
+
present?(user_id) || present?(device_id)
|
97
99
|
end
|
98
100
|
|
99
101
|
def extract_user_properties!(amplitude_hash, record)
|
@@ -123,14 +125,19 @@ module Fluent
|
|
123
125
|
|
124
126
|
def send_to_amplitude(records)
|
125
127
|
log.info("sending #{records.length} to amplitude")
|
126
|
-
|
127
|
-
|
128
|
+
errors = []
|
129
|
+
until records.empty?
|
130
|
+
res = AmplitudeAPI.track(records.pop(500))
|
128
131
|
unless res.response_code == 200
|
129
|
-
|
132
|
+
errors << [[res.response_code, res.body]]
|
130
133
|
end
|
131
|
-
rescue StandardError => e
|
132
|
-
raise AmplitudeError, "Error: #{e.message}"
|
133
134
|
end
|
135
|
+
return if errors.empty?
|
136
|
+
|
137
|
+
errors_string = errors.map do |code, body|
|
138
|
+
"Response: #{code} Body: #{body}"
|
139
|
+
end
|
140
|
+
raise AmplitudeError, "Errors: #{errors_string}"
|
134
141
|
end
|
135
142
|
end
|
136
143
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-amplitude
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vijay Ramesh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|