Skip to content

Commit dfc49b3

Browse files
committed
Tealium and Adjust SDKs added from following branches: feature/NMCLOUD-339 feature/NMCLOUD-428
NMC-3897 -- Adjust v5 migration from v4
1 parent f24ef3a commit dfc49b3

24 files changed

+447
-133
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

@@ -445,6 +446,9 @@ dependencies {
445446
implementation "com.github.nextcloud.android-common:ui:$androidCommonLibraryVersion"
446447

447448
implementation "io.coil-kt:coil:2.7.0"
449+
450+
// NMC: dependency required to capture Advertising ID for Adjust & MoEngage SDK
451+
implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"
448452
}
449453

450454
configurations.configureEach {

app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,17 @@
630630
android:name="com.nextcloud.client.etm.EtmActivity"
631631
android:exported="false"
632632
android:theme="@style/Theme.ownCloud.Toolbar" />
633+
634+
<!-- Adjust SDK Declarations -->
635+
<receiver
636+
android:name="com.adjust.sdk.AdjustReferrerReceiver"
637+
android:exported="true"
638+
android:permission="android.permission.INSTALL_PACKAGES">
639+
<intent-filter>
640+
<action android:name="com.android.vending.INSTALL_REFERRER" />
641+
</intent-filter>
642+
</receiver>
643+
633644
<activity
634645
android:name=".ui.preview.PreviewBitmapActivity"
635646
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
@@ -331,6 +331,24 @@ default void onDarkThemeModeChanged(DarkMode mode) {
331331

332332
void setCurrentAccountName(String accountName);
333333

334+
/**
335+
* Saves the data analysis from privacy settings
336+
* on disabling it we should disable Adjust SDK tracking
337+
*
338+
* @param enableDataAnalysis to enable/disable data analysis
339+
*/
340+
void setDataAnalysis(boolean enableDataAnalysis);
341+
boolean isDataAnalysisEnabled();
342+
343+
/**
344+
* Saves the privacy policy action taken by user
345+
* this will maintain the state of current privacy policy action taken
346+
* @see com.nmc.android.ui.LoginPrivacySettingsActivity for actions
347+
* @param userAction taken by user
348+
*/
349+
void setPrivacyPolicyAction(int userAction);
350+
int getPrivacyPolicyAction();
351+
334352
/**
335353
* Gets status of migration to user id, default false
336354
*

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;
@@ -112,6 +113,9 @@ public final class AppPreferencesImpl implements AppPreferences {
112113

113114
private static final String LOG_ENTRY = "log_entry";
114115

116+
private static final String PREF__DATA_ANALYSIS = "data_analysis";
117+
private static final String PREF__PRIVACY_POLICY_ACTION = "privacy_policy_action";
118+
115119
private final Context context;
116120
private final SharedPreferences preferences;
117121
private final UserAccountManager userAccountManager;
@@ -613,6 +617,27 @@ public void setCurrentAccountName(String accountName) {
613617
preferences.edit().putString(PREF__SELECTED_ACCOUNT_NAME, accountName).apply();
614618
}
615619

620+
@Override
621+
public void setDataAnalysis(boolean enableDataAnalysis) {
622+
preferences.edit().putBoolean(PREF__DATA_ANALYSIS, enableDataAnalysis).apply();
623+
}
624+
625+
@Override
626+
public boolean isDataAnalysisEnabled() {
627+
//default value will be true
628+
return preferences.getBoolean(PREF__DATA_ANALYSIS, true);
629+
}
630+
631+
@Override
632+
public void setPrivacyPolicyAction(int userAction) {
633+
preferences.edit().putInt(PREF__PRIVACY_POLICY_ACTION, userAction).apply();
634+
}
635+
636+
@Override
637+
public int getPrivacyPolicyAction() {
638+
return preferences.getInt(PREF__PRIVACY_POLICY_ACTION, PrivacyUserAction.NO_ACTION);
639+
}
640+
616641
@Override
617642
public boolean isUserIdMigrated() {
618643
return preferences.getBoolean(PREF__MIGRATED_USER_ID, false);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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.adjust.sdk.LogLevel
8+
import com.nextcloud.client.preferences.AppPreferences
9+
import com.owncloud.android.BuildConfig
10+
11+
object AdjustSdkUtils {
12+
private val TAG = AdjustSdkUtils::class.java.simpleName
13+
14+
const val EVENT_TOKEN_LOGIN = "gb97gb"
15+
const val EVENT_TOKEN_SUCCESSFUL_LOGIN = "gx6g7g"
16+
const val EVENT_TOKEN_FILE_BROWSER_SHARING = "fqtiu7"
17+
const val EVENT_TOKEN_CREATE_SHARING_LINK = "qeyql3"
18+
19+
/* event names to be tracked on clicking of FAB button which opens BottomSheet to select options */
20+
const val EVENT_TOKEN_FAB_BOTTOM_FILE_UPLOAD = "4rd8r4"
21+
const val EVENT_TOKEN_FAB_BOTTOM_PHOTO_VIDEO_UPLOAD = "v1g6ly"
22+
const val EVENT_TOKEN_FAB_BOTTOM_DOCUMENT_SCAN = "7fec8n"
23+
const val EVENT_TOKEN_FAB_BOTTOM_CAMERA_UPLOAD = "3czack"
24+
25+
/* events for settings screen */
26+
const val EVENT_TOKEN_SETTINGS_LOGOUT = "g6mj9y"
27+
const val EVENT_TOKEN_SETTINGS_RESET = "zi18r0"
28+
const val EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_ON = "vwd9yk"
29+
const val EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_OFF = "e95w5t"
30+
31+
const val EVENT_TOKEN_BACKUP_MANUAL = "oojr4y"
32+
const val EVENT_TOKEN_BACKUP_AUTO = "7dkhkx"
33+
34+
@JvmStatic
35+
fun initialiseAdjustSDK(application: Application) {
36+
val config = AdjustConfig(
37+
application, BuildConfig.ADJUST_APP_TOKEN,
38+
getAdjustEnvironment(),
39+
)
40+
config.setLogLevel(getLogLevel())
41+
// send captured events when app is running
42+
config.enableSendingInBackground()
43+
Adjust.initSdk(config)
44+
}
45+
46+
/**
47+
* method to return the sdk environment for Adjust
48+
*/
49+
@JvmStatic
50+
fun getAdjustEnvironment(): String {
51+
//for qa, beta, debug apk we have to use Sandbox env
52+
if (BuildConfig.APPLICATION_ID.contains(".beta") || BuildConfig.DEBUG) {
53+
return AdjustConfig.ENVIRONMENT_SANDBOX
54+
}
55+
56+
//for release build apart from qa, beta flavours Prod env is used
57+
return AdjustConfig.ENVIRONMENT_PRODUCTION
58+
}
59+
60+
@JvmStatic
61+
fun getLogLevel(): LogLevel {
62+
return if (BuildConfig.DEBUG) LogLevel.VERBOSE else LogLevel.WARN
63+
}
64+
65+
/**
66+
* method to track events
67+
* tracking event only if data analysis is enabled else don't track it
68+
*/
69+
@JvmStatic
70+
fun trackEvent(eventToken: String, appPreferences: AppPreferences?) {
71+
if (appPreferences?.isDataAnalysisEnabled == true) {
72+
val adjustEvent = AdjustEvent(eventToken)
73+
Adjust.trackEvent(adjustEvent)
74+
}
75+
}
76+
}
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)