### Manual Method Tracing with TraceMachine API Source: https://github.com/newrelic/newrelic-android-agent/blob/main/docs/TraceMachine.md This snippet demonstrates how to manually start and end a trace for a specific method using the TraceMachine API. It includes entering the method with category parameters and exiting it, with an example of JSON serialization in between. ```java TraceMachine.enterMethod("Class#method", categoryParams); String string = gson.toJson(src, typeOfSrc); TraceMachine.exitMethod() ``` -------------------------------- ### Initiate Command Line Build for Remote Debugging Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Start a command line build after setting GRADLE_OPTS to allow for remote debugging. ```bash ./gradlew clean assembleDebug ``` -------------------------------- ### Get Product Balances Source: https://github.com/newrelic/newrelic-android-agent/blob/main/agent-core/src/test/resources/NetworkRequests.txt Retrieves the balance information for a specific product. ```APIDOC ## GET /products/{productId}/balances ### Description Retrieves the balance information for a specific product. ### Method GET ### Endpoint /products/{productId}/balances ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product. ``` -------------------------------- ### Initialize Root Trace and Trace Machine Source: https://github.com/newrelic/newrelic-android-agent/blob/main/docs/TraceMachine.md This code initializes the root trace, its associated ThreadLocal variables, and the TraceMachine. It also sets up activity history and registers a harvest listener. This is typically called when a new ActivityTrace is started. ```java rootTrace.threadLocalTrace = ThreadLocal rootTrace.threadLocalTraceStack = ThreadLocal rootTrace.activityHistory = List rootTrace.UUID = "628b5a51-521d-2178-6c15-ed1069a8684e" rootTrace.displayName = "Display MainActivity" rootTrace.metricName = "Mobile/Activity/Name/Display MainActivity" rootTrace.metricBackgroundName = "Mobile/Activity/Background/Name/Display MainActivity" rootTrace.entryTimestamp : root trace is created rootTrace.traceMachine = new TraceMachine(rootTrace) pushTraceContext(rootTrace); rootTrace.traceMachine.activityTrace.previousActivity = getLastActivitySighting(); activityHistory.add(new ActivitySighting(rootTrace.entryTimestamp, rootTrace.displayName)); Measurements.startActivity(rootTrace.displayName) addHarvestListener(this) ``` -------------------------------- ### Enter Method Trace Source: https://github.com/newrelic/newrelic-android-agent/blob/main/docs/TraceMachine.md The class rewriter injects a call to TraceMachine.enterMethod() at the beginning of Activity.onCreate() and Fragment.onCreate() overrides to start method tracing. ```java TraceMachine.enterMethod("Activity#onCreate") ``` -------------------------------- ### Get Product Details Source: https://github.com/newrelic/newrelic-android-agent/blob/main/agent-core/src/test/resources/NetworkRequests.txt Retrieves detailed information about a specific product using its unique identifier. ```APIDOC ## GET /products/{productId} ### Description Retrieves detailed information about a specific product. ### Method GET ### Endpoint /products/{productId} ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product. ``` -------------------------------- ### Print DexGuard Mapping File Source: https://github.com/newrelic/newrelic-android-agent/blob/main/samples/agent-test-app/dexguard-qa-project.txt This directive instructs DexGuard to print a mapping file, which is essential for deobfuscating stack traces. The example shows a specific path for a QA variant, with a comment suggesting a more general path for other build variants. ```proguard -printmapping build/outputs/dexguard/mapping/qa/qa-mapping.txt # should be: -printmapping build/outputs/dexguard/mapping//mapping.txt ``` -------------------------------- ### NewRelic Agent Lifecycle Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for starting, checking the status of, and shutting down the New Relic agent. ```APIDOC ## NewRelic Agent Lifecycle Methods ### `start(Context context)` Starts the New Relic agent with the provided application context. ### `isStarted()` Checks if the New Relic agent has been started. ### `shutdown()` Shuts down the New Relic agent. ``` -------------------------------- ### Get Product Transactions Source: https://github.com/newrelic/newrelic-android-agent/blob/main/agent-core/src/test/resources/NetworkRequests.txt Retrieves transaction history for a specific product. ```APIDOC ## GET /products/{productId}/transactions ### Description Retrieves the transaction history for a specific product. ### Method GET ### Endpoint /products/{productId}/transactions ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product. ``` -------------------------------- ### Get Foreign Payment Partners Products Source: https://github.com/newrelic/newrelic-android-agent/blob/main/agent-core/src/test/resources/NetworkRequests.txt Retrieves a list of products associated with a foreign payment partner. ```APIDOC ## GET /payments/foreign-payment/partners/{partnerId}/products ### Description Retrieves a list of products associated with a specific foreign payment partner. ### Method GET ### Endpoint /payments/foreign-payment/partners/{partnerId}/products ### Parameters #### Path Parameters - **partnerId** (string) - Required - The unique identifier of the foreign payment partner. ``` -------------------------------- ### Get Remaining Disposal Amount Source: https://github.com/newrelic/newrelic-android-agent/blob/main/agent-core/src/test/resources/NetworkRequests.txt Retrieves the remaining disposal amount for a specific product. ```APIDOC ## GET /products/{productId}/remaining-disposal-amount ### Description Retrieves the remaining disposal amount for a specific product. ### Method GET ### Endpoint /products/{productId}/remaining-disposal-amount ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product. ``` -------------------------------- ### Build and Run All Checks with Gradle Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Execute this command to build the agent and run all associated checks. ```bash ./gradlew clean build ``` -------------------------------- ### Run Static Analysis with Gradle Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Perform static code analysis using the 'lint' Gradle task. ```bash ./gradlew lint ``` -------------------------------- ### Build Android Agent JAR with Gradle Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Run this command from the project root to build the agent JAR file. ```bash ./gradlew clean assemble ``` -------------------------------- ### Run Unit Tests with Gradle Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Execute unit tests for the agent using this Gradle command. ```bash ./gradlew test ``` -------------------------------- ### Sampler Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Handles the collection of various system and application metrics. ```APIDOC ## Sampler ### Description Responsible for periodically sampling system and application metrics. ### Methods - **init(Context context)**: Initializes the sampler with the application context. - **start()**: Starts the metric sampling process. - **stop()**: Stops the metric sampling process gracefully. - **stopNow()**: Immediately stops the metric sampling process. - **shutdown()**: Shuts down the sampler and releases resources. - **run()**: The main execution method for the sampler (typically called by the scheduler). - **schedule()**: Schedules the next sampling run. - **stop(boolean immediate)**: Stops the sampler, with an option for immediate termination. - **isRunning()**: Checks if the sampler is currently running. - **sample()**: Performs a single sampling cycle for memory and CPU metrics. - **clear()**: Clears all collected samples. - **sampleMemory()**: Samples the current memory usage. - **sampleMemory(ActivityManager activityManager)**: Samples memory usage using a provided ActivityManager. - **sampleCpu()**: Samples the current CPU usage. - **resetCpuSampler()**: Resets the CPU sampling mechanism. - **copySamples()**: Returns a map of the currently collected samples. ``` -------------------------------- ### Get SEPA Transfer Template Source: https://github.com/newrelic/newrelic-android-agent/blob/main/agent-core/src/test/resources/NetworkRequests.txt Retrieves a SEPA transfer template for a given partner and template ID. ```APIDOC ## GET /payments/transfer-templates/partners/self/sepa-transfers/{templateId} ### Description Retrieves a SEPA transfer template. ### Method GET ### Endpoint /payments/transfer-templates/partners/self/sepa-transfers/{templateId} ### Parameters #### Path Parameters - **templateId** (string) - Required - The unique identifier of the SEPA transfer template. ``` -------------------------------- ### MetricStore Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Provides methods for adding, retrieving, and removing metrics from the store, as well as managing metrics by scope. ```APIDOC ## MetricStore ### Description Manages a collection of metrics. ### Methods - **add(Metric metric)**: Adds a metric to the store. - **get(String name)**: Retrieves a metric by its name. - **get(String name, String scope)**: Retrieves a metric by its name and scope. - **getAll()**: Retrieves all metrics in the store. - **getAllByScope(String scope)**: Retrieves all metrics associated with a specific scope. - **getAllUnscoped()**: Retrieves all metrics that are not associated with any scope. - **remove(Metric metric)**: Removes a metric from the store. - **removeAll(List metrics)**: Removes a list of metrics from the store. - **removeAllWithScope(String scope)**: Removes all metrics associated with a specific scope. - **clear()**: Clears all metrics from the store. - **isEmpty()**: Checks if the metric store is empty. ``` -------------------------------- ### OkHttp (Apache License 2.0) Source: https://github.com/newrelic/newrelic-android-agent/blob/main/THIRD_PARTY_NOTICES.md Provides the Apache License 2.0 for the OkHttp library. ```text Copyright 2019 Square, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Agent Configuration and Data Retrieval Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt This section outlines methods for retrieving agent configuration values and data tokens. ```APIDOC ## Methods for Agent Configuration and Data Retrieval ### Description Provides access to various configuration settings and data-related information within the New Relic Android Agent. ### Methods - `boolean collectingNetworkErrors()`: Checks if network error collection is enabled. - `int errorLimit()`: Retrieves the configured limit for errors. - `java.lang.Object getDataToken()`: Gets the data token for the agent. - `java.lang.String getCrossProcessId()`: Retrieves the cross-process identifier. - `long getServerTimestamp()`: Gets the server's current timestamp. - `long getHarvestIntervalInSeconds()`: Retrieves the harvest interval in seconds. - `long getHarvestIntervalInMilliseconds()`: Retrieves the harvest interval in milliseconds. - `long getMaxTransactionAgeInSeconds()`: Gets the maximum transaction age in seconds. - `long getMaxTransactionAgeInMilliseconds()`: Gets the maximum transaction age in milliseconds. - `long getMaxTransactionCount()`: Retrieves the maximum transaction count. - `int getStackTraceLimit()`: Gets the limit for stack trace depth. - `int getResponseBodyLimit()`: Retrieves the limit for response body size. - `boolean isCollectingNetworkErrors()`: Checks if network error collection is enabled. - `int getErrorLimit()`: Retrieves the configured error limit. - `java.lang.String toString()`: Returns a string representation of the object. ``` -------------------------------- ### Print Mapping File Configuration Source: https://github.com/newrelic/newrelic-android-agent/blob/main/samples/agent-test-app/dexguard-project.txt Configures DexGuard to print the mapping file. The comment shows the correct path for variant-specific mapping files. ```proguard # -printmapping mapping.txt # should be: -printmapping build/outputs/dexguard/mapping//mapping.txt ``` -------------------------------- ### Enable Remote Debugging for Gradle Builds (Environment Variable) Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Export GRADLE_OPTS to enable remote debugging for command-line Gradle builds. This suspends the VM until a debugger is attached. ```bash export GRADLE_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5050" ``` -------------------------------- ### TraceMachineInterface Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Provides methods for interacting with the trace machine. ```APIDOC ## TraceMachineInterface Methods ### Description Provides methods to get information about the current thread and its tracing status. ### Methods - `long getCurrentThreadId()`: Retrieves the ID of the current thread. - `java.lang.String getCurrentThreadName()`: Gets the name of the current thread. - `boolean isUIThread()`: Checks if the current thread is the UI thread. ``` -------------------------------- ### ConnectionListener Interface Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Defines the callbacks for connection events. ```APIDOC ## ConnectionListener Interface ### Description An interface for listening to connection events, such as successful connections and disconnections. ### Methods - `void connected(com.newrelic.agent.android.api.v1.ConnectionEvent)`: Called when a connection is established. - `void disconnected(com.newrelic.agent.android.api.v1.ConnectionEvent)`: Called when a connection is terminated. ``` -------------------------------- ### Gson (Apache License 2.0) Source: https://github.com/newrelic/newrelic-android-agent/blob/main/THIRD_PARTY_NOTICES.md Provides the Apache License 2.0 for the Gson library. ```text Copyright 2008 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### DefaultAgentLog Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Implementation of the AgentLog interface for default logging behavior. ```APIDOC ## DefaultAgentLog Class ### Description Implementation of the AgentLog interface for default logging behavior. ### Methods - **setImpl**(com.newrelic.agent.android.logging.AgentLog impl): void - **debug**(java.lang.String message): void - **info**(java.lang.String message): void - **verbose**(java.lang.String message): void - **warning**(java.lang.String message): void - **error**(java.lang.String message): void - **error**(java.lang.String message, java.lang.Throwable throwable): void - **getLevel**(): int - **setLevel**(int level): void ``` -------------------------------- ### Run Regression Tests with Gradle Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md This command runs regression tests for the Gradle plugin, requiring the 'regressions' property. ```bash ./gradlew :plugins:gradle:check -P regressions ``` -------------------------------- ### AgentLog Interface Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Provides methods for logging messages at different levels (debug, info, warning, error) and managing the logging level. ```APIDOC ## AgentLog Interface ### Description Provides methods for logging messages at different levels and managing the logging level. ### Methods - **debug**(java.lang.String message) - **verbose**(java.lang.String message) - **info**(java.lang.String message) - **warning**(java.lang.String message) - **error**(java.lang.String message) - **error**(java.lang.String message, java.lang.Throwable throwable) - **getLevel**(): int - **setLevel**(int level): void ``` -------------------------------- ### Activity Tracking Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for tracking application activities. ```APIDOC ## Activity Tracking Methods ### `isInstrumented()` Checks if the agent is instrumented. ### `startActivity(String activityName)` Starts tracking a new activity. ### `renameActivity(String oldName, String newName)` Renames an existing activity. ### `endActivity(String activityName)` Ends tracking for a specified activity. ### `endActivity(MeasuredActivity activity)` Ends tracking for a `MeasuredActivity` object. ### `endActivityWithoutMeasurement(MeasuredActivity activity)` Ends tracking for a `MeasuredActivity` object without recording measurements. ``` -------------------------------- ### Apache HttpClient Copyright Notice Source: https://github.com/newrelic/newrelic-android-agent/blob/main/THIRD_PARTY_NOTICES.md Provides the copyright notice for Apache HttpClient. ```text Apache HttpClient Copyright 1999-2019 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). ``` -------------------------------- ### ASM (BSD-3) License Source: https://github.com/newrelic/newrelic-android-agent/blob/main/THIRD_PARTY_NOTICES.md Provides the BSD-3 license terms for the ASM bytecode manipulation framework. ```text ASM: a very small and fast Java bytecode manipulation framework Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -------------------------------- ### Enable Remote Debugging for Gradle Builds (Command Line) Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Use these flags on the build command line to enable remote debugging without setting an environment variable. This suspends the build until a debugger attaches. ```bash -Dorg.gradle.debug=true --no-daemon ``` -------------------------------- ### Keep All Code and Resources Source: https://github.com/newrelic/newrelic-android-agent/blob/main/samples/agent-test-app/dexguard-qa-project.txt These directives are used to ensure that all code and resources are kept during the DexGuard processing. While crude and not recommended for release builds, they are helpful for initial debugging to ensure no essential components are removed. ```proguard -keep class * { *; } -keepattributes * -keepresources */* -keepresourcefiles res/** -keepresourcefiles assets/** -keepresourcefiles lib/** -keepresourcexmlattributenames ** ``` -------------------------------- ### Defaults Constants Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Provides access to default configuration values for the New Relic Android Agent. ```APIDOC ## Defaults Constants ### Description Defines default constants used for various New Relic Android Agent configurations. ### Constants - `long MAX_TRANSACTION_COUNT`: Default maximum transaction count. - `long MAX_TRANSACTION_AGE_IN_SECONDS`: Default maximum transaction age in seconds. - `long HARVEST_INTERVAL_IN_SECONDS`: Default harvest interval in seconds. - `long MIN_HARVEST_DELTA_IN_SECONDS`: Default minimum harvest delta in seconds. - `long MIN_HTTP_ERROR_STATUS_CODE`: Default minimum HTTP error status code. - `boolean COLLECT_NETWORK_ERRORS`: Default value for collecting network errors. - `int ERROR_LIMIT`: Default error limit. - `int RESPONSE_BODY_LIMIT`: Default response body limit. - `int STACK_TRACE_LIMIT`: Default stack trace limit. - `float ACTIVITY_TRACE_MIN_UTILIZATION`: Default minimum utilization for activity traces. ``` -------------------------------- ### Setting Gradle Agent Version Source: https://github.com/newrelic/newrelic-android-agent/blob/main/README.md Use this command to set the agent version when running Gradle tasks. This is useful for specifying a particular version for builds or tests. ```bash ./gradlew -Pnewrelic.agent.version=6.10.0 assemble ``` -------------------------------- ### AgentLog Interface Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Provides methods for logging messages at different levels (DEBUG, VERBOSE, INFO, WARNING, ERROR) and retrieving/setting the current log level. ```APIDOC ## AgentLog Interface ### Description Interface for logging messages at various severity levels and managing the log level. ### Methods - **debug(String message)**: Logs a debug message. - **verbose(String message)**: Logs a verbose message. - **info(String message)**: Logs an informational message. - **warning(String message)**: Logs a warning message. - **error(String message)**: Logs an error message. - **error(String message, Throwable throwable)**: Logs an error message with an associated exception. - **getLevel()**: Returns the current logging level. - **setLevel(int level)**: Sets the logging level. ``` -------------------------------- ### NewRelic Agent Configuration Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for configuring the New Relic agent, including setting application tokens, SSL, collector addresses, and logging. ```APIDOC ## NewRelic Configuration Methods ### `withApplicationToken(String token)` Sets the application token for the agent. ### `usingSsl(boolean enabled)` Enables or disables SSL for agent communication. ### `usingCollectorAddress(String address)` Sets a custom collector address for the agent. ### `usingCrashCollectorAddress(String address)` Sets a custom crash collector address for the agent. ### `withLocationServiceEnabled(boolean enabled)` Enables or disables the location service. ### `withLoggingEnabled(boolean enabled)` Enables or disables agent logging. ### `withLogLevel(int level)` Sets the logging level for the agent. ### `withCrashReportingEnabled(boolean enabled)` Enables or disables crash reporting. ``` -------------------------------- ### Pause and Resume Replay for Confidential Screens Source: https://github.com/newrelic/newrelic-android-agent/blob/main/COMPOSE_COMPATIBILITY.md Use this pattern to pause New Relic replay when displaying sensitive information and resume it when the screen is no longer confidential. This ensures that confidential data is not recorded. ```kotlin @Composable fun ConfidentialScreen() { DisposableEffect(Unit) { NewRelic.pauseReplay() onDispose { NewRelic.recordReplay() } } Text("Sensitive Data") } ``` -------------------------------- ### ConnectionEvent Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt This section describes the methods related to ConnectionEvent objects. ```APIDOC ## ConnectionEvent Methods ### Description Provides access to the connection state within a ConnectionEvent. ### Methods - `com.newrelic.agent.android.api.common.ConnectionState getConnectionState()`: Retrieves the current connection state. ``` -------------------------------- ### Harvest Configuration Management Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for saving, loading, and retrieving the agent's harvest configuration. ```APIDOC ## saveHarvestConfiguration ### Description Saves the current harvest configuration. ### Method void ### Parameters - **HarvestConfiguration**: The harvest configuration to save. ## loadHarvestConfiguration ### Description Loads the harvest configuration from storage. ### Method void ## getHarvestConfiguration ### Description Retrieves the current harvest configuration. ### Method HarvestConfiguration ## has ### Description Checks if a specific configuration key exists. ### Method boolean ### Parameters - **String**: The configuration key to check. ## onHarvestConnected ### Description Callback method invoked when the harvest process connects. ### Method void ## onHarvestComplete ### Description Callback method invoked when the harvest process completes. ### Method void ## onHarvestDisconnected ### Description Callback method invoked when the harvest process disconnects. ### Method void ## onHarvestDisabled ### Description Callback method invoked when the harvest process is disabled. ### Method void ## save ### Description Saves a key-value pair to the agent's preferences. ### Method void ### Parameters - **String**: The key. - **String**: The value. ``` -------------------------------- ### Measurement Interface Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Defines the core interface for all measurements, providing access to their properties. ```APIDOC ## Measurement Interface ### Description Defines the core interface for all measurements, providing access to their properties. ### Methods - **getType**(): com.newrelic.agent.android.measurement.MeasurementType - **getName**(): java.lang.String - **getScope**(): java.lang.String - **getStartTime**(): long - **getStartTimeInSeconds**(): double - **getEndTime**(): long - **getEndTimeInSeconds**(): double - **getExclusiveTime**(): long - **getExclusiveTimeInSeconds**(): double ``` -------------------------------- ### Apache Commons Logging Copyright Notice Source: https://github.com/newrelic/newrelic-android-agent/blob/main/THIRD_PARTY_NOTICES.md Provides the copyright notice for Apache Commons Logging. ```text Apache Commons Logging Copyright 2003-2014 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). ``` -------------------------------- ### NullAgentLog Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt A null implementation of the AgentLog interface, useful for disabling logging. ```APIDOC ## NullAgentLog Class ### Description A null implementation of the AgentLog interface, useful for disabling logging. ### Methods - **debug**(java.lang.String message): void - **info**(java.lang.String message): void - **verbose**(java.lang.String message): void - **error**(java.lang.String message): void - **error**(java.lang.String message, java.lang.Throwable throwable): void - **warning**(java.lang.String message): void - **getLevel**(): int - **setLevel**(int level): void ``` -------------------------------- ### View Dispatch Order for Capture Source: https://github.com/newrelic/newrelic-android-agent/blob/main/ANDROID_VIEW_COMPATIBILITY.md Specifies the order in which view-specific captors are checked using `instanceof` to determine the most specific handler for a given view. This order prioritizes more specialized views over generic ones. ```plaintext EditText → CompoundButton → AbsSeekBar → ProgressBar → ImageView → TextView → View (generic) ``` -------------------------------- ### Pause and Resume Replay Recording Source: https://github.com/newrelic/newrelic-android-agent/blob/main/ANDROID_VIEW_COMPATIBILITY.md Use these methods in your Activity or Fragment to pause and resume replay recording, typically for confidential screens. Ensure `NewRelic.pauseReplay()` is called in `onResume()` and `NewRelic.recordReplay()` is called in `onPause()`. ```java NewRelic.pauseReplay(); NewRelic.recordReplay(); ``` -------------------------------- ### BaseMeasurementProducer Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Core methods for measurement production, including type retrieval and measurement draining. ```APIDOC ## getMeasurementType ### Description Retrieves the type of measurement produced by this producer. ### Method com.newrelic.agent.android.measurement.MeasurementType ### Parameters None ``` ```APIDOC ## produceMeasurement ### Description Produces a single measurement. ### Method void ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **measurement** (com.newrelic.agent.android.measurement.Measurement) - Required - The measurement to produce. ``` ```APIDOC ## produceMeasurements ### Description Produces a collection of measurements. ### Method void ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **measurements** (java.util.Collection) - Required - The collection of measurements to produce. ``` ```APIDOC ## drainMeasurements ### Description Drains all produced measurements from the producer. ### Method java.util.Collection ### Parameters None ``` -------------------------------- ### TransactionData Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt This section details the methods available for interacting with TransactionData objects. ```APIDOC ## TransactionData Methods ### Description Provides methods to access and manipulate transaction data, including URL, status codes, error codes, and data transfer sizes. ### Methods - `java.lang.String getUrl()`: Retrieves the transaction URL. - `java.lang.String getCarrier()`: Gets the carrier information for the transaction. - `int getStatusCode()`: Retrieves the HTTP status code of the transaction. - `int getErrorCode()`: Gets the error code associated with the transaction. - `void setErrorCode(int)`: Sets the error code for the transaction. - `long getBytesSent()`: Retrieves the number of bytes sent during the transaction. - `long getBytesReceived()`: Gets the number of bytes received during the transaction. - `java.lang.String getAppData()`: Retrieves application-specific data for the transaction. - `java.util.List asList()`: Returns the transaction data as a list. - `long getTimestamp()`: Gets the transaction timestamp. - `float getTime()`: Retrieves the transaction duration. - `com.newrelic.agent.android.api.common.TransactionData clone()`: Creates a clone of the TransactionData object. - `java.lang.String toString()`: Returns a string representation of the TransactionData object. ``` -------------------------------- ### MethodMeasurementProducer Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for producing measurements related to method execution. ```APIDOC ## produceMeasurement ### Description Produces a measurement for a method trace. ### Method void ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **trace** (com.newrelic.agent.android.tracing.Trace) - Required - The trace information for the method. ``` -------------------------------- ### Measurement and Producer Management Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for managing measurement producers and consumers. ```APIDOC ## Measurement and Producer Management Methods ### `addMeasurementProducer(MeasurementProducer producer)` Adds a measurement producer. ### `removeMeasurementProducer(MeasurementProducer producer)` Removes a measurement producer. ### `addMeasurementConsumer(MeasurementConsumer consumer)` Adds a measurement consumer. ### `removeMeasurementConsumer(MeasurementConsumer consumer)` Removes a measurement consumer. ### `process()` Processes pending measurements. ``` -------------------------------- ### AgentLogManager Class Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Manages the AgentLog instance, providing access to the current log implementation and allowing it to be set. ```APIDOC ## AgentLogManager Class ### Description Manages the singleton instance of the AgentLog. ### Fields - **instance**: The default AgentLog instance. ### Methods - **getAgentLog()**: Retrieves the current AgentLog instance. - **setAgentLog(AgentLog agentLog)**: Sets a custom AgentLog instance. ``` -------------------------------- ### NewRelic Interaction Tracking Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for tracking user interactions within the application. ```APIDOC ## NewRelic Interaction Tracking Methods ### `startInteraction(Context context, String name)` Starts a new user interaction with a given name. ### `startInteraction(Context context, String name, boolean allowDuplicates)` Starts a new user interaction with a given name and allows specifying if duplicates are allowed. ### `setInteractionName(String name)` Sets the name for the current interaction. ``` -------------------------------- ### DeviceForm Enum Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Represents different device form factors. ```APIDOC ## DeviceForm Enum ### Description An enumeration representing various device form factors. ### Enum Values - `UNKNOWN`: Unknown device form factor. - `SMALL`: Small device form factor. - `NORMAL`: Normal device form factor. - `LARGE`: Large device form factor. - `XLARGE`: Extra-large device form factor. ### Methods - `com.newrelic.agent.android.api.v1.DeviceForm[] values()`: Returns an array of all enum values. - `com.newrelic.agent.android.api.v1.DeviceForm valueOf(java.lang.String)`: Returns the enum value by its string name. ``` -------------------------------- ### Exit Method Trace Source: https://github.com/newrelic/newrelic-android-agent/blob/main/docs/TraceMachine.md The class rewriter injects calls to TraceMachine.exitMethod() and ApplicationStateMonitor.onStop() at the end of Activity.onCreate() and Fragment.onCreate() overrides to end method tracing. ```java TraceMachine.exitMethod(),activityName") ``` -------------------------------- ### Traced Method Addition Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Method for adding traced methods. ```APIDOC ## Traced Method Addition Method ### `addTracedMethod(Trace trace)` Adds a traced method to the agent. ``` -------------------------------- ### Custom Metric Addition Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for adding custom metrics. ```APIDOC ## Custom Metric Addition Methods ### `addCustomMetric(String category, String name, int count, double min, double max)` Adds a custom metric with count, minimum, and maximum values. ### `addCustomMetric(String category, String name, int count, double min, double max, MetricUnit countUnit, MetricUnit valueUnit)` Adds a custom metric with count, minimum, maximum values, and units for count and value. ### `addHttpError(String name, int count, Stringフェイルメッセージ, Map attributes)` Adds an HTTP error with associated attributes. ### `addHttpError(String name, int count, Stringフェイルメッセージ, Map attributes, ThreadInfo threadInfo)` Adds an HTTP error with associated attributes and thread information. ### `addHttpError(TransactionData transactionData, Stringフェイルメッセージ, Map attributes)` Adds an HTTP error associated with transaction data. ``` -------------------------------- ### Transaction and Network Monitoring Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for reporting HTTP transactions and network failures to the New Relic service. ```APIDOC ## noticeHttpTransaction ### Description Reports an HTTP transaction to New Relic. Overloaded to support different connection types. ### Method void ### Parameters - **String**: The URL of the transaction. - **int**: The HTTP status code. - **long**: The total time spent in the transaction. - **long**: The time spent in connection. - **long**: The time spent in reading the response. - **long**: The time spent in the request. - **String**: The HTTP method used. - **Map**: A map of request headers. - **HttpResponse/URLConnection**: The HTTP response or URL connection object. ## _noticeHttpTransaction ### Description Internal method to notice an HTTP transaction with additional parameters. ### Method void ### Parameters - **String**: The URL of the transaction. - **int**: The HTTP status code. - **long**: The total time spent in the transaction. - **long**: The time spent in connection. - **long**: The time spent in reading the response. - **long**: The time spent in the request. - **String**: The HTTP method used. - **Map**: A map of request headers. - **String**: Additional string parameter. ## noticeNetworkFailure ### Description Reports a network failure to New Relic. Overloaded to support different failure types. ### Method void ### Parameters - **String**: The URL associated with the failure. - **long**: The time spent during the network operation. - **long**: The duration of the failure. - **NetworkFailure/Exception**: The type of network failure or the exception that occurred. ``` -------------------------------- ### New Relic Android Agent Configuration Source: https://github.com/newrelic/newrelic-android-agent/blob/main/docs/TraceMachine.md This JSON object represents the configuration for the New Relic Android agent, including reporting periods, limits, and account details. ```json { "server_timestamp": 1680880043, "data_report_period": 60, "report_max_transaction_count": 1000, "report_max_transaction_age": 600, "collect_network_errors": true, "error_limit": 50, "response_body_limit": 2048, "stack_trace_limit": 100, "activity_trace_max_size": 65535, "activity_trace_min_utilization": 0.3, "at_capture": [1, []], "data_token": [601336055, 601380446], "cross_process_id": "VwUUV1ZSCwAGVFRX", "encoding_key": "d67afc830dab717fd163bfcb0b8b88423e9a1a3b", "account_id": "33", "application_id": "601336055", "trusted_account_key": "33" } ``` -------------------------------- ### Agent State and Data Management Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for managing transaction data, agent state, and retrieving agent information. ```APIDOC ## addTransactionData ### Description Adds transaction data to the agent. ### Method void ### Parameters - **TransactionData**: The transaction data to add. ## getAndClearTransactionData ### Description Retrieves and clears all accumulated transaction data. ### Method List ## mergeTransactionData ### Description Merges a list of transaction data into the agent's current data. ### Method void ### Parameters - **List**: A list of transaction data to merge. ## getCrossProcessId ### Description Retrieves the cross-process identifier for the agent. ### Method String ## getStackTraceLimit ### Description Retrieves the configured limit for stack trace depth. ### Method int ## getResponseBodyLimit ### Description Retrieves the configured limit for response body size. ### Method int ## start ### Description Starts the New Relic agent. ### Method void ## stop ### Description Stops the New Relic agent. ### Method void ## disable ### Description Disables the New Relic agent. ### Method void ## isDisabled ### Description Checks if the New Relic agent is disabled. ### Method boolean ## getNetworkCarrier ### Description Retrieves the name of the current network carrier. ### Method String ## setLocation ### Description Sets the geographical location for the agent. ### Method void ### Parameters - **String**: The latitude. - **String**: The longitude. ## getEncoder ### Description Retrieves the encoder instance used by the agent. ### Method Encoder ## getDeviceInformation ### Description Retrieves the device information for the agent. ### Method DeviceInformation ## getApplicationInformation ### Description Retrieves the application information for the agent. ### Method ApplicationInformation ## getEnvironmentInformation ### Description Retrieves the environment information for the agent. ### Method EnvironmentInformation ``` -------------------------------- ### AndroidAgentLog Class Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt An implementation of AgentLog that logs messages to the Android system log (Logcat). ```APIDOC ## AndroidAgentLog Class ### Description Implementation of AgentLog that writes logs to Android's Logcat. ### Fields - **TAG**: The tag used for Android log messages. - **level**: The current logging level. ### Methods - **debug(String message)**: Logs a debug message to Logcat. - **verbose(String message)**: Logs a verbose message to Logcat. - **info(String message)**: Logs an informational message to Logcat. - **warning(String message)**: Logs a warning message to Logcat. - **error(String message)**: Logs an error message to Logcat. - **error(String message, Throwable throwable)**: Logs an error message with an exception to Logcat. - **getLevel()**: Returns the current logging level. - **setLevel(int level)**: Sets the logging level. ``` -------------------------------- ### Apply Privacy Tags to Views Source: https://github.com/newrelic/newrelic-android-agent/blob/main/ANDROID_VIEW_COMPATIBILITY.md Use 'nr-mask', 'nr-unmask', or 'nr-block' tags on views to control their capture behavior in Session Replay. These can be applied programmatically or via XML. ```java view.setTag("nr-mask"); view.setTag("nr-unmask"); view.setTag("nr-block"); // Via privacy-specific tag view.setTag(R.id.newrelic_privacy, "nr-mask"); view.setTag(R.id.newrelic_privacy, "nr-block"); ``` ```xml ``` -------------------------------- ### Broadcast Methods Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for managing and broadcasting measurements. ```APIDOC ## Broadcast Methods ### `setBroadcastNewMeasurements(boolean enabled)` Enables or disables broadcasting of new measurements. ### `newMeasurementBroadcast()` Triggers a broadcast of new measurements. ### `broadcast()` Triggers a general broadcast. ``` -------------------------------- ### Add Debugging Configuration Source: https://github.com/newrelic/newrelic-android-agent/blob/main/samples/agent-test-app/dexguard-qa-project.txt This directive adds a default debugging configuration for DexGuard. It's a simple way to enable more verbose logging or debugging information during the build process. ```proguard -addconfigurationdebugging ``` -------------------------------- ### ActivityMeasurementProducer Source: https://github.com/newrelic/newrelic-android-agent/blob/main/plugins/gradle/src/test/resources/mapping.txt Methods for producing measurements related to Android activities. ```APIDOC ## produceMeasurement ### Description Produces a measurement for an activity. ### Method void ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **measuredActivity** (com.newrelic.agent.android.activity.MeasuredActivity) - Required - The activity to measure. ```