Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SessionReplayBroadcastReceiver #838

Merged
merged 5 commits into from
Aug 29, 2024
Merged

Conversation

jaredmixpanel
Copy link
Collaborator

Add a broadcast receiver to receive the $mp_replay_id from the Session Replay SDK

Copy link
Contributor

@zihejia zihejia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jaredmixpanel jaredmixpanel merged commit 43f8c94 into master Aug 29, 2024
1 of 2 checks passed
@carstenhag
Copy link

This change (and 7.5.2 -> 7.5.3) somehow breaks tests for me (when MixpanelAPI is instantiated).

Permission com.digitalchargingsolutions.b2c.integ.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION is required by your application to receive broadcasts, please add it to your manifest
java.lang.RuntimeException: Permission com.digitalchargingsolutions.b2c.integ.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION is required by your application to receive broadcasts, please add it to your manifest
	at androidx.core.content.ContextCompat.obtainAndCheckReceiverPermission(ContextCompat.java:970)
	at androidx.core.content.ContextCompat$Api26Impl.registerReceiver(ContextCompat.java:1117)
	at androidx.core.content.ContextCompat.registerReceiver(ContextCompat.java:822)
	at androidx.core.content.ContextCompat.registerReceiver(ContextCompat.java:769)
	at com.mixpanel.android.mpmetrics.MixpanelAPI.<init>(MixpanelAPI.java:199)
	at com.mixpanel.android.mpmetrics.MixpanelAPI.<init>(MixpanelAPI.java:123)
	at com.mixpanel.android.mpmetrics.MixpanelAPI.getInstance(MixpanelAPI.java:463)
	at com.bmw.chargenow.utils.analytics.AnalyticsTracker.<init>(AnalyticsTracker.kt:42)

MixpanelAPI.java:199 points to

       ContextCompat.registerReceiver(
                mContext.getApplicationContext(),
                sessionReplayReceiver,
                SessionReplayBroadcastReceiver.INTENT_FILTER,
                ContextCompat.RECEIVER_NOT_EXPORTED
        );

I have tried adding <uses-permission android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" /> to the manifest, but that didn't help. Could also not solve it by quick googling.

@jaredmixpanel
Copy link
Collaborator Author

@carstenhag Are your tests running with targetSdk <= 32? If so, can you bump that up to >=33?

I found this other Github issue which seems relevant here: robolectric/robolectric#9124

@carstenhag
Copy link

Yep Robolectric was the issue, thank you! We were specifying @Config(sdk = [Build.VERSION_CODES.P]), afaik due to an old bug, but it seems resolved, so now we are using the default (latest sdk).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants