diff --git a/src/messages.ts b/src/messages.ts index 110d08d..ae1cb54 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -2,6 +2,7 @@ import type { MessageItem } from 'vscode'; import { ConfigurationTarget, window } from 'vscode'; import { configuration, SuppressedMessages } from './configuration'; import { Commands } from './constants'; +import type { Container } from './container'; import type { GitCommit } from './git/models/commit'; import { Logger } from './logger'; import { executeCommand } from './system/command'; @@ -172,6 +173,24 @@ export function showIntegrationRequestTimedOutWarningMessage(providerName: strin ); } +export async function showProDiscountNotification(container: Container): Promise { + if (container.storage.get('plus:discountNotificationShown', false)) return; + + void container.storage.store('plus:discountNotificationShown', true); + + const upgrade: MessageItem = { title: 'Upgrade to Pro' }; + const result = await showMessage( + 'info', + 'GitLens Pro introductory pricing, up to a 60% discount, goes away tomorrow. Upgrade to GitLens Pro now to access [GitLens+ features](command:gitlens.plus.learn) on private repos at a reduced rate.', + undefined, + undefined, + upgrade, + ); + if (result === upgrade) { + void container.subscription.purchase(); + } +} + export async function showWhatsNewMessage(version: string) { const whatsnew = { title: "See What's New" }; const result = await showMessage( diff --git a/src/plus/subscription/subscriptionService.ts b/src/plus/subscription/subscriptionService.ts index 3d28c22..13c7c0b 100644 --- a/src/plus/subscription/subscriptionService.ts +++ b/src/plus/subscription/subscriptionService.ts @@ -27,6 +27,7 @@ import { setContext } from '../../context'; import { AccountValidationError } from '../../errors'; import type { RepositoriesChangeEvent } from '../../git/gitProviderService'; import { Logger } from '../../logger'; +import { showProDiscountNotification } from '../../messages'; import type { Subscription } from '../../subscription'; import { computeSubscriptionState, @@ -843,6 +844,16 @@ export class SubscriptionService implements Disposable { this._subscription = subscription; this._etag = Date.now(); + setTimeout(() => { + if ( + new Date() < new Date('2022-10-18T00:00:00.000Z') && + subscription!.account != null && + !isSubscriptionPaid(subscription!) + ) { + void showProDiscountNotification(this.container); + } + }, 5000); + if (!silent) { this.updateContext(); diff --git a/src/storage.ts b/src/storage.ts index c34495d..5d96e6b 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -144,6 +144,7 @@ export interface GlobalStorage { pendingWhatsNewOnFocus?: boolean; plus: { migratedAuthentication?: boolean; + discountNotificationShown?: boolean; }; // Don't change this key name ('premium`) as its the stored subscription premium: {