diff --git a/src/messages.ts b/src/messages.ts index 9dbdac4..d632eab 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 4fa7a3a..f3660c4 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 5c2d578..1edc416 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;