Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/docs/flutter/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ If you have feedback on any of our docs, please leave a rating and message at th

If you have any issues with the SDK, please [open an issue on GitHub](https://github.com/superwall/superwall-flutter/issues).

<SdkLatestVersion version="2.3.0" repoUrl="https://github.com/superwall/Superwall-Flutter" />
<SdkLatestVersion version="2.4.5" repoUrl="https://github.com/superwall/Superwall-Flutter" />
11 changes: 11 additions & 0 deletions content/docs/flutter/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,26 @@
"sdk-reference/configure",
"sdk-reference/Superwall",
"sdk-reference/register",
"sdk-reference/getPresentationResult",
"sdk-reference/identify",
"sdk-reference/setUserAttributes",
"sdk-reference/getUserId",
"sdk-reference/subscriptionStatus",
"sdk-reference/getCustomerInfo",
"sdk-reference/getEntitlements",
"sdk-reference/consume",
"sdk-reference/overrideProductsByName",
"sdk-reference/setIntegrationAttribute",
"sdk-reference/setIntegrationAttributes",
"sdk-reference/SuperwallDelegate",
"sdk-reference/PaywallPresentationHandler",
"sdk-reference/SuperwallOptions",
"sdk-reference/PaywallOptions",
"sdk-reference/PurchaseController",
"sdk-reference/PresentationResult",
"sdk-reference/CustomerInfo",
"sdk-reference/Entitlements",
"sdk-reference/IntegrationAttribute",
"sdk-reference/handleDeepLink",
"sdk-reference/advanced",

Expand Down
83 changes: 83 additions & 0 deletions content/docs/flutter/sdk-reference/CustomerInfo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: "CustomerInfo"
description: "Contains the latest subscription and entitlement information about the customer."
---

## Purpose
Represents the complete customer information including all subscription transactions, non-subscription transactions, entitlements, and user identification.

## Signature
```dart
class CustomerInfo {
final List<SubscriptionTransaction> subscriptions;
final List<NonSubscriptionTransaction> nonSubscriptions;
final List<Entitlement> entitlements;
final String userId;
}
```

## Properties

<ParamTable>
| Property | Type | Description |
|----------|------|-------------|
| `subscriptions` | `List<SubscriptionTransaction>` | All subscription transactions the user has made. |
| `nonSubscriptions` | `List<NonSubscriptionTransaction>` | All non-subscription transactions (consumables and non-consumables) the user has made. |
| `entitlements` | `List<Entitlement>` | All entitlements available to the user. |
| `userId` | `String` | The ID of the user. |
</ParamTable>

## Usage

Getting customer info:
```dart
final customerInfo = await Superwall.shared.getCustomerInfo();

// Access user ID
print('User ID: ${customerInfo.userId}');

// Check entitlements
final activeEntitlements = customerInfo.entitlements
.where((e) => e.isActive)
.toList();

// Access subscriptions
for (final subscription in customerInfo.subscriptions) {
if (subscription.isActive) {
print('Active subscription: ${subscription.productId}');
}
}
```

Checking for specific entitlements:
```dart
final customerInfo = await Superwall.shared.getCustomerInfo();

final hasPremium = customerInfo.entitlements.any(
(entitlement) =>
entitlement.id == 'premium' &&
entitlement.isActive,
);

if (hasPremium) {
// User has premium access
showPremiumContent();
}
```

Filtering active subscriptions:
```dart
final customerInfo = await Superwall.shared.getCustomerInfo();

final activeSubscriptions = customerInfo.subscriptions
.where((sub) => sub.isActive && !sub.isRevoked)
.toList();

print('User has ${activeSubscriptions.length} active subscriptions');
```

## Related
- [`getCustomerInfo()`](/flutter/sdk-reference/getCustomerInfo) - Method to retrieve customer info
- [`SubscriptionTransaction`](/flutter/sdk-reference/SubscriptionTransaction) - Subscription transaction details
- [`NonSubscriptionTransaction`](/flutter/sdk-reference/NonSubscriptionTransaction) - Non-subscription transaction details
- [`Entitlement`](/flutter/sdk-reference/Entitlement) - Entitlement information
100 changes: 100 additions & 0 deletions content/docs/flutter/sdk-reference/Entitlements.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: "Entitlements"
description: "Container for all entitlements available to the user, organized by status."
---

## Purpose
Provides organized access to user entitlements with methods to filter and query them. Returned by [`getEntitlements()`](/flutter/sdk-reference/getEntitlements).

## Signature
```dart
class Entitlements {
final Set<Entitlement> active;
final Set<Entitlement> inactive;
final Set<Entitlement> all;
final Set<Entitlement> web;

Future<Set<Entitlement>> byProductIds(Set<String> productIds);
}
```

## Properties

<ParamTable>
| Property | Type | Description |
|----------|------|-------------|
| `active` | `Set<Entitlement>` | All active entitlements available to the user. |
| `inactive` | `Set<Entitlement>` | All inactive entitlements. |
| `all` | `Set<Entitlement>` | All entitlements (both active and inactive). |
| `web` | `Set<Entitlement>` | Entitlements from web checkout. |
</ParamTable>

## Methods

### byProductIds()

Filters entitlements by product IDs. Returns all entitlements that contain any of the specified product IDs.

**Signature:**
```dart
Future<Set<Entitlement>> byProductIds(Set<String> productIds)
```

**Parameters:**
- `productIds` - A set of product identifiers to search for

**Returns:** A future that resolves to a set of entitlements that contain any of the specified product IDs.

## Usage

Accessing different entitlement sets:
```dart
final entitlements = await Superwall.shared.getEntitlements();

// Check active entitlements
if (entitlements.active.isNotEmpty) {
print('User has ${entitlements.active.length} active entitlements');
}

// Check web checkout entitlements
if (entitlements.web.isNotEmpty) {
print('User has web checkout entitlements');
}
```

Filtering by product IDs:
```dart
final entitlements = await Superwall.shared.getEntitlements();

// Find entitlements for specific products
final premiumEntitlements = await entitlements.byProductIds({
'premium_monthly',
'premium_yearly',
'premium_lifetime',
});

if (premiumEntitlements.isNotEmpty) {
print('User has premium access');
for (final entitlement in premiumEntitlements) {
print('Premium entitlement: ${entitlement.id}');
}
}
```

Checking for specific entitlement:
```dart
final entitlements = await Superwall.shared.getEntitlements();

final hasPro = entitlements.all.any(
(entitlement) => entitlement.id == 'pro' && entitlement.isActive,
);

if (hasPro) {
// User has pro access
showProFeatures();
}
```

## Related
- [`getEntitlements()`](/flutter/sdk-reference/getEntitlements) - Method to retrieve entitlements
- [`Entitlement`](/flutter/sdk-reference/Entitlement) - Individual entitlement information
107 changes: 107 additions & 0 deletions content/docs/flutter/sdk-reference/IntegrationAttribute.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: "IntegrationAttribute"
description: "Attributes for third-party integrations with Superwall."
---

## Purpose
Enumeration of integration attributes that allow you to sync user identifiers from your analytics and attribution providers with Superwall. This enables better user tracking and attribution across platforms.

## Signature
```dart
enum IntegrationAttribute {
adjustId,
amplitudeDeviceId,
amplitudeUserId,
appsflyerId,
brazeAliasName,
brazeAliasLabel,
onesignalId,
fbAnonId,
firebaseAppInstanceId,
iterableUserId,
iterableCampaignId,
iterableTemplateId,
mixpanelDistinctId,
mparticleId,
clevertapId,
airshipChannelId,
kochavaDeviceId,
tenjinId,
posthogUserId,
customerioId;
}
```

## Values

<ParamTable>
| Value | Description |
|-------|-------------|
| `adjustId` | The unique Adjust identifier for the user. |
| `amplitudeDeviceId` | The Amplitude device identifier. |
| `amplitudeUserId` | The Amplitude user identifier. |
| `appsflyerId` | The unique Appsflyer identifier for the user. |
| `brazeAliasName` | The Braze `alias_name` in User Alias Object. |
| `brazeAliasLabel` | The Braze `alias_label` in User Alias Object. |
| `onesignalId` | The OneSignal Player identifier for the user. |
| `fbAnonId` | The Facebook Anonymous identifier for the user. |
| `firebaseAppInstanceId` | The Firebase instance identifier. |
| `iterableUserId` | The Iterable identifier for the user. |
| `iterableCampaignId` | The Iterable campaign identifier. |
| `iterableTemplateId` | The Iterable template identifier. |
| `mixpanelDistinctId` | The Mixpanel user identifier. |
| `mparticleId` | The unique mParticle user identifier (mpid). |
| `clevertapId` | The CleverTap user identifier. |
| `airshipChannelId` | The Airship channel identifier for the user. |
| `kochavaDeviceId` | The unique Kochava device identifier. |
| `tenjinId` | The Tenjin identifier. |
| `posthogUserId` | The PostHog User identifier. |
| `customerioId` | The Customer.io person's identifier (`id`). |
</ParamTable>

## Usage

Setting a single integration attribute:
```dart
await Superwall.shared.setIntegrationAttribute(
IntegrationAttribute.mixpanelDistinctId,
'user_123',
);
```

Setting multiple integration attributes:
```dart
await Superwall.shared.setIntegrationAttributes({
IntegrationAttribute.mixpanelDistinctId: 'user_123',
IntegrationAttribute.amplitudeUserId: 'amp_456',
IntegrationAttribute.adjustId: 'adjust_789',
});
```

Removing an integration attribute:
```dart
// Set to null to remove
await Superwall.shared.setIntegrationAttribute(
IntegrationAttribute.mixpanelDistinctId,
null,
);
```

Syncing with analytics providers:
```dart
void _syncAnalyticsIds() async {
// Get IDs from your analytics SDKs
final mixpanelId = await MixpanelSDK.getDistinctId();
final amplitudeId = await AmplitudeSDK.getUserId();

// Sync with Superwall
await Superwall.shared.setIntegrationAttributes({
IntegrationAttribute.mixpanelDistinctId: mixpanelId,
IntegrationAttribute.amplitudeUserId: amplitudeId,
});
}
```

## Related
- [`setIntegrationAttribute()`](/flutter/sdk-reference/setIntegrationAttribute) - Set a single integration attribute
- [`setIntegrationAttributes()`](/flutter/sdk-reference/setIntegrationAttributes) - Set multiple integration attributes at once
Loading