Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)48k · #3807

applicationinsights-web-ts

Skill này làm gì

Công cụ này giúp theo dõi hiệu năng và mức sử dụng của ứng dụng web theo thời gian thực. Nó thu thập thông tin về cách người dùng tương tác với trang của bạn, chẳng hạn họ mở trang nào, bấm nút nào và có lỗi xảy ra hay không.

Khi nào nên dùng

  • ✓Khi bạn muốn biết người dùng thật đang sử dụng website của bạn như thế nào.
  • ✓Khi bạn muốn tìm và sửa các lỗi xảy ra trên trình duyệt của người dùng.
  • ✓Khi bạn muốn hiểu luồng di chuyển của người dùng và các lượt bấm quan trọng.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/applicationinsights-web-ts/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/applicationinsights-web-ts/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm thế nào để theo dõi hiệu năng website của tôi và các lỗi mà người dùng gặp phải?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Bạn thêm một đoạn mã nhỏ vào website để gửi thông tin về một dịch vụ giám sát. Dịch vụ này sắp xếp dữ liệu để bạn có thể xem.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Application Insights JavaScript SDK (Web) for TypeScript

When to Use

Use this skill when you need instrument browser/web apps with the Application Insights JavaScript SDK (@microsoft/applicationinsights-web). Use for Real User Monitoring (RUM) — page views, clicks, AJAX/fetch dependencies, exceptions, custom events, and browser-side GenAI agent traces correlated to backend...

Real User Monitoring (RUM) for browser apps with @microsoft/applicationinsights-web. Auto-collects page views, AJAX/fetch dependencies, unhandled exceptions, and (with the Click Analytics plugin) clicks. Supports custom events, metrics, and GenAI agent traces that follow OpenTelemetry GenAI semantic conventions and correlate to backend spans via W3C Trace Context.

Distinct from azure-monitor-opentelemetry-ts, which is for Node.js server apps. This skill is for browser/web code (and React Native).

Before Implementation

Search microsoft-docs MCP for current API patterns:

  • Query: "Application Insights JavaScript SDK setup"
  • Query: "Application Insights JavaScript SDK configuration"
  • Query: "Application Insights JavaScript framework extensions React Angular"
  • Verify package version: npm view @microsoft/applicationinsights-web version

Packages

Package Purpose
@microsoft/applicationinsights-web Core RUM SDK (page views, AJAX, exceptions).
@microsoft/applicationinsights-clickanalytics-js Auto-collect click telemetry.
@microsoft/applicationinsights-react-js React plugin (router instrumentation, hooks, HOC, ErrorBoundary).
@microsoft/applicationinsights-react-native React Native plugin (native crashes, sessions).
@microsoft/applicationinsights-angularplugin-js Angular plugin (router events, ErrorHandler).
@microsoft/applicationinsights-debugplugin-js Dev-only telemetry inspector.
@microsoft/applicationinsights-perfmarkmeasure-js User Timing (performance.mark/measure) integration.

Installation

npm i --save @microsoft/applicationinsights-web
# Optional plugins (install only what you use):
npm i --save @microsoft/applicationinsights-clickanalytics-js
npm i --save @microsoft/applicationinsights-react-js @microsoft/applicationinsights-react-native @microsoft/applicationinsights-angularplugin-js

Typings ship with the package — no separate @types/... install needed.

Connection String

The browser SDK requires a connection string at init time. It ships in plaintext to clients — Microsoft Entra ID auth is not supported for browser telemetry. Use a separate App Insights resource with local auth enabled for browser RUM if you need to isolate it from backend telemetry.

# Vite / CRA / Next.js — expose to client via the public env prefix
VITE_APPINSIGHTS_CONNECTION_STRING="InstrumentationKey=...;IngestionEndpoint=https://...;LiveEndpoint=https://..."
NEXT_PUBLIC_APPINSIGHTS_CONNECTION_STRING="InstrumentationKey=..."

Quick Start (npm)

import { ApplicationInsights } from "@microsoft/applicationinsights-web";

export const appInsights = new ApplicationInsights({
  config: {
    connectionString: import.meta.env.VITE_APPINSIGHTS_CONNECTION_STRING,
    enableAutoRouteTracking: true,        // SPA route changes -> page views
    enableCorsCorrelation: true,          // propagate Request-Id / traceparent to cross-origin AJAX
    enableRequestHeaderTracking: true,
    enableResponseHeaderTracking: true,
    distributedTracingMode: 2,            // DistributedTracingModes.AI_AND_W3C — emit traceparent for backend correlation
    autoTrackPageVisitTime: true,
    disableFetchTracking: false,          // fetch() is auto-instrumented by default
    excludeRequestFromAutoTrackingPatterns: [/livemetrics\.azure\.com/i]
  }
});

appInsights.loadAppInsights();
appInsights.trackPageView();

Call loadAppInsights() exactly once, as early as possible (before user interactions you want tracked). Then trackPageView() for the initial load — when enableAutoRouteTracking is on, subsequent route changes are automatic.

Quick Start (SDK Loader Script)

Recommended when you want auto-updating SDK and zero build pipeline. Paste this as the first <script> in <head>:

<script type="text/javascript" src="https://js.monitor.azure.com/scripts/b/ai.3.gbl.min.js" crossorigin="anonymous"></script>
<script type="text/javascript">
  var appInsights = window.appInsights || function (cfg) {

…
Câu hỏi thường gặp

Công cụ này có dùng được cho ứng dụng di động không?

Có, nó dùng được cho ứng dụng xây dựng bằng React Native, tức là ứng dụng chạy được trên cả Android và iOS.

Tôi có cần cài thêm gì để theo dõi lượt bấm không?

Có, để tự động theo dõi lượt bấm, bạn cần cài thêm gói `@microsoft/applicationinsights-clickanalytics-js`.

Tôi nên đặt đoạn mã theo dõi ở đâu?

Tốt nhất là đặt đoạn mã càng sớm càng tốt trong quá trình tải trang, thường là trong `<head>` hoặc ngay đầu tệp script chính.

Chi tiết

Mô tả gốc của tác giả

Instrument browser/web apps with the Application Insights JavaScript SDK (@microsoft/applicationinsights-web).

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#3807
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự