Skip to content

Commit

Permalink
Adds early adopter renewal discount notification
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio authored and d13 committed Feb 24, 2023
1 parent 8b18090 commit b32088d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/messages.ts
Expand Up @@ -197,7 +197,7 @@ export async function showWhatsNewMessage(version: string) {
}
}

async function showMessage(
export async function showMessage(
type: 'info' | 'warn' | 'error',
message: string,
suppressionKey?: SuppressedMessages,
Expand Down
26 changes: 26 additions & 0 deletions src/plus/subscription/subscriptionService.ts
Expand Up @@ -30,6 +30,7 @@ import { AccountValidationError } from '../../errors';
import type { RepositoriesChangeEvent } from '../../git/gitProviderService';
import { Logger } from '../../logger';
import { getLogScope } from '../../logScope';
import { showMessage } from '../../messages';
import type { Subscription } from '../../subscription';
import {
computeSubscriptionState,
Expand Down Expand Up @@ -898,6 +899,18 @@ export class SubscriptionService implements Disposable {
this._subscription = subscription;
this._etag = Date.now();

setTimeout(() => {
if (
subscription?.account != null &&
subscription.plan.actual.id === SubscriptionPlanId.Pro &&
!subscription.plan.actual.bundle &&
new Date(subscription.plan.actual.startedOn) >= new Date('2022-02-28T00:00:00.000Z') &&
new Date(subscription.plan.actual.startedOn) <= new Date('2022-04-31T00:00:00.000Z')
) {
showRenewalDiscountNotification(this.container);
}
}, 5000);

if (!silent) {
this.updateContext();

Expand Down Expand Up @@ -1158,3 +1171,16 @@ function licenseStatusPriority(status: GKLicense['latestStatus']): number {
return 0;
}
}

function showRenewalDiscountNotification(container: Container): void {
if (container.storage.get('plus:renewalDiscountNotificationShown', false)) return;

void container.storage.store('plus:renewalDiscountNotificationShown', true);

void showMessage(
'info',
'60% off your GitLens Pro renewal — as a thank you for being an early adopter of GitLens+. So there will be no change to your price for an additional year!',
undefined,
undefined,
);
}
1 change: 1 addition & 0 deletions src/storage.ts
Expand Up @@ -129,6 +129,7 @@ export type GlobalStorage = {
pendingWhatsNewOnFocus: boolean;
'plus:migratedAuthentication': boolean;
'plus:discountNotificationShown': boolean;
'plus:renewalDiscountNotificationShown': boolean;
// Don't change this key name ('premium`) as its the stored subscription
'premium:subscription': Stored<Subscription>;
'synced:version': string;
Expand Down

0 comments on commit b32088d

Please sign in to comment.