Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 9ac36d7

Browse files
bobheadxigithub-actions[bot]
authored andcommitted
telemetry: improve inline docstrings (#57104)
(cherry picked from commit 8b32774)
1 parent 7692314 commit 9ac36d7

3 files changed

Lines changed: 86 additions & 37 deletions

File tree

cmd/frontend/graphqlbackend/telemetry.graphql

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ input TelemetryEventInput {
5151

5252
"""
5353
Optional marketing campaign tracking parameters.
54+
55+
🚨 SECURITY: This metadata is NEVER exported from private Sourcegraph instances,
56+
and is only exported for events tracked in the public Sourcegraph.com instance.
5457
"""
5558
marketingTracking: TelemetryEventMarketingTrackingInput
5659
}
@@ -60,9 +63,7 @@ Properties comprising the source of a telemetry V2 event reported by a client.
6063
"""
6164
input TelemetryEventSourceInput {
6265
"""
63-
Source client of the event. Clients must come from a static set of predefined
64-
metadata keys in libraries - it is left as a string in the API to allow some
65-
backwards/forwards flexibility.
66+
Source client of the event.
6667
"""
6768
client: String!
6869
"""
@@ -88,7 +89,9 @@ input TelemetryEventParametersInput {
8889
Private metadata in JSON format. Unlike metadata, values can be of any type,
8990
not just numeric.
9091
91-
By default, this metadata is assumed to be unsafe for export from an instance.
92+
🚨 SECURITY: This metadata is NOT exported from instances by default, as it
93+
can contain arbitrarily-shaped data that may accidentally contain sensitive
94+
or private contents.
9295
"""
9396
privateMetadata: JSONValue
9497
"""
@@ -102,12 +105,12 @@ A single, PII-free metadata item for telemetry V2 events.
102105
"""
103106
input TelemetryEventMetadataInput {
104107
"""
105-
Metadata keys must come from a static set of predefined metadata keys in
106-
libraries - it is left as a string in the API to allow some flexibility.
108+
The key identifying this metadata entry.
107109
"""
108110
key: String!
109111
"""
110-
Numeric value associated with the key.
112+
Numeric value associated with the key. Enforcing numeric values eliminates
113+
risks of accidentally shipping sensitive or private data.
111114
"""
112115
value: Int!
113116
}
@@ -135,7 +138,8 @@ input TelemetryEventBillingMetadataInput {
135138
"""
136139
Marketing campaign tracking parameters for a telemetry V2 event.
137140
138-
By default, this metadata is assumed to be unsafe for export from an instance.
141+
🚨 SECURITY: This metadata is NEVER exported from private Sourcegraph instances,
142+
and is only exported for events tracked in the public Sourcegraph.com instance.
139143
"""
140144
input TelemetryEventMarketingTrackingInput {
141145
"""

internal/telemetrygateway/v1/telemetrygateway.pb.go

Lines changed: 41 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/telemetrygateway/v1/telemetrygateway.proto

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,20 @@ message Event {
100100
optional EventFeatureFlags feature_flags = 8;
101101
// Optional marketing campaign tracking parameters.
102102
//
103-
// 🚨 SECURITY: Do NOT export this metadata by default, as it can contain
104-
// sensitive data. Currently, only Sourcegraph.com should export this.
103+
// 🚨 SECURITY: This metadata is NEVER exported from an instance, and is only
104+
// exported for events tracked in the public Sourcegraph.com instance.
105105
optional EventMarketingTracking marketing_tracking = 9;
106106
}
107107

108108
message EventSource {
109109
message Server {
110+
// Version of the Sourcegraph server.
110111
string version = 1;
111112
}
112113
message Client {
114+
// Source client of the event.
113115
string name = 1;
116+
// Version of the cleint.
114117
optional string version = 2;
115118
}
116119

@@ -122,18 +125,22 @@ message EventSource {
122125

123126
message EventParameters {
124127
// Version of the event parameters, used for indicating the "shape" of this
125-
// event's metadata, beginning at 0.
128+
// event's metadata, beginning at 0. Useful for denoting if the shape of
129+
// metadata has changed in any way.
126130
int32 version = 1;
127-
// Strictly typed metadata, restricted to integer values.
131+
// Strictly typed metadata, restricted to integer values to avoid accidentally
132+
// exporting sensitive or private data.
128133
map<string, int64> metadata = 2;
129134
// Additional potentially sensitive metadata - i.e. not restricted to integer
130135
// values.
131-
132-
// 🚨 SECURITY: Do NOT export this metadata by default, as it can contain
133-
// arbitrarily-shaped data that may accidentally contain sensitive contents.
134136
//
135-
// This should only be exported on an allowlist basis based on combinations
136-
// of event feature and action, alongside careful audit of callsites.
137+
// 🚨 SECURITY: This metadata is NOT exported from instances by default, as it
138+
// can contain arbitrarily-shaped data that may accidentally contain sensitive
139+
// or private contents.
140+
//
141+
// This metadata is only exported on an allowlist basis based on terms of
142+
// use agreements and combinations of event feature and action, alongside
143+
// careful audit of callsites.
137144
optional google.protobuf.Struct private_metadata = 3;
138145
// Optional billing-related metadata.
139146
optional EventBillingMetadata billing_metadata = 4;
@@ -147,13 +154,14 @@ message EventBillingMetadata {
147154
}
148155

149156
message EventUser {
150-
// Database user ID of signed in user.
157+
// Database user ID of signed in user. User IDs are specific to a Sourcegraph
158+
// instance, and not universal.
151159
//
152160
// We use an int64 as an ID because in Sourcegraph, database user IDs are
153161
// always integers.
154162
optional int64 user_id = 1;
155-
// Randomized unique identifier for client (i.e. stored in localstorage in web
156-
// client).
163+
// Randomized unique identifier for an actor (e.g. stored in localstorage in
164+
// web client).
157165
optional string anonymous_user_id = 2;
158166
}
159167

@@ -167,13 +175,26 @@ message EventFeatureFlags {
167175
map<string, string> flags = 1;
168176
}
169177

178+
// Marketing campaign tracking metadata.
179+
//
180+
// 🚨 SECURITY: This metadata is NEVER exported from private Sourcegraph
181+
// instances, and is only exported for events tracked in the public
182+
// Sourcegraph.com instance.
170183
message EventMarketingTracking {
184+
// URL the event occurred on.
171185
optional string url = 1;
186+
// Initial URL the user landed on.
172187
optional string first_source_url = 2;
188+
// Cohort ID to identify the user as part of a specific A/B test.
173189
optional string cohort_id = 3;
190+
// Referrer URL that refers the user to Sourcegraph.
174191
optional string referrer = 4;
192+
// Last source URL visited by the user.
175193
optional string last_source_url = 5;
194+
// Device session ID to identify the user's session.
176195
optional string device_session_id = 6;
196+
// Session referrer URL for the user.
177197
optional string session_referrer = 7;
198+
// First URL the user visited in their current session.
178199
optional string session_first_url = 8;
179200
}

0 commit comments

Comments
 (0)