Enhance app insights integration in Boilerplate (#9945)#9950
Enhance app insights integration in Boilerplate (#9945)#9950msynk merged 1 commit intobitfoundation:developfrom yasmoradi:9945
Conversation
WalkthroughThe changes update the initialization of the Application Insights telemetry component across various project files. In code files, a dictionary parameter with Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application Startup
participant Client as Client Initialization
participant AI as ApplicationInsightsInit Component
participant Cond as Conditional Renderer
App->>Client: Begin startup
Client->>AI: Add ApplicationInsightsInit with {IsWasmStandalone: true}
AI-->>Client: Component initialized
Cond->>AI: If renderMode != null, initialize component with renderMode
sequenceDiagram
participant Browser as Browser
participant HTML as Index.html Script
participant SDK as Application Insights SDK Server
Browser->>HTML: Load HTML page
HTML->>SDK: Request to load telemetry SDK
SDK-->>HTML: Return SDK (or error if loading fails)
HTML-->>Browser: Telemetry initialization complete
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/Program.cs (1)
38-38: Add clarifying comment for IsWasmStandalone parameter.While the implementation is correct and consistent with other platforms, consider adding a comment explaining why
IsWasmStandaloneis set to true, similar to the comment in the Maui implementation.+ // The App Insights JS SDK is already included in index.html. Use `IsWasmStandalone` to prevent reloading scripts. builder.RootComponents.Add(componentType: typeof(BlazorApplicationInsights.ApplicationInsightsInit), selector: "head::after", parameters: ParameterView.FromDictionary(new Dictionary<string, object?> { { nameof(BlazorApplicationInsights.ApplicationInsightsInit.IsWasmStandalone), true } }));src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Program.cs (1)
101-101: Add clarifying comment for IsWasmStandalone parameter.While the implementation is correct and consistent with other platforms, consider adding a comment explaining why
IsWasmStandaloneis set to true, similar to the comments in other implementations.+ // The App Insights JS SDK is already included in index.html. Use `IsWasmStandalone` to prevent reloading scripts. blazorWebView.RootComponents.Add(new RootComponent("head::after", typeof(BlazorApplicationInsights.ApplicationInsightsInit), new Dictionary<string, object?> { { nameof(BlazorApplicationInsights.ApplicationInsightsInit.IsWasmStandalone), true } }));src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/wwwroot/index.html (1)
15-26: Verify the Application Insights initialization snippet configuration.
The inline script block properly initializes the Application Insights telemetry with a placeholder instrumentation key and telemetry disabled (as indicated by the comment). Please confirm that Blazor correctly updates these values at runtime and that the error handling (fallback/retry logic) behaves as intended. As a good-to-have improvement, consider externalizing this inline script to a dedicated JavaScript file if the same snippet is reused across multiple clients to enhance maintainability.src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/index.html (1)
22-33: Confirm consistency and maintainability of the telemetry script block.
The inserted Application Insights snippet mirrors the configuration used in the Maui client—with the instrumentation key preset to a placeholder value and telemetry disabled—ensuring a consistent telemetry initialization across clients. Please verify that when the application starts, these parameters are appropriately updated by Blazor. Also, consider refactoring by externalizing the script if it will be reused elsewhere, which would adhere to DRY principles and ease future maintenance.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MainPage.xaml.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/wwwroot/index.html(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/Program.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/index.html(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Windows/Program.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Components/App.razor(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build and test
🔇 Additional comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Maui/MainPage.xaml.cs (1)
14-15:Details
❓ Verification inconclusive
LGTM! Well-documented parameter addition.
The comment clearly explains the purpose of setting
IsWasmStandalone=trueto prevent script reloading, and the implementation is correct.Verify that the App Insights JS SDK is indeed included in index.html:
🏁 Script executed:
#!/bin/bash rg -l "cdn\.monitor\.azure\.com.*applicationinsights" wwwroot/index.htmlLength of output: 133
LGTM! The parameter addition is well-documented and correctly prevents duplicate script loading.
However, the automated check for the App Insights JS SDK in
wwwroot/index.htmldid not locate the file. Please verify manually (or update the search path) that the SDK is indeed included in the appropriate HTML file—either by locatingindex.htmlat its actual repository location or confirming its inclusion through other means.src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Components/App.razor (1)
45-52: Excellent optimization of App Insights initialization!The implementation cleverly optimizes App Insights by:
- Starting telemetry ASAP with an initial static render
- Properly initializing the service with renderMode when available
- Preventing duplicate script loading with IsWasmStandalone
closes #9945
Summary by CodeRabbit
New Features
Refactor