Skip to content

Commit

Permalink
Added option to disable Facebook Attribution tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
SpertsyanKM committed Dec 23, 2024
1 parent c52a5b8 commit d030ec8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/qonversion/android/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void onCreate() {
QLaunchMode.SubscriptionManagement
)
.setEnvironment(QEnvironment.Sandbox) // For Automation testing
.disableFacebookAttribution()
.build();
Qonversion.initialize(qonversionConfig);

Expand Down
12 changes: 11 additions & 1 deletion sdk/src/main/java/com/qonversion/android/sdk/QonversionConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class QonversionConfig internal constructor(
internal var entitlementsUpdateListener: QEntitlementsUpdateListener? = null
internal var proxyUrl: String? = null
internal var isKidsMode: Boolean = false
internal var sendFbAttribution: Boolean = true
@RawRes
internal var fallbackFileIdentifier: Int? = null

Expand Down Expand Up @@ -133,6 +134,15 @@ class QonversionConfig internal constructor(
this.isKidsMode = true
}

/**
* Use this function to disable tracking of Facebook Attribution ID.
* It may be helpful if you face "Social Account information tracking without
* a prominent disclosure" warning during the Google Play Review.
*/
fun disableFacebookAttribution(): Builder = apply {
sendFbAttribution = false
}

/**
* Generate [QonversionConfig] instance with all the provided configurations.
* This method also validates some of the provided data.
Expand All @@ -150,7 +160,7 @@ class QonversionConfig internal constructor(
Log.w("Qonversion", "Environment level is set to Sandbox for release build.")
}

val primaryConfig = PrimaryConfig(projectKey, launchMode, environment, proxyUrl, isKidsMode)
val primaryConfig = PrimaryConfig(projectKey, launchMode, environment, proxyUrl, isKidsMode, sendFbAttribution)
val cacheConfig = CacheConfig(entitlementsCacheLifetime, fallbackFileIdentifier)

return QonversionConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ internal class QonversionInternal(
remoteConfigManager = localRemoteConfigManager

userPropertiesManager.productCenterManager = productCenterManager
userPropertiesManager.sendFacebookAttribution()
if (internalConfig.primaryConfig.sendFbAttribution) {
userPropertiesManager.sendFacebookAttribution()
}

remoteConfigManager.userPropertiesManager = userPropertiesManager

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ internal data class PrimaryConfig(
val environment: QEnvironment,
val proxyUrl: String? = null,
val isKidsMode: Boolean = false,
val sendFbAttribution: Boolean = true,
val sdkVersion: String = BuildConfig.VERSION_NAME
)
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,32 @@ internal class QonversionConfigTest {
// then
assertThat(builder.isKidsMode).isFalse()
}

@Test
fun `disabling FB attribution tracking`() {
// given
val builder =
QonversionConfig.Builder(mockContext, projectKey, mockLaunchMode)

// when
builder.disableFacebookAttribution()

// then
assertThat(builder.sendFbAttribution).isFalse()
}

@Test
fun `remain FB attribution tracking enabled`() {
// given
val builder =
QonversionConfig.Builder(mockContext, projectKey, mockLaunchMode)

// when


// then
assertThat(builder.sendFbAttribution).isTrue()
}
}

@Nested
Expand Down

0 comments on commit d030ec8

Please sign in to comment.