Skip to content

Commit 774fba6

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

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()]
@@ -379,6 +393,20 @@ dependencies {
379393
kapt "androidx.room:room-compiler:$roomVersion"
380394
androidTestImplementation "androidx.room:room-testing:$roomVersion"
381395

396+
//Adjust SDK --> https://github.com/adjust/android_sdk
397+
implementation 'com.adjust.sdk:adjust-android:4.28.1'
398+
implementation 'com.android.installreferrer:installreferrer:2.2'
399+
//google play services identifier required for Adjust SDK
400+
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
401+
402+
//tealium sdk
403+
implementation 'com.tealium:library:5.8.0'
404+
405+
//MoEngage SDK
406+
implementation 'com.moengage:moe-android-sdk:11.3.01'
407+
//lifecycle required for MoEngage SDK
408+
implementation 'androidx.lifecycle:lifecycle-process:2.2.0'
409+
382410
implementation "io.coil-kt:coil:2.4.0"
383411

384412
//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
@@ -479,6 +479,17 @@
479479
android:name="com.nextcloud.client.etm.EtmActivity"
480480
android:exported="false"
481481
android:theme="@style/Theme.ownCloud.Toolbar" />
482+
483+
<!-- Adjust SDK Declarations -->
484+
<receiver
485+
android:name="com.adjust.sdk.AdjustReferrerReceiver"
486+
android:exported="true"
487+
android:permission="android.permission.INSTALL_PACKAGES">
488+
<intent-filter>
489+
<action android:name="com.android.vending.INSTALL_REFERRER" />
490+
</intent-filter>
491+
</receiver>
492+
482493
<activity
483494
android:name=".ui.preview.PreviewBitmapActivity"
484495
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
@@ -341,6 +341,24 @@ default void onDarkThemeModeChanged(DarkMode mode) {
341341

342342
void setCurrentAccountName(String accountName);
343343

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

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.nextcloud.client.account.User;
3131
import com.nextcloud.client.account.UserAccountManager;
3232
import com.nextcloud.client.account.UserAccountManagerImpl;
33+
import com.nmc.android.ui.PrivacyUserAction;
3334
import com.owncloud.android.datamodel.ArbitraryDataProvider;
3435
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
3536
import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -103,6 +104,9 @@ public final class AppPreferencesImpl implements AppPreferences {
103104
private static final String PREF__STORAGE_PERMISSION_REQUESTED = "storage_permission_requested";
104105
private static final String PREF__IN_APP_REVIEW_DATA = "in_app_review_data";
105106

107+
private static final String PREF__DATA_ANALYSIS = "data_analysis";
108+
private static final String PREF__PRIVACY_POLICY_ACTION = "privacy_policy_action";
109+
106110
private final Context context;
107111
private final SharedPreferences preferences;
108112
private final UserAccountManager userAccountManager;
@@ -571,6 +575,27 @@ public void setCurrentAccountName(String accountName) {
571575
preferences.edit().putString(PREF__SELECTED_ACCOUNT_NAME, accountName).apply();
572576
}
573577

578+
@Override
579+
public void setDataAnalysis(boolean enableDataAnalysis) {
580+
preferences.edit().putBoolean(PREF__DATA_ANALYSIS, enableDataAnalysis).apply();
581+
}
582+
583+
@Override
584+
public boolean isDataAnalysisEnabled() {
585+
//default value will be true
586+
return preferences.getBoolean(PREF__DATA_ANALYSIS, true);
587+
}
588+
589+
@Override
590+
public void setPrivacyPolicyAction(int userAction) {
591+
preferences.edit().putInt(PREF__PRIVACY_POLICY_ACTION, userAction).apply();
592+
}
593+
594+
@Override
595+
public int getPrivacyPolicyAction() {
596+
return preferences.getInt(PREF__PRIVACY_POLICY_ACTION, PrivacyUserAction.NO_ACTION);
597+
}
598+
574599
@Override
575600
public boolean isUserIdMigrated() {
576601
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)