Skip to content

docs: fix Offline Channel setup example - #2767

Merged
Hector Hernandez (hectorhdzg) merged 1 commit into
microsoft:mainfrom
hectorhdzg:hectorhdzg-fix-offline-channel-docs
Sep 8, 2026
Merged

docs: fix Offline Channel setup example#2767
Hector Hernandez (hectorhdzg) merged 1 commit into
microsoft:mainfrom
hectorhdzg:hectorhdzg-fix-offline-channel-docs

Conversation

@hectorhdzg

Copy link
Copy Markdown
Member

Register the channel during SDK initialization, wait for its deferred configuration, and use trackEvent with a compatible persistence level.

Updates the Offline Channel NPM setup example so it works as documented:

  • Registers OfflineChannel through config.extensions before loadAppInsights().

  • Waits until the next event-loop turn before tracking events, allowing the channel’s deferred configuration to complete.

  • Changes minPersistenceLevel to 1, matching the default Normal persistence level used by the example events.

  • Replaces the nonexistent track() calls with trackEvent().

  • Adds the missing ApplicationInsights import.

Fixes #2672
Fixes #2673

Register the channel during SDK initialization, wait for its deferred configuration, and use trackEvent with a compatible persistence level.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 8, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is isolated to documentation and the updated example aligns with the OfflineChannel’s deferred initialization and current SDK APIs.

Pull request overview

Updates the Offline Channel NPM setup documentation so the example code matches the SDK APIs and the channel’s deferred initialization behavior, preventing the “first events are dropped” footgun described in issues #2672 and #2673.

Changes:

  • Registers OfflineChannel during SDK initialization via config.extensions (instead of adding it after loadAppInsights()).
  • Delays event tracking by one macrotask (setTimeout(..., 0)) to allow the channel’s deferred configuration to complete.
  • Fixes the example API usage and configuration by using trackEvent() and setting minPersistenceLevel to 1.
File summaries
File Description
channels/offline-channel-js/README.md Fixes the NPM setup example to initialize the Offline Channel correctly and use compatible tracking/configuration.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@hectorhdzg
Hector Hernandez (hectorhdzg) merged commit ae9a83f into microsoft:main Sep 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants