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