Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2532, put user into onboarding when they click the screenshot bu…
Browse files Browse the repository at this point in the history
…tton on an unshootable page
  • Loading branch information
ianb committed Apr 6, 2017
1 parent ec4fd0b commit 2e5ce26
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
26 changes: 24 additions & 2 deletions addon/webextension/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ window.main = (function () {
return backend;
};

function getOnboardingUrl() {
return backend + "/#hello";
}

for (let permission of manifest.permissions) {
if (permission.search(/^https?:\/\//i) != -1) {
exports.setBackend(permission);
Expand Down Expand Up @@ -64,6 +68,11 @@ window.main = (function () {

browser.browserAction.onClicked.addListener(catcher.watchFunction((tab) => {
if (shouldOpenMyShots(tab.url)) {
if (! hasSeenOnboarding) {
sendEvent("goto-onboarding", "selection-button");
catcher.watchPromise(forceOnboarding());
return;
}
catcher.watchPromise(analytics.refreshTelemetryPref().then(() => {
sendEvent("goto-myshots", "about-newtab");
}));
Expand All @@ -76,10 +85,22 @@ window.main = (function () {
.then(active => {
const event = active ? "start-shot" : "cancel-shot";
sendEvent(event, "toolbar-button");
}, (error) => {
if (error.popupMessage == "UNSHOOTABLE_PAGE") {
sendEvent("goto-onboarding", "selection-button");
return forceOnboarding();
}
throw error;
}));
}
}));

function forceOnboarding() {
return browser.tabs.create({url: getOnboardingUrl()}).then((tab) => {
return toggleSelector(tab);
});
}

browser.contextMenus.create({
id: "create-screenshot",
title: browser.i18n.getMessage("contextMenuLabel"),
Expand Down Expand Up @@ -112,14 +133,15 @@ window.main = (function () {
return true;
}


browser.tabs.onUpdated.addListener(catcher.watchFunction((id, info, tab) => {
if (info.url && tab.selected) {
if (urlEnabled(info.url)) {
browser.browserAction.enable(tab.id);
}
else {
browser.browserAction.disable(tab.id);
if (hasSeenOnboarding) {
browser.browserAction.disable(tab.id);
}
}
}
}));
Expand Down
1 change: 1 addition & 0 deletions docs/METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ The primary change was in `server/src/pages/shot/share-buttons.js`
7. [ ] Cancel because the tab is navigated (such as entering something in the URL bar), **or** the tab was closed, **or** the tab was reloaded `addon/cancel-shot/tab-load` (previously closing would emit `addon/cancel-shot/tab-close` and `addon/cancel-shot/tab-reload` for those cases)
5. [x] Click My Shots `addon/goto-myshots/selection-button`
6. [x] Go to My Shots by hitting the Screenshots button on a about:newtab page `addon/goto-myshots/about-newtab`
6. [x] Go to `/#hello` to onboard (because the user pressed the Screenshots button on a page that could not be shot) `addon/goto-onboarding/selection-button`
6. [x] Click on "Save visible" `addon/capture-visible/selection-button`
7. [x] Click on "Save Full Page" `addon/capture-full-page/selection-button`
6. ~~Click My Shots button from error panel `addon/goto-myshots/error-panel`~~
Expand Down

0 comments on commit 2e5ce26

Please sign in to comment.