-
Notifications
You must be signed in to change notification settings - Fork 243
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
Multiple Application Insights with different connection strings using JavaScript(Web) SDK v3 giving warnings #2355
Comments
The SDK loaded does not support loading / initializing (directly) multiple SDK instances as (by default) it will always set (and sometimes (race condition) replace the global So I suspect that the (not often used) config that will help with what you are trying to achieve is the ApplicationInsights-JS/tools/applicationinsights-web-snippet/src/snippet-config.js Line 3 in 1f3dee1
window.appInsights (by default) where the SDK instance is registered.It's also has some additional documentation in the table in this section https://github.com/microsoft/ApplicationInsights-JS?tab=readme-ov-file#reporting-script-load-exceptions This will require 3 separate SDK Loader instances with the 3 separate SDK Loader configs, you can't do it with a single SDK Loader config. The other option is via npm where you can load the SDK code once (in your own bundle) and then initialize multiple instances. |
I am already using the |
Hmm, that is a little odd, its sounding like the multiple versions are "sharing" the same config object and therefore as each one is initialized it keeps "adding" to the existing values. By default, when the SDK initializes (for version 3+) it uses the "provided" config as a template and effective clones the objects / arrays (to avoid this exact issue) as internally it "adds" objects that are being listed as duplicates... The only time it doesn't do this is if the config has already been converted into a dynamic config (it's already undergone the initialization process)... This is the code that uses the If you have some time if you could do some initial debugging that would be helpful, the issue sounds like it would revolve around the handling / initializing of the SDK. One simple approach (assuming the issue is not in the SDK loader itself) is that if you change the "src" to |
Any update on this issue? |
Hi @rubiks-cube, apologies for the delay - I've just returned from vacation and am taking a look at the issue now. Thank you for your patience! |
Hello @rubiks-cube, thank you for bringing this issue to our attention. We were able to reproduce the problem and have identified that it is caused by a race condition. To address this, we will be releasing a new version of the snippet and SDK. Please note that this solution will not support IE and Opera Mini. However, you won't need to make any changes on your end. Thank you for your patience as we work to resolve this issue. |
@siyuniu-ms thanks for the update. |
@siyuniu-ms I see v3.2.2 is released and through npm it is installing this latest version but script loader is still loading 3.2.1 |
Hi, our cdn release (where our snippet live) will take around 5 days after our npm is released to make sure we didn't break anything. |
any update on script loader v3.2.2? still it is fetching old version file. |
@rubiks-cube It would be released early next week. Thanks for waiting. |
@rubiks-cube Both snippet package and AI 3.2.2 CDN is published which contains the newest changes. |
@siyuniu-ms I am still facing the above same issue of warnings with updated version and also |
Hi, could you provide more error details? I just did a local test with two snippet inited at the same time wtih two different ikey and both track message is delivered successfully. |
and below is my test code for reference
|
For some context, you will need both the new version "8" (see "sv": "8") of the SDK Loader AND version 3.2.2 of the SDK, if either version does not match (or greater) then the identifed race condition causing SDK A to use Loader B and Vica-versa configuration may still occur. |
The script loader mentioned in docs is different : Script Loader. Using the above snippet doesn't have this issue. |
Yeah, not all of the documentation has been updated yet, it is included on the main readme https://github.com/microsoft/ApplicationInsights-JS/blob/main/tools/grunt-tasks/minifyNames.js and it is included in v1.2.0 of the web-snippet package https://www.npmjs.com/package/@microsoft/applicationinsights-web-snippet (which we published on friday) |
Closing as released |
I am trying to have multiple Application Insights(vesrion 3) with different connection strings using JavaScript(Web) SDK Loader Script on the same HTML page. I have also given different name in the configuration. But I am getting in this warning in console:
Two extensions have same priority
How can I fix this? or is there any different way to have multiple instances using loader script? In the docs, it is mentioned that we can use "name" if you need to initialize two different SDKs at the same time.
The text was updated successfully, but these errors were encountered: