diff --git a/Gemfile b/Gemfile index 7788961..dedbbef 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ source 'https://rubygems.org' -gem 'sass', '~> 3.4.6' +gem 'sass', '~> 3.4' diff --git a/Gemfile.lock b/Gemfile.lock index 07fd731..eb9a29f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ GEM remote: https://rubygems.org/ specs: - sass (3.4.6) + sass (3.4.13) PLATFORMS ruby DEPENDENCIES - sass (~> 3.4.6) + sass (~> 3.4) diff --git a/bower.json b/bower.json index 58c9805..c797927 100644 --- a/bower.json +++ b/bower.json @@ -1,14 +1,14 @@ { "name": "atrackt", "dependencies": { - "jquery": "~2.1.1", - "jquery.scrollTo": "~1.4.13" + "jquery": "~2", + "jquery.scrollTo": "~1" }, "devDependencies": { - "chai": "~1.9.1", - "chai-as-promised": "~4.1.1", - "mocha": "~1.21.4", - "sinon": "~1.10.3", - "sinon-chai": "~2.5.0" + "chai": "~1", + "chai-as-promised": "~4", + "mocha": "~1", + "sinon": "~1", + "sinon-chai": "~2" } } diff --git a/demo/atrackt_demo.js b/demo/atrackt_demo.js index 4736844..7be9e86 100644 --- a/demo/atrackt_demo.js +++ b/demo/atrackt_demo.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 (function() { $(function() { Atrackt.setPlugin('Demo Plugin', { diff --git a/lib/atrackt.console.js b/lib/atrackt.console.js index 7f578e2..f240aae 100644 --- a/lib/atrackt.console.js +++ b/lib/atrackt.console.js @@ -1,15 +1,15 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* Atrackt Tracking Library https://github.com/brewster1134/atrackt -@version 1.0.5 +@version 1.0.0 @author Ryan Brewster */ (function() { - var __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __hasProp = {}.hasOwnProperty; (function(root, factory) { if (typeof define === 'function' && define.amd) { diff --git a/lib/atrackt.js b/lib/atrackt.js index 65766c5..4706e9a 100644 --- a/lib/atrackt.js +++ b/lib/atrackt.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* Atrackt Tracking Library https://github.com/brewster1134/atrackt -@version 1.0.2 +@version 1.0.8 @author Ryan Brewster */ @@ -33,10 +33,10 @@ https://github.com/brewster1134/atrackt Atrackt.prototype.setPlugin = function(pluginName, plugin) { if (!pluginName) { - throw 'ATRACKT ERROR: `setPlugin` - No plugin name defined'; + throw new Error('ATRACKT ERROR: `setPlugin` - No plugin name defined'); } - if (typeof (plugin != null ? plugin.send : void 0) !== 'function') { - throw "ATRACKT ERROR: `setPlugin` - No send method was defined for `" + pluginName + "`."; + if (!(plugin && typeof plugin.send === 'function')) { + throw new Error("ATRACKT ERROR: `setPlugin` - No send method was defined for `" + pluginName + "`."); } pluginName = pluginName.toLowerCase().replace(/[^a-z]/g, '-'); this.plugins[pluginName] = plugin; @@ -78,7 +78,7 @@ https://github.com/brewster1134/atrackt context = this; } if (!eventsObject) { - throw 'ATRACKT ERROR: `setEvent` - You must pass a valid event object.'; + throw new Error('ATRACKT ERROR: `setEvent` - You must pass a valid event object.'); } _results = []; for (eventType in eventsObject) { @@ -153,7 +153,7 @@ https://github.com/brewster1134/atrackt } allowedCallbacks = ['before', 'after']; if (allowedCallbacks.indexOf(name) === -1) { - throw "ATRACKT ERROR: `setCallback` - `" + name + "` is not a valid callback. Only callbacks allowed are: " + (allowedCallbacks.join(', ')); + throw new Error("ATRACKT ERROR: `setCallback` - `" + name + "` is not a valid callback. Only callbacks allowed are: " + (allowedCallbacks.join(', '))); } (_base = context._callbacks)[name] || (_base[name] = []); return context._callbacks[name].push(callback); @@ -223,7 +223,7 @@ https://github.com/brewster1134/atrackt var callback, metaData, optionsCopy, trackingData, trackingOptions, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _results; metaData = this._getTrackObject(data, event); if (!metaData) { - throw 'ATRACKT ERROR: `track` - Only valid selectors, jquery objects, or html nodes are supported.'; + throw new Error('ATRACKT ERROR: `track` - Only valid selectors, jquery objects, or html nodes are supported.'); } trackingData = $.extend(true, {}, this._data, plugin._data, options['_data'] || {}, metaData); optionsCopy = $.extend(true, {}, options, options[plugin.name] || {}); diff --git a/lib/plugins/atrackt.localytics.js b/lib/plugins/atrackt.localytics.js index b3d7a7a..4a02d53 100644 --- a/lib/plugins/atrackt.localytics.js +++ b/lib/plugins/atrackt.localytics.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* Atrackt Localytics Plugin diff --git a/lib/plugins/atrackt.omniture.js b/lib/plugins/atrackt.omniture.js index b1ac95f..3a93e58 100644 --- a/lib/plugins/atrackt.omniture.js +++ b/lib/plugins/atrackt.omniture.js @@ -1,10 +1,10 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.0 /* Atrackt Omniture Plugin https://github.com/brewster1134/atrackt @author Ryan Brewster -@version 1.0.5 +@version 1.0.6 */ (function() { @@ -36,8 +36,8 @@ https://github.com/brewster1134/atrackt }, send: function(data, options) { var arg, _ref, _ref1; - if (typeof s === 'undefined') { - return console.error('ATRACKT ERROR: PLUGIN `omniture` - Site catalyst library not loaded'); + if (typeof s === "undefined" || s === null) { + return; } $.extend(true, this.options, options); data._categories = (_ref = data._categories) != null ? _ref.join(this.options.delimiters.category) : void 0; @@ -90,9 +90,6 @@ https://github.com/brewster1134/atrackt _keyLookup: function(key) { var _newKey; _newKey = this.options.propMap[key]; - if (!_newKey) { - console.error("ATRACKT ERROR: PLUGIN `omniture` - No mapping for `" + key + "` in omniture config"); - } return _newKey || key; } }); diff --git a/spec/atrackt_spec.coffee b/spec/atrackt_spec.coffee index 7dd5b94..209aee2 100644 --- a/spec/atrackt_spec.coffee +++ b/spec/atrackt_spec.coffee @@ -1,10 +1,17 @@ # Setup plugin # + +# create plugin to test with Atrackt.setPlugin 'Foo Plugin', send: -> _plugin = Atrackt.plugins['foo-plugin'] describe 'Atrackt', -> + before -> + # make sure the foo plugin is the only registered plugin + Atrackt.plugins = + 'foo-plugin': _plugin + it 'should set the Atrackt object on window', -> expect(window.Atrackt).to.exist diff --git a/spec/index.html b/spec/index.html index 23cda1c..bb8c365 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1,45 +1,61 @@ - - - Atrackt Test - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/README.md b/src/README.md index c3aed7a..629de6c 100644 --- a/src/README.md +++ b/src/README.md @@ -1,4 +1,10 @@ ### CHANGE LOG + + +##### Core +###### 1.0.8 +* proper error throwing + ###### 1.0.7 * removed polyfill * moved plugin scoped option logic @@ -38,3 +44,7 @@ ###### 0.0.12 * Added setCallback + + +##### Console +###### 1.0.0 diff --git a/src/atrackt.coffee b/src/atrackt.coffee index c4ce9d6..b8e44f1 100644 --- a/src/atrackt.coffee +++ b/src/atrackt.coffee @@ -1,7 +1,7 @@ ### Atrackt Tracking Library https://github.com/brewster1134/atrackt -@version 1.0.2 +@version 1.0.8 @author Ryan Brewster ### @@ -28,8 +28,8 @@ https://github.com/brewster1134/atrackt # PUBLIC METHODS # setPlugin: (pluginName, plugin) -> - throw 'ATRACKT ERROR: `setPlugin` - No plugin name defined' unless pluginName - throw "ATRACKT ERROR: `setPlugin` - No send method was defined for `#{pluginName}`." unless typeof plugin?.send == 'function' + throw new Error 'ATRACKT ERROR: `setPlugin` - No plugin name defined' unless pluginName + throw new Error "ATRACKT ERROR: `setPlugin` - No send method was defined for `#{pluginName}`." unless plugin && typeof plugin.send == 'function' # Add plugin to global plugins object pluginName = pluginName.toLowerCase().replace(/[^a-z]/g, '-') @@ -56,7 +56,7 @@ https://github.com/brewster1134/atrackt # Actual event binding is done from _registerElement # setEvent: (eventsObject, context = @) -> - throw 'ATRACKT ERROR: `setEvent` - You must pass a valid event object.' unless eventsObject + throw new Error 'ATRACKT ERROR: `setEvent` - You must pass a valid event object.' unless eventsObject for eventType, objects of eventsObject @@ -114,7 +114,7 @@ https://github.com/brewster1134/atrackt allowedCallbacks = [ 'before', 'after' ] if allowedCallbacks.indexOf(name) == -1 - throw "ATRACKT ERROR: `setCallback` - `#{name}` is not a valid callback. Only callbacks allowed are: #{allowedCallbacks.join(', ')}" + throw new Error "ATRACKT ERROR: `setCallback` - `#{name}` is not a valid callback. Only callbacks allowed are: #{allowedCallbacks.join(', ')}" context._callbacks[name] ||= [] context._callbacks[name].push callback @@ -180,7 +180,7 @@ https://github.com/brewster1134/atrackt # _track: (plugin, data, options, event) -> metaData = @_getTrackObject data, event - throw 'ATRACKT ERROR: `track` - Only valid selectors, jquery objects, or html nodes are supported.' unless metaData + throw new Error 'ATRACKT ERROR: `track` - Only valid selectors, jquery objects, or html nodes are supported.' unless metaData # prepare tracking data trackingData = $.extend true, {}, @_data, plugin._data, options['_data'] || {}, metaData diff --git a/src/atrackt.console.coffee b/src/atrackt.console.coffee index c87c47d..cc85aca 100644 --- a/src/atrackt.console.coffee +++ b/src/atrackt.console.coffee @@ -1,7 +1,7 @@ ### Atrackt Tracking Library https://github.com/brewster1134/atrackt -@version 1.0.5 +@version 1.0.0 @author Ryan Brewster ### diff --git a/src/plugins/README.md b/src/plugins/README.md index 86d4a82..973f262 100644 --- a/src/plugins/README.md +++ b/src/plugins/README.md @@ -1,4 +1,6 @@ ### CHANGE LOG + + ##### Localytics Plugin ###### 1.0.0 * updated to new api @@ -13,7 +15,11 @@ ###### 0.0.1 * Just a simple send method! + ##### Omniture Plugin +###### 1.0.6 +* removed console logs + ###### 1.0.5 * options bugfix diff --git a/src/plugins/atrackt.omniture.coffee b/src/plugins/atrackt.omniture.coffee index 1658979..b3ee45b 100644 --- a/src/plugins/atrackt.omniture.coffee +++ b/src/plugins/atrackt.omniture.coffee @@ -2,7 +2,7 @@ Atrackt Omniture Plugin https://github.com/brewster1134/atrackt @author Ryan Brewster -@version 1.0.5 +@version 1.0.6 ### ((root, factory) -> @@ -34,7 +34,8 @@ https://github.com/brewster1134/atrackt _event : 'prop4' send: (data, options) -> - return console.error 'ATRACKT ERROR: PLUGIN `omniture` - Site catalyst library not loaded' if typeof s == 'undefined' + # return if the site catalyst library isnt loaded + return unless s? $.extend true, @options, options data._categories = data._categories?.join @options.delimiters.category @@ -85,5 +86,4 @@ https://github.com/brewster1134/atrackt _keyLookup: (key) -> _newKey = @options.propMap[key] - console.error "ATRACKT ERROR: PLUGIN `omniture` - No mapping for `#{key}` in omniture config" unless _newKey _newKey || key