From b32088d4e04e1f9de3e323c211f6a49976b47c87 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 18 Feb 2023 17:34:45 -0500 Subject: [PATCH] Adds early adopter renewal discount notification --- src/messages.ts | 2 +- src/plus/subscription/subscriptionService.ts | 26 ++++++++++++++++++++ src/storage.ts | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/messages.ts b/src/messages.ts index 9dbdac4c93906..d632eab4bf4aa 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -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, diff --git a/src/plus/subscription/subscriptionService.ts b/src/plus/subscription/subscriptionService.ts index 4fa7a3a74e470..f3660c493c788 100644 --- a/src/plus/subscription/subscriptionService.ts +++ b/src/plus/subscription/subscriptionService.ts @@ -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, @@ -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(); @@ -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, + ); +} diff --git a/src/storage.ts b/src/storage.ts index 5c2d5785f5af1..1edc4163fe53b 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -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; 'synced:version': string;