appvestor_billing_stats 1.0.36
appvestor_billing_stats: ^1.0.36 copied to clipboard
Flutter SDK wrapper for Appvestor Android and iOS stats framework
example/lib/main.dart
import 'package:appvestor_billing_stats/ads/ad_format.dart' as billingAdFormat;
import 'package:appvestor_billing_stats/ads/ad_impression_provider.dart';
import 'package:appvestor_billing_stats/ads/applovin_ad_provider.dart';
import 'package:appvestor_billing_stats/ads/custom_ad_provider.dart';
import 'package:appvestor_billing_stats/ads/google_ad_provider.dart';
import 'package:appvestor_billing_stats/appvestor_billing_stats.dart';
import 'package:appvestor_billing_stats/attribution/attribution_data_type.dart';
import 'package:appvestor_billing_stats/events/events.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Appvestor Stats Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Appvestor Stats SDK Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
@override
void initState() {
super.initState();
AppvestorBillingStats.initialize(androidAccountId: 'a1-63b15591-f368-4810-bdea-235c8773beeb', androidAppId: 'b0-490102db-13ed-4b4c-a793-6e72066fd64b', iosAccountId: 'a1-63b15591-f368-4810-bdea-235c8773beeb', iosAppId: 'b0-490102db-13ed-4b4c-a793-6e72066fd64b');
AppvestorBillingStats.firebaseEvents.listen((event) {
debugPrint(
"🔥 Appvestor Firebase Event: ${event['eventName']} -> ${event['payload']}",
);
});
AppvestorBillingStats.dispatchAdImpressionAppLovin(
AppLovinImpressionProvider(
adUnitId: "ueid",
adRevenue: 3.0,
adFormat: "Banner",
precision: "rffjk",
networkName: "Applovin",
),
);
AppvestorBillingStats.dispatchAdImpressionGoogleAds(
GoogleAdImpressionProvider(
adUnitId: "tgj",
valueMicros: 0.16,
adFormat: billingAdFormat.AdFormat.banner,
currencyCode: "USD",
precisionType: 2,
adSourceName: "Google",
),
);
AppvestorBillingStats.dispatchAdImpressionCustom(
CustomAdImpressionProvider(
adUnitId: "fjnhjg",
value: 4.9,
adFormat: billingAdFormat.AdFormat.banner,
currencyCode: "EUR",
precisionType: "djfh",
adSourceName: "Custom",
),
);
}
Widget _buildButton(String title, VoidCallback onPressed) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: ElevatedButton(onPressed: onPressed, child: Text(title)),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Center(
child: Column(
children: <Widget>[
const SizedBox(height: 20),
_buildButton("Dispatch Internal Event", () {
AppvestorBillingStats.dispatchEvent(
eventName: InternalEventKey.AD_CLICKED,
optionalParams: {'source': 'flutter_app'},
);
}),
_buildButton("Dispatch Ad Viewed", () {
AppvestorBillingStats.dispatchAdViewedEvent("banner_home");
AppvestorBillingStats.dispatchEvent(
eventName: InternalEventKey.AD_CLICKED,
optionalParams: {'source': 'flutter_app'},
);
AppvestorBillingStats.dispatchCustomRevenueEvent(
eventName: "purchase_made",
value: 4.99,
currency: "USD",
);
}),
_buildButton("Dispatch Ad Clicked", () {
AppvestorBillingStats.dispatchAdClickedEvent("banner_home");
}),
_buildButton("Dispatch Revenue Event", () {
AppvestorBillingStats.dispatchCustomRevenueEvent(
eventName: "purchase_made",
value: 4.99,
currency: "USD",
);
}),
_buildButton("Dispatch Ad Impression", () {
AppvestorBillingStats.dispatchAdImpressionEvent(
value: 1.2,
currency: "USD",
adPlatform: AdImpressionProvider.GAM,
);
}),
_buildButton("Dispatch Attribution Data", () {
AppvestorBillingStats.dispatchAttributionData(
type: AttributionDataType.DEFERRED_DEEP_LINK,
data: {
'tracker_token': 'abc123',
'campaign': 'spring_launch',
},
);
}),
_buildButton("Report Purchase", () {
AppvestorBillingStats.reportPurchase(
'{"orderId":"GPA.1111-2222-3333-44444"}',
);
}),
],
),
),
),
);
}
}