Panagiotis Triantafyllou

new keys

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.6rc5'
PUBLISH_VERSION = '4.5.4.6rc6'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -59,8 +59,8 @@ public class WarplyAnalyticsManager {
public static void logTrackersEvent(Context context, String eventType, String eventName) {
if (WarpUtils.getTrackersEnabled(context)) {
Warply.getInitializer(context).init();
sendEvent(null, eventType.concat(":").concat(eventName), null, false);
// Warply.getInitializer(context).init();
sendEvent(context, null, eventType.concat(":").concat(eventName), null, false);
}
}
......@@ -174,6 +174,29 @@ public class WarplyAnalyticsManager {
WarpUtils.log("analytics micro-app is not active");
}
private static void sendEvent(Context context, @Nullable String eventPage, String eventId, @Nullable JSONObject metadata, boolean force) {
boolean isInAppAnalyticsMicroAppActive = WarplyServerPreferencesManager.isMicroAppActive(context, WarpConstants.MicroApp.CUSTOM_ANALYTICS);
if (isInAppAnalyticsMicroAppActive)
try {
JSONObject jObj = new JSONObject();
if (eventPage != null) {
jObj.putOpt("page_id", eventPage);
}
jObj.putOpt("event_id", eventId);
jObj.putOpt("time_submitted", System.currentTimeMillis() / 1000);
if (metadata != null) {
jObj.putOpt("action_metadata", metadata);
}
Warply.postMicroappData(WarpConstants.MICROAPP_INAPP_ANALYTICS, jObj, force);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
}
}
else
WarpUtils.log("analytics micro-app is not active");
}
/**
* Send an in app event to the Warply server and show a campaign per screen
*
......
package ly.warp.sdk.utils.managers;
import android.content.Context;
import org.json.JSONArray;
import org.json.JSONObject;
......@@ -36,6 +38,22 @@ public class WarplyServerPreferencesManager {
MICRO_APP_STATUSES_MAP = map;
}
public static void initiateMicroAppStatusesMap(Context context) {
Map<MicroApp, Boolean> map = new HashMap<>();
WarplyPreferences wPref = new WarplyPreferences(context);
map.put(MicroApp.CONSUMER, wPref.getConsumerAppStatus());
map.put(MicroApp.APPLICATION_DATA, wPref.getAppDataStatus());
map.put(MicroApp.OFFERS, wPref.getOffersStatus());
map.put(MicroApp.LIFECYCLE_ANALYTICS, wPref.getLifeCycleAnalyticsStatus());
map.put(MicroApp.CUSTOM_ANALYTICS, wPref.getCustomAnalyticsStatus());
map.put(MicroApp.USER_TAGGING, wPref.getUserTaggingStatus());
map.put(MicroApp.DEVICE_INFO, wPref.getDeviceInfoStatus());
map.put(MicroApp.USER_SESSION, wPref.getUserSessionStatus());
map.put(MicroApp.BEACONS, wPref.getBeaconsStatus());
map.put(MicroApp.RADIO_SILENT, wPref.getRadioSilentStatus());
MICRO_APP_STATUSES_MAP = map;
}
public static boolean isMicroAppActive(MicroApp app) {
if (MICRO_APP_STATUSES_MAP == null) {
......@@ -44,6 +62,14 @@ public class WarplyServerPreferencesManager {
return MICRO_APP_STATUSES_MAP.get(app);
}
public static boolean isMicroAppActive(Context context, MicroApp app) {
if (MICRO_APP_STATUSES_MAP == null) {
initiateMicroAppStatusesMap(context);
}
return MICRO_APP_STATUSES_MAP.get(app);
}
public static void checkServerPreferences(
final ServerPreferencesReceivedListener receiveListener) {
......