Skip to content

Commit

Permalink
Disable telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Scullin committed May 20, 2024
1 parent 1edb8aa commit 1b787a6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 47 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ jobs:
CI: true
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
GA_API_SECRET: ${{ secrets.GA_API_SECRET }}
GA_MEASUREMENT_ID: ${{ secrets.GA_MEASUREMENT_ID }}
GHAPI_PAT: ${{ secrets.GHAPI_PAT }}
2 changes: 0 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ jobs:
CI: true
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
GA_API_SECRET: ${{ secrets.GA_API_SECRET }}
GA_MEASUREMENT_ID: ${{ secrets.GA_MEASUREMENT_ID }}
GHAPI_PAT: ${{ secrets.GHAPI_PAT }}
9 changes: 0 additions & 9 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,3 @@ launch profile from the "Run and Debug" panel.
3. If you make changes to Malloy that are required by the extension, merges those into main, and that will trigger an automatic developer release of Malloy.
4. Once that release completes, run `npm run malloy-update` to update dependencies to that release. This will break the link to your local version of Malloy, so if you want to resume local development, re-run `npm run malloy-link`
5. To manually unlink without updating, you may run `npm run malloy-unlink`

## Telemetry

For telemetry to work in development, you need to have the `GA_MEASUREMENT_ID` and `GA_API_SECRET` environment variables set to appropriate values. In order for these to be populated when using the "Run Malloy Extension" VSCode launch configuration, they need to be in a `.env` file at the top level of the repo, like so:

```
GA_MEASUREMENT_ID='<id goes here>'
GA_API_SECRET='<secret goes here>'
```
6 changes: 0 additions & 6 deletions cloudbuild/deploy/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ steps:
[
'VSCE_PAT',
'OVSX_TOKEN',
'GA_API_SECRET',
'GA_MEASUREMENT_ID',
'GHAPI_PAT',
]
options:
Expand All @@ -22,9 +20,5 @@ availableSecrets:
env: 'VSCE_PAT'
- versionName: projects/673673622326/secrets/ovsx-token/versions/latest
env: OVSX_TOKEN
- versionName: projects/malloy-303216/secrets/vscode-extension-CI-GA-API-SECRET/versions/latest
env: 'GA_API_SECRET'
- versionName: projects/malloy-303216/secrets/vscode-extension-CI-GA-MEASUREMENT-ID/versions/latest
env: 'GA_MEASUREMENT_ID'
- versionName: projects/malloy-303216/secrets/vscode-extension-gh-pat/versions/latest
env: 'GHAPI_PAT'
12 changes: 6 additions & 6 deletions scripts/build_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ const DEFINITIONS: Record<string, string> = {
'process.env.NODE_DEBUG': 'false', // TODO this is a hack because some package we include assumed process.env exists :(
};

const ENV_PASSTHROUGH = ['GA_API_SECRET', 'GA_MEASUREMENT_ID'];
// const ENV_PASSTHROUGH = ['GA_API_SECRET', 'GA_MEASUREMENT_ID'];

for (const variable of ENV_PASSTHROUGH) {
DEFINITIONS[`process.env.${variable}`] = JSON.stringify(
process.env[variable] || ''
);
}
// for (const variable of ENV_PASSTHROUGH) {
// DEFINITIONS[`process.env.${variable}`] = JSON.stringify(
// process.env[variable] || ''
// );
// }

// building without a target does a default build
export async function doBuild(
Expand Down
25 changes: 3 additions & 22 deletions src/extension/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*/

import * as vscode from 'vscode';
import {MALLOY_EXTENSION_STATE} from './state';
import fetch from 'node-fetch';
import {getMalloyConfig} from './utils/config';

const telemetryLog = vscode.window.createOutputChannel('Malloy Telemetry');
Expand All @@ -34,34 +32,17 @@ function isTelemetryEnabled() {
return vsCodeValue && configValue;
}

export interface GATrackingEvent {
export interface TrackingEvent {
name: string;
params: Record<string, string>;
}

const MEASUREMENT_ID = process.env['GA_MEASUREMENT_ID'];
const API_SECRET = process.env['GA_API_SECRET'];

async function track(event: GATrackingEvent) {
async function track(event: TrackingEvent) {
if (!isTelemetryEnabled()) return;

telemetryLog.appendLine(`Logging telemetry event: ${JSON.stringify(event)}.`);

try {
// process.env['NODE_DEBUG'] = "http";
await fetch(
`https://www.google-analytics.com/mp/collect?measurement_id=${MEASUREMENT_ID}&api_secret=${API_SECRET}`,
{
method: 'POST',
body: JSON.stringify({
client_id: MALLOY_EXTENSION_STATE.getClientId(),
events: [event],
}),
}
);
} catch (error) {
telemetryLog.appendLine(`Logging telemetry event failed: ${error}`);
}
// Telemetry disabled
}

export function trackQueryRun({
Expand Down

0 comments on commit 1b787a6

Please sign in to comment.