Skip to content

Commit c270faf

Browse files
committed
Tealium and Adjust SDKs added from following branches: feature/NMCLOUD-339 feature/NMCLOUD-428
1 parent a311dad commit c270faf

24 files changed

+436
-130
lines changed

app/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ if (shotTest) {
5050
apply plugin: 'shot'
5151
}
5252
apply plugin: 'com.google.devtools.ksp'
53-
53+
// apply marketing SDK for NMC
54+
apply from: "$rootProject.projectDir/nmc_marketing-dependencies.gradle"
5455

5556
println "Gradle uses Java ${Jvm.current()}"
5657

@@ -430,6 +431,9 @@ dependencies {
430431

431432
// splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
432433
implementation 'androidx.core:core-splashscreen:1.0.1'
434+
435+
// NMC: dependency required to capture Advertising ID for Adjust & MoEngage SDK
436+
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
433437
}
434438

435439
configurations.configureEach {

app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,17 @@
623623
android:name="com.nextcloud.client.etm.EtmActivity"
624624
android:exported="false"
625625
android:theme="@style/Theme.ownCloud.Toolbar" />
626+
627+
<!-- Adjust SDK Declarations -->
628+
<receiver
629+
android:name="com.adjust.sdk.AdjustReferrerReceiver"
630+
android:exported="true"
631+
android:permission="android.permission.INSTALL_PACKAGES">
632+
<intent-filter>
633+
<action android:name="com.android.vending.INSTALL_REFERRER" />
634+
</intent-filter>
635+
</receiver>
636+
626637
<activity
627638
android:name=".ui.preview.PreviewBitmapActivity"
628639
android:exported="false"

app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.app.Activity
1010
import android.app.Application.ActivityLifecycleCallbacks
1111
import android.os.Bundle
1212
import androidx.fragment.app.FragmentActivity
13+
import com.adjust.sdk.Adjust
1314
import dagger.android.AndroidInjection
1415

1516
class ActivityInjector : ActivityLifecycleCallbacks {
@@ -28,11 +29,13 @@ class ActivityInjector : ActivityLifecycleCallbacks {
2829
}
2930

3031
override fun onActivityResumed(activity: Activity) {
31-
// unused atm
32+
// NMC Customization
33+
Adjust.onResume()
3234
}
3335

3436
override fun onActivityPaused(activity: Activity) {
35-
// unused atm
37+
// NMC Customization
38+
Adjust.onPause()
3639
}
3740

3841
override fun onActivityStopped(activity: Activity) {

app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,24 @@ default void onDarkThemeModeChanged(DarkMode mode) {
339339

340340
void setCurrentAccountName(String accountName);
341341

342+
/**
343+
* Saves the data analysis from privacy settings
344+
* on disabling it we should disable Adjust SDK tracking
345+
*
346+
* @param enableDataAnalysis to enable/disable data analysis
347+
*/
348+
void setDataAnalysis(boolean enableDataAnalysis);
349+
boolean isDataAnalysisEnabled();
350+
351+
/**
352+
* Saves the privacy policy action taken by user
353+
* this will maintain the state of current privacy policy action taken
354+
* @see com.nmc.android.ui.LoginPrivacySettingsActivity for actions
355+
* @param userAction taken by user
356+
*/
357+
void setPrivacyPolicyAction(int userAction);
358+
int getPrivacyPolicyAction();
359+
342360
/**
343361
* Gets status of migration to user id, default false
344362
*

app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.nextcloud.client.account.UserAccountManager;
2323
import com.nextcloud.client.account.UserAccountManagerImpl;
2424
import com.nextcloud.client.jobs.LogEntry;
25+
import com.nmc.android.ui.PrivacyUserAction;
2526
import com.owncloud.android.datamodel.ArbitraryDataProvider;
2627
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
2728
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -114,6 +115,9 @@ public final class AppPreferencesImpl implements AppPreferences {
114115

115116
private static final String LOG_ENTRY = "log_entry";
116117

118+
private static final String PREF__DATA_ANALYSIS = "data_analysis";
119+
private static final String PREF__PRIVACY_POLICY_ACTION = "privacy_policy_action";
120+
117121
private final Context context;
118122
private final SharedPreferences preferences;
119123
private final UserAccountManager userAccountManager;
@@ -620,6 +624,27 @@ public void setCurrentAccountName(String accountName) {
620624
preferences.edit().putString(PREF__SELECTED_ACCOUNT_NAME, accountName).apply();
621625
}
622626

627+
@Override
628+
public void setDataAnalysis(boolean enableDataAnalysis) {
629+
preferences.edit().putBoolean(PREF__DATA_ANALYSIS, enableDataAnalysis).apply();
630+
}
631+
632+
@Override
633+
public boolean isDataAnalysisEnabled() {
634+
//default value will be true
635+
return preferences.getBoolean(PREF__DATA_ANALYSIS, true);
636+
}
637+
638+
@Override
639+
public void setPrivacyPolicyAction(int userAction) {
640+
preferences.edit().putInt(PREF__PRIVACY_POLICY_ACTION, userAction).apply();
641+
}
642+
643+
@Override
644+
public int getPrivacyPolicyAction() {
645+
return preferences.getInt(PREF__PRIVACY_POLICY_ACTION, PrivacyUserAction.NO_ACTION);
646+
}
647+
623648
@Override
624649
public boolean isUserIdMigrated() {
625650
return preferences.getBoolean(PREF__MIGRATED_USER_ID, false);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.nmc.android.marketTracking
2+
3+
import android.app.Application
4+
import com.adjust.sdk.Adjust
5+
import com.adjust.sdk.AdjustConfig
6+
import com.adjust.sdk.AdjustEvent
7+
import com.nextcloud.client.preferences.AppPreferences
8+
import com.owncloud.android.BuildConfig
9+
10+
object AdjustSdkUtils {
11+
private val TAG = AdjustSdkUtils::class.java.simpleName
12+
13+
const val EVENT_TOKEN_LOGIN = "gb97gb"
14+
const val EVENT_TOKEN_SUCCESSFUL_LOGIN = "gx6g7g"
15+
const val EVENT_TOKEN_FILE_BROWSER_SHARING = "fqtiu7"
16+
const val EVENT_TOKEN_CREATE_SHARING_LINK = "qeyql3"
17+
18+
/* event names to be tracked on clicking of FAB button which opens BottomSheet to select options */
19+
const val EVENT_TOKEN_FAB_BOTTOM_FILE_UPLOAD = "4rd8r4"
20+
const val EVENT_TOKEN_FAB_BOTTOM_PHOTO_VIDEO_UPLOAD = "v1g6ly"
21+
const val EVENT_TOKEN_FAB_BOTTOM_DOCUMENT_SCAN = "7fec8n"
22+
const val EVENT_TOKEN_FAB_BOTTOM_CAMERA_UPLOAD = "3czack"
23+
24+
/* events for settings screen */
25+
const val EVENT_TOKEN_SETTINGS_LOGOUT = "g6mj9y"
26+
const val EVENT_TOKEN_SETTINGS_RESET = "zi18r0"
27+
const val EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_ON = "vwd9yk"
28+
const val EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_OFF = "e95w5t"
29+
30+
const val EVENT_TOKEN_BACKUP_MANUAL = "oojr4y"
31+
const val EVENT_TOKEN_BACKUP_AUTO = "7dkhkx"
32+
33+
@JvmStatic
34+
fun initialiseAdjustSDK(application: Application) {
35+
val config = AdjustConfig(
36+
application, BuildConfig.ADJUST_APP_TOKEN,
37+
getAdjustEnvironment()
38+
)
39+
Adjust.onCreate(config)
40+
}
41+
42+
/**
43+
* method to return the sdk environment for Adjust
44+
*/
45+
@JvmStatic
46+
fun getAdjustEnvironment(): String {
47+
//for qa, beta, debug apk we have to use Sandbox env
48+
if (BuildConfig.APPLICATION_ID.contains(".beta") || BuildConfig.DEBUG) {
49+
return AdjustConfig.ENVIRONMENT_SANDBOX
50+
}
51+
52+
//for release build apart from qa, beta flavours Prod env is used
53+
return AdjustConfig.ENVIRONMENT_PRODUCTION
54+
}
55+
56+
/**
57+
* method to track events
58+
* tracking event only if data analysis is enabled else don't track it
59+
*/
60+
@JvmStatic
61+
fun trackEvent(eventToken: String, appPreferences: AppPreferences?) {
62+
if (appPreferences?.isDataAnalysisEnabled == true) {
63+
val adjustEvent = AdjustEvent(eventToken)
64+
Adjust.trackEvent(adjustEvent)
65+
}
66+
}
67+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package com.nmc.android.marketTracking
2+
3+
import android.app.Application
4+
import com.nextcloud.client.preferences.AppPreferences
5+
import com.owncloud.android.BuildConfig
6+
import com.tealium.library.Tealium
7+
8+
object TealiumSdkUtils {
9+
10+
//Pre-defined values for Tealium
11+
//** DO NOT CHANGE THE VALUES **//
12+
private const val INSTANCE_NAME = "tealium_main"
13+
private const val ACCOUNT_NAME = "telekom"
14+
private const val PROFILE_NAME = "magentacloud-app"
15+
16+
//Live Version of the app (published in app stores)
17+
private const val PROD_ENV = "prod"
18+
19+
//Quality System
20+
private const val QA_ENV = "qa"
21+
22+
//Staging System (Development System)
23+
private const val DEV_ENV = "dev"
24+
25+
const val EVENT_SUCCESSFUL_LOGIN = "magentacloud-app.login.successful"
26+
const val EVENT_FILE_BROWSER_SHARING = "magentacloud-app.filebrowser.sharing"
27+
const val EVENT_CREATE_SHARING_LINK = "magentacloud-app.sharing.create"
28+
29+
/* event names to be tracked on clicking of FAB button which opens BottomSheet to select options */
30+
const val EVENT_FAB_BOTTOM_DOCUMENT_SCAN = "magentacloud-app.plus.documentscan"
31+
const val EVENT_FAB_BOTTOM_PHOTO_VIDEO_UPLOAD = "magentacloud-app.plus.fotovideoupload"
32+
const val EVENT_FAB_BOTTOM_FILE_UPLOAD = "magentacloud-app.plus.fileupload"
33+
const val EVENT_FAB_BOTTOM_CAMERA_UPLOAD = "magentacloud-app.plus.cameraupload"
34+
35+
/* events for settings screen */
36+
const val EVENT_SETTINGS_LOGOUT = "magentacloud-app.settings.logout"
37+
const val EVENT_SETTINGS_RESET = "magentacloud-app.settings.reset"
38+
const val EVENT_SETTINGS_AUTO_UPLOAD_ON = "magentacloud-app.settings.autoupload-on"
39+
const val EVENT_SETTINGS_AUTO_UPLOAD_OFF = "magentacloud-app.settings.autoupload-off"
40+
41+
const val EVENT_BACKUP_MANUAL = "magentacloud-app.backup.manual"
42+
const val EVENT_BACKUP_AUTO = "magentacloud-app.backup.auto"
43+
44+
/* Screen View Names to be tracked */
45+
const val SCREEN_VIEW_LOGIN = "magentacloud-app.login"
46+
const val SCREEN_VIEW_FILE_BROWSER = "magentacloud-app.filebrowser"
47+
const val SCREEN_VIEW_FAB_PLUS = "magentacloud-app.plus"
48+
const val SCREEN_VIEW_SHARING = "magentacloud-app.sharing"
49+
const val SCREEN_VIEW_SETTINGS = "magentacloud-app.settings"
50+
const val SCREEN_VIEW_BACKUP = "magentacloud-app.backup"
51+
52+
@JvmStatic
53+
fun initialiseTealiumSDK(application: Application) {
54+
val tealConfig = Tealium.Config.create(
55+
application,
56+
ACCOUNT_NAME,
57+
PROFILE_NAME,
58+
getTealiumEnvironment()
59+
)
60+
61+
// Override for the tag management webview URL (mobile.html)
62+
//tealConfig.setOverrideTagManagementUrl("https://tags-eu.tiqcdn.com/utag/telekom/magentacloudapp/prod/mobile" +".html");
63+
// Override for the tag management publish URL (compare to https://tealium.github.io/tealiumandroid/)
64+
//tealConfig.setOverrideTagManagementUrl("https://tags-eu.tiqcdn.com/utag/telekom/magentacloudapp/prod");
65+
Tealium.createInstance(INSTANCE_NAME, tealConfig)
66+
}
67+
68+
/**
69+
* method to return the tealium sdk environment
70+
*/
71+
private fun getTealiumEnvironment(): String {
72+
//if flavour is qa then return the qa environment
73+
if (BuildConfig.FLAVOR == "qa") {
74+
return QA_ENV
75+
}
76+
77+
//if flavour is versionDev or the build has debug mode then return dev environment
78+
if (BuildConfig.FLAVOR == "versionDev" || BuildConfig.DEBUG) {
79+
return DEV_ENV
80+
}
81+
82+
//for release build to play store return prod environment
83+
return PROD_ENV
84+
}
85+
86+
/**
87+
* method to track events
88+
* tracking event only if data analysis is enabled else don't track it
89+
*/
90+
@JvmStatic
91+
fun trackEvent(eventName: String, appPreferences: AppPreferences?) {
92+
if (appPreferences?.isDataAnalysisEnabled == true) {
93+
Tealium.getInstance(INSTANCE_NAME).trackEvent(eventName, null)
94+
}
95+
}
96+
97+
/**
98+
* method to track view
99+
* tracking view only if data analysis is enabled else don't track it
100+
*/
101+
@JvmStatic
102+
fun trackView(viewName: String, appPreferences: AppPreferences?) {
103+
if (appPreferences?.isDataAnalysisEnabled == true) {
104+
Tealium.getInstance(INSTANCE_NAME).trackView(viewName, null)
105+
}
106+
}
107+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.nmc.android.marketTracking
2+
3+
import com.nextcloud.client.preferences.AppPreferences
4+
5+
/**
6+
* interface to track the scanning events from nmc/1867-scanbot branch
7+
* for implementation look nmc/1925-market_tracking branch
8+
* this class will have the declaration for it since it has the tracking SDK's in place
9+
* since we don't have scanning functionality in this branch so to handle the event we have used interface
10+
*/
11+
interface TrackingScanInterface {
12+
13+
fun sendScanEvent(appPreferences: AppPreferences)
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.nmc.android.marketTracking
2+
3+
import com.nextcloud.client.preferences.AppPreferences
4+
5+
/**
6+
* interface impl to send the scanning events to tealium and adjust
7+
* this class will have the implementation for it since it has the tracking SDK's in place
8+
* since we don't have scanning functionality in this branch so to handle the event we have used interface
9+
* calling of this method will be done from nmc/1867-scanbot
10+
*/
11+
class TrackingScanInterfaceImpl : TrackingScanInterface {
12+
13+
override fun sendScanEvent(appPreferences: AppPreferences) {
14+
//track event on Scan Document button click
15+
AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_FAB_BOTTOM_DOCUMENT_SCAN, appPreferences)
16+
TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_FAB_BOTTOM_DOCUMENT_SCAN, appPreferences)
17+
}
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.nmc.android.ui
2+
3+
//class to handle user action for privacy
4+
object PrivacyUserAction {
5+
//privacy user action to maintain the state of privacy policy
6+
const val NO_ACTION = 0 //user has taken no action
7+
const val REJECT_ACTION = 1 //user rejected the privacy policy
8+
const val ACCEPT_ACTION = 2 //user has accepted the privacy policy
9+
}

0 commit comments

Comments
 (0)