Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jsntv200 committed Oct 22, 2014
0 parents commit da65fc5
Show file tree
Hide file tree
Showing 12 changed files with 450 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
node_modules
bower_components
docs
36 changes: 36 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": true,
"quotmark": "single",
"undef": true,
"unused": false,
"strict": true,
"trailing": true,
"eqnull": true,
"expr": true,
"sub": true,
"browser": true,
"predef": [
"angular",

"module",
"require",

"beforeEach",
"describe",
"expect",
"it",
"inject",
"spyOn"
]
}
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.10.26
95 changes: 95 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
module.exports = function(grunt) {
'use strict';

grunt.initConfig({
// Configure tasks
pkg: grunt.file.readJSON('bower.json'),

banner: '/*!\n' +
' * <%= pkg.name %>.js v<%= pkg.version %>\n' +
' * <%= pkg.homepage %>\n' +
' */\n',

jshint: {
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
},

concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},

dist: {
src: ['src/**/*.js'],
dest: '<%= pkg.name %>.js'
}
},

ngAnnotate: {
dist: {
files: [{
src: '<%= pkg.name %>.js',
dest: '<%= pkg.name %>.min.js'
}]
}
},

uglify: {
options: {
banner: '<%= banner %>'
},

dist: {
src: '<%= pkg.name %>.min.js',
dest: '<%= pkg.name %>.min.js'
}
},

clean: {
dist: [
'<%= pkg.name %>.js',
'<%= pkg.name %>.min.js'
]
},

watch: {
dist: {
files: ['src/**/*.js'],
tasks: ['build']
}
},

bump: {
options: {
files: ['package.json', 'bower.json'],
commitFiles: ['-a'],
push: true,
createTag: true
}
},

karma: {
unit: {
configFile: 'karma.conf.js'
}
},

connect: {
server: {
options: {
port: 9001,
hostname: '0.0.0.0',
keepalive: true
}
}
}
});

// Load grunt tasks
require('load-grunt-tasks')(grunt);

// Register custom tasks
grunt.registerTask('test', ['karma']);
grunt.registerTask('build', ['jshint', 'clean:dist', 'concat', 'ngAnnotate', 'uglify']);
};
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
angular-ra-newrelic.js
======================

`ra.newrelic` module is a wrapper around newrelic-timing. It waits for the 'pageload:ready' event before firing the newRelic 'pageRendered' mark.


### Installing

Install with bower:

```
bower install angular-ra-newrelic
```

### Usage

Include `angular-ra-newrelic.js` and `newrelic-timing.js` files in your javascript.


Include `ra.newrelic` as a dependency of your application.

```javascript
angular.module('application', ['ra.newrelic']);
```
54 changes: 54 additions & 0 deletions angular-ra-newrelic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*!
* angular-ra-newrelic.js v0.0.1
*
* Copyright 2014
* MIT License
*/
(function(angular, NewrelicTiming) {
'use strict';

if (typeof angular === 'undefined' || angular === null || typeof angular.module !== 'function') {
return;
}

if (NewrelicTiming === 'undefined') {
throw new Error('NewrelicTiming is not loaded');
}

var module = angular.module('ra.newrelic', []);

if (typeof module.run !== 'function') {
return;
}

module.run(function($rootScope, $location, newrelicTiming) {
function changeStart() {
newrelicTiming.mark('navStart');
}

function changeSuccess() {
newrelicTiming.mark('domLoaded');
}

function pageLoad() {
newrelicTiming.mark('pageRendered');
newrelicTiming.sendNRBeacon($location.path());
}

// ngRoute
$rootScope.$on('$routeChangeStart', changeStart);
$rootScope.$on('$routeChangeSuccess', changeSuccess);

// ui-router
$rootScope.$on('$stateChangeStart', changeStart);
$rootScope.$on('$stateChangeSuccess', changeSuccess);

// custom ra.pageload event
$rootScope.$on('pageload:ready', pageLoad);
}).

factory('newrelicTiming', function() {
return new NewrelicTiming();
});

})(window.angular, window.NewrelicTiming);
7 changes: 7 additions & 0 deletions angular-ra-newrelic.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*!
* angular-ra-newrelic.js v0.0.1
*
* Copyright 2014
* MIT License
*/
!function(a,b){"use strict";if("undefined"!=typeof a&&null!==a&&"function"==typeof a.module){if("undefined"===b)throw new Error("NewrelicTiming is not loaded");var c=a.module("ra.newrelic",[]);"function"==typeof c.run&&c.run(["$rootScope","$location","newrelicTiming",function(a,b,c){function d(){c.mark("navStart")}function e(){c.mark("domLoaded")}function f(){c.mark("pageRendered"),c.sendNRBeacon(b.path())}a.$on("$routeChangeStart",d),a.$on("$routeChangeSuccess",e),a.$on("$stateChangeStart",d),a.$on("$stateChangeSuccess",e),a.$on("pageload:ready",f)}]).factory("newrelicTiming",function(){return new b})}}(window.angular,window.NewrelicTiming);
34 changes: 34 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "angular-ra-newrelic",
"version": "0.0.1",
"description": "AngularJS service to integrate with NewRelic's Real User Monitoring",
"author": {
"name": "Jason Taylor",
"email": "[email protected]"
},
"keywords": [
"angular",
"pageload"
],
"main": "angular-ra-newrelic.js",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"src",
"test",
"bower.json",
"Gruntfile.js",
"karma.conf.js",
"package.json"
],
"dependencies": {
"angular": ">=1.2.22",
"newrelic-timing": "~0.4.0",
"angular-ra-pageload": "~0.0.3"
},
"devDependencies": {
"angular-mocks": ">=1.2.22"
}
}
63 changes: 63 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2014-10-20 using
// generator-karma 0.8.3

module.exports = function(config) {
'use strict';

config.set({
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// base path, that will be used to resolve files and exclude
basePath: '',

// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/newrelic-timing/newrelic-timing.js',
'src/**/*.js',
'test/**/*.js'
],

// list of files / patterns to exclude
exclude: [],

// web server port
port: 8080,

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: [
'Chrome'
],

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,

colors: true,

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,

// Uncomment the following lines if you are using grunt's server to run the tests
// proxies: {
// '/': 'http://localhost:9000/'
// },
// URL root prevent conflicts with the site root
// urlRoot: '_karma_'
});
};
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "angular-ra-newrelic",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git://github.com/red-ant/angular-ra-newrelic.git"
},
"devDependencies": {
"bower": "^1.3.3",
"grunt": "^0.4.5",
"grunt-bump": "0.0.15",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-karma": "^0.9.0",
"grunt-ng-annotate": "^0.3.2",
"karma": "^0.12.14",
"karma-chrome-launcher": "^0.1.2",
"karma-jasmine": "^0.1.5",
"load-grunt-tasks": "^0.6.0"
}
}
Loading

0 comments on commit da65fc5

Please sign in to comment.