@@ -62,6 +62,7 @@ import { getLogScope, setLogScopeExit } from '../../system/logger.scope';
62
62
import { flatten } from '../../system/object' ;
63
63
import { pauseOnCancelOrTimeout } from '../../system/promise' ;
64
64
import { pluralize } from '../../system/string' ;
65
+ import { createDisposable } from '../../system/unifiedDisposable' ;
65
66
import { satisfies } from '../../system/version' ;
66
67
import { LoginUriPathPrefix } from './authenticationConnection' ;
67
68
import { authenticationProviderScopes } from './authenticationProvider' ;
@@ -871,9 +872,22 @@ export class SubscriptionService implements Disposable {
871
872
872
873
if ( ! ( await ensurePlusFeaturesEnabled ( ) ) ) return ;
873
874
874
- if ( this . container . telemetry . enabled ) {
875
- this . container . telemetry . sendEvent ( 'subscription/action' , { action : 'upgrade' } , source ) ;
876
- }
875
+ let aborted = false ;
876
+ using telemetry = this . container . telemetry . enabled
877
+ ? createDisposable (
878
+ ( ) => {
879
+ this . container . telemetry . sendEvent (
880
+ 'subscription/action' ,
881
+ {
882
+ action : 'upgrade' ,
883
+ aborted : aborted ,
884
+ } ,
885
+ source ,
886
+ ) ;
887
+ } ,
888
+ { once : true } ,
889
+ )
890
+ : undefined ;
877
891
878
892
if ( this . _subscription . account != null ) {
879
893
// Do a pre-check-in to see if we've already upgraded to a paid plan.
@@ -910,27 +924,34 @@ export class SubscriptionService implements Disposable {
910
924
911
925
try {
912
926
if ( hasAccount ) {
913
- const token = await this . container . accountAuthentication . getExchangeToken (
914
- SubscriptionUpdatedUriPathPrefix ,
915
- ) ;
916
- query . set ( 'token' , token ) ;
917
- } else {
927
+ try {
928
+ const token = await this . container . accountAuthentication . getExchangeToken (
929
+ SubscriptionUpdatedUriPathPrefix ,
930
+ ) ;
931
+ query . set ( 'token' , token ) ;
932
+ } catch ( ex ) {
933
+ Logger . error ( ex , scope ) ;
934
+ }
935
+ }
936
+
937
+ if ( ! query . has ( 'token' ) ) {
918
938
const successUri = await env . asExternalUri (
919
939
Uri . parse ( `${ env . uriScheme } ://${ this . container . context . extension . id } /${ LoginUriPathPrefix } ` ) ,
920
940
) ;
921
941
query . set ( 'success_uri' , successUri . toString ( true ) ) ;
922
942
}
923
-
924
- if ( ! ( await openUrl ( this . container . getGkDevUri ( 'purchase/checkout' , query . toString ( ) ) . toString ( true ) ) ) ) {
925
- return ;
926
- }
927
943
} catch ( ex ) {
928
944
Logger . error ( ex , scope ) ;
929
- if ( ! ( await openUrl ( this . container . getGkDevUri ( 'purchase/checkout' , query . toString ( ) ) . toString ( true ) ) ) ) {
930
- return ;
931
- }
932
945
}
933
946
947
+ aborted = ! ( await openUrl ( this . container . getGkDevUri ( 'purchase/checkout' , query . toString ( ) ) . toString ( true ) ) ) ;
948
+
949
+ if ( aborted ) {
950
+ return ;
951
+ }
952
+
953
+ telemetry ?. dispose ( ) ;
954
+
934
955
const completionPromises = [ new Promise < boolean > ( resolve => setTimeout ( ( ) => resolve ( false ) , 5 * 60 * 1000 ) ) ] ;
935
956
936
957
if ( hasAccount ) {
0 commit comments