rudderlabs / rudder-sdk-flutter

Flutter SDK for RudderStack - the Customer Data Platform for Developers. Now supports Android, iOS and Web tracking!
https://www.rudderstack.com
Other
7 stars 25 forks source link

BUG : Untracked Tracker on Live Events #129

Closed chandrabezzo closed 9 months ago

chandrabezzo commented 1 year ago

Describe the bug Our events untracked on live events (again) on the dashboard using self-hosted rudderstack. This issue just happen when we run application on release mode.

Which platform is the issue occurring on Is the error occurring on:

Expected behavior Our events tracked on live events

Screenshoot Screenshot 2023-09-25 at 10 41 36

To Reproduce

SDK initialisation snippet Standard implementation like example

Framework version of the SDK [✓] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d darwin-arm64, locale en-ID) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] VS Code (version 1.82.2) [✓] Connected device (3 available) [✓] Network resources

desusai7 commented 1 year ago

Hey @chandrabezzo

Can you explain more about the issue, are you seeing any errors, share more logs on what is happening when the events are fired ?

chandrabezzo commented 1 year ago

HI @desusai7 I was updated my description issue. Untracked on live version replicated again in self hosted.

chandrabezzo commented 1 year ago

I see at live events, only tracked on debug mode when use this version. But when we run as release version untracked on live events.

        "library": {
            "name": "com.rudderstack.android.sdk.core",
            "version": "1.19.1"
        },
desusai7 commented 1 year ago

@chandrabezzo, can you please share complete logs from the moment you run the app ?

chandrabezzo commented 1 year ago

Just log from rudderstack? In the release mode from rudderstack I just get that logs @desusai7

chandrabezzo commented 1 year ago

Maybe this issue related with proguard rules?

chandrabezzo commented 1 year ago

@desusai7 just update, after add proguard rules on the android side. We can get events on the live event dashboard at self hosted rudderstack, but the payload provide unexpected value. For example

{
    "anonymousId": "YOUR_ANONYMOUS_ID",
    "channel": "mobile",
    "context": {
        "app": {},
        "device": {},
        "library": {},
        "locale": "YOUR_LOCALE",
        "network": {},
        "os": {},
        "screen": {},
        "timezone": "YOUR_TIMEZONE",
        "traits": {
            "b": {
                "first_name": "YOUR_FIRST_NAME"
            },
            "userId": "YOUR_USER_ID"
        },
        "userAgent": "Dalvik/2.1.0 (Linux; U; Android 13; sdk_gphone64_arm64 Build/TE1A.220922.012)"
    },
    "event": "YOUR_EVENT",
    "integrations": {
        "All": true
    },
    "messageId": "YOUR_MESSSAGE_ID",
    "originalTimestamp": "YOUR_TIMESTAMP",
    "properties": {
        YOUR_PROPERTIES
    },
    "rudderId": "YOUR_RUDDER_ID",
    "sentAt": "YOUR_SENT_AT",
    "type": "track"
}
chandrabezzo commented 1 year ago

Refers json tracked above, I think we miss some value like app, device, library, network, os, screen, and our traits converted to b.

desusai7 commented 1 year ago

@chandrabezzo , can you confirm if you've added all the rules shown here ?

If not, please add everything and let us know how it goes.

chandrabezzo commented 1 year ago

@desusai7 I have been added all the rules and json value tracked like my previous comment.

desusai7 commented 1 year ago

Can you set the log level to verbose and share the complete logs from the moment you launch the app ?

chandrabezzo commented 1 year ago

@desusai7 after changed to verbose, the logs contains secret information. I can't share the logs on the comments. But, FYI events sucessfully tracked with missing information.

chandrabezzo commented 1 year ago

We upgrade the self hosted rudderstack to 1.14.1 issue still happen.

chandrabezzo commented 1 year ago

Any significant update on 1.19.1 SDK android @desusai7 ? Because we never add proguard-rules.pro but events tracked sucessfully

chandrabezzo commented 1 year ago

Any significant update on 1.19.1 SDK android @desusai7 ? Because we never add proguard-rules.pro but events tracked sucessfully

desusai7 commented 1 year ago

@chandrabezzo, please share the logs on the slack, so that we can take a look and help you resolve the issue faster

desusai7 commented 1 year ago

We've made the SDK compatible with full proguard mode from 1.19.1 of the Android SDK.

chandrabezzo commented 1 year ago

I see, but live events tracked impacted

chandrabezzo commented 1 year ago

Have you test that changes on flutter with self hosted rudderstack? Because this issue replicated on latest self hosted rudderstack.

desusai7 commented 1 year ago

@chandrabezzo, This issue seems to be related to proguard and not with the self hosted Rudderstack. Thank you for sharing the logs over the slack, we are going through them and will keep you posted on that.

In the time being to unblock you, can you please add the below rules to your proguard file:

-keep class com.rudderstack.android.sdk.core.* { *; }
-keep class com.rudderstack.android.sdk.core.ecomm.* { *; }
-keep class com.rudderstack.android.sdk.core.util.* { *; }
chandrabezzo commented 1 year ago

@desusai7 still issue

desusai7 commented 1 year ago

Let me try reproducing the issue and get back to you on the next steps.

fabioginzel commented 1 year ago

👋 Hello everyone,

I'd like to add that I'm experiencing the same issue with event tracking on Android when using the non-self-hosted version of RudderStack.

chandrabezzo commented 1 year ago

Ok @desusai7 thanks for your help, please test before your publish plugin on pub.dev. Tracker to Rudderstack is important for us. I've been feeling unstable likely from Rudderstack. Thank You.

desusai7 commented 1 year ago

@chandrabezzo, @fabioginzel I couldn't reproduce the exact issue, but I seem to figure out what would be causing the issue. Please try adding the below to your Proguard rules file and let us know how this goes.

-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}
-keep class * implements com.google.gson.JsonSerializer { *; }
-keepclassmembers class com.rudderstack.android.sdk.core.RudderContext { java.util.Map customContextMap; }
-keepclassmembers class com.rudderstack.android.sdk.core.RudderTraits { java.util.Map extras; }
fabioginzel commented 1 year ago

@desusai7 I created the proguard-rules.pro file in the android/app folder with this content and it worked!

desusai7 commented 1 year ago

We are exposing these rules as part of the Android SDK as well to ensure this kind of issue does not happen in the future. We already raised a PR for it here

desusai7 commented 1 year ago

@chandrabezzo, can you please add the below set of rules to your proguard file and your issue should be fixed ?

-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}
-keep class * implements com.google.gson.JsonSerializer { *; }
-keepclassmembers class com.rudderstack.android.sdk.core.RudderContext { java.util.Map customContextMap; }
-keepclassmembers class com.rudderstack.android.sdk.core.RudderTraits { java.util.Map extras; }
desusai7 commented 12 months ago

@chandrabezzo, we've released version 1.20.0 of Rudderstack's Android SDK with the Proguard rules bundled in it. Can you please try upgrading / re-installing the Flutter SDK so that it fetches the latest version of Android SDK and then check if this issue is solved for you?

chandrabezzo commented 12 months ago

Hi @desusai7 we can use same proguard rules value?

desusai7 commented 12 months ago

Hi @chandrabezzo, you need not to use the proguard rules file anymore, we've attached the proguard rules file along with core SDK itself.

chandrabezzo commented 12 months ago

So, @desusai7 have you published that feature for rudder_sdk_flutter with latest Android SDK?

desusai7 commented 12 months ago

@chandrabezzo, we have not yet published rudder_sdk_flutter with the latest Android SDK yet, but the current latest version of rudder_sdk_flutter will be able to fetch the latest version of Android SDK as shown in the constraints here.

You should be able to get the latest version of Android SDK by re-installing the rudder_sdk_flutter for the time being to help you unblock.

However, we are already in the works to release a new version of rudder_sdk_flutter which uses at least version 1.20.0 of Android SDK.

desusai7 commented 11 months ago

Hey @chandrabezzo,

We've released Rudderstack Flutter SDK version 2.6.0 and this version makes sure that the Android SDK version of at least 1.20.0 is used and Android SDK version >= 1.20.0 comes with built-in pro guard rules to fix this kind of issue.

Please upgrade to version 2.6.0 of the Flutter SDK and let us know if you are having any issues.

desusai7 commented 9 months ago

@chandrabezzo, closing this issue for now, feel free to open it back if the issue isn't resolved after upgrading to the latest version