Skip to content

Commit

Permalink
Merge pull request #11190 from OfficeDev/huajie/hotfix_telemetry
Browse files Browse the repository at this point in the history
fix: retire error-message
  • Loading branch information
MSFT-yiz authored Mar 27, 2024
2 parents 861612a + 576c1ac commit 338c099
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/cli/tests/unit/telemetry/cliTelemetry.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ describe("Telemetry", function () {
if (eventName === "UserError") {
expect(properties[TelemetryProperty.ErrorType]).equals(TelemetryErrorType.UserError);
expect(properties[TelemetryProperty.ErrorCode]).equals("ut.user");
expect(properties[TelemetryProperty.ErrorMessage]).equals("UserError");
// expect(properties[TelemetryProperty.ErrorMessage]).equals("UserError");
} else {
expect(properties[TelemetryProperty.ErrorType]).equals(TelemetryErrorType.SystemError);
expect(properties[TelemetryProperty.ErrorCode]).equals("ut.system");
expect(properties[TelemetryProperty.ErrorMessage]).equals("SystemError");
// expect(properties[TelemetryProperty.ErrorMessage]).equals("SystemError");
}
});
const reporter = new CliTelemetryReporter("real", "real", "real", "real");
Expand Down
16 changes: 8 additions & 8 deletions packages/fx-core/src/common/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ export function fillInTelemetryPropsForFxError(
props[TelemetryConstants.properties.errorCode] =
props[TelemetryConstants.properties.errorCode] || errorCode;
props[TelemetryConstants.properties.errorType] = errorType;
props[TelemetryConstants.properties.errorMessage] = error.message;
props[TelemetryConstants.properties.errorStack] = error.stack !== undefined ? error.stack : ""; // error stack will not append in error-message any more
// props[TelemetryConstants.properties.errorMessage] = error.message; // error-message is retired
// props[TelemetryConstants.properties.errorStack] = error.stack !== undefined ? error.stack : ""; // error stack will not append in error-message any more
props[TelemetryConstants.properties.errorName] = error.name;

// append global context properties
Expand All @@ -250,12 +250,12 @@ export function fillInTelemetryPropsForFxError(
props[TelemetryConstants.properties.errorInnerCode] = error.innerError["code"];
}

if (error.innerError) {
props[TelemetryConstants.properties.innerError] = JSON.stringify(
error.innerError,
Object.getOwnPropertyNames(error.innerError)
);
}
// if (error.innerError) { // inner-error is retired
// props[TelemetryConstants.properties.innerError] = JSON.stringify(
// error.innerError,
// Object.getOwnPropertyNames(error.innerError)
// );
// }

if (error.categories) {
props[TelemetryConstants.properties.errorCat] = error.categories.join("|");
Expand Down
4 changes: 2 additions & 2 deletions packages/fx-core/src/error/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ScriptTimeoutError extends UserError {
const errorOptions: UserErrorOptions = {
source: "script",
name: "ScriptTimeoutError",
message: getDefaultString(key, cmd),
message: getDefaultString(key, ""), //the script content maybe contains securit data that should not be reported in telemetry
displayMessage: getLocalizedString(key, cmd),
error: error,
categories: [ErrorCategory.External],
Expand All @@ -32,7 +32,7 @@ export class ScriptExecutionError extends UserError {
const errorOptions: UserErrorOptions = {
source: "script",
name: "ScriptExecutionError",
message: getDefaultString(key, script, message),
message: getDefaultString(key, "", message), //the script content maybe contains securit data that should not be reported in telemetry
displayMessage: getLocalizedString(key, script, message),
error: error,
categories: [ErrorCategory.External],
Expand Down
6 changes: 3 additions & 3 deletions packages/fx-core/tests/component/driver/aad/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ describe("aadAppCreate", async () => {
expect(endTelemetry.properties.success).to.equal("no");
expect(endTelemetry.properties["error-code"]).to.equal("aadAppCreate.HttpClientError");
expect(endTelemetry.properties["error-type"]).to.equal("user");
expect(endTelemetry.properties["error-message"]).to.equal(
'A http client error happened while performing the aadApp/create task. The error response is: {"error":{"code":"Request_BadRequest","message":"Invalid value specified for property \'displayName\' of resource \'Application\'."}}'
);
// expect(endTelemetry.properties["error-message"]).to.equal(
// 'A http client error happened while performing the aadApp/create task. The error response is: {"error":{"code":"Request_BadRequest","message":"Invalid value specified for property \'displayName\' of resource \'Application\'."}}'
// );
});

it("should send telemetries with error stack", async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/fx-core/tests/component/driver/aad/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,9 @@ describe("aadAppUpdate", async () => {
expect(endTelemetry.properties.success).to.equal("no");
expect(endTelemetry.properties["error-code"]).to.equal("aadAppUpdate.HttpServerError");
expect(endTelemetry.properties["error-type"]).to.equal("system");
expect(endTelemetry.properties["error-message"]).to.equal(
'A http server error happened while performing the aadApp/update task. Please try again later. The error response is: {"error":{"code":"InternalServerError","message":"Internal server error"}}'
);
// expect(endTelemetry.properties["error-message"]).to.equal(
// 'A http server error happened while performing the aadApp/update task. Please try again later. The error response is: {"error":{"code":"InternalServerError","message":"Internal server error"}}'
// );
});

it("should throw error when missing required environment variable in manifest", async () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/fx-core/tests/component/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ describe("TeamsFxTelemetryReporter", () => {
success: "no",
"error-code": "source.name",
"error-type": "user",
"error-message": "message",
});
reporterCalled = true;
});
Expand All @@ -299,7 +298,6 @@ describe("TeamsFxTelemetryReporter", () => {
success: "no",
"error-code": "my error code",
"error-type": "user",
"error-message": "message",
"my-property": "value",
});
reporterCalled = true;
Expand All @@ -322,7 +320,6 @@ describe("TeamsFxTelemetryReporter", () => {
.stub(mockedTelemetryReporter, "sendTelemetryErrorEvent")
.callsFake((eventName, properties, measurements, errorProps) => {
expect(errorProps).include("test");
expect(errorProps).include("error-message");
reporterCalled = true;
});

Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-extension/test/extension/extTelemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ describe("ExtTelemetry", () => {
"settings-version": "1.0.0",
"error-type": "user",
"error-name": "UserTestError",
"error-message": error.message,
"error-stack": error.stack,
// "error-message": error.message,
// "error-stack": error.stack,
"error-code": "test.UserTestError",
"error-component": "",
"error-method": "",
Expand Down

0 comments on commit 338c099

Please sign in to comment.