Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -218,6 +221,12 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
}
}
startService(new Intent(this, NotificationsScreenLockWatchService.class));

// ensure the deep linking activity is enabled. It may have been disabled elsewhere and failed to get re-enabled
WPActivityUtils.enableComponent(this, ReaderPostPagerActivity.class);

// monitor whether we're not the default app
trackDefaultApp();
}

@Override
Expand Down Expand Up @@ -345,7 +354,7 @@ protected void onResume() {

new CheckUnseenNotesTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

// ensure the deep linking activity is enabled. It may have been disabled elsewhere and failed to get re-enabled
// ensure the deep linking activity is enabled. We might be returning from the external-browser viewing of a post
WPActivityUtils.enableComponent(this, ReaderPostPagerActivity.class);

// We need to track the current item on the screen when this activity is resumed.
Expand Down Expand Up @@ -426,6 +435,16 @@ private void trackLastVisibleTab(int position, boolean trackAnalytics) {
}
}

private void trackDefaultApp() {
Intent wpcomIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.wordpresscom_sample_post)));
ResolveInfo resolveInfo = getPackageManager().resolveActivity(wpcomIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo != null && !getPackageName().equals(resolveInfo.activityInfo.name)) {
// not set as default handler so, track this to evaluate. Note, a resolver/chooser might be the default.
AnalyticsUtils.trackWithDefaultInterceptor(AnalyticsTracker.Stat.DEEP_LINK_NOT_DEFAULT_HANDER,
resolveInfo.activityInfo.name);
}
}

public void setReaderTabActive() {
if (isFinishing() || mTabLayout == null) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class AnalyticsUtils {
private static String INTENT_ACTION = "intent_action";
private static String INTENT_DATA = "intent_data";
private static String INTERCEPTED_URI = "intercepted_uri";
private static String INTERCEPTOR_CLASSNAME = "interceptor_classname";

/**
* Utility method to refresh mixpanel metadata.
Expand Down Expand Up @@ -277,7 +278,21 @@ public static void trackWithInterceptedUri(AnalyticsTracker.Stat stat, String in
AnalyticsTracker.track(stat, properties);
}

/**
/**
* Track when app launched via deep-linking but then fell back to external browser
*
* @param stat The Stat to bump
* @param interceptorClassname The name of the class that handles the intercept by default
*
*/
public static void trackWithDefaultInterceptor(AnalyticsTracker.Stat stat, String interceptorClassname) {
Map<String, Object> properties = new HashMap<>();
properties.put(INTERCEPTOR_CLASSNAME, interceptorClassname);

AnalyticsTracker.track(stat, properties);
}

/**
* Track when a railcar item has been rendered
*
* @param post The JSON string of the railcar
Expand Down
2 changes: 2 additions & 0 deletions WordPress/src/main/res/values/key_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,6 @@
<string name="asset_statements" translatable="false">
[{\"include\": \"https://wordpress.com/.well-known/assetlinks.json\"}]
</string>

<string name="wordpresscom_sample_post" translatable="false">https://en.blog.wordpress.com/2016/09/26/the-best-of-wordpress-september-2016/</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public enum Stat {
TRAIN_TRACKS_INTERACT,
DEEP_LINKED,
DEEP_LINKED_FALLBACK,
DEEP_LINK_NOT_DEFAULT_HANDER,
}

private static final List<Tracker> TRACKERS = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,10 @@ private AnalyticsTrackerMixpanelInstructionsForStat instructionsForStat(
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Deep linked fallback");
break;
case DEEP_LINK_NOT_DEFAULT_HANDER:
instructions = AnalyticsTrackerMixpanelInstructionsForStat.
mixpanelInstructionsForEventName("Deep link not default handler");
break;
default:
instructions = null;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
return "deep_linked";
case DEEP_LINKED_FALLBACK:
return "deep_linked_fallback";
case DEEP_LINK_NOT_DEFAULT_HANDER:
return "deep_link_not_default_handler";
default:
return null;
}
Expand Down