Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ITelemetryTrace parentId cannot be set to undefined #1660

Closed
zmarty opened this issue Sep 5, 2021 · 3 comments
Closed

[BUG] ITelemetryTrace parentId cannot be set to undefined #1660

zmarty opened this issue Sep 5, 2021 · 3 comments
Assignees
Milestone

Comments

@zmarty
Copy link

zmarty commented Sep 5, 2021

App Insights Browser (JS) SDK

I think this is a bug in your TypeScript types and parentId shoud be nullable. I verified in the browser that the first time an operation starts its parent is set to undefined, so why can't I do the same? I specifically want to be able to set parentId to undefined for my purposes, since I track router changes myself.

The ITelemetryTrace interface says parentId should be string:
image

But TelemetryTrace (which implements ITelemetryTrace) allows setting it to undefined:
image

Here's the ugly workaround I used:

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.appInsights.context.telemetryTrace.parentID = parentId!;

(where parentId can be undefined)

@MSNev
Copy link
Collaborator

MSNev commented Sep 7, 2021

I think the compile failure would be because of your eslint config, by default we are only using
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:security/recommended"

Having said that after looking at the code, I can't see any reason why this can't be optional

@MSNev MSNev self-assigned this Sep 7, 2021
@MSNev MSNev added this to the 2.7.0 milestone Sep 7, 2021
@MSNev MSNev added fixed - waiting release PR Committed and waiting deployment released - NPM waiting - CDN deployment and removed fixed - waiting release PR Committed and waiting deployment waiting - CDN deployment labels Sep 8, 2021
@MSNev
Copy link
Collaborator

MSNev commented Sep 13, 2021

v2.7.0 is not fully deployed to NPM and all CDN endpoints

@MSNev MSNev closed this as completed Sep 13, 2021
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants