Skip to content

Commit

Permalink
Checking if the PA manager is initialized before checking enablement
Browse files Browse the repository at this point in the history
Summary: We noticed that, sometimes joining PA group request failed because PACustomAudienceClient.enabled() did not get a chance to be triggered, e.g.  PACustomAudienceClient. enabled() is called after AppEventManager starts.  In this diff, we try to enable PA when a join request happens if it is not yet initialized in order to not miss any request.

Reviewed By: youerkang

Differential Revision:
D69957967

Privacy Context Container: L1250336

fbshipit-source-id: 1409b0e8b815dc924ad9a0e252712bd538828445
  • Loading branch information
Shen Guo authored and facebook-github-bot committed Feb 21, 2025
1 parent 462aad0 commit 7638285
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ object PACustomAudienceClient {
// Sync with RestrictiveDataManager.REPLACEMENT_STRING
private const val REPLACEMENT_STRING = "_removed_"
private var enabled = false
private var isInitialized = false
private var customAudienceManager: CustomAudienceManager? = null
private lateinit var gpsDebugLogger: GpsDebugLogger
private lateinit var baseUri: String

@JvmStatic
@TargetApi(34)
fun enable() {
isInitialized = true
val context = FacebookSdk.getApplicationContext()
gpsDebugLogger = GpsDebugLogger(context)
baseUri = "https://www.${FacebookSdk.getFacebookDomain()}/privacy_sandbox/pa/logic"
Expand Down Expand Up @@ -75,13 +77,21 @@ object PACustomAudienceClient {
}

fun joinCustomAudience(appId: String?, eventName: String?) {
if (!isInitialized) {
enable()
}

if (!enabled) return

joinCustomAudienceImpl(appId, eventName)
}


fun joinCustomAudience(appId: String?, event: AppEvent?) {
if (!isInitialized) {
enable()
}

if (!enabled) return

var eventName: String? = null
Expand Down

0 comments on commit 7638285

Please sign in to comment.