@@ -103,7 +103,7 @@ import * as path from "path";
103
103
import * as grpc from "@grpc/grpc-js" ;
104
104
import { IDEConfig , IDEConfigService } from "../ide-config" ;
105
105
import { EnvVarWithValue } from "@gitpod/gitpod-protocol/src/protocol" ;
106
- import { WithReferrerContext } from "@gitpod/gitpod-protocol/lib/protocol" ;
106
+ import { WithEditorContext , WithReferrerContext } from "@gitpod/gitpod-protocol/lib/protocol" ;
107
107
import { IDEOption , IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol" ;
108
108
import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred" ;
109
109
import { ExtendedUser } from "@gitpod/ws-manager/lib/constraints" ;
@@ -607,8 +607,12 @@ export class WorkspaceStarter {
607
607
user . additionalData . ideSettings = migratted ;
608
608
}
609
609
610
- const ideChoice = user . additionalData ?. ideSettings ?. defaultIde ;
611
- const useLatest = ! ! user . additionalData ?. ideSettings ?. useLatestVersion ;
610
+ const preferenceIDE = user . additionalData ?. ideSettings ?. defaultIde ;
611
+ const perferenceUseLatest = ! ! user . additionalData ?. ideSettings ?. useLatestVersion ;
612
+ const ideChoice = WithEditorContext . is ( workspace . context ) ? workspace . context . ide : preferenceIDE ;
613
+ const useLatest = WithEditorContext . is ( workspace . context )
614
+ ? workspace . context . useLatest ?? false
615
+ : perferenceUseLatest ;
612
616
613
617
// TODO(cw): once we allow changing the IDE in the workspace config (i.e. .gitpod.yml), we must
614
618
// give that value precedence over the default choice.
@@ -618,7 +622,7 @@ export class WorkspaceStarter {
618
622
ideConfig : {
619
623
// We only check user setting because if code(insider) but desktopIde has no latestImage
620
624
// it still need to notice user that this workspace is using latest IDE
621
- useLatest : user . additionalData ?. ideSettings ?. useLatestVersion ,
625
+ useLatest,
622
626
} ,
623
627
} ;
624
628
@@ -633,11 +637,17 @@ export class WorkspaceStarter {
633
637
configuration . desktopIdeImage = choose . desktopIdeImage ;
634
638
}
635
639
640
+ log . info (
641
+ { context : workspace . context , isEditorContext : WithEditorContext . is ( workspace . context ) } ,
642
+ "check context" ,
643
+ ) ;
644
+
636
645
const referrerIde = this . resolveReferrerIDE ( workspace , user , ideConfig ) ;
637
646
if ( referrerIde ) {
638
- configuration . desktopIdeImage = useLatest
647
+ configuration . desktopIdeImage = perferenceUseLatest
639
648
? referrerIde . option . latestImage ?? referrerIde . option . image
640
649
: referrerIde . option . image ;
650
+ configuration . ideConfig ! . useLatest = perferenceUseLatest ;
641
651
if ( ! user . additionalData ?. ideSettings ) {
642
652
// A user does not have IDE settings configured yet configure it with a referrer ide as default.
643
653
const additionalData = user ?. additionalData || { } ;
@@ -691,17 +701,24 @@ export class WorkspaceStarter {
691
701
} ,
692
702
configuration,
693
703
} ;
694
- if ( WithReferrerContext . is ( workspace . context ) ) {
704
+
705
+ const trackIDEPreferrer = ( referrer ?: string , referrerIde ?: string , useLatest ?: boolean ) => {
695
706
this . analytics . track ( {
696
707
userId : user . id ,
697
708
event : "ide_referrer" ,
698
709
properties : {
699
710
workspaceId : workspace . id ,
700
711
instanceId : instance . id ,
701
- referrer : workspace . context . referrer ,
702
- referrerIde : workspace . context . referrerIde ,
712
+ referrer,
713
+ useLatest,
714
+ referrerIde,
703
715
} ,
704
716
} ) ;
717
+ } ;
718
+ if ( WithReferrerContext . is ( workspace . context ) ) {
719
+ trackIDEPreferrer ( workspace . context . referrer , workspace . context . referrerIde , perferenceUseLatest ) ;
720
+ } else if ( WithEditorContext . is ( workspace . context ) ) {
721
+ trackIDEPreferrer ( workspace . context . referrer , workspace . context . ide , workspace . context . useLatest ) ;
705
722
}
706
723
return instance ;
707
724
}
0 commit comments