Last updated:
0 purchases
piano analytics
Piano Analytics SDK Flutter
About The Project #
The Piano Analytics Apple SDK allows you to collect audience measurement data for the Piano Analytics solution.
It can be used with Flutter applications.
This SDK makes the implementation of Piano Analytics as simple as possible, while keeping all the flexibility of the solution. By using this plugin in your applications, and using dedicated and documented methods, you will be able to send powerful events.
Getting Started #
Add this to your pubspec.yaml file:
dependencies:
piano_analytics: ^1.0.0
copied to clipboard
Install the plugin using the command
flutter pub get
copied to clipboard
Usage #
Initialize PianoAnalytics with your site and collect domain in your application initialization
import 'package:piano_analytics/piano_analytics.dart';
...
class _MyAppState extends State<MyApp> {
final _pianoAnalytics = PianoAnalytics(
site: 123456789,
collectDomain: "xxxxxxx.pa-cd.com"
);
@override
void initState() {
super.initState();
initPlugins();
}
Future<void> initPlugins() async {
...
await _pianoAnalytics.init();
}
...
}
copied to clipboard
Send events
await _pianoAnalytics.sendEvents(events: [
Event(name: "page.display", properties: [
Property.bool(name: "bool", value: true),
Property.int(name: "int", value: 1),
Property.int(name: "long", value: 9007199254740992),
Property.double(name: "double", value: 1.0),
Property.string(name: "string", value: "value"),
Property.date(name: "date", value: DateTime.now()),
Property.intArray(name: "intArray", value: [1, 2, 3]),
Property.doubleArray(name: "doubleArray", value: [1.0, 2.0, 3.0]),
Property.stringArray(name: "stringArray", value: ["a", "b", "c"])
])
]);
copied to clipboard
Consents #
Important: Initialize PianoConsents before initializing PianoAnalytics
Initialize PianoConsents
import 'package:piano_analytics/piano_analytics.dart';
import 'package:piano_analytics/piano_consents.dart';
...
class _MyAppState extends State<MyApp> {
final _pianoConsents = PianoConsents(
requireConsents: true,
defaultPurposes: {
PianoConsentProduct.pa: PianoConsentPurpose.audienceMeasurement
}
);
final _pianoAnalytics = PianoAnalytics(
site: 1,
collectDomain: "piano.io"
);
@override
void initState() {
super.initState();
initPlugins();
}
Future<void> initPlugins() async {
...
await _pianoConsents.init();
await _pianoAnalytics.init();
}
...
}
copied to clipboard
Set consents
await _pianoConsents.set(
purpose: PianoConsentPurpose.audienceMeasurement,
mode: PianoConsentMode.essential,
products: [PianoConsentProduct.pa]);
copied to clipboard
Set all consents
await _pianoConsents.setAll(mode: PianoConsentMode.essential);
copied to clipboard
Set default consents
await _pianoConsents.clear();
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.