swaarm_sdk 0.3.0 copy "swaarm_sdk: ^0.3.0" to clipboard
swaarm_sdk: ^0.3.0 copied to clipboard

Swaarm SDK

Swaarm SDK #

Installation #

To install the Swaarm SDK, add it to your Flutter project by running:

flutter pub add swaarm_sdk
copied to clipboard

Configuration #

To configure the Swaarm SDK, initialize the client in your main.dart file using the SwaarmClient.init(<domain>, <token>) method. This should be done after running your app:

import 'package:flutter/material.dart';
import 'package:swaarm_sdk/swaarm_sdk.dart';

void main() {
  runApp(const MyApp());
  SwaarmClient.init("example.swaarm.com", "<token>");
}
copied to clipboard

Replace "example.swaarm.com" with your Swaarm tracking domain and "<token>" with your specific access token.

Usage #

Automatic Event Tracking #

The Swaarm SDK automatically tracks certain events:

  • App Open Event: Fires every time the app is opened.
  • Install Event: Fires the first time the app is opened after installation.

These events include enriched user data, such as the OS version, vendorId, and, if available, the IDFA (Identifier for Advertisers).

Note: On devices running iOS 14 and later, user consent is required to access the IDFA. This consent must be requested from a visible app interface. For more details, refer to this StackOverflow answer.

Custom Events #

You can manually trigger custom events using the event and purchase methods.

Sending a Custom Event

The event method allows you to track specific user actions. It supports the following parameters:

  • typeId: The type of event you want to track (e.g., "premium_currency").
  • aggregatedValue: A numerical value that Swaarm aggregates in reports (e.g., number of items purchased).
  • customValue: A free-form string value presented as-is in reports (e.g., specific details about the event).
SwaarmClient.event(
  typeId: "premium_currency",
  aggregatedValue: 25.0,
  customValue: "yay"
);
copied to clipboard

Tracking Purchases

The purchase method is used to track purchase-related events. It supports the following parameters:

  • typeId: The type of purchase event (e.g., "subscription").
  • revenue: The amount of revenue generated by the purchase.
  • currency: The currency in which the revenue is reported (e.g., "USD").
  • receiptOrToken: The receipt data, transaction ID, or token used to verify the purchase.
  • androidPurchaseId: The purchase or subscription ID for Android transactions.
SwaarmClient.purchase(
  typeId: "subscription",
  revenue: 11.0,
  currency: "USD",
  receiptOrToken: "base64ReceiptDataOrTransactionIdOrToken",
  androidPurchaseId: "purchaseOrSubscriptionID",
);
copied to clipboard
7
likes
0
points
95
downloads

Publisher

verified publisherswaarm.com

Weekly Downloads

2024.09.29 - 2025.04.13

Swaarm SDK

Homepage

License

unknown (license)

Dependencies

advertising_id, app_set_id, archive, device_info_plus, flutter, http, logger, shared_preferences, uuid

More

Packages that depend on swaarm_sdk