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

GH-2048: Display premium icons & subscription info & GH-2036: Unlock Plus features on GBE/Midnight for all Premium & Plus users #546

Merged
merged 35 commits into from May 20, 2020

Conversation

@benstrumeyer
Copy link
Contributor

@benstrumeyer benstrumeyer commented May 8, 2020

  • Have you followed the guidelines in CONTRIBUTING.md?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you added an explanation of what your changes do?
  • Does your submission pass tests?
  • Did you lint your code prior to submission?

GH-2048

  • Display respective premium/plus icons for subscribed users
  • Upgrade account api to v2.1.0
  • Display subscription info for premium if a user has both a premium and plus subscription
  • Add premium icon in menu
  • The colored premium badge icon in the designs is not used as intended since we are upselling plus to users without a subscription

GH-2036

  • Allow premium users to view the subscription panel when clicking the subscription badge
  • Allow premium users to view the historical stats graph

Tickets:

@benstrumeyer benstrumeyer requested a review from wlycdgr May 8, 2020
@benstrumeyer benstrumeyer requested review from zarembsky and ghostery/ghostery as code owners May 8, 2020
@benstrumeyer benstrumeyer requested a review from Eden12345 May 8, 2020
app/panel/components/Header.jsx Outdated Show resolved Hide resolved
app/panel/components/Header.jsx Outdated Show resolved Hide resolved
app/panel/components/Header.jsx Outdated Show resolved Hide resolved
app/panel/components/HeaderMenu.jsx Outdated Show resolved Hide resolved
src/background.js Outdated Show resolved Hide resolved
app/panel/components/Summary.jsx Outdated Show resolved Hide resolved
app/panel/components/HeaderMenu.jsx Outdated Show resolved Hide resolved
@benstrumeyer benstrumeyer requested a review from wlycdgr May 11, 2020
</g>
</svg>
<span>{ t('ghostery_plus') }</span>
{/* Upselling plus for all users who are not premium subscribers */}

This comment has been minimized.

@wlycdgr

wlycdgr May 11, 2020
Member

Much closer to what's going on, but let's tweak this a little more to something like "Show premium icon to premium users and plus icon to basic and plus users" so the comment doesn't leave the reader confused about whether we are mistakenly upselling plus again to people who are already plus subscribers.

This comment has been minimized.

@benstrumeyer

benstrumeyer May 12, 2020
Author Contributor

Ah okay. Will make comments as clear and descriptive as possible from now on

This comment has been minimized.

@wlycdgr

wlycdgr May 12, 2020
Member

Awesome, thank you for your patience with my nittiness about this

src/classes/Account.js Outdated Show resolved Hide resolved

let subscriptionData = sub.find(subscription => subscription.productName.includes('Ghostery Premium'));
if (subscriptionData) {
callback({ subscriptionData });
}

subscriptionData = sub.find(subscription => subscription.productName.includes('Ghostery Plus'));
callback({ subscriptionData });
Comment on lines 832 to 839

This comment has been minimized.

@wlycdgr

wlycdgr May 11, 2020
Member

See my comments on Account#getUserSubscriptionData, especially the last update after getting the feedback from Tino. Note that we need to make sure we pass an empty object to the callback, and not undefined (the fail return value of Array.prototype.find), in the event that neither subscription is found. We also don't need to test the return value for whether it's an array because Account#getUserSubscriptionData will now guarantee it returns an array.

This comment has been minimized.

@benstrumeyer

benstrumeyer May 12, 2020
Author Contributor

Changed to return only the highest tier subscription, and made sure to return an empty object instead of undefined!

@wlycdgr wlycdgr requested a review from christophertino May 11, 2020
…iptions, and the background handler to return the highest tier subscription
@benstrumeyer benstrumeyer requested a review from wlycdgr May 12, 2020
src/background.js Outdated Show resolved Hide resolved
src/classes/Account.js Show resolved Hide resolved
src/classes/Account.js Outdated Show resolved Hide resolved
Copy link
Member

@wlycdgr wlycdgr left a comment

Looks good!

@benstrumeyer benstrumeyer changed the title GH-2048: Display premium icons & subscription info GH-2048: Display premium icons & subscription info & GH-2036: Unlock Plus features on GBE/Midnight for all Premium & Plus users May 13, 2020
@benstrumeyer benstrumeyer requested a review from wlycdgr May 13, 2020
app/panel/components/Detail.jsx Show resolved Hide resolved
_premiumSubscriber = () => {
const { loggedIn, user } = this.props;

return loggedIn && (user && user.subscriptionsPremium);
return loggedIn && (user && user.premiumAccess);
}

/**
Comment on lines 217 to 223

This comment has been minimized.

@wlycdgr

wlycdgr May 13, 2020
Member

Can we rename this and the matching _plusSubscriber helper to reflect that they now return access status rather than subscription status?

This comment has been minimized.

@benstrumeyer

benstrumeyer May 13, 2020
Author Contributor

Changed to _hasPlusAccess() and _hasPremiumAccess()!

@@ -517,7 +517,7 @@ class Stats extends React.Component {
return selectionData;
}

_isPlus = props => props.user && props.user.subscriptionsPlus;
_isPlus = props => props.user && props.user.plusAccess;

This comment has been minimized.

@wlycdgr

wlycdgr May 13, 2020
Member

Similarly, let's rename this helper to _hasPlusAccess

This comment has been minimized.

@benstrumeyer

benstrumeyer May 13, 2020
Author Contributor

Renamed!

@@ -329,7 +329,7 @@ class Stats extends React.Component {
monthlyAverageData: clearData,
dailyAverageData: clearData,
showResetModal: false,
showPitchModal: (!this.props.user || !this.props.user.subscriptionsPlus),
showPitchModal: (!this.props.user || !this.props.user.plusAccess),

This comment has been minimized.

@wlycdgr

wlycdgr May 13, 2020
Member

While you're in there, can you destructure this.props.user like you've done elsewhere?

This comment has been minimized.

@benstrumeyer

benstrumeyer May 13, 2020
Author Contributor

Done!

const hasPremiumAccess = user && user.premiumAccess;
const hasPlusAccess = user && user.plusAccess;
Comment on lines +757 to +758

This comment has been minimized.

@wlycdgr

wlycdgr May 13, 2020
Member

Man I'm SO ready for optional chaining to be a thing

This comment has been minimized.

@benstrumeyer

benstrumeyer May 13, 2020
Author Contributor

Ooh, I've never heard of optional chaining. Looks interesting

@@ -493,7 +494,6 @@ class Account {
conf.paid_subscription = true;
dispatcher.trigger('conf.save.paid_subscription');
}
conf.account.subscriptionData = data || null;

This comment has been minimized.

@wlycdgr

wlycdgr May 13, 2020
Member

I think we still need to save this, no?

This comment has been minimized.

@benstrumeyer

benstrumeyer May 13, 2020
Author Contributor

Thank god for PR reviews, my bad!

currentAccount.user.plusAccess = account.hasScopesUnverified(['subscriptions:plus'])
|| account.hasScopesUnverified(['subscriptions:premium']);
currentAccount.user.premiumAccess = account.hasScopesUnverified(['subscriptions:premium']);
Comment on lines +267 to +269

This comment has been minimized.

@wlycdgr

wlycdgr May 13, 2020
Member

I still wanna move this into Account but let's worry about that after. We can sneak it into one of the related tickets once this is in testing.

This comment has been minimized.

@benstrumeyer

benstrumeyer May 13, 2020
Author Contributor

I'll make a note!

…ubscriptionData in account#setSubscriptionData

return (
<PromoModalContainer
type={PREMIUM}
location="panel"
isPlus={isPlus}
isPlus={hasPlusAccess}

This comment has been minimized.

@wlycdgr

wlycdgr May 13, 2020
Member

Since we only use the return value here, we can just call this.hasPlusAccess directly here like you do with this._hasPremiumAccess at the top of the function (also, don't forget the leading underscore :) )

This comment has been minimized.

@benstrumeyer

benstrumeyer May 13, 2020
Author Contributor

Gotcha, I will be more thorough!

Copy link
Member

@wlycdgr wlycdgr left a comment

LGTM. Smoke tested.

@christophertino christophertino added this to the 8.5.1 milestone May 20, 2020
@christophertino christophertino merged commit 14d5ca0 into develop May 20, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@christophertino christophertino deleted the GH-2048 branch May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants