+
Skip to content

Add basic telemetry via VS Code telemetry #51

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 6 commits into from
Dec 6, 2021
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 1.1.0 - 6 December 2021

### Added
- Telemetry for activating, running a job, and no jobs, opt out with `"telemetry.enableTelemetry": false`. [#50](https://github.com/getlocalci/local-ci/pull/50/)

## 1.0.2 - 5 December 2021

### Added
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ If there's more than one `.circleci/config.yml` file, click the gear icon to sel

## Privacy

You can opt out of telemetry by adding this to your VS Code `settings.json`:

`"telemetry.enableTelemetry": false`

If you haven't opted out, this will send the following events via [VS Code telemetry](https://code.visualstudio.com/docs/getstarted/telemetry):

* This extension is activated
* There are no jobs found, like if there's no `.circleci/config.yml` file
* A CircleCI® job is run (but it sends no data about the job, not even the name)

If you haven't entered a license key, like during the free preview, this extension has no interaction with Local CI's site.

It does interact with CircleCI® and Docker to process and run the jobs.
Expand Down
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "local-ci",
"displayName": "Local CI",
"description": "Debug CircleCI® workflows locally, with Bash access during and after. Free preview, then paid.",
"version": "1.0.2",
"version": "1.1.0",
"publisher": "LocalCI",
"contributors": [
"Ryan Kienstra"
Expand Down Expand Up @@ -293,6 +293,7 @@
},
"dependencies": {
"axios": "^0.21.4",
"js-md5": "0.7.3"
"js-md5": "0.7.3",
"vscode-extension-telemetry": "^0.4.3"
}
}
3 changes: 3 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const EXTENSION_VERSION = '1.1.0';
export const EXTENSION_ID = 'LocalCI.local-ci';
export const COMMITTED_IMAGE_NAMESPACE = 'local-ci';
export const SELECTED_CONFIG_PATH = 'local-ci.config.path';
export const LICENSE_ERROR = 'localCiLicenseKeyError';
Expand Down Expand Up @@ -55,3 +57,4 @@ export const SCHEDULE_INTERVIEW_URL =
export const SUPPRESS_UNCOMMITTED_FILE_WARNING =
'local-ci.suppress-warning.uncommitted';
export const SURVEY_URL = 'https://www.surveymonkey.com/r/localci';
export const TELEMETRY_KEY = '90189d4e-b560-4a92-aa2c-5a9df190b66a'; // Microsoft.AppInsights Instrumentation Key.
16 changes: 14 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from 'vscode';
import TelemetryReporter from 'vscode-extension-telemetry';
import Delayer from './classes/Delayer';
import Job from './classes/Job';
import JobProvider from './classes/JobProvider';
Expand All @@ -7,12 +8,15 @@ import {
COMMITTED_IMAGE_NAMESPACE,
ENTER_LICENSE_COMMAND,
EXIT_JOB_COMMAND,
EXTENSION_ID,
EXTENSION_VERSION,
GET_LICENSE_COMMAND,
GET_LICENSE_KEY_URL,
HELP_URL,
JOB_TREE_VIEW_ID,
RUN_JOB_COMMAND,
SELECTED_CONFIG_PATH,
TELEMETRY_KEY,
TRIAL_STARTED_TIMESTAMP,
} from './constants';
import cleanUpCommittedImages from './utils/cleanUpCommittedImages';
Expand All @@ -35,9 +39,17 @@ export function activate(context: vscode.ExtensionContext): void {
context.globalState.update(TRIAL_STARTED_TIMESTAMP, new Date().getTime());
}
const jobProvider = new JobProvider(context);
const reporter = new TelemetryReporter(
EXTENSION_ID,
EXTENSION_VERSION,
TELEMETRY_KEY
);
reporter.sendTelemetryEvent('activate');
const reportRunJob = () => reporter.sendTelemetryEvent('runJob');

vscode.window.registerTreeDataProvider(JOB_TREE_VIEW_ID, jobProvider);
context.subscriptions.push(
reporter,
vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.refresh`, () =>
jobProvider.refresh()
),
Expand Down Expand Up @@ -131,7 +143,7 @@ export function activate(context: vscode.ExtensionContext): void {
jobProvider.refresh(job);
}

runJob(context, jobName);
runJob(context, jobName, reportRunJob);
}
),
vscode.commands.registerCommand(EXIT_JOB_COMMAND, (job: Job) => {
Expand All @@ -145,7 +157,7 @@ export function activate(context: vscode.ExtensionContext): void {
jobProvider.refresh(job);
const jobName = job.getJobName();
disposeTerminalsForJob(jobName);
runJob(context, jobName);
runJob(context, jobName, reportRunJob);
}),
vscode.commands.registerCommand(
'local-ci.debug.repo',
Expand Down
10 changes: 10 additions & 0 deletions src/utils/getJobs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as vscode from 'vscode';
import TelemetryReporter from 'vscode-extension-telemetry';
import Job from '../classes/Job';
import Warning from '../classes/Warning';
import Command from '../classes/Command';
import getAllConfigFilePaths from './getAllConfigFilePaths';
import getConfig from './getConfig';
import isWindows from './isWindows';
import { EXTENSION_ID, EXTENSION_VERSION, TELEMETRY_KEY } from '../constants';

export default async function getJobs(
context: vscode.ExtensionContext,
Expand Down Expand Up @@ -38,6 +40,14 @@ export default async function getJobs(
)
: [];

if (!jobs.length) {
new TelemetryReporter(
EXTENSION_ID,
EXTENSION_VERSION,
TELEMETRY_KEY
).sendTelemetryEvent('noJobs');
}

return jobs.length
? jobs.map((jobName) => new Job(jobName, jobName === runningJob))
: [
Expand Down
4 changes: 3 additions & 1 deletion src/utils/runJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import uncommittedWarning from './uncommittedWarning';

export default async function runJob(
context: vscode.ExtensionContext,
jobName: string
jobName: string,
reportRunJob: () => void
): Promise<void> {
const configFilePath = await getConfigFilePath(context);
const repoPath = path.dirname(path.dirname(configFilePath));
Expand All @@ -41,6 +42,7 @@ export default async function runJob(
cwd: repoPath,
});
terminal.show();
reportRunJob();

const processFilePath = getProcessFilePath(configFilePath);
const parsedProcessFile = getConfigFromPath(processFilePath);
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载