fluent-plugin-amplitude 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87356ba6323e223e3ce8b3b34424a1f942d2ee58
4
- data.tar.gz: 5f4552341e234469911d09c064d692d6851da300
3
+ metadata.gz: a2df4393337ff57bd66d8282d7d27d00e18fd11f
4
+ data.tar.gz: 0bb12c933cdfed442fdec1c8cde1fe66e06712b6
5
5
  SHA512:
6
- metadata.gz: 7afeee3c37fe492271e6db7d04caff6d59277c30f65fac72f24b2427b2085390578e59d80a15f0c0e15f1d5cf5f4f49194e6a43a99aaf4ac05d2198bb443d931
7
- data.tar.gz: 056333c1581a72a259ff89e42c9bc9c3ec77d2e7e227bebef478eafd2a6ecc388d47b5d60beed25a876c97c3bd769d92d425f22c52b0a2cd6dba0f46a56b0fd2
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.8'
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("Error: either user_id or device_id must be set for tag #{tag}")
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
- return present?(user_id) || present?(device_id)
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
- begin
127
- res = AmplitudeAPI.track(records)
128
+ errors = []
129
+ until records.empty?
130
+ res = AmplitudeAPI.track(records.pop(500))
128
131
  unless res.response_code == 200
129
- raise "Got #{res.response_code} #{res.body} from AmplitudeAPI"
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.8
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-17 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd