开始使用
复制一个安装步骤和完整的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
初始化初始化应用程序见解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
Section titled “setUserId”初始化后设置或更新用户 ID
import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';
await CapacitorAppInsights.setUserId({} as { userId: string });getState
Section titled “getState”获取当前的 SDK 状态
import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';
await CapacitorAppInsights.getState();PanelSDKState
Section titled “PanelSDKState”export interface PanelSDKState { initCompleted: boolean; // SDK initialization status jobScheduled: boolean; // Background job scheduling status permissionAcquired: boolean; // Required permissions status}本页面由插件生成 src/definitions.ts当上游的公共API发生变化时,请重新同步。