@sliverfish17/sx-app-insights-front-end
v0.1.0
Published
Reusable Application Insights client with correlation and user flow support
Readme
@solvexus/sx-app-insights-front-end
Reusable Application Insights client for web apps using Microsoft Application Insights.
Features:
- Correlated telemetry (ai.operation.id, parentId, traceID)
- User/session/device tags from cookies
- Exception filtering for noisy websocket disconnects
- Dependency enrichment with appVersions and user details
- React plugin support and SPA route tracking
Install
Peer dependencies:
- @microsoft/applicationinsights-web
- @microsoft/applicationinsights-react-js
Usage
import { createAppInsightsClient } from "@sliverfish17/sx-app-insights-front-end";
const { appInsights, reactPlugin, trackException } = createAppInsightsClient({
connectionString: "<APPINSIGHTS_CONNECTION_STRING>",
getCookies: () => ({ userId: "u1", deviceId: "d1", sessionId: "s1" }),
getOperationId: () => ({ id: "op1", traceID: "trace1" }),
});
export { appInsights, reactPlugin };API
createAppInsightsClient(options)
- connectionString: string
- getCookies: () => { userId?, deviceId?, sessionId? }
- getOperationId: () => { id: string; traceID: string }
- disableNetworkAutoTracking?: boolean (default true)
- enableAutoRouteTracking?: boolean (default true)
Returns: { appInsights, reactPlugin, trackException }
