microsoft / microsoft/ApplicationInsights-JS

Setauthenticatedusercontext shouldn't restrict characters accepted by AppInsights

Open
#1,495 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
685
Forks
261
Avg merge
21h 33m
Merged PRs (30d)
5

Description

`setauthenticatedusercontext` is imposing restrictions to some special characters, on it's parameters, in particular the vertical bar (as per [documentation](https://github.com/microsoft/ApplicationInsights-JS/blob/6435cfdf38bdd2c4287463c65df186314af66d92/API-reference.md#setauthenticatedusercontext), that are accepted by AI.
For example, I'm currently working on a scenario where we're using auth0, auth0 includes a vertical bar in their id (details can be found [here](https://auth0.com/docs/users/identify-users)), this creates a consistency problem between data captured in different systems. In our case we have an API built with .Net Core and frontend with React, while in the API we have been capturing this information without problems, we're now facing having to have to go and change it because of this restriction added on top of the core AI.

[Edited]
Currently the alternative is to set the properties directly to the User.
``` js
appInsights.context.user.authenticatedId = currentUser.id;
appInsights.context.user.accountId = currentUser.orgId;
```

I would like to propose to remove any restriction that is not added by AI itself.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the setauthenticatedusercontext API and inspect how it validates authenticated user and account IDs. Compare that behavior with the linked Application Insights documentation, then review the related tests and add coverage for an ID containing a vertical bar. Done means accepted characters are not restricted beyond the underlying service's requirements and the tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.