fluent-plugin-amplitude 0.1.0 → 0.2.0

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: 5a99dfa0622abec2b9b5b7eced10c234698e62f9
4
- data.tar.gz: 0b2b2e968e091881426eae51e4b812d22351bc0f
3
+ metadata.gz: 1d93878883ecfd0b74360d52da210ee1914685fa
4
+ data.tar.gz: 537a7ead298423f76e5dbaecb13487a7df983101
5
5
  SHA512:
6
- metadata.gz: 2dba48d6ac9d57bfc8871c91371bb9ee789f54ff232a28d7405f6cd11275ad606df15d4a58107a4bb45518ad4f3c1fcafcbf0afcbfc818d9d14459c6607e63a1
7
- data.tar.gz: b3e098e985a55091aee6e17668e2b92779456f39e96eb3a6e15039555225ab210f211655f45e6062217e49ba6dbfccd0ec68ee700215d70f3bf63e4754cadea1
6
+ metadata.gz: 2a155ce833996a533cb9e1ded2e07af0efd642b40da14bff03795b837ac7739cbccd48d9b36d876548685551ebc7632f9461ceffe615b8dcb3a22ff976f630bd
7
+ data.tar.gz: 2c9bf89150f181a1fcae00fd61f43292dd5fc7504e4302fe7cafcfb8d0175ecb44c9b05a35af970fcadc534a5240519603c9a4856b91ec3aff26a43cc6f35f3b
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  Gemfile.lock
2
+
3
+ *.pem
data/README.md CHANGED
@@ -48,12 +48,20 @@ You must set at least one of `user_id_key` and `device_id_key`. They will be use
48
48
  #### time_key
49
49
  If set, `time_key` will be used to pull out a timestamp field to set as `time` in the Amplitude API request. This can be an array, the first matching key will be used.
50
50
 
51
+ #### revenue_properties
52
+
53
+ `revenue_properties` are a fixed set of properties that Amplitude looks for in order to determine which events are revenue events (see Amplitude's [revenue tracking guide](https://amplitude.zendesk.com/hc/en-us/articles/115003116888-Tracking-Revenue) and [HTTP API documentation](https://amplitude.zendesk.com/hc/en-us/articles/204771828#keys-for-the-event-argument) for more information). `revenue_properties` are set as top-level properties on the API call. The `revenue_properties` we currently support are:
54
+ * quantity
55
+ * price
56
+ * revenue
57
+ * revenue_type
58
+
51
59
  #### user_properties and event_properties
52
60
  You can optionally specify lists of `user_properties` and `event_properties` to pull from the record.
53
61
 
54
62
  If `user_properties` are specified, only those properties will be included as `user_properties` in the Amplitude API call. Otherwise no `user_properties` will be sent.
55
63
 
56
- If `event_properties` are specified, only those properties will be included as `event_properties` in the Amplitude API call. Otherwise the entire record (minus the key/value for `user_id_key` and `device_id_key`, and minus any `user_properties`) will be sent as `event_properties` to Amplitude.
64
+ If `event_properties` are specified, only those properties will be included as `event_properties` in the Amplitude API call. If no `event_properties` are specified, then every field with the exception of `user_id_key`, `device_id_key`, all `revenue_properties`, and anything specified in `user_properties`, will be sent as `event_properties` in the Amplitude API call.
57
65
 
58
66
  #### event type
59
67
  The event_type is the tag. To modify this, fluent-plugin-amplitude includes the `HandleTagNameMixin` mixin which allows the following options:
@@ -4,9 +4,9 @@ $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.1.0'
8
- spec.authors = ['Vijay Ramesh']
9
- spec.email = ['vijay@change.org']
7
+ spec.version = '0.2.0'
8
+ spec.authors = ['Change.org']
9
+ spec.email = ['tech_ops@change.org']
10
10
  spec.summary = 'Fluentd plugin to output event data to Amplitude'
11
11
  spec.description = 'Fluentd plugin to output event data to Amplitude'
12
12
  spec.homepage = 'https://github.com/change/fluent-plugin-amplitude'
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.add_runtime_dependency 'fluentd', '>= 0.10.55'
20
20
  spec.add_runtime_dependency 'amplitude-api', '~> 0.0.9'
21
- spec.add_runtime_dependency 'msgpack', '~> 0'
21
+ spec.add_runtime_dependency 'msgpack', '~> 1.0'
22
22
 
23
23
  spec.add_development_dependency 'rake', '~> 11.3'
24
24
  spec.add_development_dependency 'rspec', '~> 3.5'
@@ -7,6 +7,13 @@ module Fluent
7
7
  include Fluent::HandleTagNameMixin
8
8
  include FakeActiveSupport
9
9
 
10
+ REVENUE_PROPERTIES = %w(
11
+ price
12
+ quantity
13
+ revenue
14
+ revenue_type
15
+ ).freeze
16
+
10
17
  config_param :api_key, :string, secret: true
11
18
  config_param :device_id_key, :array, default: nil
12
19
  config_param :user_id_key, :array, default: nil
@@ -16,8 +23,8 @@ module Fluent
16
23
  config_param :properties_blacklist, :array, default: nil
17
24
  config_param :events_whitelist, :array, default: nil
18
25
  config_param :events_blacklist, :array, default: nil
19
- class AmplitudeError < StandardError
20
- end
26
+
27
+ class AmplitudeError < StandardError; end
21
28
 
22
29
  def initialize
23
30
  super
@@ -44,6 +51,7 @@ module Fluent
44
51
  filter_properties_blacklist!(record)
45
52
  extract_user_and_device!(amplitude_hash, record)
46
53
  set_time!(amplitude_hash, record)
54
+ extract_revenue_properties!(amplitude_hash, record)
47
55
  extract_user_properties!(amplitude_hash, record)
48
56
  extract_event_properties!(amplitude_hash, record)
49
57
 
@@ -119,6 +127,14 @@ module Fluent
119
127
  log.info("failed to parse #{time_string}: #{e.message}")
120
128
  end
121
129
 
130
+ def extract_revenue_properties!(amplitude_hash, record)
131
+ REVENUE_PROPERTIES.each do |prop|
132
+ next if record[prop].nil?
133
+
134
+ amplitude_hash[prop.to_sym] = record.delete(prop)
135
+ end
136
+ end
137
+
122
138
  def extract_user_properties!(amplitude_hash, record)
123
139
  # if user_properties are specified, pull them off of the record
124
140
  return unless @user_properties
@@ -132,7 +148,7 @@ module Fluent
132
148
 
133
149
  def extract_event_properties!(amplitude_hash, record)
134
150
  # if event_properties are specified, pull them off of the record
135
- # otherwise, use the remaining record (minus any user_properties)
151
+ # otherwise, use the remaining record (minus any revenue_properties and user_properties)
136
152
  amplitude_hash[:event_properties] = begin
137
153
  if @event_properties
138
154
  record.select do |k, _v|
@@ -42,7 +42,11 @@ describe Fluent::AmplitudeOutput do
42
42
  'last_name' => 'Weir',
43
43
  'state' => 'CA',
44
44
  'current_source' => 'fb_share',
45
- 'recruiter_id' => 710
45
+ 'recruiter_id' => 710,
46
+ 'revenue_type' => 'sustainer',
47
+ 'quantity' => 2,
48
+ 'price' => 10.05,
49
+ 'revenue' => 20.10,
46
50
  }
47
51
  end
48
52
 
@@ -51,6 +55,10 @@ describe Fluent::AmplitudeOutput do
51
55
  event_type: tag,
52
56
  user_id: 42,
53
57
  device_id: 'e6153b00-85d8-11e6-b1bc-43192d1e493f',
58
+ price: 10.05,
59
+ quantity: 2,
60
+ revenue: 20.10,
61
+ revenue_type: 'sustainer',
54
62
  user_properties: {
55
63
  first_name: 'Bobby',
56
64
  last_name: 'Weir'
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Vijay Ramesh
7
+ - Change.org
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  version: 0.44.1
131
131
  description: Fluentd plugin to output event data to Amplitude
132
132
  email:
133
- - vijay@change.org
133
+ - tech_ops@change.org
134
134
  executables: []
135
135
  extensions: []
136
136
  extra_rdoc_files: []
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.4.5.1
167
+ rubygems_version: 2.4.5
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Fluentd plugin to output event data to Amplitude