logstash-filter-mautic 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTORS +11 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +6 -0
- data/LICENSE +13 -0
- data/NOTICE.TXT +5 -0
- data/README.md +92 -0
- data/lib/logstash/filters/mautic.rb +325 -0
- data/logstash-filter-mautic.gemspec +23 -0
- data/spec/filters/emails_spec.rb +139 -0
- data/spec/filters/forms_spec.rb +181 -0
- data/spec/filters/hit_spec.rb +132 -0
- data/spec/filters/leads_spec.rb +303 -0
- data/spec/spec_helper.rb +90 -0
- metadata +98 -0
@@ -0,0 +1,303 @@
|
|
1
|
+
require 'logstash/devutils/rspec/spec_helper'
|
2
|
+
require "logstash/filters/mautic"
|
3
|
+
|
4
|
+
RUBY_ENGINE == "jruby" and describe LogStash::Filters::Mautic do
|
5
|
+
|
6
|
+
|
7
|
+
describe "Check the id field" do
|
8
|
+
let(:config) do <<-CONFIG
|
9
|
+
filter {
|
10
|
+
mautic {
|
11
|
+
source => "message"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
CONFIG
|
15
|
+
end
|
16
|
+
|
17
|
+
entered_fields = '{ "mautic.lead_post_save_new": [
|
18
|
+
{"lead": {
|
19
|
+
"id": 25,
|
20
|
+
"points": 0,
|
21
|
+
"dateIdentified": "2015-08-26T01:25:36.000Z"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
]}'
|
25
|
+
#it "should contain points"
|
26
|
+
sample entered_fields do
|
27
|
+
#insist { subject["points"] } == 25
|
28
|
+
expect(subject).to include('leadid')
|
29
|
+
expect(subject['leadid']).to eq(25)
|
30
|
+
expect(subject['type']).to eq("lead")
|
31
|
+
expect(subject).not_to include('fields')
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "Check when no array is returned field" do
|
37
|
+
let(:config) do <<-CONFIG
|
38
|
+
filter {
|
39
|
+
mautic {
|
40
|
+
source => "message"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
CONFIG
|
44
|
+
end
|
45
|
+
|
46
|
+
entered_fields = '{ "mautic.lead_post_save_new":
|
47
|
+
{"lead": {
|
48
|
+
"id": 80,
|
49
|
+
"points": 0
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}'
|
53
|
+
#it "should contain points"
|
54
|
+
sample entered_fields do
|
55
|
+
#insist { subject["points"] } == 25
|
56
|
+
expect(subject).to include('leadid')
|
57
|
+
expect(subject['leadid']).to eq(80)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "Check the firstname field" do
|
62
|
+
let(:config) do <<-CONFIG
|
63
|
+
filter {
|
64
|
+
mautic {
|
65
|
+
source => "message"
|
66
|
+
}
|
67
|
+
}
|
68
|
+
CONFIG
|
69
|
+
end
|
70
|
+
|
71
|
+
entered_fields = '{ "mautic.lead_post_save_new": [
|
72
|
+
{"lead": {
|
73
|
+
"id": 25,
|
74
|
+
"points": 0,
|
75
|
+
"fields": {"core": { "firstname": {"value" : "New"}}}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
]}'
|
79
|
+
#it "should contain points"
|
80
|
+
sample entered_fields do
|
81
|
+
#insist { subject["points"] } == 25
|
82
|
+
expect(subject).to include("firstname")
|
83
|
+
expect(subject['firstname']).to eq("New")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "Check the tags " do
|
88
|
+
let(:config) do <<-CONFIG
|
89
|
+
filter {
|
90
|
+
mautic {
|
91
|
+
source => "message"
|
92
|
+
}
|
93
|
+
}
|
94
|
+
CONFIG
|
95
|
+
end
|
96
|
+
|
97
|
+
entered_fields = '{ "mautic.lead_post_save_new": [
|
98
|
+
{"lead": {
|
99
|
+
"id": 25,
|
100
|
+
"points": 0,
|
101
|
+
"fields": {"core": {"firstname": {"value": "test"}}},
|
102
|
+
"tags": ["test", "test2"]
|
103
|
+
}
|
104
|
+
}
|
105
|
+
]}'
|
106
|
+
#it "should contain points"
|
107
|
+
sample entered_fields do
|
108
|
+
#insist { subject["points"] } == 25
|
109
|
+
expect(subject).to include("mautic_tags")
|
110
|
+
expect(subject['mautic_tags'][0]).to eq("test")
|
111
|
+
expect(subject['mautic_tags'][1]).to eq("test2")
|
112
|
+
expect(subject).not_to include('fields')
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
describe "Check the ip addresses field" do
|
119
|
+
let(:config) do <<-CONFIG
|
120
|
+
filter {
|
121
|
+
mautic {
|
122
|
+
source => "message"
|
123
|
+
}
|
124
|
+
}
|
125
|
+
CONFIG
|
126
|
+
end
|
127
|
+
|
128
|
+
#entered_fields = LogStash::Fixtures::MauticFixtures.newLeadEntry
|
129
|
+
entered_fields = '{ "mautic.lead_post_save_new": [
|
130
|
+
{"lead": {
|
131
|
+
"id": 25,
|
132
|
+
"points": 0,
|
133
|
+
"fields": {"core": {"firstname": {"value": "test"}}},
|
134
|
+
"ipAddresses" : {
|
135
|
+
"123.14.945.113": {
|
136
|
+
"ipDetails": {
|
137
|
+
"city": "New Prague",
|
138
|
+
"region": "Minnesota",
|
139
|
+
"country": "United States",
|
140
|
+
"latitude": 44.8978,
|
141
|
+
"longitude": -93.382,
|
142
|
+
"isp": "",
|
143
|
+
"organization": "Communications Company, LLC",
|
144
|
+
"timezone": "America/Chicago",
|
145
|
+
"extra": "",
|
146
|
+
"offset": "-5",
|
147
|
+
"area_code": "0",
|
148
|
+
"dma_code": "0",
|
149
|
+
"country_code3": "USA",
|
150
|
+
"postal_code": "8989",
|
151
|
+
"continent_code": "NA",
|
152
|
+
"country_code": "US",
|
153
|
+
"region_code": "MN"
|
154
|
+
}
|
155
|
+
}, "89.14.945.55": {
|
156
|
+
"ipDetails": {
|
157
|
+
"city": "New Prague",
|
158
|
+
"region": "Minnesota",
|
159
|
+
"country": "United States",
|
160
|
+
"latitude": 44.8978,
|
161
|
+
"longitude": -93.382,
|
162
|
+
"isp": "",
|
163
|
+
"organization": "Communications Company, LLC",
|
164
|
+
"timezone": "America/Chicago",
|
165
|
+
"extra": "",
|
166
|
+
"offset": "-5",
|
167
|
+
"area_code": "0",
|
168
|
+
"dma_code": "0",
|
169
|
+
"country_code3": "USA",
|
170
|
+
"postal_code": "8989",
|
171
|
+
"continent_code": "NA",
|
172
|
+
"country_code": "US",
|
173
|
+
"region_code": "MN"
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
]}'
|
180
|
+
#it "should contain points"
|
181
|
+
sample entered_fields do
|
182
|
+
#insist { subject["points"] } == 25
|
183
|
+
expect(subject).to include("ipAddresses")
|
184
|
+
expect(subject['ipAddresses'][0]).to eq("123.14.945.113")
|
185
|
+
expect(subject['ipAddresses'][1]).to eq("89.14.945.55")
|
186
|
+
expect(subject).not_to include('fields')
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "Check multiple events" do
|
192
|
+
let(:config) do <<-CONFIG
|
193
|
+
filter {
|
194
|
+
mautic {
|
195
|
+
source => "message"
|
196
|
+
}
|
197
|
+
}
|
198
|
+
CONFIG
|
199
|
+
end
|
200
|
+
|
201
|
+
entered_fields = '{ "mautic.lead_post_save_new": [
|
202
|
+
{"lead": {
|
203
|
+
"id": 25,
|
204
|
+
"points": 0,
|
205
|
+
"fields": {"core": {"firstname": {"value": "test"}}},
|
206
|
+
"tags": ["test", "test2"]
|
207
|
+
}
|
208
|
+
},
|
209
|
+
{"lead": {
|
210
|
+
"id": 21,
|
211
|
+
"points": 10,
|
212
|
+
"fields": {"core": {"firstname": {"value": "test"}}},
|
213
|
+
"tags": ["test", "test2"]
|
214
|
+
}
|
215
|
+
}
|
216
|
+
]}'
|
217
|
+
|
218
|
+
sample entered_fields do
|
219
|
+
expect(subject[0]).to include('leadid')
|
220
|
+
expect(subject[1]).to include('leadid')
|
221
|
+
expect(subject[0]['leadid']).to eq(25)
|
222
|
+
expect(subject[1]['leadid']).to eq(21)
|
223
|
+
expect(subject[0]['points']).to eq(0)
|
224
|
+
expect(subject[1]['points']).to eq(10)
|
225
|
+
expect(subject[1]).not_to include('fields')
|
226
|
+
|
227
|
+
end # end sample
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
describe "Check the id field" do
|
232
|
+
let(:config) do <<-CONFIG
|
233
|
+
filter {
|
234
|
+
mautic {
|
235
|
+
source => "message"
|
236
|
+
}
|
237
|
+
}
|
238
|
+
CONFIG
|
239
|
+
end
|
240
|
+
|
241
|
+
entered_fields = '{ "mautic.lead_post_save_update": [
|
242
|
+
{"lead": {
|
243
|
+
"id": 25,
|
244
|
+
"points": 0,
|
245
|
+
"fields": {"core": {"firstname": {"value": "test"}}},
|
246
|
+
|
247
|
+
"dateIdentified": "2015-08-26T01:25:36.000Z"
|
248
|
+
}
|
249
|
+
}
|
250
|
+
]}'
|
251
|
+
#it "should contain points"
|
252
|
+
sample entered_fields do
|
253
|
+
#insist { subject["points"] } == 25
|
254
|
+
expect(subject).to include('leadid')
|
255
|
+
expect(subject['leadid']).to eq(25)
|
256
|
+
expect(subject).not_to include('fields')
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
describe "Check updated lead" do
|
262
|
+
let(:config) do <<-CONFIG
|
263
|
+
filter {
|
264
|
+
mautic {
|
265
|
+
source => "message"
|
266
|
+
}
|
267
|
+
}
|
268
|
+
CONFIG
|
269
|
+
end
|
270
|
+
|
271
|
+
entered_fields = '{
|
272
|
+
"mautic.lead_post_save_update": {
|
273
|
+
"lead": {
|
274
|
+
"id": 25,
|
275
|
+
"points": 0,
|
276
|
+
"color": "",
|
277
|
+
"fields": {"core": {"firstname": {"value": "test"}}},
|
278
|
+
"lastActive": null,
|
279
|
+
"owner": {
|
280
|
+
"id": 1,
|
281
|
+
"username": "drmmr763",
|
282
|
+
"firstName": "Chad",
|
283
|
+
"lastName": "Windnagle"
|
284
|
+
},
|
285
|
+
"ipAddresses": [],
|
286
|
+
"dateIdentified": "2015-08-26T01:25:36+00:00",
|
287
|
+
"preferredProfileImage": "gravatar"
|
288
|
+
}
|
289
|
+
},
|
290
|
+
"timestamp": "2015-11-12T10:40:19+11:00"
|
291
|
+
}'
|
292
|
+
#it "should contain points"
|
293
|
+
sample entered_fields do
|
294
|
+
#insist { subject["points"] } == 25
|
295
|
+
expect(subject).to include('leadid')
|
296
|
+
expect(subject).not_to include('fields')
|
297
|
+
expect(subject).to include('firstname')
|
298
|
+
expect(subject['leadid']).to eq(25)
|
299
|
+
expect(subject['type']).to eq("lead")
|
300
|
+
expect(subject['firstname']).to eq("test")
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
|
22
|
+
config.expect_with :rspec do |expectations|
|
23
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
24
|
+
# and `failure_message` of custom matchers include text for helper methods
|
25
|
+
# defined using `chain`, e.g.:
|
26
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
27
|
+
# # => "be bigger than 2 and smaller than 4"
|
28
|
+
# ...rather than:
|
29
|
+
# # => "be bigger than 2"
|
30
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
31
|
+
end
|
32
|
+
|
33
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
34
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
35
|
+
config.mock_with :rspec do |mocks|
|
36
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
37
|
+
# a real object. This is generally recommended, and will default to
|
38
|
+
# `true` in RSpec 4.
|
39
|
+
mocks.verify_partial_doubles = true
|
40
|
+
end
|
41
|
+
|
42
|
+
# The settings below are suggested to provide a good initial experience
|
43
|
+
# with RSpec, but feel free to customize to your heart's content.
|
44
|
+
=begin
|
45
|
+
# These two settings work together to allow you to limit a spec run
|
46
|
+
# to individual examples or groups you care about by tagging them with
|
47
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
48
|
+
# get run.
|
49
|
+
config.filter_run :focus
|
50
|
+
config.run_all_when_everything_filtered = true
|
51
|
+
|
52
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
53
|
+
# For more details, see:
|
54
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
55
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
56
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
57
|
+
config.disable_monkey_patching!
|
58
|
+
|
59
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
60
|
+
# be too noisy due to issues in dependencies.
|
61
|
+
config.warnings = true
|
62
|
+
|
63
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
64
|
+
# file, and it's useful to allow more verbose output when running an
|
65
|
+
# individual spec file.
|
66
|
+
if config.files_to_run.one?
|
67
|
+
# Use the documentation formatter for detailed output,
|
68
|
+
# unless a formatter has already been configured
|
69
|
+
# (e.g. via a command-line flag).
|
70
|
+
config.default_formatter = 'doc'
|
71
|
+
end
|
72
|
+
|
73
|
+
# Print the 10 slowest examples and example groups at the
|
74
|
+
# end of the spec run, to help surface which specs are running
|
75
|
+
# particularly slow.
|
76
|
+
config.profile_examples = 10
|
77
|
+
|
78
|
+
# Run specs in random order to surface order dependencies. If you find an
|
79
|
+
# order dependency and want to debug it, you can fix the order by providing
|
80
|
+
# the seed, which is printed after each run.
|
81
|
+
# --seed 1234
|
82
|
+
config.order = :random
|
83
|
+
|
84
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
85
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
86
|
+
# test failures related to randomization by passing the same `--seed` value
|
87
|
+
# as the one that triggered the failure.
|
88
|
+
Kernel.srand config.seed
|
89
|
+
=end
|
90
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-filter-mautic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zac Petterd
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - '>='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 2.0.0
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
name: logstash-core
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
name: logstash-devutils
|
40
|
+
prerelease: false
|
41
|
+
type: :development
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: This plugin lets you get the majority of you Mautic data into Elasticsearch for viewing using Kibana. Just setup a http input for logstash and a filter like so mautic { source => 'message'}. See the GitHub repository for more information
|
48
|
+
email: zac@sproutlabs.com.au
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- CHANGELOG.md
|
54
|
+
- CONTRIBUTORS
|
55
|
+
- DEVELOPER.md
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE
|
58
|
+
- NOTICE.TXT
|
59
|
+
- README.md
|
60
|
+
- lib/logstash/filters/mautic.rb
|
61
|
+
- logstash-filter-mautic.gemspec
|
62
|
+
- spec/filters/emails_spec.rb
|
63
|
+
- spec/filters/forms_spec.rb
|
64
|
+
- spec/filters/hit_spec.rb
|
65
|
+
- spec/filters/leads_spec.rb
|
66
|
+
- spec/spec_helper.rb
|
67
|
+
homepage: https://github.com/zapur1/logstash-filter-mautic
|
68
|
+
licenses:
|
69
|
+
- Apache License (2.0)
|
70
|
+
metadata:
|
71
|
+
logstash_plugin: 'true'
|
72
|
+
logstash_group: filter
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.4.8
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Receives Mautic webhook data to view in Elasticsearch
|
93
|
+
test_files:
|
94
|
+
- spec/filters/emails_spec.rb
|
95
|
+
- spec/filters/forms_spec.rb
|
96
|
+
- spec/filters/hit_spec.rb
|
97
|
+
- spec/filters/leads_spec.rb
|
98
|
+
- spec/spec_helper.rb
|