analytics-android icon indicating copy to clipboard operation
analytics-android copied to clipboard

context.device.advertisingId Not Being Collected

Open tcrawford94 opened this issue 3 years ago • 5 comments

Our Analytics track & screen calls are not being sent with a context.device.advertisingId. We have minifyEnabled set to true in our build.gradle, and disabling this fixes the issue, but that isn't an acceptable solution here.

Adding the following proguard rules to our project fixes the issue while minifying:

-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient { *; }
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { *; }

Segment SDK is only a sustainable service and library for us to use if we can assume it will continue to work between library version updates. For these reason, we would also request that you package any other necessary proguard rules in the analytics-android library itself, as opposed to instructing us to keep our proguard rules up to date based on your latest documentation:

-keep class com.segment.analytics.** { *; }
-keep class androidx.lifecycle.DefaultLifecycleObserver

Other fixes attempted: There's a small amount of documentation highlighting the requirement of including "Google Play Services Ads Library" to our project, but that does not fix the issue. Additionally, I'm confused why anything more than the Google Play Services Ads Identifier library would be necessary, as Ads Library requires us to sign up for Ad Mob like we plan to display ads in our app. I believe the documentation should clarify what is required here. I believe all that would be needed is the following line in the build.gradle, even though this didn't fix the issue.

implementation 'com.google.android.gms:play-services-ads-identifier:18.0.0'

tcrawford94 avatar Dec 17 '21 21:12 tcrawford94

Edited issue, adding more comments. Please let me know if I can provide any more details here.

tcrawford94 avatar Dec 20 '21 22:12 tcrawford94

@tcrawford94 This got me confused too. The lib documentation mentions that we should add the Google Ads Library as a dependency in order to let the Segment lib collect the Advertising ID.

Moreover, if your app targets SDK 33 or later, Google Play Store Console shows a warning mentioning that we must declare the Advertising ID permission in the Android Manifest (which is included by default by the Google Ads Library). What I do not understand is: Will the Segment Library work or not if we don't include the Google Ads Library as a dependency in our apps?

jflavio11 avatar Jul 27 '22 21:07 jflavio11

@tcrawford94 @jflavio11 I have exactly the same scenario. I have not added the Advertising ID permission in the Android Manifest and I am targeting android 13 now.

Should we declare that our app uses Advertising ID because of segment?

carlosmonzon avatar Jul 28 '22 12:07 carlosmonzon

Ideally, Segment updates their SDK to include the requirement in the manifest so it will be merged into users' apps when they update the version number.

I can also open a PR for this if no one has started yet.

mrtnrst avatar Aug 01 '22 19:08 mrtnrst

I'd like to strongly second @tcrawford94's request that the AdvertisingIdClient ProGuard rules be added to the docs, as collecting the advertising ID won't work without them. If there's a way to include these in the actual library itself, that'd be even better.

Also, @mrtnrst's suggestion of adding the following line to the library's manifest only makes sense:

    <uses-permission android:name="com.google.android.gms.permission.AD_ID" />

sterlingudell-th2 avatar Aug 02 '22 16:08 sterlingudell-th2