Skip to content

Commit

Permalink
RUM-6885 Add the docs for RumMonitor#addViewLoadingTime API
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusc83 committed Oct 28, 2024
1 parent 2ce3e0d commit daab9e8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ In addition to [tracking views automatically][4], you can also track specific di
{{% /tab %}}
{{< /tabs >}}

### Notify the SDK that your view finished loading

We are tracking the time it takes for your view to load. To notify the SDK that your view has finished loading you will need to call the `addViewLoadingTime(override=)` method
through the `GlobalRumMonitor` instance. This method should be called when your view is fully loaded and displayed to the user:

{{< tabs >}}
{{% tab "Kotlin" %}}
```kotlin
@OptIn(ExperimentalRumApi::class)
fun onViewLoaded() {
GlobalRumMonitor.get().addViewLoadingTime(override = false)
}
```
{{% /tab %}}
{{% tab "Java" %}}
```java
@OptIn(markerClass = ExperimentalRumApi.class)
public void onViewLoaded() {
GlobalRumMonitor.get().addViewLoadingTime(override);
}
```
{{% /tab %}}
{{< /tabs >}}

Use `override` option to replace previously calculated loading time for current view.

Once the view loading time is sent, the loading time is accessible as `@view.loading_time` and will be visible also in the RUM UI.
Please note that this API is still experimental and might change in the future.

### Add your own performance timing

In addition to RUM's default attributes, you can measure where your application is spending its time by using the `addTiming` API. The timing measure is relative to the start of the current RUM view. For example, you can time how long it takes for your hero image to appear:
Expand All @@ -73,6 +102,7 @@ In addition to RUM's default attributes, you can measure where your application

Once the timing is sent, the timing is accessible as `@view.custom_timings.<timing_name>`. For example: `@view.custom_timings.hero_image`. You must [create a measure][10] before graphing it in RUM analytics or in dashboards.


### Custom Actions

In addition to [tracking actions automatically][5], you can also track specific custom user actions (such as taps, clicks, and scrolls) with `RumMonitor#addAction`. For continuous action tracking (for example, tracking a user scrolling a list), use `RumMonitor#startAction` and `RumMonitor#stopAction`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@ If you are using Flutter Navigator v2.0, your setup for automatic view tracking

Flutter RUM automatically tracks attributes such as user activity, views (using the `DatadogNavigationObserver`), errors, native crashes, and network requests (using the Datadog Tracking HTTP Client). See the [RUM Data Collection documentation][3] to learn about the RUM events and default attributes. You can further enrich user session information and gain finer control over the attributes collected by tracking custom events.

### Notify the SDK that your view finished loading

We are tracking the time it takes for your view to load. To notify the SDK that your view has finished loading you will need to call the `addViewLoadingTime` method
on `DatadogRum`. This method should be called when your view is fully loaded and ready to be displayed to the user:

```dart
DatadogSdk.instance.rum?.addViewLoadingTime(override);
```

Use `override` option to replace previously calculated loading time for current view.

Once the view loading time is sent, the loading time is accessible as `@view.loading_time` and will be visible also in the RUM UI.
Please note that this API is still experimental and might change in the future.

### Add your own performance timing

In addition to RUM's default attributes, you can measure where your application is spending its time by using `DdRum.addTiming`. The timing measure is relative to the start of the current RUM view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,37 @@ DDRUMMonitor *rum = [DDRUMMonitor shared];

For more details and available options, filter the [relevant file on GitHub][9] for the `DDRUMMonitor` class.

### Notify the SDK that your view finished loading

We are tracking the time it takes for your view to load. To notify the SDK that your view has finished loading you will need to call the `addViewLoadingTime(override:)` method
through the `RUMMonitor` instance. This method should be called when your view is fully loaded and displayed to the user:

{{< tabs >}}
{{% tab "Swift" %}}
```swift
@_spi(Experimental)
import DatadogRUM

func onHeroImageLoaded() {
let rum = RUMMonitor.shared()
rum.addViewLoadingTime(override: false)
}
```
{{% /tab %}}
{{% tab "Objective-C" %}}
```objective-c
- (void)onHeroImageLoad {
[[DDRUMMonitor shared] addViewLoadingTimeWithOverride:NO | YES];
}
```
{{% /tab %}}
{{< /tabs >}}

Use `override` option to replace previously calculated loading time for current view.

Once the view loading time is sent, the loading time is accessible as `@view.loading_time` and will be visible also in the RUM UI.
Please note that this API is still experimental and might change in the future.

### Add your own performance timing

In addition to RUM's default attributes, you can measure where your application is spending its time by using the `addTiming(name:)` API. The timing measure is relative to the start of the current RUM view.
Expand Down

0 comments on commit daab9e8

Please sign in to comment.