Skip to content

Commit

Permalink
backport/vscode/1.50: chore(telemetry): remove legacy back-compat (#6265
Browse files Browse the repository at this point in the history
) (#6276)

When V2 telemetry first launched, we had to be careful to support older
instances with V1 event logs, and shortly after the launch there were a
series of bug fixes that necessitated several compatibility modes from
5.2.0 to 5.2.5, which was released in December 2023. After 5.2.5, we
never committed to removing this back-compat as we waited for customers
to slowly upgrade past 5.2.5.

Sadly, this came back to haunt us when 5.10.0 came out a few days ago,
and our compatibility mode detector [sorted 5.10.0 <
5.2.5](https://sourcegraph.slack.com/archives/C03JR7S7KRP/p1733430008785369?thread_ts=1733425399.918999&cid=C03JR7S7KRP),
causing V2T to be exported as old event logs, which prevented them from
being exported. After finding the bug and discussing it a bit, we've
decided to [remove this back-compat

entirely](https://sourcegraph.slack.com/archives/C03JR7S7KRP/p1733507755279819?thread_ts=1733425399.918999&cid=C03JR7S7KRP)
since most Cody customers have upgraded past 5.2.5. This simplifies the
code significantly.

With the backcompat gone, this basically removes the need for _any_ of
the old log-event-to-dotcom stuff, which allowed for the removal for
quite a lot of unused code, which simplifies even more stuff.

Closes

https://linear.app/sourcegraph/issue/CORE-103/vscodetelemetry-remove-legacy-v1-fallback-exporter

## Test plan

CI, plus a manual test:

Apply a simple patch to make telemetry export in dev without fenangling
configuration (this diff is not in this PR):

```diff
diff --git a/vscode/src/services/telemetry-v2.ts b/vscode/src/services/telemetry-v2.ts
index a2857b565..6dcf1e9ad 100644
--- a/vscode/src/services/telemetry-v2.ts
+++ b/vscode/src/services/telemetry-v2.ts
@@ -43,27 +43,11 @@ export function createOrUpdateTelemetryRecorderProvider(

             const initialize = telemetryRecorderProvider === undefined

-            /**
-             * In testing, send events to the mock server.
-             */
-            if (process.env.CODY_TESTING === 'true') {
-                logDebug(debugLogLabel, 'using mock exporter')
-                updateGlobalTelemetryInstances(
-                    new MockServerTelemetryRecorderProvider({
-                        configuration,
-                        clientState,
-                    })
-                )
-            } else if (isExtensionModeDevOrTest) {
-                logDebug(debugLogLabel, 'using no-op exports')
-                updateGlobalTelemetryInstances(defaultNoOpProvider)
-            } else {
                 updateGlobalTelemetryInstances(
                     new TelemetryRecorderProvider(
                         { configuration, auth, clientState },
                     )
                 )
-            }

             /**
              * On first initialization, also record some initial events.
```

Run the extension:

```
pnpm install && pnpm build && cd vscode && pnpm run dev
```

In logs:

```
█ telemetry-v2 recordEvent: cody.auth/connected:
```

in the instance:


![image](https://github.com/user-attachments/assets/5f7a40b2-662b-4447-992d-27393c9effc7)

(cherry picked from commit 717c1d7)
  • Loading branch information
bobheadxi authored and dominiccooney committed Dec 10, 2024
1 parent 71a6a43 commit ff9c201
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 685 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ interface CodyAgentServer {
fun featureFlags_getFeatureFlag(params: FeatureFlags_GetFeatureFlagParams): CompletableFuture<Boolean?>
@JsonRequest("graphql/getCurrentUserCodySubscription")
fun graphql_getCurrentUserCodySubscription(params: Null?): CompletableFuture<CurrentUserCodySubscription?>
@JsonRequest("graphql/logEvent")
fun graphql_logEvent(params: Event): CompletableFuture<Null?>
@JsonRequest("telemetry/recordEvent")
fun telemetry_recordEvent(params: TelemetryEvent): CompletableFuture<Null?>
@JsonRequest("graphql/getRepoIdIfEmbeddingExists")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ object Constants {
const val Automatic = "Automatic"
const val Error = "Error"
const val Finished = "Finished"
const val IDEEXTENSION = "IDEEXTENSION"
const val Idle = "Idle"
const val Inserting = "Inserting"
const val Invoke = "Invoke"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ data class ExtensionConfiguration(
val verboseDebug: Boolean? = null,
val telemetryClientName: String? = null,
val codebase: String? = null,
val eventProperties: EventProperties? = null,
val customConfiguration: Map<String, Any>? = null,
val customConfigurationJson: String? = null,
val baseGlobalState: Map<String, Any>? = null,
Expand Down
7 changes: 0 additions & 7 deletions agent/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,6 @@ shutdown: [null, null]
```ts
'graphql/getCurrentUserCodySubscription': [null, CurrentUserCodySubscription | null]
```
<h2 id="graphql_logEvent"><a href="#graphql_logEvent" name="graphql_logEvent"><code>graphql/logEvent</code> (<img class="emoji" title=":arrow_right:" alt=":arrow_right:" src="https://github.githubassets.com/images/icons/emoji/unicode/27a1.png" height="20" width="20">)</a></h2>
<p>Request sent from the client to client server.</p>


```ts
'graphql/logEvent': [event, null]
```
<h2 id="telemetry_recordEvent"><a href="#telemetry_recordEvent" name="telemetry_recordEvent"><code>telemetry/recordEvent</code> (<img class="emoji" title=":arrow_right:" alt=":arrow_right:" src="https://github.githubassets.com/images/icons/emoji/unicode/27a1.png" height="20" width="20">)</a></h2>
<p>Request sent from the client to client server.</p>
<p>Description: Record telemetry events.</p>
Expand Down
2 changes: 0 additions & 2 deletions agent/src/TestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ interface TestClientParams {
readonly credentials: TestingCredentials
bin?: string
telemetryExporter?: 'testing' | 'graphql' // defaults to testing, which doesn't send telemetry
logEventMode?: 'connected-instance-only' | 'all' | 'dotcom-only'
onWindowRequest?: (params: ShowWindowMessageParams) => Promise<string>
extraConfiguration?: Record<string, any>
}
Expand Down Expand Up @@ -166,7 +165,6 @@ export class TestClient extends MessageHandler {
CODY_TELEMETRY_EXPORTER: params.telemetryExporter ?? 'testing',
DISABLE_FEATURE_FLAGS: 'true',
DISABLE_UPSTREAM_HEALTH_PINGS: 'true',
CODY_LOG_EVENT_MODE: params.logEventMode,
...process.env,
},
})
Expand Down
14 changes: 0 additions & 14 deletions agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,20 +1071,6 @@ export class Agent extends MessageHandler implements ExtensionClient {
return Promise.resolve(null)
})

/**
* @deprecated use 'telemetry/recordEvent' instead.
*/
this.registerAuthenticatedRequest('graphql/logEvent', async event => {
if (typeof event.argument === 'object') {
event.argument = JSON.stringify(event.argument)
}
if (typeof event.publicArgument === 'object') {
event.publicArgument = JSON.stringify(event.publicArgument)
}
await graphqlClient.logEvent(event, 'connected-instance-only')
return null
})

this.registerRequest('graphql/getRepoIdIfEmbeddingExists', () => {
return Promise.resolve(null)
})
Expand Down
1 change: 0 additions & 1 deletion agent/src/enterprise-demo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('Enterprise', () => {
workspaceRootUri: workspace.rootUri,
name: 'enterpriseClient',
credentials: TESTING_CREDENTIALS.enterprise,
logEventMode: 'connected-instance-only',
})
// Initialize inside beforeAll so that subsequent tests are skipped if initialization fails.
beforeAll(async () => {
Expand Down
1 change: 0 additions & 1 deletion agent/src/enterprise-s2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('Enterprise - S2 (close main branch)', { timeout: 5000 }, () => {
workspaceRootUri: workspace.rootUri,
name: 'enterpriseMainBranchClient',
credentials: TESTING_CREDENTIALS.s2,
logEventMode: 'connected-instance-only',
})
const sumUri = workspace.file('src', 'sum.ts')
const animalUri = workspace.file('src', 'animal.ts')
Expand Down
1 change: 0 additions & 1 deletion lib/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ export {
EXCLUDE_EVERYTHING_CONTEXT_FILTERS,
PromptMode,
type BrowserOrNodeResponse,
type LogEventMode,
type ContextFilters,
type CodyContextFilterItem,
type RepoListResponse,
Expand Down
Loading

0 comments on commit ff9c201

Please sign in to comment.