keen-tracking
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -9,2 +9,19 @@ <!-- | ||
--> | ||
<a name="1.3.0"></a> | ||
# 1.3.0 Automated Event Tracking (browser-only) | ||
**NEW:** | ||
* Ported functionality from the Web Auto Collector into this SDK: The interface and behaviors of this feature are a little different, but the data models produced are backward compatible (#83) | ||
* New helper: `Keen.helpers.getScrollState()`: Return an object of properties profiling the current scroll state, and optionally pass this object back into the helper again to receive a new object with updated `pixel_max` and `ratio_max` values | ||
* New helper: `Keen.helper.getDomNodeProfile(<ELEMENT>)`: Return an object containing properties profiling a given DOM node | ||
* New utility: `Keen.utils.serializeForm(<FORM>, OPTIONS)`: Serialize the data of a form, with the option to ignore certain input types by passing in a `{ ignoreTypes: ['password'] }` option | ||
**FIXED:** | ||
* Wrap `JSON.parse()` in a `try/catch` block to mitigate error impact when the API returns un-parsable contents (#88) | ||
**UPDATED:** | ||
* Description meta tag content is now part of the `Keen.helpers.getBrowserProfile()` output when present | ||
<a name="1.2.1"></a> | ||
@@ -11,0 +28,0 @@ # 1.2.1 Fix queue polling |
(function(env) { | ||
'use strict'; | ||
var KeenLibrary = require('./'); | ||
var KeenCore = require('./index'); | ||
var each = require('./utils/each'); | ||
var extend = require('./utils/extend'); | ||
var listener = require('./utils/listener')(KeenLibrary); | ||
var listener = require('./utils/listener')(KeenCore); | ||
@@ -12,13 +12,20 @@ // ------------------------ | ||
// ------------------------ | ||
extend(KeenLibrary.prototype, require('./record-events-browser')); | ||
extend(KeenLibrary.prototype, require('./defer-events')); | ||
extend(KeenLibrary.prototype, { | ||
'extendEvent': require('./extend-events').extendEvent, | ||
'extendEvents': require('./extend-events').extendEvents | ||
extend(KeenCore.prototype, require('./record-events-browser')); | ||
extend(KeenCore.prototype, require('./defer-events')); | ||
extend(KeenCore.prototype, { | ||
'extendEvent' : require('./extend-events').extendEvent, | ||
'extendEvents' : require('./extend-events').extendEvents | ||
}); | ||
// ------------------------ | ||
// Auto-Tracking | ||
// ------------------------ | ||
extend(KeenCore.prototype, { | ||
'initAutoTracking': require('./browser-auto-tracking')(KeenCore) | ||
}); | ||
// ------------------------ | ||
// Deprecated | ||
// ------------------------ | ||
KeenLibrary.prototype.trackExternalLink = trackExternalLink; | ||
KeenCore.prototype.trackExternalLink = trackExternalLink; | ||
@@ -28,7 +35,9 @@ // ------------------------ | ||
// ------------------------ | ||
extend(KeenLibrary.helpers, { | ||
extend(KeenCore.helpers, { | ||
'getBrowserProfile' : require('./helpers/getBrowserProfile'), | ||
'getDatetimeIndex' : require('./helpers/getDatetimeIndex'), | ||
'getDomNodePath' : require('./helpers/getDomNodePath'), | ||
'getDomNodeProfile' : require('./helpers/getDomNodeProfile'), | ||
'getScreenProfile' : require('./helpers/getScreenProfile'), | ||
'getScrollState' : require('./helpers/getScrollState'), | ||
'getUniqueId' : require('./helpers/getUniqueId'), | ||
@@ -41,10 +50,11 @@ 'getWindowProfile' : require('./helpers/getWindowProfile') | ||
// ------------------------ | ||
extend(KeenLibrary.utils, { | ||
'cookie' : require('./utils/cookie'), | ||
'deepExtend' : require('./utils/deepExtend'), | ||
'listener' : listener, | ||
'timer' : require('./utils/timer') | ||
extend(KeenCore.utils, { | ||
'cookie' : require('./utils/cookie'), | ||
'deepExtend' : require('./utils/deepExtend'), | ||
'listener' : listener, | ||
'serializeForm' : require('./utils/serializeForm'), | ||
'timer' : require('./utils/timer') | ||
}); | ||
KeenLibrary.listenTo = function(listenerHash){ | ||
KeenCore.listenTo = function(listenerHash){ | ||
each(listenerHash, function(callback, key){ | ||
@@ -143,3 +153,3 @@ var split = key.split(' '); | ||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = KeenLibrary; | ||
module.exports = KeenCore; | ||
} | ||
@@ -150,7 +160,7 @@ | ||
define('keen-tracking', [], function(){ | ||
return KeenLibrary; | ||
return KeenCore; | ||
}); | ||
} | ||
env.Keen = KeenLibrary.extendLibrary(KeenLibrary); | ||
env.Keen = KeenCore.extendLibrary(KeenCore); | ||
}).call(this, typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); |
var getScreenProfile = require('./getScreenProfile'), | ||
getWindowProfile = require('./getWindowProfile'); | ||
function getBrowserProfile(){ | ||
function getBrowserProfile() { | ||
return { | ||
'cookies' : ('undefined' !== typeof navigator.cookieEnabled) ? navigator.cookieEnabled : false, | ||
'codeName' : navigator.appCodeName, | ||
'language' : navigator.language, | ||
'name' : navigator.appName, | ||
'online' : navigator.onLine, | ||
'platform' : navigator.platform, | ||
'useragent': navigator.userAgent, | ||
'version' : navigator.appVersion, | ||
'screen' : getScreenProfile(), | ||
'window' : getWindowProfile() | ||
'cookies' : ('undefined' !== typeof navigator.cookieEnabled) ? navigator.cookieEnabled : false, | ||
'codeName' : navigator.appCodeName, | ||
'description': getDocumentDescription(), | ||
'language' : navigator.language, | ||
'name' : navigator.appName, | ||
'online' : navigator.onLine, | ||
'platform' : navigator.platform, | ||
'useragent' : navigator.userAgent, | ||
'version' : navigator.appVersion, | ||
'screen' : getScreenProfile(), | ||
'window' : getWindowProfile() | ||
} | ||
} | ||
function getDocumentDescription() { | ||
var el; | ||
if (document && typeof document.querySelector === 'function') { | ||
el = document.querySelector('meta[name="description"]'); | ||
} | ||
return el ? el.content : ''; | ||
} | ||
module.exports = getBrowserProfile; |
@@ -206,11 +206,23 @@ var Keen = require('./index'); | ||
response.on('end', function() { | ||
var res = JSON.parse(body), error; | ||
if (res.error_code) { | ||
error = new Error(res.message || 'Unknown error occurred'); | ||
error.code = res.error_code; | ||
callback(error, null); | ||
var response, error; | ||
try { | ||
response = JSON.parse(body); | ||
} | ||
else { | ||
callback(null, res); | ||
catch (e) { | ||
// Parsing Error | ||
error = e; | ||
} | ||
if (!error && response.error_code) { | ||
// API Error | ||
error = new Error(response.message || 'Unknown error occurred'); | ||
error.code = response.error_code; | ||
} | ||
if (callback) { | ||
if (error) { | ||
callback(error, null); | ||
} | ||
if (response) { | ||
callback(null, response); | ||
} | ||
} | ||
}); | ||
@@ -217,0 +229,0 @@ }); |
{ | ||
"name": "keen-tracking", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Data Collection SDK for Keen IO", | ||
@@ -58,4 +58,5 @@ "main": "lib/server.js", | ||
"moment": "^2.10.3", | ||
"phantomjs": "^1.9.17", | ||
"phantomjs": "^1.9.7-15", | ||
"proclaim": "^3.3.0", | ||
"requirejs": "^2.3.5", | ||
"vinyl-buffer": "^1.0.0", | ||
@@ -62,0 +63,0 @@ "vinyl-source-stream": "^1.1.0" |
# keen-tracking.js [![Build Status](https://travis-ci.org/keen/keen-tracking.js.svg?branch=master)](https://travis-ci.org/keen/keen-tracking.js) | ||
### Installation | ||
@@ -15,3 +14,3 @@ | ||
```html | ||
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.2.1.min.js"></script> | ||
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.3.0.min.js"></script> | ||
``` | ||
@@ -21,3 +20,2 @@ | ||
### Project ID & API Keys | ||
@@ -27,7 +25,8 @@ | ||
## Getting started | ||
The following examples demonstrate how to implement rock-solid web analytics, capturing **pageviews**, **clicks**, and **form submissions**. Not interested in web analytics? Use these examples as a primer for getting up and running quickly. These examples also make use of several [helpers](./docs/#helpers) and [utilities](./docs/#utilities) that were designed to address common requirements and help produce insightful, valuable data models. | ||
The following examples demonstrate how to implement rock-solid web analytics, capturing **pageviews**, **clicks**, and **form submissions** with robust data models. | ||
Not interested in web analytics? Use these examples as a primer for getting up and running quickly. These examples also make use of several [helpers](./docs/#helpers) and [utilities](./docs/#utilities) that were designed to address common requirements and help produce insightful, valuable data models. | ||
[Full documentation is available here](./docs/README.md) | ||
@@ -48,5 +47,25 @@ | ||
### Automated Event Tracking (browser-only) | ||
### Setup and Pageview Tracking | ||
Automatically record `pageviews`, `clicks`, and `form_submissions` events with robust data models: | ||
```html | ||
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.3.0.min.js"></script> | ||
<script> | ||
Keen.ready(function(){ | ||
var client = new Keen({ | ||
projectId: 'YOUR_PROJECT_ID', | ||
writeKey: 'YOUR_WRITE_KEY' | ||
}); | ||
client.initAutoTracking(); | ||
}); | ||
</script> | ||
``` | ||
[Learn how to configure and customize this functionality here](./docs/auto-tracking.md) | ||
--- | ||
### Pageview Tracking | ||
First, let's create a new `client` instance with your Project ID and Write Key, and use the `.extendEvents()` method to define a solid baseline data model that will be applied to every single event that is recorded. Consistent data models and property names make life much easier later on, when analyzing and managing several event streams. This setup also includes our [data enrichment add-ons](https://keen.io/docs/streams/data-enrichment-overview/), which will populate additional information when an event is received on our end. | ||
@@ -135,4 +154,7 @@ | ||
Want to get up and running faster? This can also be achieved in the browser with [automated event tracking](./docs/auto-tracking.md). | ||
**What else can this SDK do?** | ||
* [Automated tracking (browser-only)](./docs/auto-tracking.md) | ||
* [Record multiple events in batches](./docs/record-events.md) | ||
@@ -195,2 +217,4 @@ * [Extend event data models for a single event stream](./docs/extend-events.md) | ||
Want to get up and running faster? This can also be achieved in the browser with [automated event tracking](./docs/auto-tracking.md). | ||
--- | ||
@@ -228,2 +252,4 @@ | ||
This can also be used with [automated event tracking](./docs/auto-tracking.md). | ||
--- | ||
@@ -230,0 +256,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77253
33
1853
267
33