Skip to content

Commit

Permalink
Merge branch 'in_app_notifications' into v4.1.0-RC
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowers committed Apr 1, 2014
2 parents f39d05a + 0216563 commit bcf5671
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/mixpanel/android/mpmetrics/MPConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// Set to true to see lots of internal debugging logcat output.
// This should be set to false in production builds
public static final boolean DEBUG = true;
public static final boolean DEBUG = false;

// Name for persistent storage of app referral SharedPreferences
/* package */ static final String REFERRER_PREFS_NAME = "com.mixpanel.android.mpmetrics.ReferralInfo";
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/mixpanel/android/mpmetrics/MixpanelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ public void run() {
transaction.setCustomAnimations(0, R.anim.com_mixpanel_android_slide_down);
transaction.add(android.R.id.content, inapp);
transaction.commit();
track("$campaign_delivery", showInApp.getCampaignProperties()); // TODO Move?
trackNotificationSeen(showInApp);
}
break;
case TAKEOVER: {
Expand All @@ -1172,6 +1172,7 @@ public void run() {
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.putExtra(SurveyActivity.INTENT_ID_KEY, intentId);
parent.startActivity(intent);
trackNotificationSeen(showInApp);
}
break;
default:
Expand All @@ -1182,6 +1183,21 @@ public void run() {
lock.unlock();
}
} // run()

private void trackNotificationSeen(InAppNotification notif) {
track("$campaign_delivery", notif.getCampaignProperties());

final MixpanelAPI.People people = getPeople().withIdentity(getDistinctId());
final DateFormat dateFormat = new SimpleDateFormat(ENGAGE_DATE_FORMAT_STRING);
final JSONObject notifProperties = notif.getCampaignProperties();
try {
notifProperties.put("$time", dateFormat.format(new Date()));
} catch (JSONException e) {
Log.e(LOGTAG, "Exception trying to track an in app notification seen", e);
}
people.append("$campaigns", notif.getId());
people.append("$notifications", notifProperties);
}
});
}

Expand Down

0 comments on commit bcf5671

Please sign in to comment.