Skip to content

Commit 17f2519

Browse files
committed
Adds subscription state string
1 parent fcfb328 commit 17f2519

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/plus/gk/account/subscription.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,48 @@ export interface SubscriptionPreviewTrial {
5454
readonly expiresOn: string;
5555
}
5656

57-
// Note: Pay attention to gitlens:plus:state in package.json when modifying this enum
57+
// NOTE: Pay attention to gitlens:plus:state in package.json when modifying this enum
58+
// NOTE: This is reported in telemetry so we should NOT change the values
5859
export const enum SubscriptionState {
5960
/** Indicates a user who hasn't verified their email address yet */
6061
VerificationRequired = -1,
6162
/** Indicates a Free user who hasn't yet started the preview trial */
6263
Free = 0,
6364
/** Indicates a Free user who is in preview trial */
64-
FreeInPreviewTrial,
65+
FreeInPreviewTrial = 1,
6566
/** Indicates a Free user who's preview has expired trial */
66-
FreePreviewTrialExpired,
67+
FreePreviewTrialExpired = 2,
6768
/** Indicates a Free+ user with a completed trial */
68-
FreePlusInTrial,
69+
FreePlusInTrial = 3,
6970
/** Indicates a Free+ user who's trial has expired and is not yet eligible for reactivation */
70-
FreePlusTrialExpired,
71+
FreePlusTrialExpired = 4,
7172
/** Indicated a Free+ user who's trial has expired and is eligible for reactivation */
72-
FreePlusTrialReactivationEligible,
73+
FreePlusTrialReactivationEligible = 5,
7374
/** Indicates a Paid user */
74-
Paid,
75+
Paid = 6,
76+
}
77+
78+
export function getSubscriptionStateString(state: SubscriptionState | undefined): string {
79+
switch (state) {
80+
case SubscriptionState.VerificationRequired:
81+
return 'verification';
82+
case SubscriptionState.Free:
83+
return 'free';
84+
case SubscriptionState.FreeInPreviewTrial:
85+
return 'preview';
86+
case SubscriptionState.FreePreviewTrialExpired:
87+
return 'preview-expired';
88+
case SubscriptionState.FreePlusInTrial:
89+
return 'trial';
90+
case SubscriptionState.FreePlusTrialExpired:
91+
return 'trial-expired';
92+
case SubscriptionState.FreePlusTrialReactivationEligible:
93+
return 'trial-reactivation-eligible';
94+
case SubscriptionState.Paid:
95+
return 'paid';
96+
default:
97+
return 'unknown';
98+
}
7599
}
76100

77101
export function computeSubscriptionState(subscription: Optional<Subscription, 'state'>): SubscriptionState {

src/plus/gk/account/subscriptionService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
computeSubscriptionState,
5555
getSubscriptionPlan,
5656
getSubscriptionPlanName,
57+
getSubscriptionStateString,
5758
getSubscriptionTimeRemaining,
5859
getTimeRemaining,
5960
isSubscriptionExpired,
@@ -1358,5 +1359,6 @@ function flattenSubscription(subscription: Optional<Subscription, 'state'> | und
13581359
stringify: true,
13591360
}),
13601361
'subscription.state': subscription.state,
1362+
'subscription.stateString': getSubscriptionStateString(subscription.state),
13611363
};
13621364
}

0 commit comments

Comments
 (0)