@attryio/capacitor
v0.1.11
Published
Capacitor SDK for Attry mobile app analytics, attribution, deep links, deferred deep links, and revenue events.
Maintainers
Readme
@attryio/capacitor
Capacitor SDK for Attry, a mobile app analytics and attribution platform for campaign analytics, app user analytics, deep links, deferred deep links, and revenue events.
Use this package when your app is built with Capacitor. It connects your iOS and Android app to Attry with one App ID and one live SDK key, then collects lifecycle events, native app context, install attribution signals, and custom product events.
Links
- Website: attry.io
- Dashboard: app.attry.io
- Event tracking docs: attry.io/resources/event-tracking
- Standard events: attry.io/resources/standard-events
- Domain setup: attry.io/resources/domain-setup
Install
npm install @attryio/capacitor
npx cap syncUse the App ID and live SDK key from Settings -> SDK install in your Attry dashboard. Each Attry app has one App ID and one live key; you do not need separate keys for iOS and Android.
Quick start
Create the client once during app startup.
import { createAttryCapacitor } from "@attryio/capacitor";
export const attry = await createAttryCapacitor({
appId: "457064853",
apiKey: "attry_live_..."
});The SDK starts with practical defaults:
- Tracks the first SDK install, app opens, session starts/ends, foreground/background changes, and deep link opens.
- Collects Capacitor app/device context such as platform, app version, build, OS version, model, manufacturer, locale, timezone, and available country context.
- Resolves Android Google Play Install Referrer through the native plugin.
- Requests Apple AdServices attribution tokens on iOS through the native plugin.
- Batches events and retries failed requests through the shared Attry SDK engine.
Track custom events
Use track for app-specific actions. Event names should be stable snake_case; details belong in properties.
await attry.track("quiz_generated", {
properties: {
quizId: "quiz_123",
questionCount: 12,
source: "note"
}
});Attach a signed-in user ID with identify. This is a method, not an event.
attry.identify("user_123");Purchase intent and revenue
Use initiatePurchase when the user starts a checkout, subscription, or paywall purchase flow.
await attry.initiatePurchase({
properties: {
productId: "pro_monthly",
placement: "paywall"
}
});Use purchase when money was actually captured or a paid conversion happened. purchase must include value or amountMinor plus currency.
await attry.purchase({
value: 31.42,
currency: "USD",
productId: "pro_monthly",
transactionId: "txn_123",
store: "play_store",
properties: {
plan: "monthly"
}
});Attry stores revenue as stable minor-unit fields, so campaign revenue is not guessed from arbitrary custom properties.
Standard events
Attry accepts custom event names, but these standard names are reserved for dashboard reporting:
| Event | Sent by | Purpose |
| --- | --- | --- |
| install | SDK | First SDK install for the current app installation. |
| open | SDK | App opened or became active. |
| session_started | SDK | A new app usage session started. |
| session_ended | SDK | A session ended after backgrounding or timeout. |
| app_foreground | SDK | App returned to the foreground. |
| app_background | SDK | App moved to the background. |
| deep_link_opened | SDK | App opened from a deep link, universal link, or app link. |
| initiate_purchase | App | User started a purchase or subscription flow. |
| purchase | App | Paid conversion or purchase revenue. Requires revenue. |
Everything else can be sent as a custom event with track("your_event_name", { properties }).
Configuration
const attry = await createAttryCapacitor({
appId: "457064853",
apiKey: "attry_live_...",
autoTrackLifecycleEvents: true,
autoTrackDeepLinks: true,
autoCollectInstallAttribution: true,
sessionTimeoutMs: 30 * 60 * 1000,
context: {
appName: "Noteasy"
}
});Useful options:
endpoint: custom Attry API endpoint. Defaults tohttps://api.attry.io.autoTrackLifecycleEvents: disable automatic lifecycle events when set tofalse.autoTrackDeepLinks: disable automatic deep link tracking when set tofalse.autoCollectInstallAttribution: disable Apple AdServices and Play Install Referrer collection when set tofalse.context: extra app, device, or release metadata attached to every event.
Need help?
Email [email protected] or open the Attry dashboard.
