Skip to content

Commit

Permalink
Added an article on a new mobile agents api for tracking http headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruin-NR committed Nov 2, 2023
1 parent 7cf1916 commit b558ce8
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
---
title: Mobile SDK guide
tags:
- Mobile monitoring
- API guides
metaDescription: 'Customize your mobile agent instrumentation to capture specific HTTP header fields.'
---

<Tabs>
<TabsBar>
<TabsBarItem id="android">
Android
</TabsBarItem>
<TabsBarItem id="ios">
iOS
</TabsBarItem>
<TabsBarItem id="maui">
.NET MAUI
</TabsBarItem>
<TabsBarItem id="xamarin">
Xamarin
</TabsBarItem>
</TabsBar>

<TabsPages>
<TabsPageItem id="android">
## Syntax [#syntax]

### Java [#java]

```java
NewRelic.addHTTPHeadersTrackingFor(List<String> headers)
```

### Kotlin [#kotlin]

```kotlin
NewRelic.addHTTPHeadersTrackingFor(List<String> headers)
```

## Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events.

## Parameters [#parameters]

<table>
<thead>
<tr>
<th width="30%">
Parameter
</th>

<th width="30%">
Type
</th>
<th>
Description
</th>
</tr>
</thead>

<tbody>
<tr>
<td>
`$headers`
</td>

<td>
`Exception`
</td>

<td>
Required. The HTTP header fields to be added.
</td>
</tr>

</tbody>
</table>

## Return values [#return-values]

Returns `true` if added successfully, or `false` if not.

## Examples [#examples]

Here's an example of adding some HTTP header fields:

### Java [#java]

```java
public class MainActivity extends Activity {
...

...
}
```

### Kotlin [#kotlin]

```kotlin

class MainActivity : AppCompatActivity() {

....

........
```
</TabsPageItem>
<TabsPageItem id="ios">

## Syntax [#syntax]

### Objective-c

Check warning on line 114 in src/content/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/add-tracked-headers.mdx

View workflow job for this annotation

GitHub Actions / vale-linter

[vale] reported by reviewdog 🐶 [new-relic.ComplexWords] Consider using 'aim' or 'goal' instead of 'Objective'. Raw Output: {"message": "[new-relic.ComplexWords] Consider using 'aim' or 'goal' instead of 'Objective'.", "location": {"path": "src/content/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/add-tracked-headers.mdx", "range": {"start": {"line": 114, "column": 5}}}, "severity": "INFO"}

```objectivec
(void)addHTTPHeaderTrackingFor:(NSArray<NSString*>*_Nonnull)headers;
```

### Swift [#swift]

```swift
NewRelic.addHTTPHeaderTracking(for: [String])
```

## Description [#description]

This API allows you to add any header field strings to a list that gets recorded as attributes with networking request events.

## Parameters [#parameters]

<table>
<thead>
<tr>
<th width="30%">
Parameter
</th>

<th width={200}>
Type
</th>
<th>
Description
</th>
</tr>
</thead>

<tbody>
<tr>
<td>
`headers`
</td>

<td>
`NSArray<NSString*>*_Nonnull`
</td>

<td>
Required. The HTTP header fields to be added.
</td>
</tr>

</tbody>
</table>


## Examples [#examples]

Here's an example of adding some HTTP header fields:
```objectivec
[NewRelic addHTTPHeadersTrackingFor:@[@"Example", @"Example2"]];
```
```swift
NewRelic.addHTTPHeadersTracking(for:["Example", "Example2"])
```
2 changes: 2 additions & 0 deletions src/nav/mobile-monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ pages:
path: /docs/mobile-monitoring/new-relic-mobile/mobile-sdk/network-request-success
- title: Track failing HTTP requests
path: /docs/mobile-monitoring/new-relic-mobile/mobile-sdk/network-request-failures
- title: Track HTTP requests Headers
path: /docs/mobile-monitoring/new-relic-mobile/mobile-sdk/add-tracked-headers
- title: (Android only) Set app launch time target activity
path: /docs/mobile-monitoring/new-relic-mobile/mobile-sdk/name-android-activity
- title: Best practices
Expand Down

0 comments on commit b558ce8

Please sign in to comment.