开始使用
复制一个包含安装步骤和整个 Markdown 指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-appinsights`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/appinsights/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
安装bun add @capgo/capacitor-appinsightsbunx cap sync导入
导入部分import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';API概述
API概述部分init
init部分初始化 AppInsights SDK
import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';
await CapacitorAppInsights.init({} as { partnerId: string; // Provided by our business unit partnerKey: string; // Provided by our business unit });setUserId
设置用户 ID 部分初始化后设置或更新用户 ID
import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';
await CapacitorAppInsights.setUserId({} as { userId: string });getState
标题:getState获取当前的SDK状态
import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';
await CapacitorAppInsights.getState();类型参考
标题:类型参考PanelSDKState
标题:PanelSDKStateexport interface PanelSDKState { initCompleted: boolean; // SDK initialization status jobScheduled: boolean; // Background job scheduling status permissionAcquired: boolean; // Required permissions status}真实来源
标题:真实来源本页面由插件生成 src/definitions.ts. 当公共API上游更改时,请重新同步