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] ICustomProperties does not support setting values #1191

Closed
onionhammer opened this issue Feb 18, 2020 · 4 comments · Fixed by #1237
Closed

[BUG] ICustomProperties does not support setting values #1191

onionhammer opened this issue Feb 18, 2020 · 4 comments · Fixed by #1237
Assignees
Labels
Milestone

Comments

@onionhammer
Copy link

According to the docs we should be able to assign custom values like this:

var telemetryInitializer = (envelope) => {
  envelope.data.someField = 'This item passed through my telemetry initializer';
};

However in the typescript definition, 'envelope.data' is an empty interface, which does not allow any extension.

image

@MSNev
Copy link
Collaborator

MSNev commented Feb 18, 2020

Hi,
It looks from the error, that you don't have an IEnvelope which defines the "data" element as any...

A TelemetryInitializer is passed an object that conforms to the IEnvelope interface...
Can you provide more of the code as the following works for me

var telemetryInitializer = (envelope) => {
envelope.data.someField = 'This item passed through my telemetry initializer';
};
appInsights.addTelemetryInitializer(telemetryInitializer);
appInsights.trackTrace({message: 'This message will use a telemetry initializer'});

Cheers

Nev

@MSNev MSNev self-assigned this Mar 25, 2020
@MSNev
Copy link
Collaborator

MSNev commented Mar 25, 2020

I think I have a possible solution for this, but as the issue is really just with the type safety (and perhaps strict) a workaround you could apply is to create a local variable for data and "cast" (in typescript terms) to any or some other type you want to enforce.

@MSNev MSNev added the p3 label Mar 25, 2020
MSNev added a commit that referenced this issue Apr 1, 2020
Co-authored-by: Nev Wylie <newylie@microsoft.com>
@MSNev MSNev added the fixed - waiting release PR Committed and waiting deployment label Apr 2, 2020
@MSNev MSNev linked a pull request Apr 7, 2020 that will close this issue
@MSNev MSNev added this to the 2.5.4 milestone Apr 7, 2020
@MSNev
Copy link
Collaborator

MSNev commented Apr 8, 2020

Fixed deployed as NPM and next CDN channels

@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 Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants