Giter Site home page Giter Site logo

newrelic-cordova-plugin's Introduction

Community Plus header

Android Testsuite iOS Testsuite

New Relic plugin for Cordova

The official New Relic Cordova plugin for iOS and Android.

When added the New Relic Cordova plugin will

  • Detect the platforms added to your Cordova application and apply the most recent release of the appropriate New Relic Mobile agent (Android , iOS )
  • Add post-build scripts for uploading iOS symbolication files
  • Upload Android Proguard mapping files
  • Automatically instrument mobile applications built via Cordova

Installation

Prerequisites

  1. Cordova 7.x or newer
  2. Node 6.0 or newer
  3. Cordova CLI tools
  4. Android and iOS Cordova platforms
  5. New Relic Mobile application tokens

Make sure you have fulfilled the prerequisites for adding the Android or iOS platform to your Cordova project.

If you don't have a New Relic account, create a free trial and add an application from your account page. We suggest using separate applications for iOS and Android.

Finally, copy the application tokens from your New Relic applications page, and have them ready for the next step. You only need to copy the application tokens of the platforms you are building on.

Adding the plugin

Change to your Cordova project directory and add the plugin to your project using the Cordova command line tool. The --variable argument is used to pass application tokens to the plugin.

# Install from github repository
cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="{ios-app-token}" --variable ANDROID_APP_TOKEN="{android-app-token}"

Agent Configuration Options

These options are only available on Cordova plugin v6.2.1 and above.

The --variable argument can also be used to add optional configuration options on agent start to the plugin.

# Disable Crash Reporting
cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="{ios-app-token}" --variable ANDROID_APP_TOKEN="{android-app-token}" --variable CRASH_REPORTING_ENABLED="false"

Currently, the plugin supports the following agent configuration options:

  • CRASH_REPORTING_ENABLED: Enable or disable crash reporting.
    • Possible values are true and false. Defaults to true.
  • DISTRIBUTED_TRACING_ENABLED: Enable or disable the adding of distributed tracing headers to network requests.
    • Possible values are true and false. Defaults to true.
  • INTERACTION_TRACING_ENABLED: Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested. This will disable default and custom interactions.
    • Possible values are true and false. Defaults to true.
  • DEFAULT_INTERACTIONS_ENABLED: Enable or disable default interactions. Trace instrumentation still occurs, but no traces are harvested. This will enable or disable default interactions only while custom interactions remain enabled.
    • Possible values are true and false. Defaults to true.
  • LOGGING_ENABLED: Enable or disable agent logging.
    • Possible values are true and false. Defaults to true.
  • LOG_LEVEL: Specifies the log level.
    • Possible values are ERROR (least verbose), WARNING INFO, VERBOSE, DEBUG, AUDIT (most verbose).
    • Defaults to INFO on Android and WARNING on iOS.
  • WEB_VIEW_INSTRUMENTATION (iOS ONLY): Enable (default) or disable automatic WKWebView instrumentation.
    • Possible values are true and false. Defaults to true.
  • COLLECTOR_ADDRESS: Specifies the URI authority component of the harvest data upload endpoint.
  • CRASH_COLLECTOR_ADDRESS: Specifies the authority component of the crash data upload URI.
  • FEDRAMP_ENABLED: Enable or disable reporting data using different endpoints for US government clients.
    • Possible values are true and false. Defaults to false.
  • CONSOLE_LOGS_ENABLED: Enable or disable reporting javascript console logs as custom events.
    • Possible values are true and false. Defaults to false.
  • OFFLINE_STORAGE_ENABLED: Enable or disable offline data storage when no internet connection is available. .
    • Possible values are true and false. Defaults to true.

Updating the plugin

Update the New Relic Cordova plugin to the latest released version easily via the following command:

cordova plugin update

Ionic Native Install

 ionic cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="{ios-app-token}" --variable ANDROID_APP_TOKEN="{android-app-token}"
 
 npm install @awesome-cordova-plugins/newrelic

Usage

Our plugin uses the same APIs as our native agents. See the examples below for usage and for more detail see: New Relic IOS SDK doc or Android SDK.

Ionic

For those using Ionic, you can import our plugin by using awesome-cordova-plugins.

  import { NewRelic } from '@awesome-cordova-plugins/newrelic';

Javascript

Methods in our plugin in Cordova can be called by importing NewRelic from plugins/newrelic-cordova-plugin/www/js or by using window.NewRelic.

Typescript

In TypeScript, you'll have to define our plugin before using it: declare const NewRelic: any;

noticeHttpTransaction(url: string, method: string, status: number, startTime: number, endTime: number, bytesSent: number, bytesReceived: number, body?: string)

The New Relic Cordova plugin automatically collects HTTP transactions, but if you want to manually record HTTP transactions, use this method to do so.

    NewRelic.noticeHttpTransaction('https://fakewebsiteurl.com', 'GET', 200, Date.now(), Date.now(), 0, 100000, 'fake request body');

setUserId(userId: string): void;

Set a custom user identifier value to associate user sessions with analytics events and attributes.

   NewRelic.setUserId("CORDOVA12934");

setAttribute(attributeName: string, value: boolean | number | string): void;

Creates a session-level attribute shared by multiple mobile event types. Overwrites its previous value and type each time it is called.

   NewRelic.setAttribute('CordovaCustomAttrNumber', 37);

removeAttribute(name: string, value: boolean | number | string): void;

This method removes the attribute specified by the name string..

   NewRelic.removeAttribute('CordovaCustomAttrNumber');

incrementAttribute(name: string, value?: number): void;

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

    NewRelic.incrementAttribute('CordovaCustomAttrNumber');
    NewRelic.incrementAttribute('CordovaCustomAttrNumber', 5);

Removes all attributes from the session

    NewRelic.removeAllAttributes();

recordBreadcrumb(eventName: string, attributes?: {[key: string]: boolean | number | string}): void;

Track app activity/screen that may be helpful for troubleshooting crashes.

   NewRelic.recordBreadcrumb("shoe", {"shoeColor": "blue","shoesize": 9,"shoeLaces": true});

recordCustomEvent(eventType: string, eventName?: string, attributes?: {[key: string]: boolean | number | string}): void;

Creates and records a custom event for use in New Relic Insights.

   NewRelic.recordCustomEvent("mobileClothes", "pants", {"pantsColor": "blue","pantssize": 32,"belt": true});

startInteraction(interactionName: string, cb?: function): Promise<InteractionId>;

Track a method as an interaction.

endInteraction(id: InteractionId): void;

End an interaction (Required). This uses the string ID for the interaction you want to end. This string is returned when you use startInteraction() and as a parameter to the provided callback function.

 const badApiLoad = async () => {
   const interactionId = await NewRelic.startInteraction('StartLoadBadApiCall');
   console.log(interactionId);
   const url = 'https://cordova.apache.org/moviessssssssss.json';
   fetch(url)
     .then((response) => response.json())
     .then((responseJson) => {
       console.log(responseJson);
       NewRelic.endInteraction(interactionId);
     }) .catch((error) => {
       NewRelic.endInteraction(interactionId);
       console.error(error);
     });

crashNow(message?: string): void;

Throws a demo run-time exception to test New Relic crash reporting.

    NewRelic.crashNow();
    NewRelic.crashNow("New Relic example crash message");

currentSessionId(): Promise<sessionId>;

Returns the current session ID. This method is useful for consolidating monitoring of app data (not just New Relic data) based on a single session definition and identifier.

    let sessionId = await NewRelic.currentSessionId();

noticeNetworkFailure(url: string, httpMethod: string, startTime: number, endTime: number, failure: string): void;

Records network failures. If a network request fails, use this method to record details about the failures. In most cases, place this call inside exception handlers, such as catch blocks. Supported failures are: Unknown, BadURL, TimedOut, CannotConnectToHost, DNSLookupFailed, BadServerResponse, SecureConnectionFailed

    NewRelic.noticeNetworkFailure('https://fakewebsite.com', 'GET', Date.now(), Date.now(), 'BadURL');

recordMetric(name: string, category: string, value?: number, countUnit?: string, valueUnit?: string): void;

Records custom metrics (arbitrary numerical data), where countUnit is the measurement unit of the metric count and valueUnit is the measurement unit for the metric value. If using countUnit or valueUnit, then all of value, countUnit, and valueUnit must all be set. Supported measurements for countUnit and valueUnit are: PERCENT, BYTES, SECONDS, BYTES_PER_SECOND, OPERATIONS

    NewRelic.recordMetric('CordovaCustomMetricName', 'CordovaCustomMetricCategory');
    NewRelic.recordMetric('CordovaCustomMetricName', 'CordovaCustomMetricCategory', 12);
    NewRelic.recordMetric('CordovaCustomMetricName', 'CordovaCustomMetricCategory', 13, 'PERCENT', 'SECONDS');

setMaxEventBufferTime(maxBufferTimeInSeconds: number): void;

Sets the event harvest cycle length. Default is 600 seconds (10 minutes). Minimum value can not be less than 60 seconds. Maximum value should not be greater than 600 seconds.

    NewRelic.setMaxEventBufferTime(60);

setMaxEventPoolSize(maxSize: number): void;

Sets the maximum size of the event pool stored in memory until the next harvest cycle. Default is a maximum of 1000 events per event harvest cycle. When the pool size limit is reached, the agent will start sampling events, discarding some new and old, until the pool of events is sent in the next harvest cycle.

    NewRelic.setMaxEventPoolSize(2000);

setMaxOfflineStorageSize(megaBytes: number): void;

Sets the maximum size of total data that can be stored for offline storage.By default, mobile monitoring can collect a maximum of 100 megaBytes of offline storage. When a data payload fails to send because the device doesn't have an internet connection, it can be stored in the file system until an internet connection has been made. After a typical harvest payload has been successfully sent, all offline data is sent to New Relic and cleared from storage.

    NewRelic.setMaxOfflineStorageSize(200);

The following methods allow you to set some agent configurations after the agent has started:

By default, these configurations are already set to true on agent start.

analyticsEventEnabled(enabled: boolean) : void;

FOR ANDROID ONLY. Enable or disable the collecton of event data.

    NewRelic.analyticsEventEnabled(true);

networkRequestEnabled(enabled: boolean) : void;

Enable or disable reporting successful HTTP requests to the MobileRequest event type.

    NewRelic.networkRequestEnabled(true);

networkErrorRequestEnabled(enabled: boolean) : void;

Enable or disable reporting network and HTTP request errors to the MobileRequestError event type.

    NewRelic.networkErrorRequestEnabled(true);

shutdown() : void;

Shut down the agent within the current application lifecycle during runtime.

    NewRelic.shutdown();

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events. After header fields have been added using this function, if the headers are in a network call they will be included in networking events in NR1.

  NewRelic.addHTTPHeadersTrackingFor(["Car"]);

httpRequestBodyCaptureEnabled(enabled: boolean) : void;

Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events.

    NewRelic.httpRequestBodyCaptureEnabled(true);

Error Reporting

recordError(err: Error, attributes?: {[key: string]: boolean | number | string}) : void;

Records JavaScript errors for Cordova. It is useful to add this method by adding it to the error handler of the framework that you are using. Here are some examples below:

Angular

Angular 2+ exposes an ErrorHandler class to handle errors. You can implement New Relic by extending this class as follows:

import { ErrorHandler, Injectable } from '@angular/core';
import { NewRelic } from "@awesome-cordova-plugins/newrelic";

@Injectable()
export class GlobalErrorHandler extends ErrorHandler {
  constructor() {
    super();
  }
  handleError(error: any): void {
    NewRelic.recordError(error);
    super.handleError(error);
  }
}

Then, you'll need to let Angular 2 know about this new error handler by listing overrides for the provider in app.module.ts:

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,HttpClientModule],
  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },{provide: ErrorHandler, useClass: GlobalErrorHandler}],
  bootstrap: [AppComponent],
})

React

React 16+ has added error boundary components that catch errors that bubble up from child components. These are very useful for tracking errors and reporting errors to New Relic.

import React, { Component } from "react";
import { NewRelic } from "@awesome-cordova-plugins/newrelic";

export class ErrorBoundary extends Component {
    componentDidCatch(error, errorInfo) {
        if (errorInfo && errorInfo.componentStack) {
            // Optional line to print out the component stack for debugging.
            console.log(errorInfo.componentStack);
        }

        NewRelic.recordError(error);
        this.setState({ error });
    }

    render() {
        // Render error messages or other components here.
    }
}

Redux

You can create Redux Middleware and apply it to your store. This will allow you to report any errors to New Relic.

import { NewRelic } from "@awesome-cordova-plugins/newrelic";

const NewRelicLogger = store => next => action => {
    try {
        // You can log every action as a custom event
        NewRelic.recordCustomEvent("eventType", "eventName", action);
        return next(action)
    } catch (err) { 

        // 
        NewRelic.recordBreadcrumb("NewRelicLogger error", store.getState());

        // Record the JS error to New Relic
        NewRelic.recordError(err);
    }
}

export default NewRelicLogger;

Make sure that the middleware is applied when creating your store:

import { createStore, applyMiddleware } from "redux"
import NewRelicLogger from "./middleware/NewRelicLogger"

const store = createStore(todoApp, applyMiddleware(NewRelicLogger));

Vue

Vue has a global error handler that reports native JavaScript errors and passes in the Vue instance. This handler will be useful for reporting errors to New Relic.

import { NewRelic } from "@awesome-cordova-plugins/newrelic";

Vue.config.errorHandler = (err, vm, info) => {

    // Record properties passed to the component if there are any
    if(vm.$options.propsData) {
        NewRelic.recordBreadcrumb("Props passed to component", vm.$options.propsData);
    }

    // Get the lifecycle hook, if present
    let lifecycleHookInfo = 'none';
    if (info){
        lifecycleHookInfo = info;
    }

    // Record a breadcrumb with more details such as component name and lifecycle hook
    NewRelic.recordBreadcrumb("Vue Error", { 'componentName': vm.$options.name, 'lifecycleHook': lifecycleHookInfo })

    // Record the JS error to New Relic
    NewRelic.recordError(error);
}

How to see JSErrors(Fatal/Non Fatal) in NewRelic One?

Cordova Plugin v6.2.0 and above:

JavaScript errors can be seen in the Handled Exceptions tab in New Relic One. You will be able to see the event trail, attributes, and stack trace for every JavaScript error recorded.

You can also build a dashboard for these errors using this query:

SELECT * FROM MobileHandledException SINCE 24 hours ago

Cordova Plugin v6.0.0 - v6.1.0

There is no section for JavaScript errors, but you can see JavaScript errors in custom events and also query them in NRQL explorer.

Screen Shot 2022-02-10 at 12 41 11 PM

You can also build dashboard for errors using this query:

SELECT jsAppVersion,name,Message,errorStack,isFatal FROM `JS Errors` SINCE 24 hours ago

Uploading dSYM files

Our iOS agent includes a Swift script intended to be run from a build script in your target's build phases in XCode. The script automatically uploads dSYM files in the background (or converts your dSYM to the New Relic map file format), and then performs a background upload of the files needed for crash symbolication to New Relic.

To invoke this script during an XCode build:

  1. Copy the dsym-upload-tools folder from this repository: https://github.com/newrelic/newrelic-ios-agent-spm, to your projects SRCROOT folder first.
  2. In Xcode, select your project in the navigator, then click on the application target.
  3. Select the Build Phases tab in the settings editor.
  4. Click the + icon above Target Dependencies and choose New Run Script Build Phase. Ensure the new build script is the very last build script.
  5. Add the following lines of code to the new phase and replace APP_TOKEN with your iOS application token.
    1. If there is a checkbox below Run script that says "Run script: Based on Dependency analysis" please make sure it is not checked.

Cordova Plugin 6.2.4 or higher

ARTIFACT_DIR="${BUILD_DIR%Build/*}"
SCRIPT=`/usr/bin/find "${SRCROOT}" "${ARTIFACT_DIR}" -type f -name run-symbol-tool | head -n 1`
/bin/sh "${SCRIPT}" "APP_TOKEN"

Cordova Plugin 6.2.3 or lower

SCRIPT=`/usr/bin/find "${SRCROOT}" -name newrelic_postbuild.sh | head -n 1`

if [ -z "${SCRIPT}"]; then
 ARTIFACT_DIR="${BUILD_DIR%Build/*}SourcePackages/artifacts"
 SCRIPT=`/usr/bin/find "${ARTIFACT_DIR}" -name newrelic_postbuild.sh | head -n 1`
fi

/bin/sh "${SCRIPT}" "APP_TOKEN"

Note: The automatic script requires bitcode to be disabled. You should clean and rebuild your app after adding the script.

Missing dSYMs

The automatic script will create an upload_dsym_results.log file in your project's iOS directory, which contains information about any failures that occur during symbol upload.

If dSYM files are missing, you may need to check Xcode build settings to ensure the file is being generated. Frameworks which are built locally have separate build settings and may need to be updated as well.

Build settings:

Debug Information Format : Dwarf with dSYM File
Deployment Postprocessing: Yes
Strip Linked Product: Yes
Strip Debug Symbols During Copy : Yes

Contributing Code

We welcome code contributions (in the form of pull requests) from our user community. Before submitting a pull request please review these guidelines.

Following these helps us efficiently review and incorporate your contribution and avoid breaking your code with future changes to the agent.

License

Copyright (c) 2017 - Present New Relic. All rights reserved. For New Relic agent license details see:

newrelic-cordova-plugin's People

Contributors

bryce-buchanan avatar coreyarnold avatar github-actions[bot] avatar ipiranga-atq avatar jopache avatar kennyt276 avatar mchavez-newrelic avatar ndesai-newrelic avatar rennanc avatar shamsundhar avatar stevesum avatar xixiapdx avatar ywang-nr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

newrelic-cordova-plugin's Issues

Error: EPERM: operation not permitted, symlink 'Versions/A/Headers/'

When running ionic repair it runs ionic cordova prepare and only for the newrelic plugin it has this error:

Installing "newrelic-cordova-plugin" for android
Failed to install 'newrelic-cordova-plugin': Error: EPERM: operation not permitted, symlink 'Versions/A/Headers/' -> 'plugins/newrelic-cordova-plugin/libs/ios/NewRelicAgent.framework/Headers'
at Object.symlinkSync (node:fs:1705:3)
at module.exports (C:_projects...\plugins\newrelic-cordova-plugin\hooks\ios\before_plugin_install.js:12:12)
at runScriptViaModuleLoader (C:\Users\hknaus\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:157:32)
at runScript (C:\Users\hknaus\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:136:12)
at C:\Users\hknaus\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:108:40
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Failed to restore plugin "newrelic-cordova-plugin". You might need to try adding it again. Error: Error: EPERM: operation not permitted, symlink 'Versions/A/Headers/' -> 'plugins/newrelic-cordova-plugin/libs/ios/NewRelicAgent.framework/Headers'

All other cordova plugins install without issue.

'NewRelicAgent/NewRelic.h' file not found

Hi,

I've been using Newrelic for a while with Cordova 9. No problem.
Now, I'm trying to switch to Capacitor however the build fails with NewRelicAgent/NewRelic.h file not found error.

I'm using my existing project and just add Capacitor support.

Does NewRelic supports Capacitor?

Thank you
Wils

Could not find method compile() for arguments [com.newrelic.agent.android:android-agent:6.9.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

After adding this plugin to cordova android project, build is failing with below error.

Could not find method compile() for arguments [com.newrelic.agent.android:android-agent:6.9.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Cordova version - 11.0.0
Cordova-Android - 11.0.0

Appstore submission issue: ITMS-91056: Invalid privacy manifest

Getting following error while submitting an iOS application:

ITMS-91056: Invalid privacy manifest - The PrivacyInfo.xcprivacy file from the following path is invalid: “Frameworks/NewRelic.framework/PrivacyInfo.xcprivacy”. Keys and values in any privacy manifest must be in a valid format. For more details about privacy manifest files, visit: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files.

Can anyone please help on the same?.

image

Adding plugin breaks CocoaPods in iOS

I've got a Cordova plugin that uses Cocoapods to reference a dependency. The build runs just fine when adding my plugin, however if I add this plugin as well, it breaks the 'Pod Install' command so the dependencies never get referenced correctly, causing the build of my iOS project to fail.

The error I'm seeing in the 'pod install' command is the following:

runtimeError - [!] Xcodeproj doesn't know about the following attributes {"uuid"=>"undefined"} for the 'PBXShellScriptBuildPhase' isa.
If this attribute was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new
/Users/jose.pacheco/.rvm/gems/ruby-2.4.1/gems/xcodeproj-1.5.2/lib/xcodeproj/project/object.rb:321:in `configure_with_plist'
/Users/jose.pacheco/.rvm/gems/ruby-2.4.1/gems/xcodeproj-1.5.2/lib/xcodeproj/project.rb:261:in `new_from_plist'
/Users/jose.pacheco/.rvm/gems/ruby-2.4.1/gems/xcodeproj-1.5.2/lib/xcodeproj/project/object.rb:350:in `object_with_uuid'

And looking through the plugin scripts, it looks like installing the plugin adds this to the project.pbxproj file

751B37AA16934125868FBCA2 /* "New Relic dSYM Upload" */ = {
			isa = PBXShellScriptBuildPhase;
			buildActionMask = 2147483647;
			files = (
			);
			inputPaths = (
			);
			name = "New Relic dSYM Upload";
			outputPaths = (
			);
			runOnlyForDeploymentPostprocessing = 0;
			shellPath = /bin/sh;
			shellScript = "SCRIPT=`/usr/bin/find \"${SRCROOT}\" -name newrelic_postbuild.sh | head -n 1`;/bin/sh \"${SCRIPT}\" \"key omitted\"; ";
			showEnvVarsInLog = 0;
			uuid = undefined;
		};

looks like the uuid = undefined (second to last line above) is what is causing all the trouble. If I remove the line manually, then the project will build, however this does not work with my continuous integration as it requires pulling down the repo, adding the plugins, then building and is not user intervention friendly.

Is there any way to remove the uuid = undefined or alleviate the issue? What is it even used for?

Android Gradle v5.0 - Cordova compilation error: cannot fin symbol import com.newrelic.agent.android

Hi,

Having issue when trying to integrate Android Apps with our Cordova plugin (https://github.com/newrelic/newrelic-cordova-plugin). However, they're getting complication error while building their Apps, please see attached screenshot re the error.

Android platform 9.0, Android grade version 5.0, app build by Ionic version 3.6.
![image002]

(https://user-images.githubusercontent.com/30440097/111939172-a4cbd180-8b1f-11eb-802d-df42129b2158.png)

Sounds like some compatibility issue? Do we have newer version of the Cordova plug-in?

Any help would be much appreciate,

Thank you,

Unable to compile app with latest code

Hello newrelic team,

With recent builds i am getting below error with my configuration. Any help to point me what i am missing will be much appreciated.

in my package.json I have

my configuration:

devDependencies:
"newrelic-cordova-plugin": "git+https://github.com/newrelic/newrelic-cordova-plugin.git",

cordova:
 "newrelic-cordova-plugin": {
                "IOS_APP_TOKEN": "xx-NRMA",
                "ANDROID_APP_TOKEN": "xx-NRMA",
                "PLUGIN_VERSION": "5.0.0",
                "ANDROID_AGENT_VER": "6.11.1"
            }


Compilation out

:CordovaLib:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.


> Task :app:compileReleaseJavaWithJavac
\product\build\release\platforms\android\app\src\main\java\com\newrelic\cordova\plugin\NewRelicCordovaPlugin.java:14: error: cannot find symbol
import com.newrelic.agent.android.HttpHeaders;
                                 ^
  symbol:   class HttpHeaders
  location: package com.newrelic.agent.android
\product\build\release\platforms\android\app\src\main\java\com\newrelic\cordova\plugin\NewRelicCordovaPlugin.java:460: error: cannot find symbol
                    NewRelic.addHTTPHeadersTrackingFor(headerList);
                            ^
  symbol:   method addHTTPHeadersTrackingFor(List<String>)
  location: class NewRelic
\product\build\release\platforms\android\app\src\main\java\com\newrelic\cordova\plugin\NewRelicCordovaPlugin.java:465: error: cannot find symbol
                    List<String> arr = new ArrayList<>(HttpHeaders.getInstance().getHttpHeaders());
                                                       ^
  symbol:   variable HttpHeaders
  location: class NewRelicCordovaPlugin

Any Help to point what i am missing will be helpful.

Thanks
Kay

Cannot add plugin after upgrading cordova 11 to 12

After upgrading Cordova version from 11 to 12, running cordova prepare or cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="{ios-app-token}" --variable ANDROID_APP_TOKEN="{android-app-token}" exactly as instructed in the documentation results in the following error message
Failed to fetch plugin https://github.com/newrelic/newrelic-cordova-plugin.git via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. CordovaError: Error: Command failed with exit code 1: npm install https://github.com/newrelic/newrelic-cordova-plugin.git --save-dev

There seems to be a problem with npm install. Running npm install https://github.com/newrelic/newrelic-cordova-plugin.git --save-dev gives me the same error, adding the --legacy-peer-deps flag, however, installs the plugin successfully. Anyone know which change between cordova 11 and 12 caused this to happen and any solutions?

Unable to see any response in one.newrelic.com

Hello Relic team, I am trying to integrate new-relic to my app.

Environment:

Cordova: 10.0.0
Ionic: 6.14.1
NPM: 7.13.0
Node: v12.16.0`

Steps:

I generated a key in new-relic mobile monitoring for iOS.

I added new-relic to my application as mentioned in documentation

ionic cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="{ioskey}" --variable ANDROID_APP_TOKEN="{androidkey}"

I am able to see package.json changes

While running

ionic cordova build --prod --release ios

i am getting below error

/Plugins/newrelic-cordova-plugin/NewRelicAgent.framework/NewRelicAgent(NRMATableViewIntrumentation.o), building for iOS Simulator, but linking in object file built for iOS, file '<<apname>>/Plugins/newrelic-cordova-plugin/NewRelicAgent.framework/NewRelicAgent' for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I tried opening my .xcodeproj and running the same project in xcode. All seems to work as expected

I am also seeing the NewRelicAgent.framework added in frameworks.

In one.newrelic.com i am not seeing any httprequest or any info getting passed from my app.

Any help appreciated.

HTTP requests not tracking in Android

HTTP requests do not seem to be tracking in Android, but are tracking in iOS. any idea for the difference?

currently using cordova 8.0.0 and cordova-android 7.0.0.

when attempting to view results on New Relic Mobile, any of the HTTP requests pages return "No data matches this filter...".

Cannot create a customAttribute with this plugin

RIght the only way to create custom attributes is to create an iframe to hold newrelic custom javascript functions to send custom information about the app. Is it possible to extend the plugin so it would have a public interface to create transactions, send custom attributes etc?

Doesn't work with Phonegap Build

I tried using this plugin with Phonegap Build and it returns the following error in the build process. Would love to see whether this plugin supports phonegap build.

`/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:14: error: package com.newrelic.agent.android does not exist
import com.newrelic.agent.android.Agent;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:15: error: package com.newrelic.agent.android does not exist
import com.newrelic.agent.android.ApplicationPlatform;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:16: error: package com.newrelic.agent.android does not exist
import com.newrelic.agent.android.NewRelic;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:17: error: package com.newrelic.agent.android.analytics does not exist
import com.newrelic.agent.android.analytics.AnalyticAttribute;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:18: error: package com.newrelic.agent.android.harvest does not exist
import com.newrelic.agent.android.harvest.DeviceInformation;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:19: error: package com.newrelic.agent.android.logging does not exist
import com.newrelic.agent.android.logging.AgentLog;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:41: error: cannot find symbol
NewRelic.withApplicationToken(appToken)
^
symbol: variable NewRelic
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:45: error: cannot find symbol
final DeviceInformation devInfo = Agent.getDeviceInformation();
^
symbol: class DeviceInformation
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:45: error: cannot find symbol
final DeviceInformation devInfo = Agent.getDeviceInformation();
^
symbol: variable Agent
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:47: error: cannot find symbol
devInfo.setApplicationPlatform(ApplicationPlatform.Cordova);
^
symbol: variable ApplicationPlatform
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:50: error: cannot find symbol
NewRelic.setAttribute(AnalyticAttribute.APPLICATION_PLATFORM_VERSION_ATTRIBUTE, pluginVersion);
^
symbol: variable AnalyticAttribute
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:50: error: cannot find symbol
NewRelic.setAttribute(AnalyticAttribute.APPLICATION_PLATFORM_VERSION_ATTRIBUTE, pluginVersion);
^
symbol: variable NewRelic
location: class NewRelicCordovaPlugin
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
12 errors
:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.812 secs
Error: /project/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Warning: AndroidManifest.xml already defines debuggable (in http://schemas.android.com/apk/res/android); using existing value in manifest.

/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:14: error: package com.newrelic.agent.android does not exist
import com.newrelic.agent.android.Agent;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:15: error: package com.newrelic.agent.android does not exist
import com.newrelic.agent.android.ApplicationPlatform;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:16: error: package com.newrelic.agent.android does not exist
import com.newrelic.agent.android.NewRelic;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:17: error: package com.newrelic.agent.android.analytics does not exist
import com.newrelic.agent.android.analytics.AnalyticAttribute;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:18: error: package com.newrelic.agent.android.harvest does not exist
import com.newrelic.agent.android.harvest.DeviceInformation;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:19: error: package com.newrelic.agent.android.logging does not exist
import com.newrelic.agent.android.logging.AgentLog;
^
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:41: error: cannot find symbol
NewRelic.withApplicationToken(appToken)
^
symbol: variable NewRelic
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:45: error: cannot find symbol
final DeviceInformation devInfo = Agent.getDeviceInformation();
^
symbol: class DeviceInformation
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:45: error: cannot find symbol
final DeviceInformation devInfo = Agent.getDeviceInformation();
^
symbol: variable Agent
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:47: error: cannot find symbol
devInfo.setApplicationPlatform(ApplicationPlatform.Cordova);
^
symbol: variable ApplicationPlatform
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:50: error: cannot find symbol
NewRelic.setAttribute(AnalyticAttribute.APPLICATION_PLATFORM_VERSION_ATTRIBUTE, pluginVersion);
^
symbol: variable AnalyticAttribute
location: class NewRelicCordovaPlugin
/project/src/com/newrelic/cordova/plugin/NewRelicCordovaPlugin.java:50: error: cannot find symbol
NewRelic.setAttribute(AnalyticAttribute.APPLICATION_PLATFORM_VERSION_ATTRIBUTE, pluginVersion);
^
symbol: variable NewRelic
location: class NewRelicCordovaPlugin
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
12 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    at ChildProcess.whenDone (/project/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)`

New version breaks with cordova < 8.0

It seems as though the newest version of newrelic breaks with projects running a version of cordova less than 8.0 (we're currently on 7.1.0). Specifically, we're getting a build path error since the app/ folder doesn't exist. Could you allow backwards compatibility for lesser cordova versions or introduce releases so that we can reference a specific release number in our project? Thanks!

New version breaks backward compatibility

Hi,

The changes in the code in the last couple of months broke compatibility with our software. Could you fix the way you are releasing new versions by creating releases on Git? This way we could make a reference to a specific version the same way we would when referencing any other plugin (i.e. plugin-name@version) thus preventing new versions of this plugin to find its way into our build without the required QA process.

Thanks, Emerson

NullPointerException

We use the start and end interaction from Android native code in our application.
In GooglePlay CrashLog I found this message:
Exception java.lang.NullPointerException: Attempt to invoke virtual method 'void com.newrelic.agent.android.tracing.TraceMachine.completeActivityTrace()' on a null object reference at com.newrelic.agent.android.tracing.TraceMachine.endTrace (TraceMachine.java:191) at com.newrelic.agent.android.NewRelic.endInteraction (NewRelic.java:580)

We use the latest 6.1.0 from the plugin.
The impacted device and os version were the following:

  • Samsung galaxy a52sxq (Galaxy A52s 5G) - Android 13 (SDK 33)

Cordova 8.0.0 compile fails

Ran this command:
cordova plugin add https://github.com/newrelic/newrelic-cordova-plugin.git --variable IOS_APP_TOKEN="removed" --variable ANDROID_APP_TOKEN="removed"

then cordova run android

I get a gradle errror:

$ cordova run android
Android Studio project detected
ANDROID_HOME=/Users/johan/Library/Android/sdk/
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/johan/projects/smrt-system/cordova/platforms/android/build.gradle' line: 63

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method compile() for arguments [com.newrelic.agent.android:android-agent:5.17.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
(node:56675) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/johan/projects/smrt-system/cordova/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/johan/projects/smrt-system/cordova/platforms/android/build.gradle' line: 63

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method compile() for arguments [com.newrelic.agent.android:android-agent:5.17.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
(node:56675) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Is this project compatible with cordova 8? It is the current version of cordova on npm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.