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+ }
0 commit comments