From 619e4a25da5feca7fc6d7961b64a4bcde82dfef4 Mon Sep 17 00:00:00 2001 From: sailxjx Date: Tue, 13 Aug 2013 13:08:36 +0800 Subject: [PATCH 1/2] remerge and update cake-dog --- Cakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cakefile b/Cakefile index 47aff43..375aba9 100644 --- a/Cakefile +++ b/Cakefile @@ -1 +1,2 @@ -require('cake-dog') +require("cake-dog") + From df358ceee8f962093e025f39b19ffced21643112 Mon Sep 17 00:00:00 2001 From: sailxjx Date: Thu, 22 Aug 2013 11:36:34 +0800 Subject: [PATCH 2/2] fix initial bug --- lib/index.js | 13 +++++++------ src/index.coffee | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/index.js b/lib/index.js index a438397..05f9280 100644 --- a/lib/index.js +++ b/lib/index.js @@ -69,6 +69,7 @@ function Base(option) { this.option = option; this.option.account = option.account || ''; + this._initial(); } return Base; @@ -101,7 +102,7 @@ return _results; }).apply(this, arguments); data = typeof args[0] === 'object' ? args[0] : args.join('_'); - return window.ga('send', 'pageview', data); + return typeof window.ga === "function" ? window.ga('send', 'pageview', data) : void 0; }; Google.prototype.event = function() { @@ -115,7 +116,7 @@ } return _results; }).apply(this, arguments); - return window.ga('send', 'events', args); + return typeof window.ga === "function" ? window.ga('send', 'events', args) : void 0; }; return Google; @@ -137,7 +138,7 @@ }; Baidu.prototype.pageview = function() { - var args, data, i, v, val; + var args, data, i, v, val, _ref; args = (function() { var _results; _results = []; @@ -166,11 +167,11 @@ } else { data = args.join('_'); } - return window._hmt.push(['_trackPageview', data]); + return (_ref = window._hmt) != null ? _ref.push(['_trackPageview', data]) : void 0; }; Baidu.prototype.event = function() { - var args, data, i, val; + var args, data, i, val, _ref; args = (function() { var _results; _results = []; @@ -181,7 +182,7 @@ return _results; }).apply(this, arguments); data = ['_trackEvent'].concat(args); - return window._htm.push(data); + return (_ref = window._hmt) != null ? _ref.push(data) : void 0; }; return Baidu; diff --git a/src/index.coffee b/src/index.coffee index d6a4a3f..25db08b 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -42,6 +42,7 @@ class Gta constructor: (option) -> @option = option @option.account = option.account or '' + @_initial() class @Google extends @Base @@ -63,11 +64,11 @@ class Gta pageview: -> args = (val for i, val of arguments) data = if typeof args[0] == 'object' then args[0] else args.join('_') - window.ga('send', 'pageview', data) + window.ga?('send', 'pageview', data) event: -> args = (val for i, val of arguments) - window.ga('send', 'events', args) + window.ga?('send', 'events', args) class @Baidu extends @Base @@ -98,11 +99,11 @@ class Gta data = data.join('_') else data = args.join('_') - window._hmt.push(['_trackPageview', data]) + window._hmt?.push(['_trackPageview', data]) event: -> args = (val for i, val of arguments) data = ['_trackEvent'].concat(args) - window._htm.push(data) + window._hmt?.push(data) exports.Gta = Gta \ No newline at end of file