Important
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 [#kotlin]
NewRelic.setInteractionName(name: String?)
Description [#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 [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
Example [#example]
This example uses NewRelic.setInteractionName()
at the beginning of the onCreate()
method as part of the Activity
class:
Java [#java]
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
//Rename the in-flight interaction NewRelic.setInteractionName("Display MyCustomInteraction"); }
// ... continue methods ...
}
Kotlin [#kotlin]
NewRelic.setInteractionName("Display MyCustomInteraction")
Syntax
Objective-c
- (NSString*) customNewRelicInteractionName;
Swift [#swift]
@objc func customNewRelicInteractionName() -> String
Description [#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 [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The custom interaction name. |
Examples [#examples]
Objective-C [#obj-c]
- (NSString*) customNewRelicInteractionName { return @"CustomInteractionNameViewController";}
Swift [#swift]
@objc func customNewRelicInteractionName() -> String { return "CustomInteractionNameViewController"}