Skip to content

Commit b147a29

Browse files
Merge branch 'main' into jetbrains/phpstorm-221-5591-58
2 parents e22a239 + 0780270 commit b147a29

26 files changed

+313
-28
lines changed

WORKSPACE.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defaultArgs:
1212
jetbrainsBackendQualifier: stable
1313
intellijDownloadUrl: "https://download.jetbrains.com/idea/ideaIU-2022.1.1.tar.gz"
1414
golandDownloadUrl: "https://download.jetbrains.com/go/goland-2022.1.tar.gz"
15-
pycharmDownloadUrl: "https://download.jetbrains.com/python/pycharm-professional-2022.1.tar.gz"
15+
pycharmDownloadUrl: "https://download.jetbrains.com/python/pycharm-professional-2022.1.1.tar.gz"
1616
phpstormDownloadUrl: "https://download.jetbrains.com/webide/PhpStorm-2022.1.1.tar.gz"
1717
provenance:
1818
enabled: true

components/BUILD.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ packages:
8686
- components/supervisor-api/typescript-grpc:publish
8787
- components/supervisor-api/typescript-grpcweb:publish
8888
- components/ide/jetbrains/gateway-plugin:publish
89+
- components/public-api/typescript:publish
8990
- name: all-apps
9091
type: generic
9192
deps:

components/common-go/baseserver/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"google.golang.org/grpc"
2828
"google.golang.org/grpc/credentials"
2929
"google.golang.org/grpc/health/grpc_health_v1"
30+
"google.golang.org/grpc/reflection"
3031
)
3132

3233
func New(name string, opts ...Option) (*Server, error) {
@@ -291,6 +292,8 @@ func (s *Server) initializeGRPC() error {
291292

292293
s.grpc = grpc.NewServer(opts...)
293294

295+
reflection.Register(s.grpc)
296+
294297
// Register health service by default
295298
grpc_health_v1.RegisterHealthServer(s.grpc, s.options.grpcHealthCheck)
296299

components/dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"private": true,
66
"dependencies": {
77
"@gitpod/gitpod-protocol": "0.1.5",
8+
"configcat-js": "^5.7.2",
89
"countries-list": "^2.6.1",
910
"js-cookie": "^3.0.1",
1011
"moment": "^2.29.1",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
import { Attributes, Client } from "./client";
7+
8+
// AlwaysReturningDefaultValueClient is an implemention of an experiments.Client which performs no lookup/network operation
9+
// and always returns the default value for a given experimentName.
10+
// This client is used for non-SaaS version of Gitpod, in particular for self-hosted installations where external
11+
// network connections are not desirable or even possible.
12+
class AlwaysReturningDefaultValueClient implements Client {
13+
getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T> {
14+
return Promise.resolve(defaultValue);
15+
}
16+
17+
dispose(): void {
18+
// there is nothing to dispose, no-op.
19+
}
20+
}
21+
22+
export function newAlwaysReturningDefaultValueClient(): Client {
23+
return new AlwaysReturningDefaultValueClient();
24+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
// Attributes define attributes which can be used to segment audiences.
8+
// Set the attributes which you want to use to group audiences into.
9+
import { newNonProductionConfigCatClient, newProductionConfigCatClient } from "./configcat";
10+
import { newAlwaysReturningDefaultValueClient } from "./always-default";
11+
12+
export interface Attributes {
13+
userID?: string;
14+
email?: string;
15+
16+
// Gitpod Project ID
17+
projectID?: string;
18+
19+
// Gitpod Team ID
20+
teamID?: string;
21+
// Gitpod Team Name
22+
teamName?: string;
23+
}
24+
25+
export interface Client {
26+
getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T>;
27+
28+
// dispose will dispose of the client, no longer retrieving flags
29+
dispose(): void;
30+
}
31+
32+
let client: Client | undefined;
33+
34+
export function getExperimentsClient(): Client {
35+
// We have already instantiated a client, we can just re-use it.
36+
if (client !== undefined) {
37+
return client;
38+
}
39+
40+
const host = window.location.hostname;
41+
if (host === "gitpod.io") {
42+
client = newProductionConfigCatClient();
43+
} else if (host === "gitpod-staging.com" || host.endsWith("gitpod-dev.com") || host.endsWith("gitpod-io-dev.com")) {
44+
client = newNonProductionConfigCatClient();
45+
} else {
46+
// We're gonna use a client which always returns the default value.
47+
client = newAlwaysReturningDefaultValueClient();
48+
}
49+
50+
return client;
51+
}
52+
53+
export const PROJECT_ID_ATTRIBUTE = "project_id";
54+
export const TEAM_ID_ATTRIBUTE = "team_id";
55+
export const TEAM_NAME_ATTRIBUTE = "team_name";
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import * as configcat from "configcat-js";
8+
import { IConfigCatClient } from "configcat-common/lib/ConfigCatClient";
9+
import { User } from "configcat-common/lib/RolloutEvaluator";
10+
import { Attributes, Client, PROJECT_ID_ATTRIBUTE, TEAM_ID_ATTRIBUTE, TEAM_NAME_ATTRIBUTE } from "./client";
11+
12+
// newProductionConfigCatClient constructs a new ConfigCat client with production configuration.
13+
// DO NOT USE DIRECTLY! Use getExperimentsClient() instead.
14+
export function newProductionConfigCatClient(): Client {
15+
// clientKey is an identifier of our ConfigCat application. It is not a secret.
16+
const clientKey = "WBLaCPtkjkqKHlHedziE9g/TwAe6YyftEGPnGxVRXd0Ig";
17+
const client = configcat.createClient(clientKey, {
18+
logger: configcat.createConsoleLogger(2),
19+
});
20+
21+
return new ConfigCatClient(client);
22+
}
23+
24+
// newNonProductionConfigCatClient constructs a new ConfigCat client with non-production configuration.
25+
// DO NOT USE DIRECTLY! Use getExperimentsClient() instead.
26+
export function newNonProductionConfigCatClient(): Client {
27+
// clientKey is an identifier of our ConfigCat application. It is not a secret.
28+
const clientKey = "WBLaCPtkjkqKHlHedziE9g/LEAOCNkbuUKiqUZAcVg7dw";
29+
const client = configcat.createClient(clientKey, {
30+
pollIntervalSeconds: 60 * 3, // 3 minutes
31+
logger: configcat.createConsoleLogger(3),
32+
});
33+
34+
return new ConfigCatClient(client);
35+
}
36+
37+
class ConfigCatClient implements Client {
38+
private client: IConfigCatClient;
39+
40+
constructor(cc: IConfigCatClient) {
41+
this.client = cc;
42+
}
43+
44+
getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T> {
45+
return this.client.getValueAsync(experimentName, defaultValue, attributesToUser(attributes));
46+
}
47+
48+
dispose(): void {
49+
return this.client.dispose();
50+
}
51+
}
52+
53+
function attributesToUser(attributes: Attributes): User {
54+
const userID = attributes.userID || "";
55+
const email = attributes.email || "";
56+
57+
const custom: { [key: string]: string } = {};
58+
if (attributes.projectID) {
59+
custom[PROJECT_ID_ATTRIBUTE] = attributes.projectID;
60+
}
61+
if (attributes.teamID) {
62+
custom[TEAM_ID_ATTRIBUTE] = attributes.teamID;
63+
}
64+
if (attributes.teamName) {
65+
custom[TEAM_NAME_ATTRIBUTE] = attributes.teamName;
66+
}
67+
68+
return new User(userID, email, "", custom);
69+
}

components/dashboard/src/workspaces/Workspaces.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { User } from "@gitpod/gitpod-protocol";
1818
import { useLocation } from "react-router";
1919
import { StartWorkspaceModalContext, StartWorkspaceModalKeyBinding } from "./start-workspace-modal-context";
2020
import SelectIDEModal from "../settings/SelectIDEModal";
21+
import { getExperimentsClient } from "../experiments/client";
2122

2223
export interface WorkspacesProps {}
2324

@@ -36,6 +37,7 @@ export default function () {
3637
const [inactiveWorkspaces, setInactiveWorkspaces] = useState<WorkspaceInfo[]>([]);
3738
const [workspaceModel, setWorkspaceModel] = useState<WorkspaceModel>();
3839
const { setIsStartWorkspaceModalVisible } = useContext(StartWorkspaceModalContext);
40+
const [isExperimentEnabled, setExperiment] = useState<boolean>(false);
3941

4042
useEffect(() => {
4143
(async () => {
@@ -45,13 +47,22 @@ export default function () {
4547
}, [teams, location]);
4648

4749
const isOnboardingUser = user && User.isOnboardingUser(user);
50+
useEffect(() => {
51+
(async () => {
52+
if (teams && teams.length > 0) {
53+
const isEnabled = await getExperimentsClient().getValueAsync("isMyFirstFeatureEnabled", false, {
54+
teamName: teams[0]?.name,
55+
});
56+
setExperiment(isEnabled);
57+
}
58+
})();
59+
}, [teams]);
60+
console.log("Is experiment enabled? ", isExperimentEnabled);
4861

4962
return (
5063
<>
5164
<Header title="Workspaces" subtitle="Manage recent and stopped workspaces." />
52-
5365
{isOnboardingUser && <SelectIDEModal />}
54-
5566
{workspaceModel?.initialized &&
5667
(activeWorkspaces.length > 0 || inactiveWorkspaces.length > 0 || workspaceModel.searchTerm ? (
5768
<>

components/public-api/typescript/BUILD.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,26 @@ packages:
44
deps:
55
- components/gitpod-protocol:lib
66
srcs:
7-
- "src/*.ts"
8-
- "src/*.js"
7+
- src/**
98
- package.json
9+
- tsconfig.json
1010
config:
1111
packaging: library
1212
dontTest: true
1313
commands:
1414
build: ["yarn", "build"]
1515
yarnLock: ${coreYarnLockBase}/../yarn.lock
1616
tsconfig: tsconfig.json
17+
18+
- name: publish
19+
type: generic
20+
env:
21+
- DO_PUBLISH=${publishToNPM}
22+
argdeps:
23+
- npmPublishTrigger
24+
deps:
25+
- :lib
26+
- components/gitpod-protocol:scripts
27+
config:
28+
commands:
29+
- ["node", "components-gitpod-protocol--scripts/publish.js", "${version}", "components-public-api-typescript--lib/package"]

components/public-api/typescript/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"private": true,
32
"name": "@gitpod/public-api",
43
"version": "0.1.5",
54
"license": "UNLICENSED",
65
"files": [
7-
"client",
86
"lib"
97
],
108
"scripts": {
@@ -14,11 +12,9 @@
1412
"test:brk": "yarn test --inspect-brk"
1513
},
1614
"dependencies": {
17-
"@gitpod/content-service": "0.1.5",
1815
"@gitpod/gitpod-protocol": "0.1.5",
1916
"@grpc/grpc-js": "^1.3.7",
2017
"google-protobuf": "^3.19.1",
21-
"inversify": "^5.0.1",
2218
"opentracing": "^0.14.4"
2319
},
2420
"devDependencies": {
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
// GENERATED CODE -- NO SERVICES IN PROTO
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
// GENERATED CODE -- NO SERVICES IN PROTO

components/public-api/typescript/src/gitpod/v1/pagination_pb.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// package: gitpod.v1
28
// file: gitpod/v1/pagination.proto
39

components/public-api/typescript/src/gitpod/v1/pagination_pb.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// source: gitpod/v1/pagination.proto
28
/**
39
* @fileoverview

components/public-api/typescript/src/gitpod/v1/prebuilds_grpc_pb.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// package: gitpod.v1
28
// file: gitpod/v1/prebuilds.proto
39

components/public-api/typescript/src/gitpod/v1/prebuilds_grpc_pb.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// GENERATED CODE -- DO NOT EDIT!
28

39
'use strict';

components/public-api/typescript/src/gitpod/v1/prebuilds_pb.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// package: gitpod.v1
28
// file: gitpod/v1/prebuilds.proto
39

components/public-api/typescript/src/gitpod/v1/prebuilds_pb.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// source: gitpod/v1/prebuilds.proto
28
/**
39
* @fileoverview

components/public-api/typescript/src/gitpod/v1/workspaces_grpc_pb.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// package: gitpod.v1
28
// file: gitpod/v1/workspaces.proto
39

components/public-api/typescript/src/gitpod/v1/workspaces_grpc_pb.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// GENERATED CODE -- DO NOT EDIT!
28

39
'use strict';

components/public-api/typescript/src/gitpod/v1/workspaces_pb.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// package: gitpod.v1
28
// file: gitpod/v1/workspaces.proto
39

components/public-api/typescript/src/gitpod/v1/workspaces_pb.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
17
// source: gitpod/v1/workspaces.proto
28
/**
39
* @fileoverview

0 commit comments

Comments
 (0)