fluent-plugin-mixpanel 0.0.4 → 0.0.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1511b088e5a44ccfaaf5496c9c6016ed9d0868b
|
4
|
+
data.tar.gz: 1af1398470ca349149446515f2c23ad41e0bb3b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb42e76500502a2c4e883041abc18c234f69a687f90bffced64cf578d483d30d5c86f3bb81bec9ee4240bc41a3da4296b863b71e9513b2436f9bd72b5df3e0a3
|
7
|
+
data.tar.gz: 57418f562b980b1a061c765e9ff78e773f276b3cf77016a1b7dcae23aa514f018b13a77111989c58986e469c65e76bec2f01867e03a20a1d0a4250ffe46160a6
|
@@ -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-mixpanel"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.5"
|
8
8
|
spec.authors = ["Kazuyuki Honda"]
|
9
9
|
spec.email = ["hakobera@gmail.com"]
|
10
10
|
spec.summary = %q{Fluentd plugin to input/output event track data to mixpanel}
|
@@ -45,32 +45,39 @@ class Fluent::MixpanelOutput < Fluent::BufferedOutput
|
|
45
45
|
records = []
|
46
46
|
chunk.msgpack_each do |tag, time, record|
|
47
47
|
data = {}
|
48
|
+
prop = data['properties'] = record.dup
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
record.delete(@distinct_id_key)
|
52
|
-
else
|
53
|
-
log.warn('no distinct_id')
|
54
|
-
return
|
55
|
-
end
|
50
|
+
# Ignore token in record
|
51
|
+
prop.delete('token')
|
56
52
|
|
57
53
|
if @event_map_tag
|
58
54
|
data['event'] = tag.gsub(/^#{@remove_tag_prefix}(\.)?/, '')
|
59
55
|
elsif record[@event_key]
|
60
56
|
data['event'] = record[@event_key]
|
61
|
-
|
57
|
+
prop.delete(@event_key)
|
62
58
|
else
|
63
59
|
log.warn('no event')
|
64
60
|
return
|
65
61
|
end
|
66
62
|
|
63
|
+
# Ignore browswer only special event
|
64
|
+
return if data['event'].start_with?('mp_')
|
65
|
+
|
66
|
+
if record[@distinct_id_key]
|
67
|
+
data['distinct_id'] = record[@distinct_id_key]
|
68
|
+
prop.delete(@distinct_id_key)
|
69
|
+
else
|
70
|
+
log.warn('no distinct_id')
|
71
|
+
return
|
72
|
+
end
|
73
|
+
|
67
74
|
if !@ip_key.nil? and record[@ip_key]
|
68
|
-
|
69
|
-
|
75
|
+
prop['ip'] = record[@ip_key]
|
76
|
+
prop.delete(@ip_key)
|
70
77
|
end
|
71
78
|
|
72
|
-
|
73
|
-
|
79
|
+
prop.select! {|key, _| !key.start_with?('mp_') }
|
80
|
+
prop.merge!('time' => time.to_i)
|
74
81
|
|
75
82
|
records << data
|
76
83
|
end
|
@@ -42,7 +42,7 @@ class HttpMixpanelInputTest < Test::Unit::TestCase
|
|
42
42
|
d.expected_emits.each {|tag,time,record|
|
43
43
|
res = track("#{tag}", {"json"=>record})
|
44
44
|
assert_equal "200", res.code
|
45
|
-
assert_equal '
|
45
|
+
assert_equal '1', res.body
|
46
46
|
assert_equal 'true', res.header['access-control-allow-credentials']
|
47
47
|
assert_equal 'X-Requested-With', res.header['access-control-allow-headers']
|
48
48
|
assert_equal 'GET, POST, OPTIONS', res.header['access-control-allow-methods']
|
@@ -66,6 +66,7 @@ class MixpanelOutputTest < Test::Unit::TestCase
|
|
66
66
|
d.emit(sample_record, time)
|
67
67
|
d.run
|
68
68
|
|
69
|
+
assert_equal "test_token", @out[0]['properties']['token']
|
69
70
|
assert_equal "123", @out[0]['properties']['distinct_id']
|
70
71
|
assert_equal "event1", @out[0]['event']
|
71
72
|
assert_equal time.to_i, @out[0]['properties']['time']
|
@@ -140,6 +141,48 @@ class MixpanelOutputTest < Test::Unit::TestCase
|
|
140
141
|
assert_equal "value2", @out[0]['properties']['key2']
|
141
142
|
end
|
142
143
|
|
144
|
+
def test_write_ignore_special_event
|
145
|
+
stub_mixpanel
|
146
|
+
d = create_driver(CONFIG + "event_key event")
|
147
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
148
|
+
d.emit({ user_id: '123', event: 'mp_page_view' }, time)
|
149
|
+
d.run
|
150
|
+
|
151
|
+
assert_equal 0, @out.length
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_write_ignore_special_property
|
155
|
+
stub_mixpanel
|
156
|
+
d = create_driver(CONFIG + "event_key event")
|
157
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
158
|
+
d.emit(sample_record.merge('mp_event' => '3'), time)
|
159
|
+
d.run
|
160
|
+
|
161
|
+
assert_equal "test_token", @out[0]['properties']['token']
|
162
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
163
|
+
assert_equal "event1", @out[0]['event']
|
164
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
165
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
166
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
167
|
+
assert_equal false, @out[0]['properties'].key?('mp_event')
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_write_delete_supried_token
|
171
|
+
stub_mixpanel
|
172
|
+
d = create_driver(CONFIG + "event_key event")
|
173
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
174
|
+
d.emit(sample_record.merge('token' => '123'), time)
|
175
|
+
d.run
|
176
|
+
|
177
|
+
assert_equal "test_token", @out[0]['properties']['token']
|
178
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
179
|
+
assert_equal "event1", @out[0]['event']
|
180
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
181
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
182
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
183
|
+
assert_equal false, @out[0]['properties'].key?('mp_event')
|
184
|
+
end
|
185
|
+
|
143
186
|
def test_request_error
|
144
187
|
stub_mixpanel_unavailable
|
145
188
|
d = create_driver(CONFIG + "event_key event")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mixpanel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuyuki Honda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|