Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
Created January 28, 2017 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnygleason/95eaef8b3dd4be3ec10f95868d29dd92 to your computer and use it in GitHub Desktop.
Save sunnygleason/95eaef8b3dd4be3ec10f95868d29dd92 to your computer and use it in GitHub Desktop.
PubNub Monitoring BLOCK w/ New Relic
export default (request) => {
var xhr = require('xhr');
var accountId = 'YOUR_ACCOUNT_ID';
var insightsKey = 'YOUR_INSIGHTS_KEY';
var url = 'https://insights-collector.newrelic.com/v1/accounts/'
+ accountId + '/events';
var params = {
method: 'POST',
headers: {
'X-Insert-Key': insightsKey,
'Content-Type': 'application/json'
},
body: request.message
};
return xhr.fetch(url, params)
.then(function (resp) {
request.message.newrelic_result = {
headers: resp.headers,
result: JSON.parse(resp.body)
};
return request.ok();
}).catch((err) => {
console.log('error happened for XHR.fetch', err);
return request.ok();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment