Skip to content
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

backport/vscode/1.50: chore(telemetry): remove legacy back-compat (#6265) #6276

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

bobheadxi
Copy link
Member

@bobheadxi bobheadxi commented Dec 6, 2024

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, 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
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 --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

(cherry picked from commit 717c1d7)

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

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)
Copy link
Contributor

@kalanchan kalanchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by Grace (thread) as emergency patch release to address telemetry issues related to billing metrics.

@kalanchan kalanchan merged commit ab0da18 into vscode-v1.50.x Dec 6, 2024
25 of 27 checks passed
@kalanchan kalanchan deleted the backport-6265-to-vscode-v1.50.x branch December 6, 2024 20:40
dominiccooney pushed a commit that referenced this pull request Dec 10, 2024
) (#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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants