fluent-plugin-amplitude 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-amplitude.gemspec +1 -1
- data/lib/fluent/plugin/fake_active_support.rb +22 -0
- data/lib/fluent/plugin/out_amplitude.rb +5 -11
- data/spec/out_amplitude_spec.rb +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01e61239e194c3e3ed6d86efc525edcd1b45df04
|
4
|
+
data.tar.gz: 629c94af197ff1b8c0e59b06cc78d7e2f00a47f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 699c3638100a649487f63f19eac4b3e48f2cb2bff4e7501998e3b2a3411342d3ee8710747cc20c46fdc0617d4faf5ebe7490684967d14cfea5c31c95b8061b34
|
7
|
+
data.tar.gz: 6431d376d1862d0cc5fa819b4f51d49efe84a25b446d2af10bc7ff14d31264e7838274b9ad5d8a1edb5adaadbd94c2f5f4f91d4114adc558ec6a17528829faa2
|
@@ -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.3'
|
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'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Some things we want from ActiveSupport
|
2
|
+
module FakeActiveSupport
|
3
|
+
def simple_symbolize_keys(hsh)
|
4
|
+
Hash[hsh.map do |k, v|
|
5
|
+
begin
|
6
|
+
[k.to_sym, v]
|
7
|
+
rescue
|
8
|
+
[k, v]
|
9
|
+
end
|
10
|
+
end]
|
11
|
+
end
|
12
|
+
|
13
|
+
def blank?(var)
|
14
|
+
# rubocop:disable DoubleNegation
|
15
|
+
var.respond_to?(:empty?) ? !!var.empty? : !var
|
16
|
+
# rubocop:enable DoubleNegation
|
17
|
+
end
|
18
|
+
|
19
|
+
def present?(var)
|
20
|
+
!blank?(var)
|
21
|
+
end
|
22
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require './lib/fluent/plugin/fake_active_support'
|
1
2
|
module Fluent
|
2
3
|
# Fluent::AmplitudeOutput plugin
|
3
4
|
class AmplitudeOutput < Fluent::BufferedOutput
|
4
5
|
Fluent::Plugin.register_output('amplitude', self)
|
5
6
|
|
6
7
|
include Fluent::HandleTagNameMixin
|
8
|
+
include FakeActiveSupport
|
7
9
|
|
8
10
|
config_param :api_key, :string, secret: true
|
9
11
|
config_param :device_id_key, :string
|
@@ -76,7 +78,9 @@ module Fluent
|
|
76
78
|
end
|
77
79
|
|
78
80
|
def verify_user_and_device_or_fail(amplitude_hash)
|
79
|
-
|
81
|
+
user_id = amplitude_hash[:user_id]
|
82
|
+
device_id = amplitude_hash[:device_id]
|
83
|
+
return if present?(user_id) || present?(device_id)
|
80
84
|
raise AmplitudeError, 'Error: either user_id or device_id must be set'
|
81
85
|
end
|
82
86
|
|
@@ -116,15 +120,5 @@ module Fluent
|
|
116
120
|
raise AmplitudeError, "Error: #{e.message}"
|
117
121
|
end
|
118
122
|
end
|
119
|
-
|
120
|
-
def simple_symbolize_keys(hsh)
|
121
|
-
Hash[hsh.map do |k, v|
|
122
|
-
begin
|
123
|
-
[k.to_sym, v]
|
124
|
-
rescue
|
125
|
-
[k, v]
|
126
|
-
end
|
127
|
-
end]
|
128
|
-
end
|
129
123
|
end
|
130
124
|
end
|
data/spec/out_amplitude_spec.rb
CHANGED
@@ -144,6 +144,25 @@ describe Fluent::AmplitudeOutput do
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
context 'the input only contains empty user_id and device_id fields' do
|
148
|
+
let(:event) do
|
149
|
+
{
|
150
|
+
'user_id' => '',
|
151
|
+
'uuid' => '',
|
152
|
+
'first_name' => 'Bobby',
|
153
|
+
'last_name' => 'Weir',
|
154
|
+
'state' => 'CA',
|
155
|
+
'current_source' => 'fb_share',
|
156
|
+
'recruiter_id' => 710
|
157
|
+
}
|
158
|
+
end
|
159
|
+
it 'raises a Fluent::AmplitudeOutput::AmplitudeError' do
|
160
|
+
expect { amplitude.run }.to raise_error(
|
161
|
+
Fluent::AmplitudeOutput::AmplitudeError
|
162
|
+
)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
147
166
|
context 'properties_blacklist is specified' do
|
148
167
|
let(:conf) do
|
149
168
|
%(
|
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.3
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- README.md
|
142
142
|
- Rakefile
|
143
143
|
- fluent-plugin-amplitude.gemspec
|
144
|
+
- lib/fluent/plugin/fake_active_support.rb
|
144
145
|
- lib/fluent/plugin/out_amplitude.rb
|
145
146
|
- spec/out_amplitude_spec.rb
|
146
147
|
- spec/spec_helper.rb
|