added device identification to form submissions

This commit is contained in:
David Baldwynn 2015-11-12 17:40:23 -08:00
parent 7eccc07d02
commit 0d1e76e8ea
5 changed files with 28 additions and 4 deletions

View file

@ -115,6 +115,10 @@ exports.createSubmission = function(req, res) {
if(ip && process.env.NODE_ENV !== 'development') submission.ipAddr = ip;
}
if(req.device){
submission.device = req.device;
}
if(form.autofillPDFs){
try {
submission.fdfData = pdfFiller.convFieldJson2FDF(submission.form_fields);

View file

@ -71,6 +71,14 @@ var FormSubmissionSchema = new Schema({
geoLocation: {
type: Schema.Types.Mixed,
},
device: {
type: {
type: String,
},
name: {
type: String,
}
},
pdfFilePath: {
type: Schema.Types.Mixed,

View file

@ -23,6 +23,7 @@ var fs = require('fs-extra'),
config = require('./config'),
consolidate = require('consolidate'),
path = require('path'),
device = require('express-device'),
client = new raven.Client(config.DSN);
@ -128,6 +129,9 @@ module.exports = function(db) {
app.use(passport.initialize());
app.use(passport.session());
// setup express-device
app.use(device.capture());
// connect flash for flash messages
app.use(flash());

View file

@ -14,7 +14,7 @@
},
"engines": {
"node": "~5.0.0",
"npm": "~2.11.2"
"npm": "~3.3.6"
},
"scripts": {
"start": "grunt",
@ -85,7 +85,9 @@
"shortid": "^2.2.2",
"soap": "^0.11.0",
"swig": "~1.4.1",
"then-fs": "~2.0.0"
"then-fs": "~2.0.0",
"useragent": "~2.1.7",
"express-device" "~0.4.2"
},
"devDependencies": {
"node-mandrill": "^1.0.1",

View file

@ -44,7 +44,10 @@
Time Elapsed
</th>
<th>
Geolacation
Device
</th>
<th>
Location
</th>
<th>
IP Address
@ -81,7 +84,10 @@
{{row.timeElapsed}}
</td>
<td>
{{row.geoLocation}}
{{row.device.name}}, {{row.device.type}}
</td>
<td>
{{row.geoLocation.city}}, {{row.geoLocation.country}}
</td>
<td>
{{row.ipAddr}}