Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorStevo Slavic <sslavic@gmail.com>2014-06-23 16:55:23 +0400
committerStevo Slavic <sslavic@gmail.com>2014-06-23 16:55:23 +0400
commitc38beb332efd2882525b57b8cd34104e65492dbc (patch)
tree6b0d291d70e20c0a772ff33f03e37246a4bc2f60 /js
parent49543b2c34ef8b1ee904f8c543894e15d835aa98 (diff)
Added option to configure custom request content processing logic before request content is sent to tracker
Diffstat (limited to 'js')
-rw-r--r--js/piwik.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/js/piwik.js b/js/piwik.js
index 9fe9c4b333..a9745ebada 100644
--- a/js/piwik.js
+++ b/js/piwik.js
@@ -1175,6 +1175,8 @@ if (typeof Piwik !== 'object') {
// Custom Variables read from cookie, scope "visit"
customVariables = false,
+ configCustomRequestContentProcessing,
+
// Custom Variables, scope "page"
customVariablesPage = {},
@@ -1824,6 +1826,11 @@ if (typeof Piwik !== 'object') {
if (configAppendToTrackingUrl.length) {
request += '&' + configAppendToTrackingUrl;
}
+
+ if (isFunction(configCustomRequestContentProcessing)) {
+ request = configCustomRequestContentProcessing(request);
+ }
+
return request;
}
@@ -2427,6 +2434,27 @@ if (typeof Piwik !== 'object') {
},
/**
+ * Configure function with custom request content processing logic.
+ * It gets called after request content in form of query parameters string has been prepared and before request content gets sent.
+ *
+ * Examples:
+ * tracker.setCustomRequestContentProcessing(function(request){
+ * var pairs = request.split('&');
+ * var result = {};
+ * pairs.forEach(function(pair) {
+ * pair = pair.split('=');
+ * result[pair[0]] = decodeURIComponent(pair[1] || '');
+ * });
+ * return JSON.stringify(result);
+ * });
+ *
+ * @param function customRequestContentProcessingLogic
+ */
+ setCustomRequestContentProcessing: function(customRequestContentProcessingLogic) {
+ configCustomRequestContentProcessing = customRequestContentProcessingLogic;
+ },
+
+ /**
* Get custom data
*
* @return mixed