fluent-plugin-mixpanel 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -3
- data/fluent-plugin-mixpanel.gemspec +1 -1
- data/lib/fluent/plugin/out_mixpanel.rb +8 -4
- data/test/plugin/test_out_mixpanel.rb +83 -11
- 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: ce61d35f6244b42e741d6d7f3c783ab3ca163673
|
4
|
+
data.tar.gz: c63f6f73b9cd17f02a1463d8bf8eccf490b4a29a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13c356b9919ce45d9d0a9659193088f76c795bda5dc09228e8979d97954ea1b539bb9178f52c6af59850b5cd7302e3cd47d7000d0182ab2f93bcdbbb09fecca4
|
7
|
+
data.tar.gz: 395b697c73e01b9d39a5dea0607fa4e9f75dbd11462e1b8032944d27f35b003699e5a3f33bc57454fe20c2f60e43b96eaee93aa6ffbd68623eb9cac248d03904
|
data/README.md
CHANGED
@@ -60,14 +60,23 @@ tracker.track("123", "event1", { key1: "value1", key2: "value2" })
|
|
60
60
|
|
61
61
|
#### Use distinct_id_key and event_map_tag
|
62
62
|
|
63
|
-
You can use tag name as event name like this.
|
63
|
+
You can use tag name as event name like this. (see additional tag manipulations options below)
|
64
|
+
|
65
|
+
##PLEASE NOTE (breaking api change in a future release)
|
66
|
+
|
67
|
+
The api for remove_tag_prefix will be changing in a future release. There is currently a boolean option,
|
68
|
+
use_legacy_prefix_behavior, which will ensure legacy behavior is maintained until that time. Eventually this option will go away
|
69
|
+
as well and the new behavior will be the only way. The difference is pretty simple, the '.' in the prefix needs to be specified.
|
70
|
+
This change allows this plugin to use Fluet's mixin and unifies syntax across plugins. Currently, use_legacy_prefix_behavior
|
71
|
+
defaults to true, which will work either way, but eventually you will need to specify the '.' in your prefix. Again, use_legacy_prefix_behavior simply removes any '.' along with the specified prefix and will behave properly even after you change your configs
|
72
|
+
to be current as seen below. You do not need to set this option.
|
64
73
|
|
65
74
|
```
|
66
75
|
<match output.mixpanel.*>
|
67
76
|
type mixpanel
|
68
77
|
project_token YOUR_PROJECT_TOKEN
|
69
78
|
distinct_id_key user_id
|
70
|
-
remove_tag_prefix output.mixpanel
|
79
|
+
remove_tag_prefix output.mixpanel.
|
71
80
|
event_map_tag true
|
72
81
|
</match>
|
73
82
|
```
|
@@ -94,7 +103,7 @@ You can use tag name as event name like this.
|
|
94
103
|
type mixpanel
|
95
104
|
project_token YOUR_PROJECT_TOKEN
|
96
105
|
distinct_id_key user_id
|
97
|
-
remove_tag_prefix output.mixpanel
|
106
|
+
remove_tag_prefix output.mixpanel.
|
98
107
|
event_map_tag true
|
99
108
|
use_import true
|
100
109
|
api_key YOUR_API_KEY
|
@@ -114,6 +123,17 @@ tracker = Mixpanel::Tracker.new(YOUR_PROJECT_TOKEN)
|
|
114
123
|
tracker.import(api_key, "123", "event1", { key1: "value1", key2: "value2" })
|
115
124
|
```
|
116
125
|
|
126
|
+
---
|
127
|
+
|
128
|
+
fluentd-plugin-mixpanel also includes the HandleTagNameMixin mixin which allows the following additional options:
|
129
|
+
|
130
|
+
```
|
131
|
+
remove_tag_prefix <tag_prefix_to_remove_including_the_dot>
|
132
|
+
remove_tag_suffix <tag_suffix_to_remove_including_the_dot>
|
133
|
+
add_tag_prefix <tag_prefix_to_add_including_the_dot>
|
134
|
+
add_tag_suffix <tag_suffix_to_add_including_the_dot>
|
135
|
+
```
|
136
|
+
|
117
137
|
### HttpMixpanelInput
|
118
138
|
|
119
139
|
HttpMixpanelInput has same configuration as [http Input Plugin](http://docs.fluentd.org/en/articles/in_http).
|
@@ -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.7"
|
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}
|
@@ -1,15 +1,18 @@
|
|
1
|
+
|
1
2
|
class Fluent::MixpanelOutput < Fluent::BufferedOutput
|
2
3
|
Fluent::Plugin.register_output('mixpanel', self)
|
3
4
|
|
5
|
+
include Fluent::HandleTagNameMixin
|
6
|
+
|
4
7
|
config_param :project_token, :string
|
5
8
|
config_param :api_key, :string, :default => ''
|
6
9
|
config_param :use_import, :bool, :default => nil
|
7
10
|
config_param :distinct_id_key, :string
|
8
11
|
config_param :event_key, :string, :default => nil
|
9
12
|
config_param :ip_key, :string, :default => nil
|
10
|
-
|
11
|
-
config_param :remove_tag_prefix, :string, :default => nil
|
12
13
|
config_param :event_map_tag, :bool, :default => false
|
14
|
+
#NOTE: This will be removed in a future release. Please specify the '.' on any prefix
|
15
|
+
config_param :use_legacy_prefix_behavior, :default => true
|
13
16
|
|
14
17
|
class MixpanelError < StandardError
|
15
18
|
end
|
@@ -25,10 +28,10 @@ class Fluent::MixpanelOutput < Fluent::BufferedOutput
|
|
25
28
|
@distinct_id_key = conf['distinct_id_key']
|
26
29
|
@event_key = conf['event_key']
|
27
30
|
@ip_key = conf['ip_key']
|
28
|
-
@remove_tag_prefix = conf['remove_tag_prefix']
|
29
31
|
@event_map_tag = conf['event_map_tag']
|
30
32
|
@api_key = conf['api_key']
|
31
33
|
@use_import = conf['use_import']
|
34
|
+
@use_legacy_prefix_behavior = conf['use_legacy_prefix_behavior']
|
32
35
|
|
33
36
|
if @event_key.nil? and !@event_map_tag
|
34
37
|
raise Fluent::ConfigError, "'event_key' must be specifed when event_map_tag == false."
|
@@ -58,7 +61,8 @@ class Fluent::MixpanelOutput < Fluent::BufferedOutput
|
|
58
61
|
prop.delete('token')
|
59
62
|
|
60
63
|
if @event_map_tag
|
61
|
-
|
64
|
+
tag.gsub!(/^\./, '') if @use_legacy_prefix_behavior
|
65
|
+
data['event'] = tag
|
62
66
|
elsif record[@event_key]
|
63
67
|
data['event'] = record[@event_key]
|
64
68
|
prop.delete(@event_key)
|
@@ -15,6 +15,7 @@ class MixpanelOutputTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
IMPORT_CONFIG = CONFIG + %[ api_key test_api_key
|
17
17
|
use_import true
|
18
|
+
use_legacy_prefix_behavior false
|
18
19
|
]
|
19
20
|
|
20
21
|
def create_driver(conf = CONFIG)
|
@@ -58,12 +59,11 @@ class MixpanelOutputTest < Test::Unit::TestCase
|
|
58
59
|
end
|
59
60
|
|
60
61
|
def test_configure_with_event_map_tag
|
61
|
-
d = create_driver(CONFIG + "
|
62
|
+
d = create_driver(CONFIG + "event_map_tag true")
|
62
63
|
|
63
64
|
assert_equal 'test_token', d.instance.project_token
|
64
65
|
assert_equal 'user_id', d.instance.distinct_id_key
|
65
66
|
assert_equal nil, d.instance.event_key
|
66
|
-
assert_equal 'mixpanel', d.instance.remove_tag_prefix
|
67
67
|
assert_equal true.to_s, d.instance.event_map_tag
|
68
68
|
end
|
69
69
|
|
@@ -121,9 +121,23 @@ class MixpanelOutputTest < Test::Unit::TestCase
|
|
121
121
|
assert_equal "value2", @out[0]['properties']['key2']
|
122
122
|
end
|
123
123
|
|
124
|
-
def
|
124
|
+
def test_write_with_no_tag_manipulation
|
125
|
+
stub_mixpanel
|
126
|
+
d = create_driver(CONFIG + "event_map_tag true")
|
127
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
128
|
+
d.emit(sample_record, time)
|
129
|
+
d.run
|
130
|
+
|
131
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
132
|
+
assert_equal "mixpanel.test", @out[0]['event']
|
133
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
134
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
135
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_write_with_event_map_tag_removing_prefix
|
125
139
|
stub_mixpanel
|
126
|
-
d = create_driver(CONFIG + "remove_tag_prefix mixpanel
|
140
|
+
d = create_driver(CONFIG + "remove_tag_prefix mixpanel.\n event_map_tag true")
|
127
141
|
time = Time.new('2014-01-01T01:23:45+00:00')
|
128
142
|
d.emit(sample_record, time)
|
129
143
|
d.run
|
@@ -135,20 +149,78 @@ class MixpanelOutputTest < Test::Unit::TestCase
|
|
135
149
|
assert_equal "value2", @out[0]['properties']['key2']
|
136
150
|
end
|
137
151
|
|
138
|
-
def
|
152
|
+
def test_write_with_event_map_tag_removing_prefix_LEGACY
|
139
153
|
stub_mixpanel
|
140
|
-
d = create_driver(CONFIG + "event_map_tag true")
|
154
|
+
d = create_driver(CONFIG + "remove_tag_prefix mixpanel\n event_map_tag true\n use_legacy_prefix_behavior true")
|
141
155
|
time = Time.new('2014-01-01T01:23:45+00:00')
|
142
156
|
d.emit(sample_record, time)
|
143
157
|
d.run
|
144
158
|
|
145
|
-
assert_equal "123",
|
146
|
-
assert_equal "
|
147
|
-
assert_equal time.to_i,
|
148
|
-
assert_equal "value1",
|
149
|
-
assert_equal "value2",
|
159
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
160
|
+
assert_equal "test", @out[0]['event']
|
161
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
162
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
163
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_write_with_event_map_tag_removing_prefix_LEGACY_with_dot
|
167
|
+
stub_mixpanel
|
168
|
+
d = create_driver(CONFIG + "remove_tag_prefix mixpanel.\n event_map_tag true\n use_legacy_prefix_behavior true")
|
169
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
170
|
+
d.emit(sample_record, time)
|
171
|
+
d.run
|
172
|
+
|
173
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
174
|
+
assert_equal "test", @out[0]['event']
|
175
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
176
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
177
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_write_with_event_map_tag_removing_suffix
|
181
|
+
stub_mixpanel
|
182
|
+
d = create_driver(CONFIG + "remove_tag_suffix .test\n event_map_tag true")
|
183
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
184
|
+
d.emit(sample_record, time)
|
185
|
+
d.run
|
186
|
+
|
187
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
188
|
+
assert_equal "mixpanel", @out[0]['event']
|
189
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
190
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
191
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_write_with_event_map_tag_adding_prefix
|
195
|
+
stub_mixpanel
|
196
|
+
d = create_driver(CONFIG + "add_tag_prefix foo.\n event_map_tag true")
|
197
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
198
|
+
d.emit(sample_record, time)
|
199
|
+
d.run
|
200
|
+
|
201
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
202
|
+
assert_equal "foo.mixpanel.test", @out[0]['event']
|
203
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
204
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
205
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_write_with_event_map_tag_adding_suffix
|
209
|
+
stub_mixpanel
|
210
|
+
d = create_driver(CONFIG + "add_tag_suffix .foo\n event_map_tag true")
|
211
|
+
time = Time.new('2014-01-01T01:23:45+00:00')
|
212
|
+
d.emit(sample_record, time)
|
213
|
+
d.run
|
214
|
+
|
215
|
+
assert_equal "123", @out[0]['properties']['distinct_id']
|
216
|
+
assert_equal "mixpanel.test.foo", @out[0]['event']
|
217
|
+
assert_equal time.to_i, @out[0]['properties']['time']
|
218
|
+
assert_equal "value1", @out[0]['properties']['key1']
|
219
|
+
assert_equal "value2", @out[0]['properties']['key2']
|
150
220
|
end
|
151
221
|
|
222
|
+
|
223
|
+
|
152
224
|
def test_write_ignore_special_event
|
153
225
|
stub_mixpanel
|
154
226
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuyuki Honda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|