dub_flutter
An unofficial Flutter SDK for Dub - track clicks, leads, and sales with the open-source link management platform.
Features
- 🔗 Track Clicks: Automatically detect and track deep link opens.
- 👥 Track Leads: Monitor user sign-ups and other lead events.
- 💰 Track Sales: Record revenue events and associate them with customers.
- 📱 Cross-Platform: Support for Android and iOS.
Installation
Add dub_flutter to your pubspec.yaml:
dependencies:
dub_flutter: ^0.0.1
Usage
Initialization
Initialize the SDK with your publishable key, typically in your main() function.
import 'package:dub_flutter/dub_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Dub.init(
publishableKey: 'dub_xxxxx',
// Optional: defaults to 'dub.sh'
domain: 'dub.sh',
);
runApp(MyApp());
}
Track a Click (App Open)
Track when your app is opened via a deep link.
// Auto-detect from clipboard or initial intent
await Dub.instance.trackOpen();
// Or provide an explicit deep link if you are handling deep linking manually
await Dub.instance.trackOpen('https://dub.sh/abc123');
Track a Lead
Track events like user sign-ups.
await Dub.instance.trackLead(
eventName: 'User Sign Up',
customerExternalId: 'user_123',
customerEmail: '[email protected]', // Optional
metadata: {
'plan': 'free',
},
);
Track a Sale
Track revenue-generating events.
await Dub.instance.trackSale(
eventName: 'Subscription Started',
customerExternalId: 'user_123',
amount: 999, // Amount in cents
currency: 'USD',
paymentProcessor: PaymentProcessor.stripe,
);
Contributing
Contributions are welcome! Please read our Contributing Guide for details on how to submit pull requests, report issues, and contribute to the project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Libraries
- dub_flutter
- Flutter SDK for Dub - track clicks, leads, and sales.