Skip to main content

kissmyapps 1.1.0 copy "kissmyapps: ^1.1.0" to clipboard
kissmyapps: ^1.1.0 copied to clipboard

Analytics for Flutter apps: installs, sessions, screens and your own events, install attribution and deep links, sent to your KissMyApps dashboard. Offline queue.

example/lib/main.dart

// Flutter after 3.47 moves Material to package:material_ui; the SDK still supports 3.24.
// ignore: deprecated_member_use
import 'package:flutter/material.dart';
import 'package:kissmyapps/kissmyapps.dart';

void main() {
  // Your project's client key, from Settings > API keys in the KissMyApps console.
  KissMyApps.start(
    const String.fromEnvironment('KMA_KEY',
        defaultValue: 'kma_pk_test_ReplaceWithYourOwnKey00'),
    options: const KissMyAppsOptions(debug: true),
  );
  // The deferred deep link after an install, and one each time a smart link
  // opens the app.
  KissMyApps.onDeepLink((link) {
    debugPrint('KissMyApps deep link: ${link.value} ${link.params}');
  });
  runApp(const ExampleApp());
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'KissMyApps example',
      theme: ThemeData(colorSchemeSeed: const Color(0xFFFF80BF)),
      navigatorObservers: [KissMyAppsObserver()],
      routes: {
        '/': (_) => const HomeScreen(),
        '/lesson': (_) => const LessonScreen(),
      },
    );
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Home')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            FilledButton(
              onPressed: () => Navigator.pushNamed(context, '/lesson'),
              child: const Text('Open a lesson'),
            ),
            const SizedBox(height: 12),
            OutlinedButton(
              onPressed: () => KissMyApps.identify(
                'user-42',
                traits: {'plan': 'annual'},
              ),
              child: const Text('Sign in as user-42'),
            ),
            TextButton(
              onPressed: KissMyApps.reset,
              child: const Text('Sign out'),
            ),
          ],
        ),
      ),
    );
  }
}

class LessonScreen extends StatelessWidget {
  const LessonScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Lesson 3')),
      body: Center(
        child: FilledButton(
          onPressed: () {
            KissMyApps.track('lesson_completed',
                properties: {'lesson': 3, 'score': 0.92});
            Navigator.pop(context);
          },
          child: const Text('Complete the lesson'),
        ),
      ),
    );
  }
}
0
likes
160
points
761
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Analytics for Flutter apps: installs, sessions, screens and your own events, install attribution and deep links, sent to your KissMyApps dashboard. Offline queue.

Homepage
Repository (GitHub)
View/report issues

Topics

#analytics #tracking #events #mobile-analytics #sessions

License

MIT (license)

Dependencies

flutter

More

Packages that depend on kissmyapps

Packages that implement kissmyapps