@vscode/extension-telemetry
Advanced tools
Comparing version 0.8.5 to 0.9.0
@@ -9,45 +9,3 @@ /*--------------------------------------------------------- | ||
import { TelemetryUtil } from "../common/util"; | ||
const webAppInsightsClientFactory = async (key, replacementOptions) => { | ||
let appInsightsClient; | ||
try { | ||
const web = await import /* webpackMode: "eager" */("@microsoft/applicationinsights-web-basic"); | ||
appInsightsClient = new web.ApplicationInsights({ | ||
instrumentationKey: key, | ||
disableAjaxTracking: true, | ||
disableExceptionTracking: true, | ||
disableFetchTracking: true, | ||
disableCorrelationHeaders: true, | ||
disableCookiesUsage: true, | ||
autoTrackPageVisitTime: false, | ||
emitLineDelimitedJson: false, | ||
disableInstrumentationKeyValidation: true | ||
}); | ||
} | ||
catch (e) { | ||
return Promise.reject(e); | ||
} | ||
// Sets the appinsights client into a standardized form | ||
const telemetryClient = { | ||
logEvent: (eventName, data) => { | ||
const properties = { ...data?.properties, ...data?.measurements }; | ||
if (replacementOptions?.length) { | ||
TelemetryUtil.applyReplacements(properties, replacementOptions); | ||
} | ||
appInsightsClient?.track({ name: eventName, data: properties }); | ||
}, | ||
flush: async () => { | ||
appInsightsClient?.flush(false); | ||
}, | ||
dispose: async () => { | ||
const unloadPromise = new Promise((resolve) => { | ||
appInsightsClient?.unload(true, () => { | ||
resolve(); | ||
appInsightsClient = undefined; | ||
}, 1000); | ||
}); | ||
return unloadPromise; | ||
} | ||
}; | ||
return telemetryClient; | ||
}; | ||
import { appInsightsClientFactory } from "../common/appInsightsClientFactory"; | ||
function getBrowserRelease(navigator) { | ||
@@ -64,3 +22,3 @@ if (navigator.userAgentData) { | ||
constructor(key, replacementOptions) { | ||
let clientFactory = (key) => webAppInsightsClientFactory(key, replacementOptions); | ||
let clientFactory = (key) => appInsightsClientFactory(key, undefined, replacementOptions); | ||
// If key is usable by 1DS use the 1DS SDk | ||
@@ -67,0 +25,0 @@ if (TelemetryUtil.shouldUseOneDataSystemSDK(key)) { |
@@ -83,3 +83,3 @@ /*--------------------------------------------------------- | ||
// Trusted values are not sanitized, which is what we want for raw telemetry | ||
modifiedProperties[propertyKey] = new this.vscodeAPI.TelemetryTrustedValue(typeof propertyValue === 'string' ? propertyValue : propertyValue.value); | ||
modifiedProperties[propertyKey] = new this.vscodeAPI.TelemetryTrustedValue(typeof propertyValue === "string" ? propertyValue : propertyValue.value); | ||
} | ||
@@ -86,0 +86,0 @@ } |
@@ -53,3 +53,3 @@ /*--------------------------------------------------------- | ||
// Do not change this string as it gets found and replaced upon packaging | ||
"common.telemetryclientversion": "0.8.5" | ||
"common.telemetryclientversion": "0.9.0" | ||
}; | ||
@@ -56,0 +56,0 @@ } |
@@ -86,3 +86,3 @@ "use strict"; | ||
// Trusted values are not sanitized, which is what we want for raw telemetry | ||
modifiedProperties[propertyKey] = new this.vscodeAPI.TelemetryTrustedValue(typeof propertyValue === 'string' ? propertyValue : propertyValue.value); | ||
modifiedProperties[propertyKey] = new this.vscodeAPI.TelemetryTrustedValue(typeof propertyValue === "string" ? propertyValue : propertyValue.value); | ||
} | ||
@@ -89,0 +89,0 @@ } |
@@ -56,3 +56,3 @@ "use strict"; | ||
// Do not change this string as it gets found and replaced upon packaging | ||
"common.telemetryclientversion": "0.8.5" | ||
"common.telemetryclientversion": "0.9.0" | ||
}; | ||
@@ -59,0 +59,0 @@ } |
@@ -36,103 +36,4 @@ "use strict"; | ||
const _1dsClientFactory_1 = require("../common/1dsClientFactory"); | ||
const appInsightsClientFactory_1 = require("../common/appInsightsClientFactory"); | ||
/** | ||
* A factory function which creates a telemetry client to be used by an sender to send telemetry in a node application. | ||
* | ||
* @param key The app insights key | ||
* @param replacementOptions Optional list of {@link ReplacementOption replacements} to apply to the telemetry client. This allows | ||
* the sender to filter out any sensitive or unnecessary information from the telemetry server. | ||
* | ||
* @returns A promise which resolves to the telemetry client or rejects upon error | ||
*/ | ||
const appInsightsClientFactory = async (key, replacementOptions) => { | ||
let appInsightsClient; | ||
try { | ||
process.env["APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL"] = "1"; | ||
const appInsights = await Promise.resolve().then(() => __importStar(require(/* webpackMode: "eager" */ "applicationinsights"))); | ||
//check if another instance is already initialized | ||
if (appInsights.defaultClient) { | ||
appInsightsClient = new appInsights.TelemetryClient(key); | ||
// no other way to enable offline mode | ||
appInsightsClient.channel.setUseDiskRetryCaching(true); | ||
} | ||
else { | ||
appInsights.setup(key) | ||
.setAutoCollectRequests(false) | ||
.setAutoCollectPerformance(false) | ||
.setAutoCollectExceptions(false) | ||
.setAutoCollectDependencies(false) | ||
.setAutoDependencyCorrelation(false) | ||
.setAutoCollectConsole(false) | ||
.setAutoCollectHeartbeat(false) | ||
.setAutoCollectIncomingRequestAzureFunctions(false) | ||
.setUseDiskRetryCaching(true) | ||
.start(); | ||
appInsightsClient = appInsights.defaultClient; | ||
} | ||
if (vscode && vscode.env) { | ||
appInsightsClient.context.tags[appInsightsClient.context.keys.userId] = vscode.env.machineId; | ||
appInsightsClient.context.tags[appInsightsClient.context.keys.sessionId] = vscode.env.sessionId; | ||
appInsightsClient.context.tags[appInsightsClient.context.keys.cloudRole] = vscode.env.appName; | ||
appInsightsClient.context.tags[appInsightsClient.context.keys.cloudRoleInstance] = vscode.env.appName; | ||
} | ||
} | ||
catch (e) { | ||
return Promise.reject("Failed to initialize app insights!\n" + e.message); | ||
} | ||
if (replacementOptions?.length) { | ||
addReplacementOptions(appInsightsClient, replacementOptions); | ||
} | ||
// Sets the appinsights client into a standardized form | ||
const telemetryClient = { | ||
logEvent: (eventName, data) => { | ||
try { | ||
appInsightsClient?.trackEvent({ | ||
name: eventName, | ||
properties: data?.properties, | ||
measurements: data?.measurements | ||
}); | ||
} | ||
catch (e) { | ||
throw new Error("Failed to log event to app insights!\n" + e.message); | ||
} | ||
}, | ||
flush: async () => { | ||
try { | ||
appInsightsClient?.flush(); | ||
} | ||
catch (e) { | ||
throw new Error("Failed to flush app insights!\n" + e.message); | ||
} | ||
}, | ||
dispose: async () => { | ||
appInsightsClient?.flush({ isAppCrashing: true }); | ||
appInsightsClient = undefined; | ||
} | ||
}; | ||
return telemetryClient; | ||
}; | ||
/** | ||
* Adds replacement options to this {@link TelemetryClient}. | ||
* | ||
* If any replacement options are specified, this function will search through any event about to be | ||
* sent to the telemetry server and replace any matches with the specified replacement string. Both | ||
* the envelope and the base data will be searched. | ||
* | ||
* @param appInsightsClient The {@link TelemetryClient} to add the filters to. | ||
* @param replacementOptions The replacement options to add. | ||
*/ | ||
function addReplacementOptions(appInsightsClient, replacementOptions) { | ||
appInsightsClient.addTelemetryProcessor((event) => { | ||
if (Array.isArray(event.tags)) { | ||
event.tags.forEach(tag => util_1.TelemetryUtil.applyReplacements(tag, replacementOptions)); | ||
} | ||
else if (event.tags) { | ||
util_1.TelemetryUtil.applyReplacements(event.tags, replacementOptions); | ||
} | ||
if (event.data.baseData) { | ||
util_1.TelemetryUtil.applyReplacements(event.data.baseData, replacementOptions); | ||
} | ||
return true; | ||
}); | ||
} | ||
/** | ||
* Create a replacement for the XHTMLRequest object utilizing nodes HTTP module. | ||
@@ -180,3 +81,3 @@ * @returns A XHR override object used to override the XHTMLRequest object in the 1DS SDK | ||
constructor(key, replacementOptions) { | ||
let clientFactory = (key) => appInsightsClientFactory(key, replacementOptions); | ||
let clientFactory = (key) => (0, appInsightsClientFactory_1.appInsightsClientFactory)(key, getXHROverride(), replacementOptions); | ||
// If key is usable by 1DS use the 1DS SDk | ||
@@ -183,0 +84,0 @@ if (util_1.TelemetryUtil.shouldUseOneDataSystemSDK(key)) { |
{ | ||
"name": "@vscode/extension-telemetry", | ||
"description": "A module for Visual Studio Code extensions to report consistent telemetry.", | ||
"version": "0.8.5", | ||
"version": "0.9.0", | ||
"author": { | ||
@@ -23,19 +23,18 @@ "name": "Microsoft Corporation" | ||
"dependencies": { | ||
"@microsoft/1ds-core-js": "^3.2.13", | ||
"@microsoft/1ds-post-js": "^3.2.13", | ||
"@microsoft/applicationinsights-web-basic": "^3.0.2", | ||
"applicationinsights": "^2.7.1" | ||
"@microsoft/1ds-core-js": "^4.0.3", | ||
"@microsoft/1ds-post-js": "^4.0.3", | ||
"@microsoft/applicationinsights-web-basic": "^3.0.4" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.4.9", | ||
"@types/sinon": "^10.0.16", | ||
"@types/mocha": "^10.0.3", | ||
"@types/node": "^20.8.9", | ||
"@types/sinon": "^10.0.20", | ||
"@types/vscode": "^1.75.0", | ||
"@typescript-eslint/eslint-plugin": "^6.3.0", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"eslint": "^8.46.0", | ||
"@typescript-eslint/eslint-plugin": "^6.9.1", | ||
"@typescript-eslint/parser": "^6.9.1", | ||
"eslint": "^8.52.0", | ||
"mocha": "^10.2.0", | ||
"sinon": "^15.2.0", | ||
"typescript": "^5.1.6", | ||
"user-agent-data-types": "^0.3.1" | ||
"sinon": "^17.0.0", | ||
"typescript": "^5.2.2", | ||
"user-agent-data-types": "^0.4.2" | ||
}, | ||
@@ -42,0 +41,0 @@ "repository": { |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
67971
3
17
1248
0
+ Added@microsoft/1ds-core-js@4.3.3(transitive)
+ Added@microsoft/1ds-post-js@4.3.3(transitive)
- Removedapplicationinsights@^2.7.1
- Removed@azure/abort-controller@2.1.2(transitive)
- Removed@azure/core-auth@1.7.2(transitive)
- Removed@azure/core-rest-pipeline@1.16.3(transitive)
- Removed@azure/core-tracing@1.2.0(transitive)
- Removed@azure/core-util@1.11.0(transitive)
- Removed@azure/logger@1.1.4(transitive)
- Removed@azure/opentelemetry-instrumentation-azure-sdk@1.0.0-beta.7(transitive)
- Removed@microsoft/1ds-core-js@3.2.18(transitive)
- Removed@microsoft/1ds-post-js@3.2.18(transitive)
- Removed@microsoft/applicationinsights-core-js@2.8.18(transitive)
- Removed@microsoft/applicationinsights-shims@2.0.2(transitive)
- Removed@microsoft/applicationinsights-web-snippet@1.0.1(transitive)
- Removed@microsoft/dynamicproto-js@1.1.11(transitive)
- Removed@opentelemetry/api@1.9.0(transitive)
- Removed@opentelemetry/api-logs@0.53.0(transitive)
- Removed@opentelemetry/core@1.26.0(transitive)
- Removed@opentelemetry/instrumentation@0.53.0(transitive)
- Removed@opentelemetry/resources@1.26.0(transitive)
- Removed@opentelemetry/sdk-trace-base@1.26.0(transitive)
- Removed@opentelemetry/semantic-conventions@1.27.0(transitive)
- Removed@types/shimmer@1.2.0(transitive)
- Removedacorn@8.13.0(transitive)
- Removedacorn-import-attributes@1.9.5(transitive)
- Removedagent-base@7.1.1(transitive)
- Removedapplicationinsights@2.9.6(transitive)
- Removedasync-hook-jl@1.7.6(transitive)
- Removedasync-listener@0.6.10(transitive)
- Removedcjs-module-lexer@1.4.1(transitive)
- Removedcls-hooked@4.2.2(transitive)
- Removedcontinuation-local-storage@3.2.1(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddiagnostic-channel@1.1.1(transitive)
- Removeddiagnostic-channel-publishers@1.0.8(transitive)
- Removedemitter-listener@1.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-proxy-agent@7.0.2(transitive)
- Removedhttps-proxy-agent@7.0.5(transitive)
- Removedimport-in-the-middle@1.11.2(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedmodule-details-from-path@1.0.3(transitive)
- Removedms@2.1.3(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedrequire-in-the-middle@7.4.0(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsemver@5.7.27.6.3(transitive)
- Removedshimmer@1.2.1(transitive)
- Removedstack-chain@1.3.7(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)