Importante
If you're using a hybrid mobile agent (React Native, .NET Maui, etc.), refer to the platform-specific methods below.
Syntax
Java
NewRelic.setInteractionName(string $interactionName)
Kotlin
NewRelic.setInteractionName(name: String?)
Description
Set a new name for an interaction that is already being tracked by New Relic.
Use setInteractionName()
to change the name of an interaction in an instrumented app.
For example, you have an interaction that is being reported under a single activity name, like FragmentActivity
, or under an obfuscated name, like baseclass.a
, and you want to rename the interaction to be more descriptive,. You could use setInteractionName
at the beginning of each onCreate()
method to change the name.
To create a new interaction, see startInteraction()
.
For general info on using this API, see the Android SDK API usage guide.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
Example
This example uses NewRelic.setInteractionName()
at the beginning of the onCreate()
method as part of the Activity
class:
Java
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
//Rename the in-flight interaction NewRelic.setInteractionName("Display MyCustomInteraction"); }
// ... continue methods ...}
Kotlin
NewRelic.setInteractionName("Display MyCustomInteraction")
Syntax
Objective-c
- (NSString*) customNewRelicInteractionName;
Swift
@objc func customNewRelicInteractionName() -> String
Description
Sets the name to rename default interaction names reported to New Relic.
If you implement this method in your UIViewController
, New Relic will call this method before starting an interaction (from -viewDidLoad
or -viewDidAppear
) and rename the interaction with the string returned (instead of the default name of display <ViewControllerName>
).
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The custom interaction name. |
Examples
Objective-C
- (NSString*) customNewRelicInteractionName { return @"CustomInteractionNameViewController";}
Swift
@objc func customNewRelicInteractionName() -> String { return "CustomInteractionNameViewController"}