Description
Description/Screenshot
SDK LOAD Failure is not being sent successfully with instrumentation key errors as response.
This is all due to a mix of issues in the actual snippet code but also the snippet as presented in the README: see additional context below.
Steps to Reproduce
- Use latest snippet from README
- Configure using connection string as copied from Azure portal:
connectionString: "InstrumentationKey=[KEY];IngestionEndpoint=[ENDPOINT];LiveEndpoint=[LIVEENDPOINT]"
- Enter an invalid URL as script src to simulate loading error
- Load page and inspect track request.
- Notice
iKey
of payload containing the entire connection string and not just the instrumentation key. - Notice the http 400 response with "Invalid instrumentation key" message.
- Notice
Expected behavior
Connection string to be parsed correctly and exception being tracked successfully.
Additional context
-
Using connection string only has not been working for quite some time due to a mistake in the snippet:
- The connection string is being parsed and it's parts is being stored as lower case in the snippet
ApplicationInsights-JS/AISKU/snippet/snippet.js
Lines 37 to 44 in 5d7e042
- But then when the load error code tries to get the instrumentation key from the connection string, it uses a constant that is not lower case which results in no instrumentation key being found.
ApplicationInsights-JS/AISKU/snippet/snippet.js
Lines 75 to 76 in 5d7e042
- The connection string is being parsed and it's parts is being stored as lower case in the snippet
-
The above issue used to possible to be worked around by also providing an instrumenctionKey in the snippet config that then would be used instead, but with the snippet from the current readme this no longer works due:
- Someone updated the readme to remove instrumentation key config, and I suppose accidentally also replaced the constant
D
in the snippet frominstrumentationKey
toconnectionString
. - This leads to the entire connection string being passed as iKey as noted of the repro steps.
- Someone updated the readme to remove instrumentation key config, and I suppose accidentally also replaced the constant
I am willing to post a PR if you are open for that.