Last active
December 9, 2016 09:40
-
-
Save amk221/43bf8dcf79bd648875f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Service from 'ember-service'; | |
import on from 'ember-evented/on'; | |
import { bind } from 'ember-runloop'; | |
import { subscribe } from 'ember-instrumentation'; | |
const { newrelic } = window; | |
export default Service.extend({ | |
_instrumentComponents: on('init', { | |
subscribe('render.component', { | |
before: bind(this, '_beforeRenderComponent'), | |
after: bind(this, '_afterRenderComponent') | |
}) | |
}, | |
_beforeRenderComponent(name, timestamp) { | |
return timestamp; | |
}, | |
_afterRenderComponent(name, end, payload, start) { | |
let seconds = (end - start) / 1000; | |
if (seconds > .1) { | |
newrelic.addPageAction(payload.containerKey, {seconds}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment