Skip to content

Commit

Permalink
Cleanup post-review.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetto committed Feb 11, 2015
1 parent 37cb0f7 commit b40cb5b
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@
{% endblock %}

{% block js %}
<script>
var FXA_RELIER = {
clientId: '{{ settings.FXA_RELIER_CLIENT_ID }}',
contentHost: '{{ settings.FXA_RELIER_CONTENT_HOST }}',
contentOauth: '{{ settings.FXA_RELIER_CONTENT_OAUTH }}'
};
</script>
{{ js('growth_firstrun_test1') }}
{% endblock %}

Expand Down Expand Up @@ -64,7 +57,7 @@ <h1>{{ _('Welcome to Firefox') }}</h1>
{% endblock %}

{% block secondary_content %}
<div id="fxa-extra" tabindex="-1">
<div id="fxa-extra" tabindex="-1" data-fxa-client-id="{{ settings.FXA_RELIER_CLIENT_ID }}" data-fxa-content-host="{{ settings.FXA_RELIER_CONTENT_HOST }}" data-fxa-content-oauth="{{ settings.FXA_RELIER_CONTENT_OAUTH }}">
<header id="fxa-value-prop" class="fxa-extra-content">
<div id="fxa-value-prop-intro">
<h2>
Expand Down
26 changes: 26 additions & 0 deletions bedrock/firefox/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,32 @@ def test_fx_australis_secure_redirect_secure(self, render_mock):
resp = self.view(req, version='29.0')
eq_(resp.status_code, 200)

# tests from growth firstrun test. should be removed after 2/24/2015.

@override_settings(DEV=True)
def test_fx_growth_tour_0_35_0_1(self, render_mock):
"""Should use firstrun 34 tour template for 35.0.1 with funnelcake 34"""
req = self.rf.get('/en-US/firefox/firstrun/?f=34')
self.view(req, version='35.0.1')
template = render_mock.call_args[0][1]
eq_(template, ['firefox/australis/firstrun-34-tour.html'])

@override_settings(DEV=True)
def test_fx_growth_tour_1_35_0_1(self, render_mock):
"""Should use growth tour template 1 for 35.0.1 with funnelcake 35"""
req = self.rf.get('/en-US/firefox/firstrun/?f=35')
self.view(req, version='35.0.1')
template = render_mock.call_args[0][1]
eq_(template, ['firefox/australis/growth-firstrun-test1.html'])

@override_settings(DEV=True)
def test_fx_growth_tour_2_35_0_1(self, render_mock):
"""Should use growth tour template 2 for 35.0.1 with funnelcake 36"""
req = self.rf.get('/en-US/firefox/firstrun/?f=36')
self.view(req, version='35.0.1')
template = render_mock.call_args[0][1]
eq_(template, ['firefox/australis/growth-firstrun-test2.html'])


@patch.object(fx_views, 'firefox_details', firefox_details)
class FxVersionRedirectsMixin(object):
Expand Down
5 changes: 4 additions & 1 deletion bedrock/firefox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from bedrock.releasenotes import version_re
from bedrock.firefox.forms import SMSSendForm
from bedrock.mozorg.context_processors import funnelcake_param
from bedrock.mozorg.views import process_partnership_form
from bedrock.firefox.firefox_details import firefox_details, mobile_details
from lib.l10n_utils.dotlang import _
Expand Down Expand Up @@ -373,7 +374,9 @@ def get_template_names(self):
locale = l10n_utils.get_locale(self.request)

# variant is present for growth tests
variant = self.request.GET.get('f', None)
ctx = funnelcake_param(self.request)

variant = ctx.get('funnelcake_id', None)

if variant == '35' and version == '35.0.1':
template = 'firefox/australis/growth-firstrun-test1.html'
Expand Down
2 changes: 2 additions & 0 deletions bedrock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,13 @@ def JINJA_CONFIG():
'js/firefox/australis/australis-uitour.js',
'js/firefox/australis/growth-browser-tour.js',
'js/libs/fxa-relier-client.min.js',
'js/firefox/sync-animation.js',
'js/firefox/australis/growth-firstrun-test1.js',
),
'growth_firstrun_test2': (
'js/firefox/australis/australis-uitour.js',
'js/firefox/australis/growth-browser-tour.js',
'js/firefox/sync-animation.js',
'js/firefox/australis/growth-firstrun-test2.js',
),
'home': (
Expand Down
125 changes: 80 additions & 45 deletions media/js/firefox/australis/growth-firstrun-test1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// declare vars (might as well be here because hoisting)
var $body;
var $ghosteryIframe;
var $outerWrapper = $('#outer-wrapper');
var pageId = $('body').prop('id');

// determines if tour opens or not
var showDoorhanger;
Expand All @@ -13,6 +15,7 @@
// reference FxA elements
var $fxaOverlay;
var $fxaIframe;
var $fxaExtra;
var $fxaValueProp;
var $fxaDelayedCTAs;

Expand All @@ -24,19 +27,38 @@
var initFxA;
var enableIframe;
var showFxA;
var trackSyncClick;

var showDefaultContent = function() {
var toggleDefaultContent = function(show) {
// show default #outer-wrapper
$('#outer-wrapper').show();
if (show) {
$outerWrapper.show();

Mozilla.syncAnimation();
} else {
$outerWrapper.hide();
}
};

// Only run experiment content if user is on Firefox 29+ for desktop and has not just submitted email form
if (window.isFirefox() && !window.isFirefoxMobile() && window.getFirefoxMasterVersion() >= 29 && window.location.hash !== '#footer-email-form') {
// fallback in case UITour doesn't load
$outerWrapper.show();

// Only run experiment content if user is on Firefox 35 for desktop and has not just submitted email form
if (window.isFirefox() && !window.isFirefoxMobile() && window.getFirefoxMasterVersion() >= 35 && window.location.hash !== '#footer-email-form') {
// initialize vars
$body = $('body');
$ghosteryIframe = $('iframe.addon');

fxaClientID = window.FXA_RELIER.clientId;
// grab FxA settings from data-* attributes
$fxaExtra = $('#fxa-extra');

Mozilla.FXA_RELIER = {
clientId: $fxaExtra.attr('data-fxa-client-id'),
contentHost: $fxaExtra.attr('data-fxa-content-host'),
contentOauth: $fxaExtra.attr('data-fxa-content-oauth')
};

fxaClientID = Mozilla.FXA_RELIER.clientId;

// determine whether or not to show doorhanger (50% of users)
showDoorhanger = Math.random() >= 0.5;
Expand Down Expand Up @@ -69,13 +91,13 @@
initFxA = function() {
// set up FxA client
fxaClient = new window.FxaRelierClient(fxaClientID, {
contentHost: window.FXA_RELIER.contentHost,
oauthHost: window.FXA_RELIER.contentOauth
contentHost: Mozilla.FXA_RELIER.contentHost,
oauthHost: Mozilla.FXA_RELIER.contentOauth
});

// conjure FxA lightbox
fxaClient.auth.signUp({
redirectUri: 'http://localhost:8000/',
redirectUri: 'http://localhost:8000/', // TODO: must match creds? Seems to work on demo5 though...
scope: 'profile',
state: '123456', // TODO: create real CSRF token
ui: 'lightbox',
Expand All @@ -100,10 +122,22 @@
}, function(err) {
// on error, get rid of overlay and fall back to default content
$fxaOverlay.remove();
showDefaultContent();
toggleDefaultContent(true);
});
};

// track Sync CTA click and link to about:accounts where posiible
trackSyncClick = function(e) {
e.preventDefault();

var goToAccounts = function () {
// available on Firefox 31 and greater
Mozilla.UITour.showFirefoxAccounts();
};

gaTrack(['_trackEvent', pageId + ' Page Interactions - New Firefox Tour', 'button click', 'Get Started with Sync'], goToAccounts);
};

// listen for postMessage from iframes
window.addEventListener('message', function(event) {
// listen for fxa communiques
Expand Down Expand Up @@ -137,44 +171,44 @@
if (showDoorhanger) {
// Query if the UITour API is working before we start the tour
Mozilla.UITour.getConfiguration('sync', function() {
// if user has submitted newsletter don't show the tour again
if (window.location.hash !== '#footer-email-form') {
// conditionally show doorhanger/tour mask
if (showDoorhanger) {
// id is used for Telemetry
var tour = new Mozilla.BrowserTour({
id: $('#tour-page').data('telemetry'),
startTour: function() {
// prepare FxA stuff
initFxA();

// enable AMO iframe
enableIframe();

// give FxA a moment to initialize before getting rid of mask
setTimeout(function() {
tour.doCloseTour();
}, 600);
},
cancelTour: function() {
tour.doCloseTour();

showDefaultContent();

if ($fxaOverlay) {
$fxaOverlay.fadeOut('fast');
}
}
});

tour.init();
} else {
$body.addClass('noscroll');
// hide default content
toggleDefaultContent(false);

// wire up sync click in default content
$('.sync-cta').on('click', '.button', trackSyncClick);

// id is used for Telemetry
var tour = new Mozilla.BrowserTour({
id: $('#tour-page').data('telemetry'),
startTour: function() {
// prepare FxA stuff
initFxA();

// enable AMO iframe
enableIframe();

// give FxA a moment to initialize before getting rid of mask
setTimeout(function() {
tour.doCloseTour();
}, 600);
},
cancelTour: function() {
tour.doCloseTour();

toggleDefaultContent(true);

if ($fxaOverlay) {
$fxaOverlay.fadeOut('fast');
}
}
}
});

tour.init();
});
// if not showing tour, just get to FxA UI
} else {
toggleDefaultContent(false);

// prepare FxA stuff
initFxA();

Expand All @@ -186,6 +220,9 @@
$('#highlight-sync').on('click', function(e) {
e.preventDefault();

// call twice two correctly position highlight
// https://bugzilla.mozilla.org/show_bug.cgi?id=1049130
Mozilla.UITour.showHighlight('accountStatus', 'wobble');
Mozilla.UITour.showHighlight('accountStatus', 'wobble');

// timeout so event isn't captured with *this* click
Expand All @@ -211,7 +248,5 @@
});
}
});
} else {
showDefaultContent();
}
})(window.jQuery, window.Mozilla);
28 changes: 26 additions & 2 deletions media/js/firefox/australis/growth-firstrun-test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function onYouTubeIframeAPIReady() {
'use strict';

var $document;
var pageId = $('body').prop('id');
var tour;
var installedAddons;

Expand All @@ -30,8 +31,20 @@ function onYouTubeIframeAPIReady() {
var openFinalNotice;
var enableIframes;

// Only run experiment content if user is on Firefox 29+ for desktop and has not just submitted email form
if (window.isFirefox() && !window.isFirefoxMobile() && window.getFirefoxMasterVersion() >= 29 && window.location.hash !== '#footer-email-form') {
// track Sync CTA click and link to about:accounts where posiible
var trackSyncClick = function(e) {
e.preventDefault();

var goToAccounts = function () {
// available on Firefox 31 and greater
Mozilla.UITour.showFirefoxAccounts();
};

gaTrack(['_trackEvent', pageId + ' Page Interactions - New Firefox Tour', 'button click', 'Get Started with Sync'], goToAccounts);
};

// Only run experiment content if user is on Firefox 35 for desktop and has not just submitted email form
if (window.isFirefox() && !window.isFirefoxMobile() && window.getFirefoxMasterVersion() >= 35 && window.location.hash !== '#footer-email-form') {
$document = $(document);
installedAddons = [];

Expand All @@ -48,6 +61,8 @@ function onYouTubeIframeAPIReady() {
// show default #outer-wrapper
$('#outer-wrapper').show();
tour.doCloseTour();

Mozilla.syncAnimation();
};

logAddonInstall = function(addon) {
Expand Down Expand Up @@ -77,6 +92,9 @@ function onYouTubeIframeAPIReady() {
$('#ui-initial').fadeOut('fast', function() {
$('#ui-final').fadeIn();

// call twice to correctly position highlight
// https://bugzilla.mozilla.org/show_bug.cgi?id=1049130
Mozilla.UITour.showHighlight('addons', 'wobble');
Mozilla.UITour.showHighlight('addons', 'wobble');

$document.one('click', function() {
Expand Down Expand Up @@ -132,6 +150,9 @@ function onYouTubeIframeAPIReady() {

// Query if the UITour API is working before we start the tour
Mozilla.UITour.getConfiguration('sync', function() {
// wire up default content sync button
$('.sync-cta').on('click', '.button', trackSyncClick);

var suppressDoorhanger = Math.random() >= 0.5;

// GA
Expand Down Expand Up @@ -185,6 +206,9 @@ function onYouTubeIframeAPIReady() {
$('#highlight-addons').on('click', function(e) {
e.preventDefault();

// call twice to correctly position highlight
// https://bugzilla.mozilla.org/show_bug.cgi?id=1049130
Mozilla.UITour.showHighlight('addons', 'none');
Mozilla.UITour.showHighlight('addons', 'none');

// timeout so event isn't captured with *this* click
Expand Down
6 changes: 4 additions & 2 deletions media/js/firefox/australis/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
// GA tracking for Firstrun tests
// https://bugzilla.mozilla.org/show_bug.cgi?id=1128726
// should be removed after 2/24/2015
gaTrack(['_setCustomVar' ,7, 'first run tests', 'variation 1', 2]);
gaTrack(['_trackEvent','/firstrun/ A/B Test', 'page load', 'variation 1']);
if (window.location.search.indexOf('f=34') > -1) {
gaTrack(['_setCustomVar' ,7, 'first run tests', 'variation 1', 2]);
gaTrack(['_trackEvent','/firstrun/ A/B Test', 'page load', 'variation 1']);
}

//Only run the tour if user is on Firefox 29 for desktop.
if (window.isFirefox() && !window.isFirefoxMobile() && window.getFirefoxMasterVersion() >= 29) {
Expand Down

0 comments on commit b40cb5b

Please sign in to comment.