Skip to content

Commit defad4a

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

22 files changed

+448
-4
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 {
@@ -88,6 +98,10 @@ android {
8898
buildConfigField 'boolean', 'CI', ciBuild.toString()
8999
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
90100

101+
//NMC customization
102+
buildConfigField "String", "ADJUST_APP_TOKEN", "${ADJUST_APP_TOKEN}"
103+
buildConfigField "String", "MOENGAGE_APP_ID", "${MOENGAGE_APP_ID}"
104+
91105
javaCompileOptions {
92106
annotationProcessorOptions {
93107
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
@@ -384,6 +398,20 @@ dependencies {
384398
kapt "androidx.room:room-compiler:$roomVersion"
385399
androidTestImplementation "androidx.room:room-testing:$roomVersion"
386400

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

389417
//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
@@ -489,6 +489,17 @@
489489
android:name="com.nextcloud.client.etm.EtmActivity"
490490
android:exported="false"
491491
android:theme="@style/Theme.ownCloud.Toolbar" />
492+
493+
<!-- Adjust SDK Declarations -->
494+
<receiver
495+
android:name="com.adjust.sdk.AdjustReferrerReceiver"
496+
android:exported="true"
497+
android:permission="android.permission.INSTALL_PACKAGES">
498+
<intent-filter>
499+
<action android:name="com.android.vending.INSTALL_REFERRER" />
500+
</intent-filter>
501+
</receiver>
502+
492503
<activity
493504
android:name=".ui.preview.PreviewBitmapActivity"
494505
android:exported="false"

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import android.app.Activity;
2424
import android.app.Application;
2525
import android.os.Bundle;
26+
27+
import com.adjust.sdk.Adjust;
28+
2629
import androidx.fragment.app.FragmentActivity;
2730
import androidx.fragment.app.FragmentManager;
2831
import dagger.android.AndroidInjection;
@@ -48,12 +51,14 @@ public final void onActivityStarted(Activity activity) {
4851

4952
@Override
5053
public final void onActivityResumed(Activity activity) {
51-
// not needed
54+
//NMC Customization
55+
Adjust.onResume();
5256
}
5357

5458
@Override
5559
public final void onActivityPaused(Activity activity) {
56-
// not needed
60+
//NMC Customization
61+
Adjust.onPause();
5762
}
5863

5964
@Override

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

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

347347
void setCurrentAccountName(String accountName);
348348

349+
/**
350+
* Saves the data analysis from privacy settings
351+
* on disabling it we should disable Adjust SDK tracking
352+
*
353+
* @param enableDataAnalysis to enable/disable data analysis
354+
*/
355+
void setDataAnalysis(boolean enableDataAnalysis);
356+
boolean isDataAnalysisEnabled();
357+
358+
/**
359+
* Saves the privacy policy action taken by user
360+
* this will maintain the state of current privacy policy action taken
361+
* @see com.nmc.android.ui.LoginPrivacySettingsActivity for actions
362+
* @param userAction taken by user
363+
*/
364+
void setPrivacyPolicyAction(int userAction);
365+
int getPrivacyPolicyAction();
366+
349367
/**
350368
* Gets status of migration to user id, default false
351369
*

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.nextcloud.client.account.User;
3333
import com.nextcloud.client.account.UserAccountManager;
3434
import com.nextcloud.client.account.UserAccountManagerImpl;
35+
import com.nmc.android.ui.PrivacyUserAction;
3536
import com.owncloud.android.datamodel.ArbitraryDataProvider;
3637
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
3738
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -107,6 +108,9 @@ public final class AppPreferencesImpl implements AppPreferences {
107108
private static final String PREF__STORAGE_PERMISSION_REQUESTED = "storage_permission_requested";
108109
private static final String PREF__IN_APP_REVIEW_DATA = "in_app_review_data";
109110

111+
private static final String PREF__DATA_ANALYSIS = "data_analysis";
112+
private static final String PREF__PRIVACY_POLICY_ACTION = "privacy_policy_action";
113+
110114
private final Context context;
111115
private final SharedPreferences preferences;
112116
private final UserAccountManager userAccountManager;
@@ -585,6 +589,27 @@ public void setCurrentAccountName(String accountName) {
585589
preferences.edit().putString(PREF__SELECTED_ACCOUNT_NAME, accountName).apply();
586590
}
587591

592+
@Override
593+
public void setDataAnalysis(boolean enableDataAnalysis) {
594+
preferences.edit().putBoolean(PREF__DATA_ANALYSIS, enableDataAnalysis).apply();
595+
}
596+
597+
@Override
598+
public boolean isDataAnalysisEnabled() {
599+
//default value will be true
600+
return preferences.getBoolean(PREF__DATA_ANALYSIS, true);
601+
}
602+
603+
@Override
604+
public void setPrivacyPolicyAction(int userAction) {
605+
preferences.edit().putInt(PREF__PRIVACY_POLICY_ACTION, userAction).apply();
606+
}
607+
608+
@Override
609+
public int getPrivacyPolicyAction() {
610+
return preferences.getInt(PREF__PRIVACY_POLICY_ACTION, PrivacyUserAction.NO_ACTION);
611+
}
612+
588613
@Override
589614
public boolean isUserIdMigrated() {
590615
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+
}

0 commit comments

Comments
 (0)