Skip to content

[Telemetry] Bug fix in codedError.data from trackException()#14191

Merged
danielayala94 merged 4 commits intomicrosoft:mainfrom
danielayala94:trackExceptionDataUndefined
Dec 10, 2024
Merged

[Telemetry] Bug fix in codedError.data from trackException()#14191
danielayala94 merged 4 commits intomicrosoft:mainfrom
danielayala94:trackExceptionDataUndefined

Conversation

@danielayala94
Copy link
Copy Markdown
Contributor

@danielayala94 danielayala94 commented Dec 10, 2024

Description

This PR eliminates the risk of writing into undefined struct fields in trackException().

Type of Change

Bug fix

Why

Error telemetry instances were lost when hitting MS Build errors sometimes, plus avoid unnecesssary CLI error noise.

Resolves #14184

What

One-line change:
codedErrorStruct.data[f] = (error as any)[f];

instead of:
codedErrorStruct.data.codedError.data[f] = (error as any)[f];

Context:
In error telemetry instances, codedError contains relevant information about an exception thrown from the RNW CLI.
There are two ways to populate codedError: either a errorUtils.CodedError object is passed to trackException(), or a MSBuild error was hit, and the Error object contains any of the following fields: errno, syscall or code. It's in the second scenario where things go wrong.

In trackException(), codedErrorStruct copies the exception data from the Error object that was passed as parameter. This corresponds to codedError.data in the telemetry envelope. However, the MSBuild info was attempted to be copied into codedError.data.codedError.data, causing the Telemetry instance to throw.

Screenshots

N/A

Testing

Added a unit test that makes use of a CustomErrorTest object, based on Error but different from CodedError, to re-create the conditions where the bug was caught.

Changelog

Yes - Fix bug in error telemetry collection.

Microsoft Reviewers: Open in CodeFlow

@danielayala94 danielayala94 requested review from a team as code owners December 10, 2024 21:31
@danielayala94 danielayala94 changed the title Track exception data undefined [Telemetry] Bug fix in codedError.data from trackException() Dec 10, 2024
@danielayala94 danielayala94 merged commit bd901aa into microsoft:main Dec 10, 2024
danielayala94 added a commit to danielayala94/react-native-windows that referenced this pull request Jan 4, 2025
…rosoft#14191)

* Bug fix

* Simplify fix, add unit test

* Change files

* Nit: change test description
danielayala94 added a commit that referenced this pull request Jan 7, 2025
…)` (#14238)

* [Telemetry] Bug fix in `codedError.data` from `trackException()` (#14191)

* Bug fix

* Simplify fix, add unit test

* Change files

* Nit: change test description

* Change files
danielayala94 added a commit to danielayala94/react-native-windows that referenced this pull request Jan 28, 2025
…rosoft#14191)

* Bug fix

* Simplify fix, add unit test

* Change files

* Nit: change test description
danielayala94 added a commit that referenced this pull request Jan 29, 2025
* [Telemetry] Migration from AppInsights to 1DS (#13493)

* Draft of telemetry refactoring

* Better draft, including most (if not all?) properties

* Various fixes, it now compiles

* Refactor, and temporary commenting tests

* All tests passing! But will need to clean up a few things

* Polished some code, re-enabled some errorUtils tests

* Change files

* Update yarn.lock

* Let yarn lint:fix cook

* Simplifying

* Nit: ordering

* Avoid unnecessary JSON work

* nit

* Mostly placing some common props into Part A ext, plus adding/removing props

* Distinguish between deviceClass and nodePlatform

* Nit

* [Telemetry] Enable data uploading (#14039)

* Set instrumentation key

* Change files

* Nit: Minor lint fix

* [Telemetry] Expand field sanitization to codedError.data (#14161)

* Scrub PII from codedError, add unit test

* Nit: comment updates

* Lint fixes

* Change files

* Enhanced bug fix using recursion, added test field cases

* Lint fix

* Sanitize any, and test fixes

* Lint fix, again

* [Telemetry] Bug fix in `codedError.data` from `trackException()` (#14191)

* Bug fix

* Simplify fix, add unit test

* Change files

* Nit: change test description

* Manual change to add UseFabric (RnwNewArch not in 0.75)

* [Telemetry] Address package name limitations - Take 2 (#14259)

* Introducing package name processing

* Add trimming if string length > 100

* Change files

* Change files

* Update yarn.lock

* Lint fixes

* Add RnwNewArch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Telemetry] Bug in trackException() where data is undefined

2 participants