heap_flutter_bridge 0.5.0
heap_flutter_bridge: ^0.5.0 copied to clipboard
Heap manual track SDK for Flutter apps on iOS, Android, and macOS.
example/example.md
Heap Flutter Bridge Example #
Getting Started #
For full documentation, installation instructions, and API reference, check out the Heap Flutter SDK documentation.
Simple Usage Example #
This example demonstrates the most common use cases of the Heap Flutter Bridge SDK:
Initialize the SDK #
Start by initializing Heap with your environment ID in the main() function:
import 'package:flutter/material.dart';
import 'package:heap_flutter_bridge/heap_flutter_bridge.dart';
void main() async {
// Initialize Heap SDK with your environment ID
await Heap().startRecording('YOUR_ENVIRONMENT_ID');
runApp(const MyApp());
}
Track Custom Events #
Track events with optional properties:
void _incrementCounter() {
setState(() {
_counter++;
});
// Track custom event with properties
Heap().track('button_clicked', {
'counter_value': _counter,
'screen': 'home',
});
}
Identify Users #
Identify users and add user properties:
void _identifyUser() {
// Identify the user with a unique ID
Heap().identify('user_12345');
// Add user properties
Heap().addUserProperties({
'subscription_tier': 'premium',
'signup_date': '2024-01-01',
});
}
Track Pageviews #
Manually track pageviews:
void _trackPageview() {
// Track a pageview manually
Heap().trackPageview(
pageviewProperties: const PageviewProperties(
title: 'Home Page',
),
);
}