@vscode/extension-telemetry
Advanced tools
Comparing version 0.9.6 to 0.9.7
@@ -6,6 +6,6 @@ /*--------------------------------------------------------- | ||
import { oneDataSystemClientFactory } from "../common/1dsClientFactory"; | ||
import { appInsightsClientFactory } from "../common/appInsightsClientFactory"; | ||
import { BaseTelemetryReporter } from "../common/baseTelemetryReporter"; | ||
import { BaseTelemetrySender } from "../common/baseTelemetrySender"; | ||
import { BaseTelemetryReporter } from "../common/baseTelemetryReporter"; | ||
import { TelemetryUtil } from "../common/util"; | ||
import { appInsightsClientFactory } from "../common/appInsightsClientFactory"; | ||
function getBrowserRelease(navigator) { | ||
@@ -23,6 +23,6 @@ if (navigator.userAgentData) { | ||
export default class TelemetryReporter extends BaseTelemetryReporter { | ||
constructor(key, replacementOptions) { | ||
let clientFactory = (key) => appInsightsClientFactory(key, undefined, replacementOptions); | ||
constructor(connectionString, replacementOptions) { | ||
let clientFactory = (connectionString) => appInsightsClientFactory(connectionString, vscode.env.machineId, undefined, replacementOptions); | ||
// If key is usable by 1DS use the 1DS SDk | ||
if (TelemetryUtil.shouldUseOneDataSystemSDK(key)) { | ||
if (TelemetryUtil.shouldUseOneDataSystemSDK(connectionString)) { | ||
clientFactory = (key) => oneDataSystemClientFactory(key, vscode); | ||
@@ -35,5 +35,5 @@ } | ||
}; | ||
const sender = new BaseTelemetrySender(key, clientFactory); | ||
const sender = new BaseTelemetrySender(connectionString, clientFactory); | ||
// AIF is no longer supported | ||
if (key && (key.indexOf("AIF") === 0)) { | ||
if (connectionString && (connectionString.indexOf("AIF") === 0)) { | ||
throw new Error("AIF keys are no longer supported. Please switch to 1DS keys for 1st party extensions"); | ||
@@ -40,0 +40,0 @@ } |
@@ -7,3 +7,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { TelemetryUtil } from "./util"; | ||
export const appInsightsClientFactory = async (key, xhrOverride, replacementOptions) => { | ||
export const appInsightsClientFactory = async (connectionString, machineId, xhrOverride, replacementOptions) => { | ||
let appInsightsClient; | ||
@@ -22,3 +22,3 @@ try { | ||
appInsightsClient = new basicAISDK.ApplicationInsights({ | ||
instrumentationKey: key, | ||
connectionString: connectionString, | ||
disableAjaxTracking: true, | ||
@@ -49,2 +49,3 @@ disableExceptionTracking: true, | ||
baseType: "EventData", | ||
ext: { user: { id: machineId, authId: machineId } }, | ||
baseData: { name: eventName, properties: data?.properties, measurements: data?.measurements } | ||
@@ -51,0 +52,0 @@ }); |
@@ -20,3 +20,3 @@ /*--------------------------------------------------------- | ||
/** | ||
* Given a key checks if it is a valid 1DS key | ||
* Given a key / connection string checks if it is a valid 1DS key | ||
* @param key The key to check if it's a valid 1DS key | ||
@@ -54,3 +54,3 @@ */ | ||
// Do not change this string as it gets found and replaced upon packaging | ||
"common.telemetryclientversion": "0.9.6" | ||
"common.telemetryclientversion": "0.9.7" | ||
}; | ||
@@ -57,0 +57,0 @@ } |
@@ -33,3 +33,3 @@ "use strict"; | ||
const util_1 = require("./util"); | ||
const appInsightsClientFactory = async (key, xhrOverride, replacementOptions) => { | ||
const appInsightsClientFactory = async (connectionString, machineId, xhrOverride, replacementOptions) => { | ||
let appInsightsClient; | ||
@@ -48,3 +48,3 @@ try { | ||
appInsightsClient = new basicAISDK.ApplicationInsights({ | ||
instrumentationKey: key, | ||
connectionString: connectionString, | ||
disableAjaxTracking: true, | ||
@@ -75,2 +75,3 @@ disableExceptionTracking: true, | ||
baseType: "EventData", | ||
ext: { user: { id: machineId, authId: machineId } }, | ||
baseData: { name: eventName, properties: data?.properties, measurements: data?.measurements } | ||
@@ -77,0 +78,0 @@ }); |
@@ -23,3 +23,3 @@ "use strict"; | ||
/** | ||
* Given a key checks if it is a valid 1DS key | ||
* Given a key / connection string checks if it is a valid 1DS key | ||
* @param key The key to check if it's a valid 1DS key | ||
@@ -57,3 +57,3 @@ */ | ||
// Do not change this string as it gets found and replaced upon packaging | ||
"common.telemetryclientversion": "0.9.6" | ||
"common.telemetryclientversion": "0.9.7" | ||
}; | ||
@@ -60,0 +60,0 @@ } |
@@ -29,10 +29,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const https = __importStar(require("https")); | ||
const os = __importStar(require("os")); | ||
const vscode = __importStar(require("vscode")); | ||
const https = __importStar(require("https")); | ||
const _1dsClientFactory_1 = require("../common/1dsClientFactory"); | ||
const appInsightsClientFactory_1 = require("../common/appInsightsClientFactory"); | ||
const baseTelemetryReporter_1 = require("../common/baseTelemetryReporter"); | ||
const baseTelemetrySender_1 = require("../common/baseTelemetrySender"); | ||
const util_1 = require("../common/util"); | ||
const _1dsClientFactory_1 = require("../common/1dsClientFactory"); | ||
const appInsightsClientFactory_1 = require("../common/appInsightsClientFactory"); | ||
/** | ||
@@ -80,6 +80,6 @@ * Create a replacement for the XHTMLRequest object utilizing nodes HTTP module. | ||
class TelemetryReporter extends baseTelemetryReporter_1.BaseTelemetryReporter { | ||
constructor(key, replacementOptions) { | ||
let clientFactory = (key) => (0, appInsightsClientFactory_1.appInsightsClientFactory)(key, getXHROverride(), replacementOptions); | ||
// If key is usable by 1DS use the 1DS SDk | ||
if (util_1.TelemetryUtil.shouldUseOneDataSystemSDK(key)) { | ||
constructor(connectionString, replacementOptions) { | ||
let clientFactory = (connectionString) => (0, appInsightsClientFactory_1.appInsightsClientFactory)(connectionString, vscode.env.machineId, getXHROverride(), replacementOptions); | ||
// If connection string is usable by 1DS use the 1DS SDk | ||
if (util_1.TelemetryUtil.shouldUseOneDataSystemSDK(connectionString)) { | ||
clientFactory = (key) => (0, _1dsClientFactory_1.oneDataSystemClientFactory)(key, vscode, getXHROverride()); | ||
@@ -92,4 +92,4 @@ } | ||
}; | ||
const sender = new baseTelemetrySender_1.BaseTelemetrySender(key, clientFactory); | ||
if (key && key.indexOf("AIF-") === 0) { | ||
const sender = new baseTelemetrySender_1.BaseTelemetrySender(connectionString, clientFactory); | ||
if (connectionString && connectionString.indexOf("AIF-") === 0) { | ||
throw new Error("AIF keys are no longer supported. Please switch to 1DS keys for 1st party extensions"); | ||
@@ -96,0 +96,0 @@ } |
@@ -31,6 +31,6 @@ /*--------------------------------------------------------- | ||
/** | ||
* @param key The app insights key | ||
* @param connectionString The app insights connection string | ||
* @param replacementOptions A list of replacement options for the app insights client. This allows the sender to filter out any sensitive or unnecessary information from the telemetry server. | ||
*/ | ||
constructor(key: string, replacementOptions?: ReplacementOption[]); | ||
constructor(connectionString: string, replacementOptions?: ReplacementOption[]); | ||
@@ -37,0 +37,0 @@ /** |
{ | ||
"name": "@vscode/extension-telemetry", | ||
"description": "A module for Visual Studio Code extensions to report consistent telemetry.", | ||
"version": "0.9.6", | ||
"version": "0.9.7", | ||
"author": { | ||
@@ -23,5 +23,5 @@ "name": "Microsoft Corporation" | ||
"dependencies": { | ||
"@microsoft/1ds-core-js": "^4.1.2", | ||
"@microsoft/1ds-post-js": "^4.1.2", | ||
"@microsoft/applicationinsights-web-basic": "^3.1.2" | ||
"@microsoft/1ds-core-js": "^4.3.0", | ||
"@microsoft/1ds-post-js": "^4.3.0", | ||
"@microsoft/applicationinsights-web-basic": "^3.3.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -6,3 +6,3 @@ # [@vscode/extension-telemetry](https://www.npmjs.com/package/@vscode/extension-telemetry) | ||
Follow [guide to set up Application Insights](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource) in Azure and get your key. Don't worry about hardcoding it, it is not sensitive. | ||
Follow [guide to set up Application Insights](https://learn.microsoft.com/en-us/azure/azure-monitor/app/create-workspace-resource) in Azure and get your connection string. Don't worry about hardcoding it, it is not sensitive. | ||
@@ -12,2 +12,3 @@ # Install | ||
`npm install @vscode/extension-telemetry` | ||
With yarn: | ||
@@ -23,4 +24,4 @@ `yarn add @vscode/extension-telemetry` | ||
// the application insights key (also known as instrumentation key) | ||
const key = '<your key>'; | ||
// the connection string | ||
const connectionString = '<your connection string>'; | ||
@@ -32,3 +33,3 @@ // telemetry reporter | ||
// create telemetry reporter on extension activation | ||
reporter = new TelemetryReporter(key); | ||
reporter = new TelemetryReporter(connectionString); | ||
// ensure it gets properly disposed. Upon disposal the events will be flushed | ||
@@ -35,0 +36,0 @@ context.subscriptions.push(reporter); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69167
1260
69