# ads-extension-telemetry

> A module for first party microsoft extensions to report consistent telemetry.

Latest version **1.0.0** (published 2020-06-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ads-extension-telemetry
pnpm add ads-extension-telemetry
yarn add ads-extension-telemetry
bun add ads-extension-telemetry
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-06-10 |
| First published | 2020-06-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Microsoft Corporation |
| Maintainers | chgagnon |

## Links

- npm: https://www.npmjs.com/package/ads-extension-telemetry
- Repository: https://github.com/Charles-Gagnon/ads-extension-telemetry
- Homepage: https://github.com/Charles-Gagnon/ads-extension-telemetry#readme
- Issues: https://github.com/Charles-Gagnon/ads-extension-telemetry/issues
- npm.io page: https://npm.io/package/ads-extension-telemetry

## Dependencies (1)

- [vscode-extension-telemetry](https://npm.io/package/vscode-extension-telemetry.md) 0.1.2

## Recent versions

- 1.0.0 (latest) — 2020-06-10
- 0.1.0 — 2020-06-10

## README

# ads-extension-telemetry
This module provides a consistent way for first-party extensions to report telemetry
over Application Insights. The module respects the user's decision about whether or
not to send telemetry data.

Follow [guide to set up Application Insights](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-nodejs-quick-start) in Azure and get your key.

# install
`npm install ads-extension-telemetry`

# usage
 ```javascript
 const vscode = require('vscode');
 const TelemetryReporter = require('ads-extension-telemetry');

 // all events will be prefixed with this event name
 const extensionId = '<your extension unique name>';

 // extension version will be reported as a property with each event
 const extensionVersion = '<your extension version>';

 // the application insights key (also known as instrumentation key)
 const key = '<your key>';

// telemetry reporter
 let reporter;

 function activate(context: vscode.ExtensionContext) {
    ...
    // create telemetry reporter on extension activation
    reporter = new TelemetryReporter(extensionId, extensionVersion, key);
    // ensure it gets property disposed
    context.subscriptions.push(reporter);
    ...
 }

 function deactivate() {
   // This will ensure all pending events get flushed
    reporter.dispose();
 }

 ...
 // send event any time after activation

 // Immediately send event
 reporter.sendViewEvent('ConnectionDialog');
 reporter.sendActionEvent('ConnectionDialog', 'Click', 'OKButton', 'Mouse', 123);
 reporter.sendMetricsEvent({ 'dialogLoadTimeMs', 578 }, 'ConnectionDialog');
 reporter.sendErrorEvent('ConnectionDialog', 'connectionFailed', '4060', 'SqlException');

// Add on additional properties and then send event
reporter.createViewEvent('ConnectionDialog')
	.withAdditionalProperties( { myProp: 'MyPropValue' })
	.withAdditionalMeasurements( { myMeasure: 123 })
	.withConnectionInfo(connectionProfile)
	.send();
  ```

# common properties
- `common.extname`
- `common.extversion`
- `common.vscodemachineid`
- `common.vscodesessionid`
- `common.vscodeversion`
- `common.os`
- `common.platformversion`

# License
[MIT](LICENSE)

---
_Source: https://npm.io/package/ads-extension-telemetry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
