cordova plugin for newrelic native SDK
a cordova plugin for providing direct access to native newrelic SDK APIs
Installation
cordova plugin add <path to this project>
eg:
cordova plugin add ~/Documents/newrelic/cordova-newrelic-sdk-plugin/
Prerequisites
-
New Relic plugin for Cordova which is the official plugin from NewRelic. It does not work out of box and have no APIS that can called directly. So When I was doing the configuration for a Cordova App. I built this plugin so that we can call those APIs directly.
-
There is another way of logging HTTP requests inside a cordova/ionic app. which is add the JS configuration code to 'index.html' and check the results within 'browser' instead of mobile;
-
My advice is using both the browser & mobile solution together and use NewRelic analysts to combine them together by using 'setCustomAttributes';
Usages
if(window.NewRelicSDK) {
// all params are String-typed to avoid conflicts between JS and ObjectiveC/JAVA
window.NewRelicSDK.noticeNetworkRequestForIOS(
requestUrl,
method,
`${timeElapsedInMilliseconds}`,
JSON.stringify(response.headers),
`${response.status}`,
`${bytesSent}`,
`${bytesReceived}`,
JSON.stringify(response.data),
()=>{/* success callback */ },
(e)=>{/* error callback */ }
);
}else{
$log.error("NewRelicSDK not available");
}
Available APIs
IOS (NewRelicSDK.*)
noticeNetworkRequestForIOS(url, httpMethod, timeElapsedInMilliseconds, headers, httpStatusCode, bytesSent, bytesReceived, responseData)
noticeNetworkRequestFailureForIOS(url, httpMethod, timeElapsedInMilliseconds, httpStatusCode)
setAttributeForIOS(key, value)
setUserIdForIOS(value)
crashNowForIOS(value)
incrementAttributeForIOS(key, value)
recordCustomEventForIOS(eventType, eventName, eventAttributes)
Android (NewRelicSDK.*)
noticeNetworkRequestForIOS(url, method, statusCode, startTimeMs, endTimeMs, bytesSent, bytesReceived)
noticeNetworkRequestFailureForIOS(url, method, startTime, endTime, exceptionString)
setAttributeForIOS(key, value)
setUserIdForIOS(value)
crashNowForIOS(value)
incrementAttributeForIOS(key, value)
recordCustomEventForIOS(eventType, eventName, eventAttributes)