Socket
Socket
Sign inDemoInstall

@react-native-windows/telemetry

Package Overview
Dependencies
1
Maintainers
2
Versions
168
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0-canary.11 to 0.0.0-canary.12

lib-commonjs/CodedError.d.ts

17

CHANGELOG.json

@@ -5,3 +5,18 @@ {

{
"date": "Thu, 03 Dec 2020 23:55:37 GMT",
"date": "Tue, 05 Jan 2021 05:06:04 GMT",
"tag": "@react-native-windows/telemetry_v0.0.0-canary.12",
"version": "0.0.0-canary.12",
"comments": {
"prerelease": [
{
"comment": "Rework error reporting/telemetry to only log the minimal amount of data",
"author": "asklar@microsoft.com",
"commit": "226fc2c5f4fc300ad90bfc413d275e0fe0adf87f",
"package": "@react-native-windows/telemetry"
}
]
}
},
{
"date": "Thu, 03 Dec 2020 23:59:32 GMT",
"tag": "@react-native-windows/telemetry_v0.0.0-canary.11",

@@ -8,0 +23,0 @@ "version": "0.0.0-canary.11",

# Change Log - @react-native-windows/telemetry
This log was last generated on Thu, 03 Dec 2020 23:55:37 GMT and should not be manually modified.
This log was last generated on Tue, 05 Jan 2021 05:06:04 GMT and should not be manually modified.
<!-- Start content -->
## 0.0.0-canary.12
Tue, 05 Jan 2021 05:06:04 GMT
### Changes
- Rework error reporting/telemetry to only log the minimal amount of data (asklar@microsoft.com)
## 0.0.0-canary.11
Thu, 03 Dec 2020 23:55:37 GMT
Thu, 03 Dec 2020 23:59:32 GMT

@@ -11,0 +19,0 @@ ### Changes

@@ -7,1 +7,2 @@ /**

export { Telemetry, isMSFTInternal, getDiskFreeSpace } from './telemetry';
export { CodedError, CodedErrorType, CodedErrors } from './CodedError';

@@ -12,2 +12,5 @@ "use strict";

Object.defineProperty(exports, "getDiskFreeSpace", { enumerable: true, get: function () { return telemetry_1.getDiskFreeSpace; } });
var CodedError_1 = require("./CodedError");
Object.defineProperty(exports, "CodedError", { enumerable: true, get: function () { return CodedError_1.CodedError; } });
Object.defineProperty(exports, "CodedErrors", { enumerable: true, get: function () { return CodedError_1.CodedErrors; } });
//# sourceMappingURL=index.js.map

4

lib-commonjs/telemetry.d.ts

@@ -10,5 +10,7 @@ /**

static disable(): void;
static setup(): void;
static setup(preserveMessages?: boolean): void;
static isCI(): boolean;
static trackException(e: Error, properties?: Record<string, any>): void;
static shouldDisable: boolean;
static preserveMessages: boolean;
}

@@ -15,0 +17,0 @@ /**

@@ -13,2 +13,3 @@ "use strict";

const child_process_1 = require("child_process");
const CodedError_1 = require("./CodedError");
class Telemetry {

@@ -21,3 +22,3 @@ static disable() {

}
static setup() {
static setup(preserveMessages) {
if (Telemetry.isCI()) {

@@ -38,2 +39,3 @@ this.disable();

}
Telemetry.preserveMessages = preserveMessages ? true : false;
if (process.env.RNW_CLI_TEST) {

@@ -54,2 +56,20 @@ Telemetry.client.commonProperties.isTest = process.env.RNW_CLI_TEST;

}
static trackException(e, properties) {
var _a;
const props = {};
if (e instanceof CodedError_1.CodedError) {
Object.assign(props, e.data);
}
const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];
for (const f of syscallExceptionFieldsToCopy) {
if (e[f]) {
props[f] = [f];
}
}
Object.assign(props, props, properties);
(_a = Telemetry.client) === null || _a === void 0 ? void 0 : _a.trackException({
exception: e,
properties: props,
});
}
}

@@ -59,2 +79,3 @@ exports.Telemetry = Telemetry;

Telemetry.shouldDisable = false;
Telemetry.preserveMessages = false;
function getAnonymizedPath(filepath) {

@@ -153,3 +174,12 @@ const projectRoot = process.cwd().toLowerCase();

data.properties.errorCode = errorCode;
exception.message = sanitizeMessage(exception.message);
// CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.
// The message may contain PII information. This can be sanitized, but for now delete it.
// Note that the type of data.exceptions[0] is always going to be ExceptionDetails. It is not the original thrown exception.
// https://github.com/microsoft/ApplicationInsights-node.js/issues/707
if (Telemetry.preserveMessages) {
exception.message = sanitizeMessage(exception.message);
}
else {
delete exception.message;
}
}

@@ -156,0 +186,0 @@ }

@@ -11,4 +11,5 @@ "use strict";

const path_1 = require("path");
const CodedError_1 = require("../CodedError");
delete process.env.AGENT_NAME; // allow this test to run in Azure DevOps / GHA
telemetry_1.Telemetry.setup();
telemetry_1.Telemetry.setup(true);
telemetry_1.Telemetry.client.config.disableAppInsights = true;

@@ -221,2 +222,39 @@ test('Sanitize message, no-op', () => {

});
/////////////////////////
// CodedError tests
test('No message', done => {
telemetry_1.Telemetry.preserveMessages = false;
let pass = false;
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
if (envelope.data.baseType === 'ExceptionData') {
const data = envelope.data.baseData;
expect(data.exceptions).toBeDefined();
expect(data.exceptions.length).toEqual(1);
expect(data.exceptions[0].message).toBeUndefined();
expect(data.exceptions[0].typeName).toEqual('MSBuildError');
// This should be 42, but instead it is '42'
// https://github.com/microsoft/ApplicationInsights-node.js/issues/708
expect(data.properties.foo).toBeDefined();
expect(parseInt(data.properties.foo, 10)).toEqual(42);
pass = true;
}
return true;
});
try {
throw new CodedError_1.CodedError('MSBuildError', 'Something secret', {
foo: 42,
});
}
catch (e) {
telemetry_1.Telemetry.client.trackException({
exception: e,
properties: e.data,
});
telemetry_1.Telemetry.client.flush();
}
expect(pass).toEqual(true);
telemetry_1.Telemetry.client.clearTelemetryProcessors();
telemetry_1.Telemetry.client.addTelemetryProcessor(telemetry_1.sanitizeEnvelope);
done();
});
//# sourceMappingURL=sanitize.test.js.map
{
"name": "@react-native-windows/telemetry",
"version": "0.0.0-canary.11",
"version": "0.0.0-canary.12",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "lib-commonjs/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc