Skip to content

Latest commit

 

History

History
863 lines (645 loc) · 16.4 KB

increment-session-attribute-count.mdx

File metadata and controls

863 lines (645 loc) · 16.4 KB
title type shortDescription tags metaDescription redirects freshnessValidatedDate
Increment session attribute count
apiDoc
Increments the count of a session attribute. Overwrites previous value and type each time called.
Mobile monitoring
Mobile SDK API
Mobile app monitoring API used to increment a custom session attribute value.
/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api/incrementattribute-android-agent-api
/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api/incrementattribute-android-sdk-api
/docs/mobile-monitoring/new-relic-mobile-android/android-sdk-api/increment-attribute
/docs/mobile-monitoring/new-relic-mobile-ios/ios-sdk-api/incrementattribute-ios-sdk-api
/docs/mobile-monitoring/new-relic-mobile-ios/ios-sdk-api/increment-attribute
2023-07-20
Android iOS Capacitor Cordova .NET MAUI Flutter React Native Unity Unreal Engine Xamarin
</TabsBar>

<TabsPages>
    <TabsPageItem id="android">

Syntax [#syntax]

Java [#java]

NewRelic.incrementAttribute(string $name[, float $value])

Kotlin [#kotlin]

NewRelic.incrementAttribute(name: String!, value : Double)

Description [#description]

Increments the count of an attribute. Overwrites its previous value and type each time it is called.

When passed with only a name value, this method increments the count for the specified attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1. When passed an optional float value, it increments the count for the specified attribute by the float value.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>
  <th>
    Description
  </th>
</tr>
  <td>
    `string`
  </td>

  <td>
   Required. The name of the attribute.
  </td>
</tr>

<tr>
  <td>
    `$value`
  </td>

  <td>
    `float`
  </td>
  <td>
    Optional. The attribute is incremented by this float value.
  </td>
</tr>
Parameter
`$name`

Return values [#return-values]

Returns true if recorded successfully, or false if not.

Examples [#examples]

Here's an example to increment the count for the specified attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:

Java [#java]

boolean incremented = NewRelic.incrementAttribute("rate");

Kotlin [#kotlin]

    val incremented = NewRelic.incrementAttribute("rate")

Here's an example to increment the count for the specified attribute by the float value amount:

Java [#java]

boolean incremented = NewRelic.incrementAttribute("rate", 9999.99, false);

Kotlin [#kotlin]

val incremented: Boolean = NewRelic.incrementAttribute("rate", 9999.99)
    </TabsPageItem>
    <TabsPageItem id="ios">

Syntax [#syntax]

Objective-c [#objc]

incrementAttribute:(NSString*)name value:(NSNumber*)amount;

Swift [#swift]

NewRelic.incrementAttribute(string $name[, float $value])

Description [#description]

Increments the count of a session attribute. Overwrites previous value and type each time called.

When passed with only a name value, this method increments the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1. When passed an optional float value, it increments the count for the specified attribute by the float value.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>
  <th>
    Description
  </th>
</tr>
  <td>
    `string`
  </td>

  <td>
   Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `amount`
  </td>

  <td>
    `number`
  </td>
  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Examples [#examples]

Objective-C [#obj-c]

Here's an example to increment the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:

BOOL incremented = [NewRelic incrementAttribute@"rate"];

Here's another example to increment the count for the specified session attribute by the amount specified in NSNumber*:

BOOL incremented = [NewRelic incrementAttribute:@"rate" value:@1];

Swift [#swift]

Here's an example to increment the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:

let incremented = NewRelic.incrementAttribute("rate")

Here's another example to increment the count for the specified session attribute by the amount specified in NSNumber!:

let incremented = NewRelic.incrementAttribute(name: String!, value: NSNumber!)
    </TabsPageItem>
    <TabsPageItem id="capacitor">

Syntax [#syntax]

incrementAttribute(options: { name: string; value?: number; }) => void

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Example [#example]

        NewRelicCapacitorPlugin.incrementAttribute({ name: 'CapacitorAttribute', value: 15 })
    </TabsPageItem>
    <TabsPageItem id="cordova">

Syntax [#syntax]

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

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Example [#example]

  NewRelic.incrementAttribute('CordovaCustomAttrNumber');
  NewRelic.incrementAttribute('CordovaCustomAttrNumber', 5);
    </TabsPageItem>
   <TabsPageItem id="maui">

Syntax [#syntax]

RecordCustomEvent(string eventType, string eventName, Dictionary<string, object> attributes): bool;

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Example [#example]

    // Increment by 1
    CrossNewRelic.Current.IncrementAttribute("MAUINumAttr");
    // Increment by value
    CrossNewRelic.Current.IncrementAttribute("MAUINumAttr", 12.3);
    </TabsPageItem>
    <TabsPageItem id="flutter">

Syntax [#syntax]

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

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Example [#example]

    NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber");
    NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber",value :5.0);
    </TabsPageItem>
    <TabsPageItem id="react">

Syntax [#syntax]

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

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Example [#example]

   NewRelic.incrementAttribute('RNCustomAttrNumber');
   NewRelic.incrementAttribute('RNCustomAttrNumber', 5);
    </TabsPageItem>

Syntax [#syntax]

incrementAttribute(string name, float value = 1) : bool;

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Example [#example]

    // Increment by 1
    NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber');
    // Increment by value
    NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber', 5);
    </TabsPageItem>

Syntax [#syntax]

incrementAttribute(FString name,double value): void;

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Example [#example]

    // Increment by 1
   UNewRelicBPLibrary::incrementAttribute("Unreal Double",5.0);
    </TabsPageItem>
    <TabsPageItem id="xamarin">

Syntax [#syntax]

IncrementAttribute(string name, float value = 1) : bool;

Description [#description]

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.

Parameters [#parameters]

  <th width={200}>
    Type
  </th>

  <th>
    Description
  </th>
</tr>
        <td>
    `string`
  </td>

  <td>
    Required. The name of the attribute to increment.
  </td>
</tr>

<tr>
  <td>
    `value`
  </td>

        <td>
    `number`
  </td>

  <td>
    Optional. The amount to increment the attribute by.
  </td>
</tr>
Parameter
`name`

Return values [#return-values]

Returns true if the event is recorded successfully, or false if not.

Example [#example]

    // Increment by 1
    CrossNewRelicClient.Current.IncrementAttribute("XamarinNumAttr");
    // Increment by value
    CrossNewRelicClient.Current.IncrementAttribute("XamarinNumAttr", 12.3);
    </TabsPageItem>

</TabsPages>