Skip to content

Commit

Permalink
Tealium, Adjust and MoEngage SDKs added from following branches: feat…
Browse files Browse the repository at this point in the history
…ure/NMCLOUD-339 feature/NMCLOUD-177 feature/NMCLOUD-428
  • Loading branch information
surinder-tsys committed Feb 8, 2024
1 parent 9e6ac2c commit 7b5394c
Show file tree
Hide file tree
Showing 24 changed files with 460 additions and 128 deletions.
28 changes: 28 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ buildscript {
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
}

//NMC Customization
allprojects {
repositories {
jcenter()
maven {
url "https://maven.tealiumiq.com/android/releases/"
}
}
}
}

plugins {
Expand Down Expand Up @@ -90,6 +100,10 @@ android {
buildConfigField 'boolean', 'CI', ciBuild.toString()
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()

//NMC customization
buildConfigField "String", "ADJUST_APP_TOKEN", "${ADJUST_APP_TOKEN}"
buildConfigField "String", "MOENGAGE_APP_ID", "${MOENGAGE_APP_ID}"

javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
Expand Down Expand Up @@ -388,6 +402,20 @@ dependencies {
ksp "androidx.room:room-compiler:$roomVersion"
androidTestImplementation "androidx.room:room-testing:$roomVersion"

//Adjust SDK --> https://github.com/adjust/android_sdk
implementation 'com.adjust.sdk:adjust-android:4.28.1'
implementation 'com.android.installreferrer:installreferrer:2.2'
//google play services identifier required for Adjust SDK
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'

//tealium sdk
implementation 'com.tealium:library:5.8.0'

//MoEngage SDK
implementation 'com.moengage:moe-android-sdk:11.3.01'
//lifecycle required for MoEngage SDK
implementation 'androidx.lifecycle:lifecycle-process:2.2.0'

implementation "io.coil-kt:coil:2.4.0"

// splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,17 @@
android:name="com.nextcloud.client.etm.EtmActivity"
android:exported="false"
android:theme="@style/Theme.ownCloud.Toolbar" />

<!-- Adjust SDK Declarations -->
<receiver
android:name="com.adjust.sdk.AdjustReferrerReceiver"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

<activity
android:name=".ui.preview.PreviewBitmapActivity"
android:exported="false"
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.app.Activity
import android.app.Application.ActivityLifecycleCallbacks
import android.os.Bundle
import androidx.fragment.app.FragmentActivity
import com.adjust.sdk.Adjust
import dagger.android.AndroidInjection

class ActivityInjector : ActivityLifecycleCallbacks {
Expand All @@ -41,11 +42,13 @@ class ActivityInjector : ActivityLifecycleCallbacks {
}

override fun onActivityResumed(activity: Activity) {
// unused atm
// NMC Customization
Adjust.onResume()
}

override fun onActivityPaused(activity: Activity) {
// unused atm
// NMC Customization
Adjust.onPause()
}

override fun onActivityStopped(activity: Activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@ default void onDarkThemeModeChanged(DarkMode mode) {

void setCurrentAccountName(String accountName);

/**
* Saves the data analysis from privacy settings
* on disabling it we should disable Adjust SDK tracking
*
* @param enableDataAnalysis to enable/disable data analysis
*/
void setDataAnalysis(boolean enableDataAnalysis);
boolean isDataAnalysisEnabled();

/**
* Saves the privacy policy action taken by user
* this will maintain the state of current privacy policy action taken
* @see com.nmc.android.ui.LoginPrivacySettingsActivity for actions
* @param userAction taken by user
*/
void setPrivacyPolicyAction(int userAction);
int getPrivacyPolicyAction();

/**
* Gets status of migration to user id, default false
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.account.UserAccountManagerImpl;
import com.nextcloud.client.jobs.LogEntry;
import com.nmc.android.ui.PrivacyUserAction;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
import com.owncloud.android.datamodel.FileDataStorageManager;
Expand Down Expand Up @@ -115,6 +116,9 @@ public final class AppPreferencesImpl implements AppPreferences {

private static final String LOG_ENTRY = "log_entry";

private static final String PREF__DATA_ANALYSIS = "data_analysis";
private static final String PREF__PRIVACY_POLICY_ACTION = "privacy_policy_action";

private final Context context;
private final SharedPreferences preferences;
private final UserAccountManager userAccountManager;
Expand Down Expand Up @@ -621,6 +625,27 @@ public void setCurrentAccountName(String accountName) {
preferences.edit().putString(PREF__SELECTED_ACCOUNT_NAME, accountName).apply();
}

@Override
public void setDataAnalysis(boolean enableDataAnalysis) {
preferences.edit().putBoolean(PREF__DATA_ANALYSIS, enableDataAnalysis).apply();
}

@Override
public boolean isDataAnalysisEnabled() {
//default value will be true
return preferences.getBoolean(PREF__DATA_ANALYSIS, true);
}

@Override
public void setPrivacyPolicyAction(int userAction) {
preferences.edit().putInt(PREF__PRIVACY_POLICY_ACTION, userAction).apply();
}

@Override
public int getPrivacyPolicyAction() {
return preferences.getInt(PREF__PRIVACY_POLICY_ACTION, PrivacyUserAction.NO_ACTION);
}

@Override
public boolean isUserIdMigrated() {
return preferences.getBoolean(PREF__MIGRATED_USER_ID, false);
Expand Down
67 changes: 67 additions & 0 deletions app/src/main/java/com/nmc/android/marketTracking/AdjustSdkUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.nmc.android.marketTracking

import android.app.Application
import com.adjust.sdk.Adjust
import com.adjust.sdk.AdjustConfig
import com.adjust.sdk.AdjustEvent
import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.BuildConfig

object AdjustSdkUtils {
private val TAG = AdjustSdkUtils::class.java.simpleName

const val EVENT_TOKEN_LOGIN = "gb97gb"
const val EVENT_TOKEN_SUCCESSFUL_LOGIN = "gx6g7g"
const val EVENT_TOKEN_FILE_BROWSER_SHARING = "fqtiu7"
const val EVENT_TOKEN_CREATE_SHARING_LINK = "qeyql3"

/* event names to be tracked on clicking of FAB button which opens BottomSheet to select options */
const val EVENT_TOKEN_FAB_BOTTOM_FILE_UPLOAD = "4rd8r4"
const val EVENT_TOKEN_FAB_BOTTOM_PHOTO_VIDEO_UPLOAD = "v1g6ly"
const val EVENT_TOKEN_FAB_BOTTOM_DOCUMENT_SCAN = "7fec8n"
const val EVENT_TOKEN_FAB_BOTTOM_CAMERA_UPLOAD = "3czack"

/* events for settings screen */
const val EVENT_TOKEN_SETTINGS_LOGOUT = "g6mj9y"
const val EVENT_TOKEN_SETTINGS_RESET = "zi18r0"
const val EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_ON = "vwd9yk"
const val EVENT_TOKEN_SETTINGS_AUTO_UPLOAD_OFF = "e95w5t"

const val EVENT_TOKEN_BACKUP_MANUAL = "oojr4y"
const val EVENT_TOKEN_BACKUP_AUTO = "7dkhkx"

@JvmStatic
fun initialiseAdjustSDK(application: Application) {
val config = AdjustConfig(
application, BuildConfig.ADJUST_APP_TOKEN,
getAdjustEnvironment()
)
Adjust.onCreate(config)
}

/**
* method to return the sdk environment for Adjust
*/
@JvmStatic
fun getAdjustEnvironment(): String {
//for qa, beta, debug apk we have to use Sandbox env
if (BuildConfig.APPLICATION_ID.contains(".beta") || BuildConfig.DEBUG) {
return AdjustConfig.ENVIRONMENT_SANDBOX
}

//for release build apart from qa, beta flavours Prod env is used
return AdjustConfig.ENVIRONMENT_PRODUCTION
}

/**
* method to track events
* tracking event only if data analysis is enabled else don't track it
*/
@JvmStatic
fun trackEvent(eventToken: String, appPreferences: AppPreferences?) {
if (appPreferences?.isDataAnalysisEnabled == true) {
val adjustEvent = AdjustEvent(eventToken)
Adjust.trackEvent(adjustEvent)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.nmc.android.marketTracking

import android.app.Application
import com.moengage.core.MoEngage
import com.owncloud.android.BuildConfig
import com.owncloud.android.R

object MoEngageSdkUtils {

//enable/disable moengage as we are not using it right now due to no proper firebase api key
private const val MOENGAGE_ENABLED = false

@JvmStatic
fun initMoEngageSDK(application: Application) {
if (MOENGAGE_ENABLED) {
val moEngage = MoEngage.Builder(application, BuildConfig.MOENGAGE_APP_ID)
.build()
MoEngage.initialise(moEngage)
}
}
}
107 changes: 107 additions & 0 deletions app/src/main/java/com/nmc/android/marketTracking/TealiumSdkUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.nmc.android.marketTracking

import android.app.Application
import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.BuildConfig
import com.tealium.library.Tealium

object TealiumSdkUtils {

//Pre-defined values for Tealium
//** DO NOT CHANGE THE VALUES **//
private const val INSTANCE_NAME = "tealium_main"
private const val ACCOUNT_NAME = "telekom"
private const val PROFILE_NAME = "magentacloud-app"

//Live Version of the app (published in app stores)
private const val PROD_ENV = "prod"

//Quality System
private const val QA_ENV = "qa"

//Staging System (Development System)
private const val DEV_ENV = "dev"

const val EVENT_SUCCESSFUL_LOGIN = "magentacloud-app.login.successful"
const val EVENT_FILE_BROWSER_SHARING = "magentacloud-app.filebrowser.sharing"
const val EVENT_CREATE_SHARING_LINK = "magentacloud-app.sharing.create"

/* event names to be tracked on clicking of FAB button which opens BottomSheet to select options */
const val EVENT_FAB_BOTTOM_DOCUMENT_SCAN = "magentacloud-app.plus.documentscan"
const val EVENT_FAB_BOTTOM_PHOTO_VIDEO_UPLOAD = "magentacloud-app.plus.fotovideoupload"
const val EVENT_FAB_BOTTOM_FILE_UPLOAD = "magentacloud-app.plus.fileupload"
const val EVENT_FAB_BOTTOM_CAMERA_UPLOAD = "magentacloud-app.plus.cameraupload"

/* events for settings screen */
const val EVENT_SETTINGS_LOGOUT = "magentacloud-app.settings.logout"
const val EVENT_SETTINGS_RESET = "magentacloud-app.settings.reset"
const val EVENT_SETTINGS_AUTO_UPLOAD_ON = "magentacloud-app.settings.autoupload-on"
const val EVENT_SETTINGS_AUTO_UPLOAD_OFF = "magentacloud-app.settings.autoupload-off"

const val EVENT_BACKUP_MANUAL = "magentacloud-app.backup.manual"
const val EVENT_BACKUP_AUTO = "magentacloud-app.backup.auto"

/* Screen View Names to be tracked */
const val SCREEN_VIEW_LOGIN = "magentacloud-app.login"
const val SCREEN_VIEW_FILE_BROWSER = "magentacloud-app.filebrowser"
const val SCREEN_VIEW_FAB_PLUS = "magentacloud-app.plus"
const val SCREEN_VIEW_SHARING = "magentacloud-app.sharing"
const val SCREEN_VIEW_SETTINGS = "magentacloud-app.settings"
const val SCREEN_VIEW_BACKUP = "magentacloud-app.backup"

@JvmStatic
fun initialiseTealiumSDK(application: Application) {
val tealConfig = Tealium.Config.create(
application,
ACCOUNT_NAME,
PROFILE_NAME,
getTealiumEnvironment()
)

// Override for the tag management webview URL (mobile.html)
//tealConfig.setOverrideTagManagementUrl("https://tags-eu.tiqcdn.com/utag/telekom/magentacloudapp/prod/mobile" +".html");
// Override for the tag management publish URL (compare to https://tealium.github.io/tealiumandroid/)
//tealConfig.setOverrideTagManagementUrl("https://tags-eu.tiqcdn.com/utag/telekom/magentacloudapp/prod");
Tealium.createInstance(INSTANCE_NAME, tealConfig)
}

/**
* method to return the tealium sdk environment
*/
private fun getTealiumEnvironment(): String {
//if flavour is qa then return the qa environment
if (BuildConfig.FLAVOR == "qa") {
return QA_ENV
}

//if flavour is versionDev or the build has debug mode then return dev environment
if (BuildConfig.FLAVOR == "versionDev" || BuildConfig.DEBUG) {
return DEV_ENV
}

//for release build to play store return prod environment
return PROD_ENV
}

/**
* method to track events
* tracking event only if data analysis is enabled else don't track it
*/
@JvmStatic
fun trackEvent(eventName: String, appPreferences: AppPreferences?) {
if (appPreferences?.isDataAnalysisEnabled == true) {
Tealium.getInstance(INSTANCE_NAME).trackEvent(eventName, null)
}
}

/**
* method to track view
* tracking view only if data analysis is enabled else don't track it
*/
@JvmStatic
fun trackView(viewName: String, appPreferences: AppPreferences?) {
if (appPreferences?.isDataAnalysisEnabled == true) {
Tealium.getInstance(INSTANCE_NAME).trackView(viewName, null)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nmc.android.marketTracking

import com.nextcloud.client.preferences.AppPreferences

/**
* interface to track the scanning events from nmc/1867-scanbot branch
* for implementation look nmc/1925-market_tracking branch
* this class will have the declaration for it since it has the tracking SDK's in place
* since we don't have scanning functionality in this branch so to handle the event we have used interface
*/
interface TrackingScanInterface {

fun sendScanEvent(appPreferences: AppPreferences)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.nmc.android.marketTracking

import com.nextcloud.client.preferences.AppPreferences

/**
* interface impl to send the scanning events to tealium and adjust
* this class will have the implementation for it since it has the tracking SDK's in place
* since we don't have scanning functionality in this branch so to handle the event we have used interface
* calling of this method will be done from nmc/1867-scanbot
*/
class TrackingScanInterfaceImpl : TrackingScanInterface {

override fun sendScanEvent(appPreferences: AppPreferences) {
//track event on Scan Document button click
AdjustSdkUtils.trackEvent(AdjustSdkUtils.EVENT_TOKEN_FAB_BOTTOM_DOCUMENT_SCAN, appPreferences)
TealiumSdkUtils.trackEvent(TealiumSdkUtils.EVENT_FAB_BOTTOM_DOCUMENT_SCAN, appPreferences)
}
}
Loading

0 comments on commit 7b5394c

Please sign in to comment.