Skip to content

Commit

Permalink
Finally track notifications sent, so we don't repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Anlu Wang committed Apr 1, 2014
1 parent 9bc6f2a commit 0216563
Showing 1 changed file with 17 additions and 1 deletion.
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 0216563

Please sign in to comment.