summaryrefslogtreecommitdiffstats
path: root/mobile/android/base/java/org/mozilla/gecko/telemetry/measurements/CampaignIdMeasurements.java
diff options
context:
space:
mode:
Diffstat (limited to 'mobile/android/base/java/org/mozilla/gecko/telemetry/measurements/CampaignIdMeasurements.java')
-rw-r--r--mobile/android/base/java/org/mozilla/gecko/telemetry/measurements/CampaignIdMeasurements.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/measurements/CampaignIdMeasurements.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/measurements/CampaignIdMeasurements.java
new file mode 100644
index 000000000..61229b21b
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/measurements/CampaignIdMeasurements.java
@@ -0,0 +1,37 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, you can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.mozilla.gecko.telemetry.measurements;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+
+import org.mozilla.gecko.GeckoSharedPrefs;
+import org.mozilla.gecko.adjust.AttributionHelperListener;
+
+/**
+ * A class to retrieve and store the campaign Id pref that is used when the Adjust SDK gives us
+ * new attribution from the {@link AttributionHelperListener}.
+ */
+public class CampaignIdMeasurements {
+ private static final String PREF_CAMPAIGN_ID = "measurements-campaignId";
+
+ public static String getCampaignIdFromPrefs(@NonNull final Context context) {
+ return GeckoSharedPrefs.forProfile(context)
+ .getString(PREF_CAMPAIGN_ID, null);
+ }
+
+ public static void updateCampaignIdPref(@NonNull final Context context, @NonNull final String campaignId) {
+ if (TextUtils.isEmpty(campaignId)) {
+ return;
+ }
+ GeckoSharedPrefs.forProfile(context)
+ .edit()
+ .putString(PREF_CAMPAIGN_ID, campaignId)
+ .apply();
+ }
+}