From 749c2ad039a28b267f3b1b0e89ef22ccce6bff3e Mon Sep 17 00:00:00 2001 From: Cesar Andreu Date: Tue, 18 Feb 2014 16:19:51 -0800 Subject: [PATCH 1/2] NREUM should be empty object if it's undefined --- spec/newrelic-timing.spec.js | 6 ++++++ src/newrelic-timing.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/newrelic-timing.spec.js b/spec/newrelic-timing.spec.js index c8ce0a4..ec7697c 100644 --- a/spec/newrelic-timing.spec.js +++ b/spec/newrelic-timing.spec.js @@ -8,6 +8,12 @@ newrelicTiming = new global.NewrelicTiming(); }); + describe('NREUM', function () { + it('it should define an object in case it has not been loaded yet', function () { + expect(newrelicTiming.NREUM).toEqual({}); + }); + }); + describe('mark', function() { it('marks an event', function() { diff --git a/src/newrelic-timing.js b/src/newrelic-timing.js index f158529..8d84081 100644 --- a/src/newrelic-timing.js +++ b/src/newrelic-timing.js @@ -41,4 +41,4 @@ return this.marks.navStart && this.marks.domLoaded && this.marks.pageRendered; }; }; -})(window, window.NREUM); +})(window, (window.NREUM = window.NREUM || {})); From b85901fb22fa8cebac71251a5a6fea86f5641683 Mon Sep 17 00:00:00 2001 From: Cesar Andreu Date: Tue, 18 Feb 2014 16:23:51 -0800 Subject: [PATCH 2/2] Bumped up version to 0.4.1 --- README.md | 4 ++++ bower.json | 2 +- newrelic-timing-angular.js | 2 +- newrelic-timing-angular.min.js | 2 +- newrelic-timing.js | 4 ++-- newrelic-timing.min.js | 4 ++-- package.json | 2 +- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b550d32..b7744fe 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ Please take a look at `newrelic-timing-angular.js` as an example of how to integ ### Changelog +#### 0.4.1 (February 18, 2014) + +- NREUM will now be set to be an object if it's not defined when NewrelicTiming is created, this means newrelic scripts can load _after_ it's defined and it should still work. + #### 0.4.0 (February 11, 2014) - added support for [ui-router](https://github.com/angular-ui/ui-router) diff --git a/bower.json b/bower.json index f366f8a..be823cc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "newrelic-timing", - "version": "0.4.0", + "version": "0.4.1", "authors": [ "Diogo Terror ", "pitr " diff --git a/newrelic-timing-angular.js b/newrelic-timing-angular.js index b139226..0206d6c 100644 --- a/newrelic-timing-angular.js +++ b/newrelic-timing-angular.js @@ -1,5 +1,5 @@ /*! - * newrelic-timing v0.4.0 - Integrates Single Page Apps with NewRelic's Real User Monitoring + * newrelic-timing v0.4.1 - Integrates Single Page Apps with NewRelic's Real User Monitoring * Copyright (c) 2014 Diogo Terror , pitr - https://github.com/uken/newrelic-timing * License: MIT */ diff --git a/newrelic-timing-angular.min.js b/newrelic-timing-angular.min.js index bfc496c..c1d04df 100644 --- a/newrelic-timing-angular.min.js +++ b/newrelic-timing-angular.min.js @@ -1,5 +1,5 @@ /*! - * newrelic-timing v0.4.0 - Integrates Single Page Apps with NewRelic's Real User Monitoring + * newrelic-timing v0.4.1 - Integrates Single Page Apps with NewRelic's Real User Monitoring * Copyright (c) 2014 Diogo Terror , pitr - https://github.com/uken/newrelic-timing * License: MIT */ diff --git a/newrelic-timing.js b/newrelic-timing.js index 461fd3f..e4de1be 100644 --- a/newrelic-timing.js +++ b/newrelic-timing.js @@ -1,5 +1,5 @@ /*! - * newrelic-timing v0.4.0 - Integrates Single Page Apps with NewRelic's Real User Monitoring + * newrelic-timing v0.4.1 - Integrates Single Page Apps with NewRelic's Real User Monitoring * Copyright (c) 2014 Diogo Terror , pitr - https://github.com/uken/newrelic-timing * License: MIT */ @@ -47,4 +47,4 @@ return this.marks.navStart && this.marks.domLoaded && this.marks.pageRendered; }; }; -})(window, window.NREUM); \ No newline at end of file +})(window, (window.NREUM = window.NREUM || {})); \ No newline at end of file diff --git a/newrelic-timing.min.js b/newrelic-timing.min.js index 0af4b69..584132f 100644 --- a/newrelic-timing.min.js +++ b/newrelic-timing.min.js @@ -1,7 +1,7 @@ /*! - * newrelic-timing v0.4.0 - Integrates Single Page Apps with NewRelic's Real User Monitoring + * newrelic-timing v0.4.1 - Integrates Single Page Apps with NewRelic's Real User Monitoring * Copyright (c) 2014 Diogo Terror , pitr - https://github.com/uken/newrelic-timing * License: MIT */ -!function(a,b){a.NewrelicTiming=function(){this.marks={},this.NREUM=b,this.mark=function(a){this.marks[a]=+new Date},this.measure=function(a,b){var c,d;return b?(d=this.marks[b],c=this.marks[a]):(d=this.marks[a],c=+new Date),c-d},this.sendNRBeacon=function(b){if(this.checkBeaconRequirements()){b||(b=a.location.hash.substring(1));var c=this.measure("domLoaded","navStart"),d=this.measure("pageRendered","navStart");this.NREUM.inlineHit(b,0,0,0,c,d)}},this.checkBeaconRequirements=function(){return this.NREUM&&this.NREUM.inlineHit&&"function"==typeof this.NREUM.inlineHit?this.marks.navStart&&this.marks.domLoaded&&this.marks.pageRendered:!1}}}(window,window.NREUM); \ No newline at end of file +!function(a,b){a.NewrelicTiming=function(){this.marks={},this.NREUM=b,this.mark=function(a){this.marks[a]=+new Date},this.measure=function(a,b){var c,d;return b?(d=this.marks[b],c=this.marks[a]):(d=this.marks[a],c=+new Date),c-d},this.sendNRBeacon=function(b){if(this.checkBeaconRequirements()){b||(b=a.location.hash.substring(1));var c=this.measure("domLoaded","navStart"),d=this.measure("pageRendered","navStart");this.NREUM.inlineHit(b,0,0,0,c,d)}},this.checkBeaconRequirements=function(){return this.NREUM&&this.NREUM.inlineHit&&"function"==typeof this.NREUM.inlineHit?this.marks.navStart&&this.marks.domLoaded&&this.marks.pageRendered:!1}}}(window,window.NREUM=window.NREUM||{}); \ No newline at end of file diff --git a/package.json b/package.json index c6b46e4..d4aa2e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "newrelic-timing", - "version": "0.4.0", + "version": "0.4.1", "scripts": { "test": "grunt test --verbose" },