Browse Source

Merge pull request #65 from keen/fix-resource-mapping

Fix resource mapping
master v1.1.2
Dustin Larimer 8 years ago
committed by GitHub
parent
commit
1d982487e4
  1. 7
      CHANGELOG.md
  2. 2
      README.md
  3. 47
      dist/keen-tracking.js
  4. 4
      dist/keen-tracking.min.js
  5. 25
      lib/browser.js
  6. 15
      lib/index.js
  7. 4
      package.json

7
CHANGELOG.md

@ -6,6 +6,13 @@
**BREAKING:**
**CHANGE:**
-->
<a name="1.1.2"></a>
# 1.1.1 Fix Resource Mapping
**NEW:**
* This patch installs `keen-core@0.1.2` and removes the internal `events` resource mapping (now in keen-core) to fix an issue with prototype inheritance and state.
<a name="1.1.1"></a>
# 1.1.1 Global Namespace Fix (Pt2)

2
README.md

@ -130,7 +130,7 @@ Copy/paste this snippet of JavaScript above the `</head>` tag of your page to lo
// Loads the library asynchronously from any URI
!function(name,path,ctx){
var latest,prev=name!=='Keen'&&window.Keen?window.Keen:false;ctx[name]=ctx[name]||{ready:function(fn){var h=document.getElementsByTagName('head')[0],s=document.createElement('script'),w=window,loaded;s.onload=s.onerror=s.onreadystatechange=function(){if((s.readyState&&!(/^c|loade/.test(s.readyState)))||loaded){return}s.onload=s.onreadystatechange=null;loaded=1;latest=w.Keen;if(prev){w.Keen=prev}else{try{delete w.Keen}catch(e){w.Keen=void 0}}ctx[name]=latest;ctx[name].ready(fn)};s.async=1;s.src=path;h.parentNode.insertBefore(s,h)}}
}('Keen','https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.1.1.min.js',this);
}('Keen','https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.1.2.min.js',this);
// Executes when the library is loaded and ready
Keen.ready(function(){

47
dist/keen-tracking.js

@ -2,18 +2,18 @@
(function (global){
(function(env) {
'use strict';
var K = require('./');
var KeenLibrary = require('./');
var each = require('./utils/each');
var extend = require('./utils/extend');
var listener = require('./utils/listener')(K);
extend(K.prototype, require('./record-events-browser'));
extend(K.prototype, require('./defer-events'));
extend(K.prototype, {
var listener = require('./utils/listener')(KeenLibrary);
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
});
K.prototype.trackExternalLink = trackExternalLink;
extend(K.helpers, {
KeenLibrary.prototype.trackExternalLink = trackExternalLink;
extend(KeenLibrary.helpers, {
'getBrowserProfile' : require('./helpers/getBrowserProfile'),
'getDatetimeIndex' : require('./helpers/getDatetimeIndex'),
'getDomNodePath' : require('./helpers/getDomNodePath'),
@ -21,13 +21,13 @@
'getUniqueId' : require('./helpers/getUniqueId'),
'getWindowProfile' : require('./helpers/getWindowProfile')
});
extend(K.utils, {
extend(KeenLibrary.utils, {
'cookie' : require('./utils/cookie'),
'deepExtend' : require('./utils/deepExtend'),
'listener' : listener,
'timer' : require('./utils/timer')
});
K.listenTo = function(listenerHash){
KeenLibrary.listenTo = function(listenerHash){
each(listenerHash, function(callback, key){
var split = key.split(' ');
var eventType = split[0],
@ -104,14 +104,14 @@
};
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = K;
module.exports = KeenLibrary;
}
if (typeof define !== 'undefined' && define.amd) {
define('keen-tracking', [], function(){
return K;
return KeenLibrary;
});
}
env.Keen = K.extendLibrary(K);
env.Keen = KeenLibrary.extendLibrary(KeenLibrary);
}).call(this, typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {});
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./":10,"./defer-events":2,"./extend-events":3,"./helpers/getBrowserProfile":4,"./helpers/getDatetimeIndex":5,"./helpers/getDomNodePath":6,"./helpers/getScreenProfile":7,"./helpers/getUniqueId":8,"./helpers/getWindowProfile":9,"./record-events-browser":11,"./utils/cookie":13,"./utils/deepExtend":14,"./utils/each":15,"./utils/extend":16,"./utils/listener":17,"./utils/timer":19}],2:[function(require,module,exports){
@ -331,13 +331,12 @@ module.exports = getWindowProfile;
document.documentElement.offsetHeight/Width is a workaround for IE8 and below, where window.innerHeight/Width is undefined
*/
},{}],10:[function(require,module,exports){
var K = require('keen-core');
var KeenCore = require('keen-core');
var each = require('./utils/each'),
extend = require('./utils/extend'),
queue = require('./utils/queue');
K.helpers = K.helpers || {};
K.resources.events = '{protocol}://{host}/3.0/projects/{projectId}/events';
K.on('client', function(client){
KeenCore.helpers = KeenCore.helpers || {};
KeenCore.on('client', function(client){
client.extensions = {
events: [],
collections: {}
@ -347,13 +346,13 @@ K.on('client', function(client){
client.recordDeferredEvents();
});
});
K.prototype.writeKey = function(str){
KeenCore.prototype.writeKey = function(str){
if (!arguments.length) return this.config.writeKey;
this.config.writeKey = (str ? String(str) : null);
return this;
};
K.prototype.setGlobalProperties = function(props){
K.log('This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events');
KeenCore.prototype.setGlobalProperties = function(props){
KeenCore.log('This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events');
if (!props || typeof props !== 'function') {
this.emit('error', 'Invalid value for global properties: ' + props);
return;
@ -361,7 +360,7 @@ K.prototype.setGlobalProperties = function(props){
this.config.globalProperties = props;
return this;
};
module.exports = K;
module.exports = KeenCore;
},{"./utils/each":15,"./utils/extend":16,"./utils/queue":18,"keen-core":22}],11:[function(require,module,exports){
var Keen = require('./index');
var base64 = require('./utils/base64');
@ -1274,7 +1273,7 @@ Emitter.prototype.hasListeners = function(event){
debug: false,
enabled: true,
loaded: false,
version: '1.1.1'
version: '1.1.2'
});
Client.helpers = Client.helpers || {};
Client.resources = Client.resources || {};
@ -1282,7 +1281,9 @@ Emitter.prototype.hasListeners = function(event){
'base' : '{protocol}://{host}',
'version' : '{protocol}://{host}/3.0',
'projects' : '{protocol}://{host}/3.0/projects',
'projectId' : '{protocol}://{host}/3.0/projects/{projectId}'
'projectId' : '{protocol}://{host}/3.0/projects/{projectId}',
'events' : '{protocol}://{host}/3.0/projects/{projectId}/events',
'queries' : '{protocol}://{host}/3.0/projects/{projectId}/queries'
});
Client.utils = Client.utils || {};
extend(Client.utils, {
@ -1367,7 +1368,7 @@ Emitter.prototype.hasListeners = function(event){
};
Client.prototype.url = function(name){
var args = Array.prototype.slice.call(arguments, 1),
baseUrl = Client.resources.base || '{protocol}://{host}',
baseUrl = this.config.resources.base || '{protocol}://{host}',
path;
if (name && typeof name === 'string') {
if (this.config.resources[name]) {

4
dist/keen-tracking.min.js

File diff suppressed because one or more lines are too long

25
lib/browser.js

@ -1,17 +1,17 @@
(function(env) {
'use strict';
var K = require('./');
var KeenLibrary = require('./');
var each = require('./utils/each');
var extend = require('./utils/extend');
var listener = require('./utils/listener')(K);
var listener = require('./utils/listener')(KeenLibrary);
// ------------------------
// Methods
// ------------------------
extend(K.prototype, require('./record-events-browser'));
extend(K.prototype, require('./defer-events'));
extend(K.prototype, {
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
});
@ -19,12 +19,12 @@
// ------------------------
// Deprecated
// ------------------------
K.prototype.trackExternalLink = trackExternalLink;
KeenLibrary.prototype.trackExternalLink = trackExternalLink;
// ------------------------
// Helpers
// ------------------------
extend(K.helpers, {
extend(KeenLibrary.helpers, {
'getBrowserProfile' : require('./helpers/getBrowserProfile'),
'getDatetimeIndex' : require('./helpers/getDatetimeIndex'),
'getDomNodePath' : require('./helpers/getDomNodePath'),
@ -36,14 +36,14 @@
// ------------------------
// Utils
// ------------------------
extend(K.utils, {
extend(KeenLibrary.utils, {
'cookie' : require('./utils/cookie'),
'deepExtend' : require('./utils/deepExtend'),
'listener' : listener,
'timer' : require('./utils/timer')
});
K.listenTo = function(listenerHash){
KeenLibrary.listenTo = function(listenerHash){
each(listenerHash, function(callback, key){
var split = key.split(' ');
var eventType = split[0],
@ -137,16 +137,15 @@
// CommonJS
if (typeof module !== 'undefined' && module.exports) {
module.exports = K;
module.exports = KeenLibrary;
}
// RequireJS
if (typeof define !== 'undefined' && define.amd) {
define('keen-tracking', [], function(){
return K;
return KeenLibrary;
});
}
env.Keen = K.extendLibrary(K);
env.Keen = KeenLibrary.extendLibrary(KeenLibrary);
}).call(this, typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {});

15
lib/index.js

@ -1,14 +1,13 @@
var K = require('keen-core');
var KeenCore = require('keen-core');
var each = require('./utils/each'),
extend = require('./utils/extend'),
queue = require('./utils/queue');
K.helpers = K.helpers || {};
K.resources.events = '{protocol}://{host}/3.0/projects/{projectId}/events';
KeenCore.helpers = KeenCore.helpers || {};
// Install internal queue
K.on('client', function(client){
KeenCore.on('client', function(client){
client.extensions = {
events: [],
collections: {}
@ -20,15 +19,15 @@ K.on('client', function(client){
});
// Accessors
K.prototype.writeKey = function(str){
KeenCore.prototype.writeKey = function(str){
if (!arguments.length) return this.config.writeKey;
this.config.writeKey = (str ? String(str) : null);
return this;
};
// DEPRECATED
K.prototype.setGlobalProperties = function(props){
K.log('This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events');
KeenCore.prototype.setGlobalProperties = function(props){
KeenCore.log('This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events');
if (!props || typeof props !== 'function') {
this.emit('error', 'Invalid value for global properties: ' + props);
return;
@ -37,4 +36,4 @@ K.prototype.setGlobalProperties = function(props){
return this;
};
module.exports = K;
module.exports = KeenCore;

4
package.json

@ -1,6 +1,6 @@
{
"name": "keen-tracking",
"version": "1.1.1",
"version": "1.1.2",
"description": "Data Collection SDK for Keen IO",
"main": "lib/server.js",
"browser": "lib/browser.js",
@ -24,7 +24,7 @@
"dependencies": {
"component-emitter": "^1.2.0",
"js-cookie": "2.1.0",
"keen-core": "0.1.1"
"keen-core": "0.1.2"
},
"devDependencies": {
"browserify": "^9.0.8",

Loading…
Cancel
Save