Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup_number ping parameter #669

Merged
merged 16 commits into from Jan 29, 2021
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -2436,7 +2436,7 @@
"ghostery_dawn_onboarding_select_option": {
"message": "Select option"
},
"ghostery_dawn_onboarding_you_have_selected_an_alternate_serach_engine": {
"ghostery_dawn_onboarding_you_have_selected_an_alternate_search_engine": {
"message": "You have selected an alternate search engine:"
},
"ghostery_dawn_onboarding_create_account_for_trial": {
@@ -19,3 +19,19 @@ export const BLOCK_SETTINGS = '2';
export const CHOOSE_DEFAULT_SEARCH = '3';
export const CHOOSE_PLAN = '4';
export const SUCCESS = '5';

// Setup Step Constants

// Step 1
export const SIGN_IN_SUCCESSFUL = '1';
export const CREATE_ACCOUNT_SUCCESSFUL = '2';
export const SKIP_ACCOUNT_CREATION = '3';

// Step 4
export const FREE_USER_NO_TRIAL = '1';
export const FREE_USER_PLUS_TRIAL = '2';
export const FREE_USER_PLUS_SUBSCRIPTION = '3';
export const FREE_USER_PREMIUM_SUBSCRIPTION = '4';
export const PLUS_SUBSCRIBER_KEEP_SUBSCRIPTION = '5';
export const PLUS_SUBSCRIBER_PREMIUM_SUBSCRIPTION = '6';
export const PREMIUM_SUBSCRIBER_KEEP_SUBSCRIPTION = '7';
@@ -17,7 +17,13 @@ import PropTypes from 'prop-types';
import Step1_LogInForm from '../Step1_LogInForm';
import Step1_CreateAccountForm from '../Step1_CreateAccountForm';
import globals from '../../../../../src/classes/Globals';
import { LOGIN, ONBOARDING } from '../../OnboardingView/OnboardingConstants';
import {
LOGIN,
ONBOARDING,
SIGN_IN_SUCCESSFUL,
CREATE_ACCOUNT_SUCCESSFUL,
SKIP_ACCOUNT_CREATION
} from '../../OnboardingView/OnboardingConstants';

const SIGN_IN = 'SIGN_IN';
const CREATE_ACCOUNT = 'CREATE_ACCOUNT';
@@ -59,8 +65,12 @@ const Step1_CreateAccountView = (props) => {

const [view, setView] = useState(CREATE_ACCOUNT);

const handleSkipButton = () => {
setSetupStep({ setup_step: LOGIN, origin: ONBOARDING });
const handleSkipButton = (dawn_setup_number) => {
setSetupStep({
setup_step: LOGIN,
dawn_setup_number,
origin: ONBOARDING,
});
setToast({
toastMessage: '',
toastClass: ''
@@ -70,6 +80,12 @@ const Step1_CreateAccountView = (props) => {
const handleNextOnSelectPlanStep = () => {
const { prev } = props;

setSetupStep({
setup_step: LOGIN,
dawn_setup_number: CREATE_ACCOUNT_SUCCESSFUL,
origin: ONBOARDING,
});

setToast({
toastMessage: '',
toastClass: ''
@@ -82,7 +98,7 @@ const Step1_CreateAccountView = (props) => {
<div className="row align-center-middle">
<div className="columns small-10 medium-6" />
<div className="columns small-10 medium-6">
<NavLink className="Step1_CreateAccountView__skip" to="/onboarding/2" onClick={() => handleSkipButton()}>
<NavLink className="Step1_CreateAccountView__skip" to="/onboarding/2" onClick={() => handleSkipButton(SKIP_ACCOUNT_CREATION)}>
<span>{t('ghostery_dawn_onboarding_skip')}</span>
</NavLink>
</div>
@@ -99,7 +115,7 @@ const Step1_CreateAccountView = (props) => {
<div className="Step1_CreateAccountView__email">{email}</div>
<div className="Step1_CreateAccountView__ctaButtonContainer">
{step === LOGIN && (
<NavLink className="Step1_CreateAccountView__ctaButton" to="/onboarding/2" onClick={() => handleSkipButton()}>
<NavLink className="Step1_CreateAccountView__ctaButton" to="/onboarding/2" onClick={() => handleSkipButton(SIGN_IN_SUCCESSFUL)}>
<span>{t('next')}</span>
</NavLink>
)}
@@ -42,7 +42,7 @@ class BlockSettingsView extends Component {
this.setState({
recommendedChoices: true,
blockAds: true,
kindsOfTrackers: 1,
kindsOfTrackers: 2,
antiTracking: true,
smartBrowsing: true
});
@@ -61,6 +61,23 @@ class BlockSettingsView extends Component {
this.setState({ [category]: answer });
}

// Refer to https://ghostery.atlassian.net/wiki/spaces/BI/pages/488079383/Ghostery+Browser+-+Onboarding+Pings for setup_number string formatting
buildSetupNumberString = () => {
const {
blockAds,
kindsOfTrackers,
antiTracking,
smartBrowsing
} = this.state;

const partOne = (blockAds) ? '1' : '2';
const partTwo = kindsOfTrackers.toString();
const partThree = (antiTracking) ? '1' : '2';
const partFour = (smartBrowsing) ? '1' : '2';

return `${partOne}${partTwo}${partThree}${partFour}`;
}

This conversation was marked as resolved by wlycdgr
Comment on lines +64 to +80

This comment has been minimized.

@wlycdgr

wlycdgr Jan 28, 2021
Member

Very nice and clean

handleSubmit = () => {
const {
blockAds, kindsOfTrackers, antiTracking, smartBrowsing
@@ -87,21 +104,24 @@ class BlockSettingsView extends Component {

let blockingPolicy;
switch (kindsOfTrackers) {
case 0:
case 1:
blockingPolicy = 'BLOCKING_POLICY_EVERYTHING';
break;
case 1:
case 2:
blockingPolicy = 'BLOCKING_POLICY_RECOMMENDED';
break;
case 2:
case 3:
blockingPolicy = 'BLOCKING_POLICY_NOTHING';
break;
default:
break;
}
setBlockingPolicy({ blockingPolicy });

setSetupStep({ setup_step: CHOOSE_DEFAULT_SEARCH, origin: ONBOARDING });
setSetupStep({
setup_step: CHOOSE_DEFAULT_SEARCH,
dawn_setup_number: this.buildSetupNumberString(),
origin: ONBOARDING
});
history.push('/onboarding/3');
} else {
setToast({
@@ -160,9 +180,9 @@ class BlockSettingsView extends Component {
</div>
</div>
</li>
{this.renderAnswerBlock((kindsOfTrackers === 0), 'kindsOfTrackers', 0, t('ghostery_dawn_onboarding_kinds_of_trackers_all'))}
{this.renderAnswerBlock((kindsOfTrackers === 1), 'kindsOfTrackers', 1, t('ghostery_dawn_onboarding_kinds_of_trackers_ad_and_analytics'))}
{this.renderAnswerBlock((kindsOfTrackers === 2), 'kindsOfTrackers', 2, t('ghostery_dawn_onboarding_kinds_of_trackers_none'))}
{this.renderAnswerBlock((kindsOfTrackers === 1), 'kindsOfTrackers', 1, t('ghostery_dawn_onboarding_kinds_of_trackers_all'))}
{this.renderAnswerBlock((kindsOfTrackers === 2), 'kindsOfTrackers', 2, t('ghostery_dawn_onboarding_kinds_of_trackers_ad_and_analytics'))}
{this.renderAnswerBlock((kindsOfTrackers === 3), 'kindsOfTrackers', 3, t('ghostery_dawn_onboarding_kinds_of_trackers_none'))}
<li className="BlockSettingsView_question">
<div className="BlockSettingsView_questionBlock">
{t('ghostery_dawn_onboarding_question_anti_tracking')}
@@ -15,5 +15,15 @@ export const SET_DEFAULT_SEARCH = 'SET_DEFAULT_SEARCH';
export const SEARCH_GHOSTERY = 'Ghostery';
export const SEARCH_BING = 'Bing';
export const SEARCH_YAHOO = 'Yahoo';
export const SEARCH_STARTPAGE = 'Startpage';
export const SEARCH_STARTPAGE = 'StartPage';
export const SEARCH_DUCKDUCK_GO = 'DuckDuckGo';
export const SEARCH_ECOSIA = 'Ecosia Search';
export const SEARCH_EKORU = 'ekoru';
export const SEARCH_GIBIRU = 'Gibiru.com';
export const SEARCH_GOOGLE = 'Google';
export const SEARCH_ONESEARCH = 'OneSearch';
export const SEARCH_PRIVADO = 'Privado';
export const SEARCH_QWANT = 'Qwant';
export const SEARCH_ENCRYPT = 'TODO: Add Search Encrypt browser.search.get() string';
export const SEARCH_TAILCAT = 'Tailcat';
export const SEARCH_OTHER = t('ghostery_dawn_onboarding_other');
@@ -18,13 +18,40 @@ import RadioButton from '../../../../shared-components/RadioButton';
import { ONBOARDING, CHOOSE_PLAN } from '../../OnboardingView/OnboardingConstants';
import {
SEARCH_GHOSTERY,
SEARCH_BING,
SEARCH_YAHOO,
SEARCH_STARTPAGE,
SEARCH_BING,
SEARCH_DUCKDUCK_GO,
SEARCH_ECOSIA,
SEARCH_EKORU,
SEARCH_GIBIRU,
SEARCH_GOOGLE,
SEARCH_ONESEARCH,
SEARCH_PRIVADO,
SEARCH_QWANT,
SEARCH_ENCRYPT,
SEARCH_TAILCAT,
SEARCH_OTHER
} from './ChooseDefaultSearchConstants';
import { Modal } from '../../../../shared-components';

const searchSetupNumbers = [
{ name: SEARCH_GHOSTERY, dawn_setup_number: 1 },
{ name: SEARCH_BING, dawn_setup_number: 2 },
{ name: SEARCH_YAHOO, dawn_setup_number: 3 },
{ name: SEARCH_STARTPAGE, dawn_setup_number: 4 },
{ name: SEARCH_GOOGLE, dawn_setup_number: 5 },
{ name: SEARCH_DUCKDUCK_GO, dawn_setup_number: 6 },
{ name: SEARCH_ECOSIA, dawn_setup_number: 7 },
{ name: SEARCH_EKORU, dawn_setup_number: 8 },
{ name: SEARCH_GIBIRU, dawn_setup_number: 9 },
{ name: SEARCH_ONESEARCH, dawn_setup_number: 10 },
{ name: SEARCH_PRIVADO, dawn_setup_number: 11 },
{ name: SEARCH_QWANT, dawn_setup_number: 12 },
{ name: SEARCH_ENCRYPT, dawn_setup_number: 13 },
{ name: SEARCH_TAILCAT, dawn_setup_number: 14 },
];

class ChooseDefaultSearchView extends Component {
constructor(props) {
super(props);
@@ -42,6 +69,16 @@ class ChooseDefaultSearchView extends Component {
this.fetchSearchEnginesAsync = this.fetchSearchEnginesAsync.bind(this);
}

componentDidMount() {
document.addEventListener('click', this.handleClickAway);

this.fetchSearchEnginesAsync();
}

componentWillUnmount() {
document.removeEventListener('click', this.handleClickAway);
}

async fetchSearchEnginesAsync() {
// eslint-disable-next-line no-undef
if (typeof browser === 'undefined' || typeof browser.search === 'undefined') { // we are not in Dawn
@@ -67,16 +104,6 @@ class ChooseDefaultSearchView extends Component {
}));
}

componentDidMount() {
document.addEventListener('click', this.handleClickAway);

this.fetchSearchEnginesAsync();
}

componentWillUnmount() {
document.removeEventListener('click', this.handleClickAway);
}

updateSelection = () => this.setState(prevState => (
{
chosenSearch: prevState.searchBeingConsidered,
@@ -129,7 +156,12 @@ class ChooseDefaultSearchView extends Component {
}

setDefaultSearch(chosenSearchName);
setSetupStep({ setup_step: CHOOSE_PLAN, origin: ONBOARDING });

setSetupStep({
setup_step: CHOOSE_PLAN,
dawn_setup_number: searchSetupNumbers.find(elem => elem.name === chosenSearchName).dawn_setup_number,
origin: ONBOARDING
});
history.push(`/${ONBOARDING}/${CHOOSE_PLAN}`);
}

@@ -254,7 +286,7 @@ class ChooseDefaultSearchView extends Component {
{(searchBeingConsidered === SEARCH_OTHER) && (
<Fragment>
{
`${t('ghostery_dawn_onboarding_you_have_selected_an_alternate_serach_engine')} \n
`${t('ghostery_dawn_onboarding_you_have_selected_an_alternate_search_engine')} \n
${otherSearchSelected}`
}
</Fragment>
ProTip! Use n and p to navigate between commits in a pull request.