Skip to content

Commit f4bcb4a

Browse files
committed
Tealium, Adjust and MoEngage SDKs added from following branches: feature/NMCLOUD-339 feature/NMCLOUD-177 feature/NMCLOUD-428
1 parent 43f4b1a commit f4bcb4a

22 files changed

+458
-128
lines changed

app/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ buildscript {
1313
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
1414
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
1515
}
16+
17+
//NMC Customization
18+
allprojects {
19+
repositories {
20+
jcenter()
21+
maven {
22+
url "https://maven.tealiumiq.com/android/releases/"
23+
}
24+
}
25+
}
1626
}
1727

1828
plugins {
@@ -90,6 +100,10 @@ android {
90100
buildConfigField 'boolean', 'CI', ciBuild.toString()
91101
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
92102

103+
//NMC customization
104+
buildConfigField "String", "ADJUST_APP_TOKEN", "${ADJUST_APP_TOKEN}"
105+
buildConfigField "String", "MOENGAGE_APP_ID", "${MOENGAGE_APP_ID}"
106+
93107
javaCompileOptions {
94108
annotationProcessorOptions {
95109
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
@@ -387,6 +401,20 @@ dependencies {
387401
ksp "androidx.room:room-compiler:$roomVersion"
388402
androidTestImplementation "androidx.room:room-testing:$roomVersion"
389403

404+
//Adjust SDK --> https://github.com/adjust/android_sdk
405+
implementation 'com.adjust.sdk:adjust-android:4.28.1'
406+
implementation 'com.android.installreferrer:installreferrer:2.2'
407+
//google play services identifier required for Adjust SDK
408+
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
409+
410+
//tealium sdk
411+
implementation 'com.tealium:library:5.8.0'
412+
413+
//MoEngage SDK
414+
implementation 'com.moengage:moe-android-sdk:11.3.01'
415+
//lifecycle required for MoEngage SDK
416+
implementation 'androidx.lifecycle:lifecycle-process:2.2.0'
417+
390418
implementation "io.coil-kt:coil:2.4.0"
391419

392420
// splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate

app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,17 @@
499499
android:name="com.nextcloud.client.etm.EtmActivity"
500500
android:exported="false"
501501
android:theme="@style/Theme.ownCloud.Toolbar" />
502+
503+
<!-- Adjust SDK Declarations -->
504+
<receiver
505+
android:name="com.adjust.sdk.AdjustReferrerReceiver"
506+
android:exported="true"
507+
android:permission="android.permission.INSTALL_PACKAGES">
508+
<intent-filter>
509+
<action android:name="com.android.vending.INSTALL_REFERRER" />
510+
</intent-filter>
511+
</receiver>
512+
502513
<activity
503514
android:name=".ui.preview.PreviewBitmapActivity"
504515
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
@@ -23,6 +23,7 @@ import android.app.Activity
2323
import android.app.Application.ActivityLifecycleCallbacks
2424
import android.os.Bundle
2525
import androidx.fragment.app.FragmentActivity
26+
import com.adjust.sdk.Adjust
2627
import dagger.android.AndroidInjection
2728

2829
class ActivityInjector : ActivityLifecycleCallbacks {
@@ -41,11 +42,13 @@ class ActivityInjector : ActivityLifecycleCallbacks {
4142
}
4243

4344
override fun onActivityResumed(activity: Activity) {
44-
// unused atm
45+
// NMC Customization
46+
Adjust.onResume()
4547
}
4648

4749
override fun onActivityPaused(activity: Activity) {
48-
// unused atm
50+
// NMC Customization
51+
Adjust.onPause()
4952
}
5053

5154
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
@@ -356,6 +356,24 @@ default void onDarkThemeModeChanged(DarkMode mode) {
356356

357357
void setCurrentAccountName(String accountName);
358358

359+
/**
360+
* Saves the data analysis from privacy settings
361+
* on disabling it we should disable Adjust SDK tracking
362+
*
363+
* @param enableDataAnalysis to enable/disable data analysis
364+
*/
365+
void setDataAnalysis(boolean enableDataAnalysis);
366+
boolean isDataAnalysisEnabled();
367+
368+
/**
369+
* Saves the privacy policy action taken by user
370+
* this will maintain the state of current privacy policy action taken
371+
* @see com.nmc.android.ui.LoginPrivacySettingsActivity for actions
372+
* @param userAction taken by user
373+
*/
374+
void setPrivacyPolicyAction(int userAction);
375+
int getPrivacyPolicyAction();
376+
359377
/**
360378
* Gets status of migration to user id, default false
361379
*

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.nextcloud.client.account.UserAccountManager;
3636
import com.nextcloud.client.account.UserAccountManagerImpl;
3737
import com.nextcloud.client.jobs.LogEntry;
38+
import com.nmc.android.ui.PrivacyUserAction;
3839
import com.owncloud.android.datamodel.ArbitraryDataProvider;
3940
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
4041
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -115,6 +116,9 @@ public final class AppPreferencesImpl implements AppPreferences {
115116

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

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

628+
@Override
629+
public void setDataAnalysis(boolean enableDataAnalysis) {
630+
preferences.edit().putBoolean(PREF__DATA_ANALYSIS, enableDataAnalysis).apply();
631+
}
632+
633+
@Override
634+
public boolean isDataAnalysisEnabled() {
635+
//default value will be true
636+
return preferences.getBoolean(PREF__DATA_ANALYSIS, true);
637+
}
638+
639+
@Override
640+
public void setPrivacyPolicyAction(int userAction) {
641+
preferences.edit().putInt(PREF__PRIVACY_POLICY_ACTION, userAction).apply();
642+
}
643+
644+
@Override
645+
public int getPrivacyPolicyAction() {
646+
return preferences.getInt(PREF__PRIVACY_POLICY_ACTION, PrivacyUserAction.NO_ACTION);
647+
}
648+
624649
@Override
625650
public boolean isUserIdMigrated() {
626651
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.nmc.android.marketTracking
2+
3+
import android.app.Application
4+
import com.moengage.core.MoEngage
5+
import com.owncloud.android.BuildConfig
6+
import com.owncloud.android.R
7+
8+
object MoEngageSdkUtils {
9+
10+
//enable/disable moengage as we are not using it right now due to no proper firebase api key
11+
private const val MOENGAGE_ENABLED = false
12+
13+
@JvmStatic
14+
fun initMoEngageSDK(application: Application) {
15+
if (MOENGAGE_ENABLED) {
16+
val moEngage = MoEngage.Builder(application, BuildConfig.MOENGAGE_APP_ID)
17+
.build()
18+
MoEngage.initialise(moEngage)
19+
}
20+
}
21+
}
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+
}

0 commit comments

Comments
 (0)