Panagiotis Triantafyllou

new keys

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4.6rc5' 5 + PUBLISH_VERSION = '4.5.4.6rc6'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -59,8 +59,8 @@ public class WarplyAnalyticsManager { ...@@ -59,8 +59,8 @@ public class WarplyAnalyticsManager {
59 59
60 public static void logTrackersEvent(Context context, String eventType, String eventName) { 60 public static void logTrackersEvent(Context context, String eventType, String eventName) {
61 if (WarpUtils.getTrackersEnabled(context)) { 61 if (WarpUtils.getTrackersEnabled(context)) {
62 - Warply.getInitializer(context).init(); 62 +// Warply.getInitializer(context).init();
63 - sendEvent(null, eventType.concat(":").concat(eventName), null, false); 63 + sendEvent(context, null, eventType.concat(":").concat(eventName), null, false);
64 } 64 }
65 } 65 }
66 66
...@@ -174,6 +174,29 @@ public class WarplyAnalyticsManager { ...@@ -174,6 +174,29 @@ public class WarplyAnalyticsManager {
174 WarpUtils.log("analytics micro-app is not active"); 174 WarpUtils.log("analytics micro-app is not active");
175 } 175 }
176 176
177 + private static void sendEvent(Context context, @Nullable String eventPage, String eventId, @Nullable JSONObject metadata, boolean force) {
178 + boolean isInAppAnalyticsMicroAppActive = WarplyServerPreferencesManager.isMicroAppActive(context, WarpConstants.MicroApp.CUSTOM_ANALYTICS);
179 + if (isInAppAnalyticsMicroAppActive)
180 + try {
181 + JSONObject jObj = new JSONObject();
182 + if (eventPage != null) {
183 + jObj.putOpt("page_id", eventPage);
184 + }
185 + jObj.putOpt("event_id", eventId);
186 + jObj.putOpt("time_submitted", System.currentTimeMillis() / 1000);
187 + if (metadata != null) {
188 + jObj.putOpt("action_metadata", metadata);
189 + }
190 + Warply.postMicroappData(WarpConstants.MICROAPP_INAPP_ANALYTICS, jObj, force);
191 + } catch (JSONException e) {
192 + if (WarpConstants.DEBUG) {
193 + e.printStackTrace();
194 + }
195 + }
196 + else
197 + WarpUtils.log("analytics micro-app is not active");
198 + }
199 +
177 /** 200 /**
178 * Send an in app event to the Warply server and show a campaign per screen 201 * Send an in app event to the Warply server and show a campaign per screen
179 * 202 *
......
1 package ly.warp.sdk.utils.managers; 1 package ly.warp.sdk.utils.managers;
2 2
3 +import android.content.Context;
4 +
3 import org.json.JSONArray; 5 import org.json.JSONArray;
4 import org.json.JSONObject; 6 import org.json.JSONObject;
5 7
...@@ -36,6 +38,22 @@ public class WarplyServerPreferencesManager { ...@@ -36,6 +38,22 @@ public class WarplyServerPreferencesManager {
36 MICRO_APP_STATUSES_MAP = map; 38 MICRO_APP_STATUSES_MAP = map;
37 } 39 }
38 40
41 + public static void initiateMicroAppStatusesMap(Context context) {
42 + Map<MicroApp, Boolean> map = new HashMap<>();
43 + WarplyPreferences wPref = new WarplyPreferences(context);
44 + map.put(MicroApp.CONSUMER, wPref.getConsumerAppStatus());
45 + map.put(MicroApp.APPLICATION_DATA, wPref.getAppDataStatus());
46 + map.put(MicroApp.OFFERS, wPref.getOffersStatus());
47 + map.put(MicroApp.LIFECYCLE_ANALYTICS, wPref.getLifeCycleAnalyticsStatus());
48 + map.put(MicroApp.CUSTOM_ANALYTICS, wPref.getCustomAnalyticsStatus());
49 + map.put(MicroApp.USER_TAGGING, wPref.getUserTaggingStatus());
50 + map.put(MicroApp.DEVICE_INFO, wPref.getDeviceInfoStatus());
51 + map.put(MicroApp.USER_SESSION, wPref.getUserSessionStatus());
52 + map.put(MicroApp.BEACONS, wPref.getBeaconsStatus());
53 + map.put(MicroApp.RADIO_SILENT, wPref.getRadioSilentStatus());
54 + MICRO_APP_STATUSES_MAP = map;
55 + }
56 +
39 public static boolean isMicroAppActive(MicroApp app) { 57 public static boolean isMicroAppActive(MicroApp app) {
40 58
41 if (MICRO_APP_STATUSES_MAP == null) { 59 if (MICRO_APP_STATUSES_MAP == null) {
...@@ -44,6 +62,14 @@ public class WarplyServerPreferencesManager { ...@@ -44,6 +62,14 @@ public class WarplyServerPreferencesManager {
44 return MICRO_APP_STATUSES_MAP.get(app); 62 return MICRO_APP_STATUSES_MAP.get(app);
45 } 63 }
46 64
65 + public static boolean isMicroAppActive(Context context, MicroApp app) {
66 +
67 + if (MICRO_APP_STATUSES_MAP == null) {
68 + initiateMicroAppStatusesMap(context);
69 + }
70 + return MICRO_APP_STATUSES_MAP.get(app);
71 + }
72 +
47 public static void checkServerPreferences( 73 public static void checkServerPreferences(
48 final ServerPreferencesReceivedListener receiveListener) { 74 final ServerPreferencesReceivedListener receiveListener) {
49 75
......