From 41d4277b946b2ae288c9fc2399ffd6bbc5920eba Mon Sep 17 00:00:00 2001 From: Andreas Marschke Date: Tue, 18 Nov 2014 12:22:22 +0100 Subject: [PATCH 1/5] GUID.js: set a GUID cookie for unique users throughout a web application session This plugin is intended to be used in the context of a web application where you want to trace the path of a user through the page and how bandwidth and performance of the application inhibits the user from his usual workload in an application. The technique used in this case is checking wether or not a UUID has been set for the sesssion as a cookie. It is intended to be used as searchable entity in the later beacon analysis phase. Configuration for this plugin may look like this: ```javascript BOOMR.init({ GUID: { cookieName: "myCookieName" } }); ``` You may use the cookie name as the unique key to search for in your beacon data. --- plugins/GUID.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 plugins/GUID.js diff --git a/plugins/GUID.js b/plugins/GUID.js new file mode 100644 index 000000000..3d3300ac7 --- /dev/null +++ b/plugins/GUID.js @@ -0,0 +1,41 @@ +/* + Tag users with a unique GUID +*/ +(function(w) { + + var impl = { + expires: 604800, + cookieName: "GUID", + generate: function() { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); + }; + + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); + } + }; + + BOOMR.plugins.GUID = { + init: function(config) { + var properties = ["cookieName", "expires"]; + BOOMR.utils.pluginConfig(impl, config, "GUID", properties); + BOOMR.info("Initializing plugin GUID " + impl.cookieName , "GUID"); + + if( BOOMR.utils.getCookie(impl.cookieName) == null ) { + BOOMR.info("Could not find a cookie for " + impl.cookieName, "GUID"); + + var guid = impl.generate(); + + BOOMR.utils.setCookie(impl.cookieName,guid, impl.expires); + + BOOMR.info("Setting GUID Cookie value to: " + guid + " expiring in: " + impl.expires + "s", "GUID"); + } else { + BOOMR.info("Found a cookie named: " + impl.cookieName + " value: " + BOOMR.getCookie(impl.cookieName) , "GUID"); + } + return this; + }, + is_complete: function() { + return true; + } + }; +}(this)); From e2739ce9d2b3ddd2875fd61dcee731395fe923d4 Mon Sep 17 00:00:00 2001 From: Andreas Marschke Date: Tue, 18 Nov 2014 12:30:58 +0100 Subject: [PATCH 2/5] Add GUID documentation --- doc/api/GUID.html | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 doc/api/GUID.html diff --git a/doc/api/GUID.html b/doc/api/GUID.html new file mode 100644 index 000000000..e8548d6c8 --- /dev/null +++ b/doc/api/GUID.html @@ -0,0 +1,71 @@ + + + + + The GUID API + + + All Docs | Index +

The Clicks Plugin

+

The GUID Plugin adds a tracking cookie to the user that will be sent to the beacon-server as cookie

+

The GUID API is encapsulated in the BOOMR.plugins.GUID namespace

+ +

Configuration

+

+ The GUID plugin configuration is contained in the GUID namespace in the initial Boomerang configuration Object. +

+

See "Howto #6 — Configuring boomerang" for more information on how to configure Boomerang

+ +
+
cookieName
+
+ [required] + The name of the cookie to be set in the browser session +
+
expires
+
+ [optional] + An expiry time for the cookie in seconds. By default 7 days. +
+
+ +

Methods

+ +
+ +
init(oConfig)
+
+

+ Called by the BOOMR.init() method to configure the clicks plugin. +

+
+      BOOMR.init({
+        GUID: {
+          cookieName: "boomerang-guid",
+	  expires: 6000
+        }
+      });
+    
+

Parameters

+
+
oConfig
+
The configuration object passed in via BOOMR.init(). See the Configuration section for details. +
+

Returns

+

+ a reference to the BOOMR.plugins.GUID object, so you can chain methods. +

+
+ + +

Beacon Parameters

+

+ None: no beacon parameters will be set cookies will be sent in the HTTP Header +

+ + + + From 1b9a8aaa9b3cbbf8b33d24e19ecc491fdb806437 Mon Sep 17 00:00:00 2001 From: Andreas Marschke Date: Fri, 21 Nov 2014 14:23:38 +0100 Subject: [PATCH 3/5] Fix Typo in reporting when Cookie has been found --- plugins/GUID.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/GUID.js b/plugins/GUID.js index 3d3300ac7..30a018dee 100644 --- a/plugins/GUID.js +++ b/plugins/GUID.js @@ -30,7 +30,7 @@ BOOMR.info("Setting GUID Cookie value to: " + guid + " expiring in: " + impl.expires + "s", "GUID"); } else { - BOOMR.info("Found a cookie named: " + impl.cookieName + " value: " + BOOMR.getCookie(impl.cookieName) , "GUID"); + BOOMR.info("Found a cookie named: " + impl.cookieName + " value: " + BOOMR.utils.getCookie(impl.cookieName) , "GUID"); } return this; }, From a77dd780655ac0d313857c147714c2b71e3c0062 Mon Sep 17 00:00:00 2001 From: Andreas Marschke Date: Tue, 23 Dec 2014 04:09:21 +0100 Subject: [PATCH 4/5] If setting a cookie fails try to set it again in before_beacon --- plugins/GUID.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/GUID.js b/plugins/GUID.js index 30a018dee..ead7b6f3f 100644 --- a/plugins/GUID.js +++ b/plugins/GUID.js @@ -26,7 +26,11 @@ var guid = impl.generate(); - BOOMR.utils.setCookie(impl.cookieName,guid, impl.expires); + if (!BOOMR.utils.setCookie(impl.cookieName,guid, impl.expires)) { + BOOMR.subscribe("before_beacon", function() { + BOOMR.utils.setCookie(impl.cookieName,guid, impl.expires); + }); + } BOOMR.info("Setting GUID Cookie value to: " + guid + " expiring in: " + impl.expires + "s", "GUID"); } else { From 7c0fbb7f92d2d1b3a5f43105c4395d1ccd68c199 Mon Sep 17 00:00:00 2001 From: Andreas Marschke Date: Tue, 23 Dec 2014 20:04:29 +0100 Subject: [PATCH 5/5] Properly check for falsiness when testing for existing cookies --- plugins/GUID.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/GUID.js b/plugins/GUID.js index ead7b6f3f..a3ca116cc 100644 --- a/plugins/GUID.js +++ b/plugins/GUID.js @@ -21,7 +21,7 @@ BOOMR.utils.pluginConfig(impl, config, "GUID", properties); BOOMR.info("Initializing plugin GUID " + impl.cookieName , "GUID"); - if( BOOMR.utils.getCookie(impl.cookieName) == null ) { + if(!BOOMR.utils.getCookie(impl.cookieName)) { BOOMR.info("Could not find a cookie for " + impl.cookieName, "GUID"); var guid = impl.generate();