From 4d027b4725b9a40378c30c320b85dcc858f0037c Mon Sep 17 00:00:00 2001 From: Kevin Gaudin Date: Sun, 9 Dec 2012 02:06:26 +0100 Subject: [PATCH] Update function which split some report values into arrays. More views for pie charts. --- .ericaignore | 1 + .gitignore | 2 + updates/report.js | 59 +++++++++++++++++++ views/reports-per-android-sdk-version/map.js | 5 ++ .../reports-per-android-sdk-version/reduce.js | 3 + views/reports-per-android-version/map.js | 5 ++ views/reports-per-android-version/reduce.js | 3 + views/reports-per-app-version-code/map.js | 5 ++ views/reports-per-app-version-code/reduce.js | 3 + views/reports-per-app-version-name/map.js | 5 ++ views/reports-per-app-version-name/reduce.js | 3 + views/reports-per-day/map.js | 2 +- 12 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .ericaignore create mode 100644 .gitignore create mode 100644 updates/report.js create mode 100644 views/reports-per-android-sdk-version/map.js create mode 100644 views/reports-per-android-sdk-version/reduce.js create mode 100644 views/reports-per-android-version/map.js create mode 100644 views/reports-per-android-version/reduce.js create mode 100644 views/reports-per-app-version-code/map.js create mode 100644 views/reports-per-app-version-code/reduce.js create mode 100644 views/reports-per-app-version-name/map.js create mode 100644 views/reports-per-app-version-name/reduce.js diff --git a/.ericaignore b/.ericaignore new file mode 100644 index 0000000..a98becd --- /dev/null +++ b/.ericaignore @@ -0,0 +1 @@ +[".idea"] \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6ef218 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea + diff --git a/updates/report.js b/updates/report.js new file mode 100644 index 0000000..589d953 --- /dev/null +++ b/updates/report.js @@ -0,0 +1,59 @@ +/** + * Inserts a reception timestamp and transforms some multiple values fields into arrays. + **/ +function(doc,req) { + var data = JSON.parse(req.body); + data.timestamp = new Date(); + data.user_ip = req.peer; + data["_id"] = data.REPORT_ID; + if(data.STACK_TRACE) { + data.STACK_TRACE = data.STACK_TRACE.split('\n'); + } + + if(data.LOGCAT) { + data.LOGCAT = data.LOGCAT.split('\n'); + } + if(data.RADIOLOG) { + data.RADIOLOG = data.RADIOLOG.split('\n'); + } + if(data.EVENTSLOG) { + data.EVENTSLOG = data.EVENTSLOG.split('\n'); + } + if(data.SETTINGS_SECURE.ENABLED_INPUT_METHODS) { + data.SETTINGS_SECURE.ENABLED_INPUT_METHODS = data.SETTINGS_SECURE.ENABLED_INPUT_METHODS.split(':'); + } + if(data.SETTINGS_SYSTEM.AIRPLANE_MODE_RADIOS) { + data.SETTINGS_SYSTEM.AIRPLANE_MODE_RADIOS = data.SETTINGS_SYSTEM.AIRPLANE_MODE_RADIOS.split(','); + } + if(data.SETTINGS_GLOBAL.AIRPLANE_MODE_RADIOS) { + data.SETTINGS_GLOBAL.AIRPLANE_MODE_RADIOS = data.SETTINGS_GLOBAL.AIRPLANE_MODE_RADIOS.split(','); + } + if(data.SETTINGS_GLOBAL.AIRPLANE_MODE_TOGGLEABLE_RADIOS) { + data.SETTINGS_GLOBAL.AIRPLANE_MODE_TOGGLEABLE_RADIOS = data.SETTINGS_GLOBAL.AIRPLANE_MODE_TOGGLEABLE_RADIOS.split(','); + } + if(data.INITIAL_CONFIGURATION.screenLayout) { + data.INITIAL_CONFIGURATION.screenLayout = data.INITIAL_CONFIGURATION.screenLayout.split('+'); + } + if(data.INITIAL_CONFIGURATION.uiMode) { + data.INITIAL_CONFIGURATION.uiMode = data.INITIAL_CONFIGURATION.uiMode.split('+'); + } + if(data.CRASH_CONFIGURATION.screenLayout) { + data.CRASH_CONFIGURATION.screenLayout = data.CRASH_CONFIGURATION.screenLayout.split('+'); + } + if(data.CRASH_CONFIGURATION.uiMode) { + data.CRASH_CONFIGURATION.uiMode = data.CRASH_CONFIGURATION.uiMode.split('+'); + } +// This causes Error 500... +/* if(data.DISPLAY) { + data.DISPLAY.forEach( function(d) { + if(d.flags){ + d.flags = d.flags.split('+'); + } + }); + } +*/ + + data.requestHeaders = req.headers; + message = "OK"; + return [ data, message]; +} \ No newline at end of file diff --git a/views/reports-per-android-sdk-version/map.js b/views/reports-per-android-sdk-version/map.js new file mode 100644 index 0000000..1527941 --- /dev/null +++ b/views/reports-per-android-sdk-version/map.js @@ -0,0 +1,5 @@ +function(doc) { + if(doc.BUILD.VERSION.SDK) { + emit(doc.BUILD.VERSION.SDK, 1); + } +} \ No newline at end of file diff --git a/views/reports-per-android-sdk-version/reduce.js b/views/reports-per-android-sdk-version/reduce.js new file mode 100644 index 0000000..ff7bd5b --- /dev/null +++ b/views/reports-per-android-sdk-version/reduce.js @@ -0,0 +1,3 @@ +function(keys, values, rereduce) { + return sum(values); +} \ No newline at end of file diff --git a/views/reports-per-android-version/map.js b/views/reports-per-android-version/map.js new file mode 100644 index 0000000..48ad662 --- /dev/null +++ b/views/reports-per-android-version/map.js @@ -0,0 +1,5 @@ +function(doc) { + if(doc.ANDROID_VERSION) { + emit(doc.ANDROID_VERSION, 1); + } +} \ No newline at end of file diff --git a/views/reports-per-android-version/reduce.js b/views/reports-per-android-version/reduce.js new file mode 100644 index 0000000..ff7bd5b --- /dev/null +++ b/views/reports-per-android-version/reduce.js @@ -0,0 +1,3 @@ +function(keys, values, rereduce) { + return sum(values); +} \ No newline at end of file diff --git a/views/reports-per-app-version-code/map.js b/views/reports-per-app-version-code/map.js new file mode 100644 index 0000000..3929ddf --- /dev/null +++ b/views/reports-per-app-version-code/map.js @@ -0,0 +1,5 @@ +function(doc) { + if(doc.APP_VERSION_CODE) { + emit(doc.APP_VERSION_CODE, 1); + } +} \ No newline at end of file diff --git a/views/reports-per-app-version-code/reduce.js b/views/reports-per-app-version-code/reduce.js new file mode 100644 index 0000000..ff7bd5b --- /dev/null +++ b/views/reports-per-app-version-code/reduce.js @@ -0,0 +1,3 @@ +function(keys, values, rereduce) { + return sum(values); +} \ No newline at end of file diff --git a/views/reports-per-app-version-name/map.js b/views/reports-per-app-version-name/map.js new file mode 100644 index 0000000..82f6aba --- /dev/null +++ b/views/reports-per-app-version-name/map.js @@ -0,0 +1,5 @@ +function(doc) { + if(doc.APP_VERSION_NAME) { + emit(doc.APP_VERSION_NAME, 1); + } +} \ No newline at end of file diff --git a/views/reports-per-app-version-name/reduce.js b/views/reports-per-app-version-name/reduce.js new file mode 100644 index 0000000..ff7bd5b --- /dev/null +++ b/views/reports-per-app-version-name/reduce.js @@ -0,0 +1,3 @@ +function(keys, values, rereduce) { + return sum(values); +} \ No newline at end of file diff --git a/views/reports-per-day/map.js b/views/reports-per-day/map.js index f52f33f..26c8907 100644 --- a/views/reports-per-day/map.js +++ b/views/reports-per-day/map.js @@ -2,7 +2,7 @@ function(doc) { if(doc.USER_CRASH_DATE) { var crashDate = new Date(doc.USER_CRASH_DATE); if(crashDate.getFullYear() > 2000) { - emit([crashDate.getFullYear(), crashDate.getMonth() , crashDate.getDate()], 1); + emit([crashDate.getFullYear(), crashDate.getMonth() , crashDate.getDate(), crashDate.getHours(), crashDate.getMinutes(), crashDate.getSeconds(), crashDate.getMilliseconds()], 1); } } } \ No newline at end of file