diff --git a/.gitignore b/.gitignore
index 6eadbe346..3ce970ca1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -85,6 +85,7 @@ gen-external-apklibs
.mls_token
.nimbus
.wallpaper_url
+.pocket_consumer_key
# Python Byte-compiled / optimized / DLL files
__pycache__/
diff --git a/app/build.gradle b/app/build.gradle
index f1af1a008..e3370b4ad 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -389,6 +389,21 @@ android.applicationVariants.all { variant ->
buildConfigField 'String', 'WALLPAPER_URL', '""'
println("--")
}
+
+// -------------------------------------------------------------------------------------------------
+// BuildConfig: Set the Pocket consumer key from a local file if it exists
+// -------------------------------------------------------------------------------------------------
+
+ print("Pocket consumer key: ")
+
+ try {
+ def token = new File("${rootDir}/.pocket_consumer_key").text.trim()
+ buildConfigField 'String', 'POCKET_CONSUMER_KEY', '"' + token + '"'
+ println "(Added from .pocket_consumer_key file)"
+ } catch (FileNotFoundException ignored) {
+ buildConfigField 'String', 'POCKET_CONSUMER_KEY', '""'
+ println("--")
+ }
}
// Generate Kotlin code for the Fenix Glean metrics.
diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt
index bb0cad54c..7ed670dbf 100644
--- a/app/src/main/java/org/mozilla/fenix/components/Core.kt
+++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt
@@ -365,8 +365,10 @@ class Core(
PocketStoriesConfig(
client,
Frequency(4, TimeUnit.HOURS),
- // These need to be updated. See https://mozilla-hub.atlassian.net/browse/FNXV2-20329.
- Profile(UUID.randomUUID(), "fenix")
+ Profile(
+ profileId = UUID.fromString(context.settings().pocketSponsoredStoriesProfileId),
+ appId = BuildConfig.POCKET_CONSUMER_KEY
+ )
)
}
val pocketStoriesService by lazyMonitored { PocketStoriesService(context, pocketStoriesConfig) }
diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
index 521fed877..d22aa1f5e 100644
--- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
+++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
@@ -53,6 +53,7 @@ import org.mozilla.fenix.settings.sitepermissions.AUTOPLAY_BLOCK_ALL
import org.mozilla.fenix.settings.sitepermissions.AUTOPLAY_BLOCK_AUDIBLE
import org.mozilla.fenix.wallpapers.WallpaperManager
import java.security.InvalidParameterException
+import java.util.UUID
private const val AUTOPLAY_USER_SETTING = "AUTOPLAY_USER_SETTING"
@@ -1274,6 +1275,15 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = { homescreenSections[HomeScreenSection.POCKET] == true },
)
+ /**
+ * Get the profile id to use in the sponsored stories communications with the Pocket endpoint.
+ */
+ val pocketSponsoredStoriesProfileId by stringPreference(
+ appContext.getPreferenceKey(R.string.pref_key_pocket_sponsored_stories_profile),
+ default = UUID.randomUUID().toString(),
+ persistDefaultIfNotExists = true
+ )
+
/**
* Indicates if the Contile functionality should be visible.
*/
diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml
index cd6302f4c..fae4725c5 100644
--- a/app/src/main/res/values/preference_keys.xml
+++ b/app/src/main/res/values/preference_keys.xml
@@ -279,6 +279,10 @@
pref_key_open_next_tab_desktop_mode
+
+ pref_key_pocket_homescreen_recommendations
+ pref_key_pocket_sponsored_stories_profile
+
pref_key_secret_debug_info
@@ -287,6 +291,5 @@
pref_key_nimbus_experiments
pref_key_nimbus_use_preview
pref_key_history_metadata_feature
- pref_key_pocket_homescreen_recommendations
pref_key_show_unified_search
diff --git a/taskcluster/fenix_taskgraph/transforms/build.py b/taskcluster/fenix_taskgraph/transforms/build.py
index 51c8bed35..81aa5720a 100644
--- a/taskcluster/fenix_taskgraph/transforms/build.py
+++ b/taskcluster/fenix_taskgraph/transforms/build.py
@@ -55,6 +55,7 @@ def add_shippable_secrets(config, tasks):
("mls", ".mls_token"),
("nimbus_url", ".nimbus"),
("wallpaper_url", ".wallpaper_url"),
+ ("pocket_consumer_key", ".pocket_consumer_key"),
)
]
)