DataDog / dd-sdk-android

Datadog SDK for Android (Compatible with Kotlin and Java)
Apache License 2.0
146 stars 59 forks source link

Unable to log custom actions #1985

Open cmtanko opened 4 months ago

cmtanko commented 4 months ago

Describe the bug

    @Kroll.method
    public void startAction(String actionName, KrollDict actionAttributes) {
        // Convert KrollDict to HashMap
        HashMap<String, Object> attributes = (HashMap<String, Object>) actionAttributes;

        GlobalRumMonitor.get().addAction(RumActionType.TAP, actionName, attributes);
    }

So, I have this addAction to record tap event , but on using I am getting this error and my tap event is not logged. Any thoughts ?

[WARN] Datadog: [_dd.sdk_core.default]: RUM Action (TAP on ) was dropped, because another action is still active for the same view [WARN] Datadog: [_dd.sdk_core.default]: RUM Action (TAP on myAction) was dropped, because another action is still active for the same view

Reproduction steps

    @Kroll.method
    public void startAction(String actionName, KrollDict actionAttributes) {
        // Convert KrollDict to HashMap
        HashMap<String, Object> attributes = (HashMap<String, Object>) actionAttributes;

        GlobalRumMonitor.get().addAction(RumActionType.TAP, actionName, attributes);
    }
    ```
var actionType = 'TAP';
        var actionName = 'myAction';
        var actionAttributes = {
            attribute1: 'value1',
            attribute2: 'value2'
        };

        Datadog.startAction(actionName, actionAttributes);


### Logcat logs

[WARN]  Datadog: [_dd.sdk_core.default]: RUM Action (TAP on ) was dropped, because another action is still active for the same view
[WARN]  Datadog: [_dd.sdk_core.default]: RUM Action (TAP on myAction) was dropped, because another action is still active for the same view

### Expected behavior

Its expected to log MyAction action on the tap 

### Affected SDK versions

2.7.1

### Latest working SDK version

2.8.0

### Did you confirm if the latest SDK version fixes the bug?

Yes

### Kotlin / Java version

_No response_

### Gradle / AGP version

_No response_

### Other dependencies versions

_No response_

### Device Information

_No response_

### Other relevant information

_No response_
xgouchet commented 4 months ago

Hi @cmtanko, thanks for opening this ticket.

This behaviour is working on purpose, any non custom action stays alive for a short while to be linked with the following errors or resources.

Sending a custom action can be done at any time, by using the type RumActionType.CUSTOM instead of RumActionType.TAP, e.g.:

GlobalRumMonitor.get().addAction(RumActionType.CUSTOM, actionName, attributes);