-
Notifications
You must be signed in to change notification settings - Fork 255
[Main][Task] 35656109: [Snippet] Fix Snippet Loader Error #2659
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue with the Application Insights web snippet loader by properly handling sourcemap comments in the generated SDK loader script. The fix extracts sourcemap comments from the original snippet before wrapping it in an IIFE, then re-appends the comment after the function to prevent loader errors.
Key Changes:
- Added utility function to extract and preserve sourcemap comments
- Modified SDK loader script generation to handle sourcemap comments separately
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tools/applicationinsights-web-snippet/src/common/utils.ts | Added _getSourceMap utility function to extract sourcemap comments from code strings |
| tools/applicationinsights-web-snippet/src/applicationinsights-web-snippet.ts | Updated getSdkLoaderScript to extract sourcemap comments before wrapping code and re-append them after |
tools/applicationinsights-web-snippet/src/applicationinsights-web-snippet.ts
Show resolved
Hide resolved
|
|
||
| let configString: string = JSON.stringify(snippetConfig); | ||
| return "!(function (cfg){" + originSnippet + "}})(\n" + configString + "\n);"; | ||
| let result = "!(function (cfg){" + cleanedSnippet + "})(\n" + configString + "\n);"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure we have unit tests for snippet creation so this do not happen in the future
No description provided.