Skip to content

Conversation

@Karlie-777
Copy link
Contributor

No description provided.

@Karlie-777 Karlie-777 requested a review from a team as a code owner October 21, 2025 23:56
Copilot AI review requested due to automatic review settings October 21, 2025 23:56
Copy link
Contributor

Copilot AI left a 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

@Karlie-777
Copy link
Contributor Author

#2653


let configString: string = JSON.stringify(snippetConfig);
return "!(function (cfg){" + originSnippet + "}})(\n" + configString + "\n);";
let result = "!(function (cfg){" + cleanedSnippet + "})(\n" + configString + "\n);";
Copy link
Member

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

@Karlie-777 Karlie-777 merged commit 97fb763 into main Nov 6, 2025
9 of 15 checks passed
@Karlie-777 Karlie-777 deleted the karlie/fixsnippet branch November 6, 2025 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants