Skip to content

installation-telemetry: add customer ID #10629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions components/dashboard/src/admin/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,47 @@ export default function Settings() {
subtitle="Configure settings for your Gitpod cluster."
>
<h3>Usage Statistics</h3>
<p className="text-base text-gray-500 pb-4 max-w-2xl">
We collect usage telemetry to gain insights on how you use your Gitpod instance, so we can provide a
better overall experience.
</p>
<p>
<a className="gp-link" href="https://www.gitpod.io/privacy">
Read our Privacy Policy
</a>
</p>
<CheckBox
title="Enable Service Ping"
title="Enable usage telemetry"
desc={
<span>
The following usage data is sent to provide insights on how you use your Gitpod instance, so
we can provide a better overall experience.{" "}
<a className="gp-link" href="https://www.gitpod.io/privacy">
Read our Privacy Policy
</a>
Enable usage telemetry on your Gitpod instance. A preview of your telemetry is available
below.
</span>
}
checked={adminSettings?.sendTelemetry ?? false}
onChange={(evt) =>
actuallySetTelemetryPrefs({
...adminSettings,
sendTelemetry: evt.target.checked,
})
} as InstallationAdminSettings)
}
/>
<CheckBox
title="Include customer ID in telemetry"
desc={
<span>
Include an optional customer ID in usage telemetry to provide individualized support.
</span>
}
checked={adminSettings?.sendCustomerID ?? false}
onChange={(evt) =>
actuallySetTelemetryPrefs({
...adminSettings,
sendCustomerID: evt.target.checked,
} as InstallationAdminSettings)
}
/>
<h3 className="mt-4">Telemetry preview</h3>
<InfoBox>
<pre>{JSON.stringify(telemetryData, null, 2)}</pre>
</InfoBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { v4 as uuidv4 } from "uuid";

const InstallationAdminSettingsPrototype = {
sendTelemetry: true,
sendCustomerID: true,
};

export type InstallationAdminSettings = typeof InstallationAdminSettingsPrototype;
Expand All @@ -29,6 +30,7 @@ export interface TelemetryData {
totalWorkspaces: number;
totalInstances: number;
licenseType: string;
customerID?: string;
}

export namespace InstallationAdmin {
Expand Down
21 changes: 13 additions & 8 deletions components/installation-telemetry/cmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,20 @@ var sendCmd = &cobra.Command{
err = client.Close()
}()

properties := analytics.NewProperties().
Set("version", versionId).
Set("totalUsers", data.TotalUsers).
Set("totalWorkspaces", data.TotalWorkspaces).
Set("totalInstances", data.TotalInstances)

if data.InstallationAdmin.Settings.SendCustomerID {
properties.Set("customerID", data.CustomerID)
}

telemetry := analytics.Track{
UserId: data.InstallationAdmin.ID,
Event: "Installation telemetry",
Properties: analytics.NewProperties().
Set("version", versionId).
Set("totalUsers", data.TotalUsers).
Set("totalWorkspaces", data.TotalWorkspaces).
Set("totalInstances", data.TotalInstances).
Set("licenseType", data.LicenseType),
UserId: data.InstallationAdmin.ID,
Event: "Installation telemetry",
Properties: properties,
}

client.Enqueue(telemetry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
)

type InstallationAdminSettings struct {
SendTelemetry bool `json:"sendTelemetry"`
SendTelemetry bool `json:"sendTelemetry"`
SendCustomerID bool `json:"sendCustomerID"`
}

type Data struct {
Expand All @@ -23,6 +24,7 @@ type Data struct {
TotalWorkspaces int64 `json:"totalWorkspaces"`
TotalInstances int64 `json:"totalInstances"`
LicenseType string `json:"licenseType"`
CustomerID string `json:"customerID,omitempty"`
}

type InstallationAdmin struct {
Expand Down
3 changes: 3 additions & 0 deletions components/licensor/ee/pkg/licensor/licensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type LicensePayload struct {

// Seats == 0 means there's no seat limit
Seats int `json:"seats"`

// CustomerID is used to identify installations in installation analytics
CustomerID string `json:"customerID"`
}

type licensePayload struct {
Expand Down
3 changes: 3 additions & 0 deletions components/licensor/ee/pkg/licensor/replicated.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ func newReplicatedEvaluator(client *http.Client) (res *Evaluator) {

case "seats":
lic.Seats = int(i.Value.(float64))

case "customerId":
lic.CustomerID = i.Value.(string)
}
}

Expand Down
1 change: 1 addition & 0 deletions components/licensor/typescript/ee/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface LicensePayload {
level: LicenseLevel
validUntil: string
seats: number
customerID: string
}

export enum LicenseSubscriptionLevel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export class InstallationAdminTelemetryDataProvider {
totalWorkspaces: await this.workspaceDb.getWorkspaceCount(),
totalInstances: await this.workspaceDb.getInstanceCount(),
licenseType: this.licenseEvaluator.getLicenseData().type,
customerID: this.licenseEvaluator.getLicenseData().payload.customerID,
} as TelemetryData;

if (data.installationAdmin.settings.sendCustomerID) {
data.customerID = this.licenseEvaluator.getLicenseData().payload.customerID;
}

return data;
} finally {
span.finish();
Expand Down