Skip to content

Commit

Permalink
fix(honeycomb-opentelemetry-web): Add check for lcpEntry.element (#342)
Browse files Browse the repository at this point in the history
<!--
Thank you for contributing to the project! 💜
Please see our [OSS process
document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#)
to get an idea of how we operate.
-->

## Which problem is this PR solving?
Sometimes `lcpEntry.element` is null or undefined, this check prevents
an `Cannot read properties of undefined (reading 'dataset')` error.

## How to verify that this has the expected result
  • Loading branch information
wolfgangcodes authored Oct 22, 2024
1 parent 103b283 commit 2a7adab
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export class WebVitalsInstrumentation extends InstrumentationAbstract {
});

const el: HTMLElement = lcpEntry?.element as HTMLElement;
if (el.dataset) {
if (el?.dataset) {
for (const attrName in el.dataset) {
const attrValue = el.dataset[attrName];
if (
Expand Down

0 comments on commit 2a7adab

Please sign in to comment.