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,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-filter-mautic'
|
3
|
+
s.version = '0.1'
|
4
|
+
s.licenses = ['Apache License (2.0)']
|
5
|
+
s.summary = "Receives Mautic webhook data to view in Elasticsearch"
|
6
|
+
s.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"
|
7
|
+
s.authors = ["Zac Petterd"]
|
8
|
+
s.email = 'zac@sproutlabs.com.au'
|
9
|
+
s.homepage = "https://github.com/zapur1/logstash-filter-mautic"
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
14
|
+
# Tests
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
|
17
|
+
# Special flag to let us know this is actually a logstash plugin
|
18
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
19
|
+
|
20
|
+
# Gem dependencies
|
21
|
+
s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
|
22
|
+
s.add_development_dependency 'logstash-devutils'
|
23
|
+
end
|
@@ -0,0 +1,139 @@
|
|
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 top-level fields" do
|
8
|
+
let(:config) do <<-CONFIG
|
9
|
+
filter {
|
10
|
+
mautic {
|
11
|
+
source => "message"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
CONFIG
|
15
|
+
end
|
16
|
+
|
17
|
+
entered_fields = '{
|
18
|
+
"mautic.email_on_open": {
|
19
|
+
"stat": {
|
20
|
+
"id": 8,
|
21
|
+
"emailAddress": "chad.windnagle@websparkinc.com",
|
22
|
+
"ipAddress": [],
|
23
|
+
"dateSent": "2015-08-26T01:34:37+00:00",
|
24
|
+
"isRead": true,
|
25
|
+
"isFailed": false,
|
26
|
+
"dateRead": "2015-08-26T01:35:53+00:00",
|
27
|
+
"retryCount": 0,
|
28
|
+
"source": "email",
|
29
|
+
"openCount": 1,
|
30
|
+
"lastOpened": "2015-08-26T01:35:53+00:00",
|
31
|
+
"sourceId": 5,
|
32
|
+
"trackingHash": "55dd17adace91",
|
33
|
+
"viewedInBrowser": false,
|
34
|
+
"lead": {
|
35
|
+
"id": 26,
|
36
|
+
"points": 10,
|
37
|
+
"color": "",
|
38
|
+
"fields": {}
|
39
|
+
},
|
40
|
+
"email": {
|
41
|
+
"id": 5,
|
42
|
+
"name": "Email",
|
43
|
+
"subject": "Email",
|
44
|
+
"language": "en",
|
45
|
+
"category": null,
|
46
|
+
"fromAddress": null,
|
47
|
+
"fromName": null,
|
48
|
+
"replyToAddress": null,
|
49
|
+
"bccAddress": null,
|
50
|
+
"publishUp": null,
|
51
|
+
"publishDown": null,
|
52
|
+
"readCount": 1,
|
53
|
+
"sentCount": 3,
|
54
|
+
"revision": 1,
|
55
|
+
"assetAttachments": [],
|
56
|
+
"variantStartDate": null,
|
57
|
+
"variantSentCount": 0,
|
58
|
+
"variantReadCount": 0,
|
59
|
+
"variantParent": null,
|
60
|
+
"variantChildren": []
|
61
|
+
}
|
62
|
+
}
|
63
|
+
},
|
64
|
+
"timestamp": "2015-11-11T22:44:51+11:00"
|
65
|
+
}'
|
66
|
+
#it "should contain points"
|
67
|
+
sample entered_fields do
|
68
|
+
#insist { subject["points"] } == 25
|
69
|
+
expect(subject).to include('emailopenid')
|
70
|
+
expect(subject).not_to include("lead")
|
71
|
+
expect(subject['emailopenid']).to eq(8)
|
72
|
+
expect(subject['leadid']).to eq(26)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "Check when not an array" do
|
77
|
+
let(:config) do <<-CONFIG
|
78
|
+
filter {
|
79
|
+
mautic {
|
80
|
+
source => "message"
|
81
|
+
}
|
82
|
+
}
|
83
|
+
CONFIG
|
84
|
+
end
|
85
|
+
|
86
|
+
entered_fields = '{
|
87
|
+
"mautic.email_on_open": {
|
88
|
+
"stat": {
|
89
|
+
"id": 5745,
|
90
|
+
"lead": {"id" : 123}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}'
|
94
|
+
#it "should contain points"
|
95
|
+
sample entered_fields do
|
96
|
+
#insist { subject["points"] } == 25
|
97
|
+
expect(subject).to include('emailopenid')
|
98
|
+
expect(subject).not_to include("lead")
|
99
|
+
expect(subject['emailopenid']).to eq(5745)
|
100
|
+
expect(subject['leadid']).to eq(123)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "Check when multiple" do
|
105
|
+
let(:config) do <<-CONFIG
|
106
|
+
filter {
|
107
|
+
mautic {
|
108
|
+
source => "message"
|
109
|
+
}
|
110
|
+
}
|
111
|
+
CONFIG
|
112
|
+
end
|
113
|
+
|
114
|
+
entered_fields = '{
|
115
|
+
"mautic.email_on_open": [{
|
116
|
+
"stat": {
|
117
|
+
"id": 5745,
|
118
|
+
"lead": {"id" : 123}
|
119
|
+
}
|
120
|
+
},
|
121
|
+
{
|
122
|
+
"stat": {
|
123
|
+
"id": 128,
|
124
|
+
"lead": {"id" : 153}
|
125
|
+
}
|
126
|
+
}]
|
127
|
+
}'
|
128
|
+
#it "should contain points"
|
129
|
+
sample entered_fields do
|
130
|
+
#insist { subject["points"] } == 25
|
131
|
+
expect(subject[0]).to include('emailopenid')
|
132
|
+
expect(subject[0]).not_to include("lead")
|
133
|
+
expect(subject[0]['emailopenid']).to eq(5745)
|
134
|
+
expect(subject[0]['leadid']).to eq(123)
|
135
|
+
expect(subject[1]['emailopenid']).to eq(128)
|
136
|
+
expect(subject[1]['leadid']).to eq(153)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,181 @@
|
|
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 top-level fields" do
|
8
|
+
let(:config) do <<-CONFIG
|
9
|
+
filter {
|
10
|
+
mautic {
|
11
|
+
source => "message"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
CONFIG
|
15
|
+
end
|
16
|
+
|
17
|
+
entered_fields = '{
|
18
|
+
"mautic.form_on_submit": {
|
19
|
+
"submission": {
|
20
|
+
"id": 89,
|
21
|
+
"ipAddress": [],
|
22
|
+
"form": {
|
23
|
+
"id": 4,
|
24
|
+
"name": "lead points",
|
25
|
+
"alias": "leadpoints",
|
26
|
+
"category": null
|
27
|
+
},
|
28
|
+
"lead": {
|
29
|
+
"id": 26,
|
30
|
+
"points": 10,
|
31
|
+
"color": null,
|
32
|
+
"fields": {}
|
33
|
+
},
|
34
|
+
"trackingId": "dd4adafdabe75184bc206037a15d9f840adb5ec0",
|
35
|
+
"dateSubmitted": "2015-08-26T01:30:34+00:00",
|
36
|
+
"referer": "http://mautic-gh.com/index_dev.php/s/forms/preview/4",
|
37
|
+
"page": null,
|
38
|
+
"results": {
|
39
|
+
"email": "email@formsubmit.com"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
},
|
43
|
+
"timestamp": "2015-11-11T22:37:31+11:00"
|
44
|
+
}'
|
45
|
+
#it "should contain points"
|
46
|
+
sample entered_fields do
|
47
|
+
#insist { subject["points"] } == 25
|
48
|
+
expect(subject).to include('submissionid')
|
49
|
+
expect(subject).not_to include("lead")
|
50
|
+
expect(subject).to include("form")
|
51
|
+
expect(subject['submissionid']).to eq(89)
|
52
|
+
expect(subject['leadid']).to eq(26)
|
53
|
+
expect(subject['type']).to eq("form_submission")
|
54
|
+
expect(subject['results']['email']).to eq ("email@formsubmit.com")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "Check when not an array" do
|
59
|
+
let(:config) do <<-CONFIG
|
60
|
+
filter {
|
61
|
+
mautic {
|
62
|
+
source => "message"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
CONFIG
|
66
|
+
end
|
67
|
+
|
68
|
+
entered_fields = '{
|
69
|
+
"mautic.form_on_submit": {
|
70
|
+
"submission": {
|
71
|
+
"id": 34,
|
72
|
+
"ipAddress": [],
|
73
|
+
"form": {},
|
74
|
+
"lead": {
|
75
|
+
"id": 26
|
76
|
+
},
|
77
|
+
"results": {
|
78
|
+
"email": "email@formsubmit.com"
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}'
|
83
|
+
#it "should contain points"
|
84
|
+
sample entered_fields do
|
85
|
+
#insist { subject["points"] } == 25
|
86
|
+
expect(subject).to include('submissionid')
|
87
|
+
expect(subject).not_to include("lead")
|
88
|
+
expect(subject).to include("form")
|
89
|
+
expect(subject['submissionid']).to eq(34)
|
90
|
+
expect(subject['leadid']).to eq(26)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
describe "Check multiple events" do
|
96
|
+
let(:config) do <<-CONFIG
|
97
|
+
filter {
|
98
|
+
mautic {
|
99
|
+
source => "message"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
CONFIG
|
103
|
+
end
|
104
|
+
|
105
|
+
entered_fields = '{
|
106
|
+
"mautic.form_on_submit": [
|
107
|
+
{
|
108
|
+
"submission": {
|
109
|
+
"id": 893,
|
110
|
+
"ipAddress": {
|
111
|
+
"ipDetails": {
|
112
|
+
}
|
113
|
+
},
|
114
|
+
"form": {
|
115
|
+
"id": 25,
|
116
|
+
"name": "nhkjhjk",
|
117
|
+
"alias": "internalwe",
|
118
|
+
"category": []
|
119
|
+
},
|
120
|
+
"lead": {
|
121
|
+
"id": 89,
|
122
|
+
"points": 0,
|
123
|
+
"color": null,
|
124
|
+
"fields": {}
|
125
|
+
},
|
126
|
+
"trackingId": null,
|
127
|
+
"dateSubmitted": "2015-11-12T07:55:39+11:00",
|
128
|
+
"referer": "http://mautic.ghgjhg.com.au/s/forms/preview/25",
|
129
|
+
"page": null,
|
130
|
+
"results": {
|
131
|
+
"email": "example@afads.com"
|
132
|
+
}
|
133
|
+
},
|
134
|
+
"timestamp": "2015-11-11T20:55:42+00:00"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"submission": {
|
138
|
+
"id": 894,
|
139
|
+
"ipAddress": {
|
140
|
+
"ipDetails": {
|
141
|
+
}
|
142
|
+
},
|
143
|
+
"form": {
|
144
|
+
"id": 25,
|
145
|
+
"name": "jhjkhkj",
|
146
|
+
"alias": "kjhjk",
|
147
|
+
"category": []
|
148
|
+
},
|
149
|
+
"lead": {
|
150
|
+
"id": 897,
|
151
|
+
"points": 0,
|
152
|
+
"color": null,
|
153
|
+
"fields": {}
|
154
|
+
|
155
|
+
},
|
156
|
+
"trackingId": null,
|
157
|
+
"dateSubmitted": "2015-11-12T07:55:42+11:00",
|
158
|
+
"referer": "http://mautic.mjhjk.com/s/forms/preview/25",
|
159
|
+
"page": null,
|
160
|
+
"results": {
|
161
|
+
"email": "jkhj@hgjh.com."
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"timestamp": "2015-11-11T20:55:43+00:00"
|
165
|
+
}
|
166
|
+
]
|
167
|
+
}'
|
168
|
+
#it "should contain points"
|
169
|
+
sample entered_fields do
|
170
|
+
#insist { subject["points"] } == 25
|
171
|
+
expect(subject[0]).to include('submissionid')
|
172
|
+
expect(subject[0]).not_to include("lead")
|
173
|
+
expect(subject[0]).to include("form")
|
174
|
+
expect(subject[0]['submissionid']).to eq(893)
|
175
|
+
expect(subject[0]['leadid']).to eq(89)
|
176
|
+
expect(subject[0]['type']).to eq("form_submission")
|
177
|
+
expect(subject[1]['submissionid']).to eq(894)
|
178
|
+
expect(subject[1]['leadid']).to eq(897)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,132 @@
|
|
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 a basic hit" do
|
8
|
+
let(:config) do <<-CONFIG
|
9
|
+
filter {
|
10
|
+
mautic {
|
11
|
+
source => "message"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
CONFIG
|
15
|
+
end
|
16
|
+
|
17
|
+
entered_fields = '{
|
18
|
+
"mautic.page_on_hit": {
|
19
|
+
"hit": {
|
20
|
+
"dateHit": "2015-08-26T01:32:39+00:00",
|
21
|
+
"dateLeft": null,
|
22
|
+
"page": {
|
23
|
+
"id": 1,
|
24
|
+
"title": "PageHit",
|
25
|
+
"alias": "pagehit",
|
26
|
+
"category": null
|
27
|
+
},
|
28
|
+
"redirect": null,
|
29
|
+
"email": null,
|
30
|
+
"lead": {
|
31
|
+
"id": 26,
|
32
|
+
"points": 10,
|
33
|
+
"color": null,
|
34
|
+
"fields": {}
|
35
|
+
},
|
36
|
+
"ipAddress": [],
|
37
|
+
"country": null,
|
38
|
+
"region": null,
|
39
|
+
"city": null,
|
40
|
+
"isp": null,
|
41
|
+
"organization": null,
|
42
|
+
"code": 200,
|
43
|
+
"referer": null,
|
44
|
+
"url": "http://mautic-gh.com/index_dev.php/pagehit",
|
45
|
+
"urlTitle": null,
|
46
|
+
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36",
|
47
|
+
"remoteHost": "localhost",
|
48
|
+
"pageLanguage": "en",
|
49
|
+
"browserLanguages": [
|
50
|
+
"en-US",
|
51
|
+
"en;q=0.8"
|
52
|
+
],
|
53
|
+
"trackingId": "833fecc93e16d37baf1530df643b6a8b10714c65",
|
54
|
+
"source": null,
|
55
|
+
"sourceId": null
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"timestamp": "2015-11-11T22:42:59+11:00"
|
59
|
+
}'
|
60
|
+
#it "should contain points"
|
61
|
+
sample entered_fields do
|
62
|
+
#insist { subject["points"] } == 25
|
63
|
+
expect(subject).to include("leadid")
|
64
|
+
expect(subject).not_to include("lead")
|
65
|
+
expect(subject).to include("url")
|
66
|
+
expect(subject['leadid']).to eq(26)
|
67
|
+
expect(subject['code']).to eq(200)
|
68
|
+
expect(subject['type']).to eq("page_hit")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "Check multiple hits" do
|
73
|
+
let(:config) do <<-CONFIG
|
74
|
+
filter {
|
75
|
+
mautic {
|
76
|
+
source => "message"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
CONFIG
|
80
|
+
end
|
81
|
+
|
82
|
+
entered_fields = '{
|
83
|
+
"mautic.page_on_hit": [
|
84
|
+
{
|
85
|
+
"hit": {
|
86
|
+
"dateHit": "2015-08-26T01:32:39+00:00",
|
87
|
+
"dateLeft": null,
|
88
|
+
"lead": {
|
89
|
+
"id": 26,
|
90
|
+
"points": 10,
|
91
|
+
"color": null
|
92
|
+
},
|
93
|
+
"code": 200,
|
94
|
+
"referer": null,
|
95
|
+
"url": "http://mautic-gh.com/index_dev.php/pagehit",
|
96
|
+
"urlTitle": null
|
97
|
+
}
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"hit": {
|
101
|
+
"dateHit": "2015-08-26T01:32:39+00:00",
|
102
|
+
"dateLeft": null,
|
103
|
+
"lead": {
|
104
|
+
"id": 70,
|
105
|
+
"points": 10,
|
106
|
+
"color": null
|
107
|
+
},
|
108
|
+
"code": 400,
|
109
|
+
"referer": null,
|
110
|
+
"url": "http://mautic-gh.com/index_dev.php/pagehit",
|
111
|
+
"urlTitle": null
|
112
|
+
}
|
113
|
+
}
|
114
|
+
]
|
115
|
+
}'
|
116
|
+
#it "should contain points"
|
117
|
+
sample entered_fields do
|
118
|
+
#insist { subject["points"] } == 25
|
119
|
+
expect(subject[0]).to include("leadid")
|
120
|
+
expect(subject[0]).to include("url")
|
121
|
+
expect(subject[0]['leadid']).to eq(26)
|
122
|
+
expect(subject[0]['code']).to eq(200)
|
123
|
+
expect(subject[1]['leadid']).to eq(70)
|
124
|
+
expect(subject[1]['code']).to eq(400)
|
125
|
+
expect(subject[1]['type']).to eq("page_hit")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
end
|
132
|
+
|