Skip to main content
@capgo/capacitor-appinsights Analytics Open source

AppInsights Capacitor plugin

Track app usage, performance metrics, and user behavior with Apptopia AppInsights

Install

bun add @capgo/capacitor-appinsights bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-appinsights
  • pnpm add @capgo/capacitor-appinsights
  • yarn add @capgo/capacitor-appinsights

Guide

How to use AppInsights in Capacitor

Using @capgo/capacitor-appinsights

A wrapper around the https://github.com/apptopia/appinsights SDK.

Install

bun add @capgo/capacitor-appinsights
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';

API at a glance

Method Description
init Initialize the AppInsights SDK.
setUserId Set or update the user ID after initialization.
getState Get the current state of the SDK.

Examples

init()

Initialize the AppInsights SDK.

import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';

await CapacitorAppInsights.init({
  partnerId: 'partner-id-123',
  partnerKey: 'partner-key-123',
});

setUserId()

Set or update the user ID after initialization.

import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';

await CapacitorAppInsights.setUserId({ userId: 'user-id-123' });

getState()

Get the current state of the SDK.

import { CapacitorAppInsights } from '@capgo/capacitor-appinsights';

const result = await CapacitorAppInsights.getState();
console.log(result);

Full reference

Keep going from Using @capgo/capacitor-appinsights

If you are using Using @capgo/capacitor-appinsights to plan native plugin work, connect it with @capgo/capacitor-appinsights for the implementation detail in @capgo/capacitor-appinsights, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.

FAQ

AppInsights plugin FAQ

How do I install the AppInsights plugin in a Capacitor app?

Run "bun add @capgo/capacitor-appinsights" (or "npm install @capgo/capacitor-appinsights"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-appinsights" in your app code.

Does @capgo/capacitor-appinsights work with React, Vue and Angular?

Yes. AppInsights is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-appinsights support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-appinsights free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-appinsights/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses AppInsights without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship AppInsights changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo