From 25c9d33a701be1c6d230f199309566b8b518ebbb Mon Sep 17 00:00:00 2001 From: Beech Horn Date: Sat, 4 Jan 2014 18:49:17 +0000 Subject: [PATCH] Fixed bug where analytics.js was not loaded. --- Gruntfile.coffee | 2 +- README.md | 2 +- dist/GoogleAnalytics.js | 13 ++++++++++++- dist/README.html | 2 +- package.json | 2 +- src/GoogleAnalytics.litcoffee | 14 +++++++++++++- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index a7cd8cf..1349e3d 100755 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -189,7 +189,7 @@ module.exports = (grunt) => mainConfigFile: '<%= pkg.temp %>/main.js' out: '<%= pkg.temp %>/optimized.js' optimize: 'none' - findNestedDependencies: true + findNestedDependencies: false # Does not work with this enabled # grunt-contrib-watch: https://github.com/gruntjs/grunt-contrib-watch # Run predefined tasks whenever watched file patterns are added, changed or deleted. diff --git a/README.md b/README.md index 02f7e1c..4acb701 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Installation via bower ```json { "dependencies": { - "requirejs-google-analytics": "~0.1.7" + "requirejs-google-analytics": "~0.1.9" } } ``` diff --git a/dist/GoogleAnalytics.js b/dist/GoogleAnalytics.js index 76fcbab..1787e8a 100644 --- a/dist/GoogleAnalytics.js +++ b/dist/GoogleAnalytics.js @@ -5,6 +5,17 @@ __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; }, __slice = [].slice; + require.config({ + paths: { + 'ga': '//www.google-analytics.com/analytics' + }, + shim: { + 'ga': { + exports: 'ga' + } + } + }); + define(['module', 'EventEmitter'], function(module, EventEmitter) { var GoogleAnalytics; GoogleAnalytics = (function(_super) { @@ -43,7 +54,7 @@ } this.view(); if (!this.config.ga) { - require(['//www.google-analytics.com/analytics'], function(ga) { + require(['ga'], function(ga) { _this.ga = ga; return _this.fireEvent('ready', _this.ga); }); diff --git a/dist/README.html b/dist/README.html index a3e8abf..483f0cb 100644 --- a/dist/README.html +++ b/dist/README.html @@ -135,7 +135,7 @@

Installation

Installation via bower

{
   "dependencies": {
-      "requirejs-google-analytics": "~0.1.7"
+      "requirejs-google-analytics": "~0.1.9"
   }
 }

Usage

diff --git a/package.json b/package.json index 8487596..4b95c29 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "requirejs-google-analytics", "description": "Google Analytics loader", - "version": "0.1.7", + "version": "0.1.9", "scripts": { "test": "grunt travis --verbose" }, diff --git a/src/GoogleAnalytics.litcoffee b/src/GoogleAnalytics.litcoffee index 8d5050b..bf61803 100644 --- a/src/GoogleAnalytics.litcoffee +++ b/src/GoogleAnalytics.litcoffee @@ -7,6 +7,18 @@ Strict helps to trap more potential bugs. 'use strict' +Load +[Google Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/) +using requirejs. +Feel free to just use this snippet for a lightweight implementation. + + require.config + paths: + 'ga': '//www.google-analytics.com/analytics' + shim: + 'ga': + exports: 'ga' + `module` is used to retrieve the [configuration](http://requirejs.org/docs/api.html#config-moduleconfig) and [EventEmitter](https://github.com/thomaswelton/bower-event-emitter) is used @@ -39,7 +51,7 @@ Set the chosen variation for the Visitor for unless @config.ga # Load the actual Google Analytics library - require ['//www.google-analytics.com/analytics'], (@ga) => + require ['ga'], (@ga) => @fireEvent 'ready', @ga else @ga = @config.ga