daybook
The core of Daybook's SDKs for Flutter. Start it once, with one key, and every Daybook module the app has installed starts with it: analytics, subscriptions, feedback. By itself the core sends nothing; it holds what the modules share, which is the key, the install id, who the user is and the person's tracking consent.
Install
Add the core and the modules you use. A module you do not add is not in your app.
flutter pub add daybook daybook_analytics
dependencies:
daybook: ^0.1.0
daybook_analytics: ^0.3.0 # events, people, the install report
daybook_subscriptions: ^0.10.0 # purchases, access, paywalls
daybook_feedback: ^0.4.0 # reports from inside the app
Start
The key is the app's own, dbk_…. In Daybook, open the project's settings, find the app under App key
and issue one; there is one per build kind (Production, Staging, Development). It is not a secret: it
only says which app, of which project, in which environment.
import 'package:daybook/daybook.dart';
import 'package:daybook_analytics/daybook_analytics.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final daybook = await Daybook.initialize('dbk_…');
daybook.analytics.track('app_opened');
runApp(const App());
}
Later, anywhere: Daybook.instance. The app names no module: each module's package registers itself
with the core as the app starts.
The user
Say it once. Every module hears it: the person in Analytics, the customer in Subscriptions, the reporter in Feedback.
await daybook.identify(user.id, email: user.email, name: user.name); // at sign-in
await daybook.reset(); // at sign-out
A user known at launch can be given to initialize(key, userId: …).
Modules
Each module's package adds its own door:
daybook.analytics.track('lesson_completed', properties: {'level': 3});
final profile = await daybook.subscriptions.getProfile();
daybook.feedback.open();
Tracking consent
final daybook = await Daybook.initialize('dbk_…', trackingConsent: false); // off until the person agrees
await daybook.setTrackingConsent(true);
It covers analytics and the install report. Purchases and feedback are functions of the app and keep
working. The person's answer is kept and wins over what initialize is given from then on.
What the core keeps
One file, daybook.json, in a folder the platform leaves out of backups: the install id, who is signed
in, and the consent answer. The install id is made once and never changes; reset() does not touch it.
When something does not start
Daybook.initialize never throws. A module that cannot start (an unknown key, a hub that is off for the
project, feedback not set up for the app) says so in the log with its own name, and the others start.
daybook.failedModules has the same reasons.
Platforms
iOS 15 and later, Android 7 (API 24) and later. The native part is a few lines on each: it names the
folder the SDKs keep their files in. A flutter create app starts at iOS 13, so raise
IPHONEOS_DEPLOYMENT_TARGET in ios/Runner.xcodeproj (and platform :ios in a Podfile, if there is one).
Daybook.initialize(key, serverUrl: …) points the SDKs at a Daybook of your own; otherwise they talk to
https://api.daybook.team.
Privacy
The core reads no advertising id and no identifier for vendor, asks for no permission, and makes no request of its own. The install id is a random UUID made on the device at first launch. It is kept outside backups, so a backup restored on another phone does not carry it there. The iOS privacy manifest declares no tracking, no tracking domains and no required-reason API. What each module sends is in that module's README.
Libraries
- daybook
- The core of Daybook's SDKs for Flutter (PM-R-0110).