m8ty_client_tracking
Package overview
Section titled “Package overview”m8ty_client_tracking solves this by standardizing how apps submit user-behavior events, allowing teams to measure journeys and prioritize experience improvements.
Tracking client to send user behaviour analytics events to the server.
Before you start
Section titled “Before you start”Check the documentation of the m8ty_client_tracking library to get an idea about the available models and their properties.
Import all needed libraries
Section titled “Import all needed libraries” import 'package:dio/dio.dart'; import 'package:m8ty_client_tracking/m8ty_client_tracking.dart'; import 'package:m8ty_client_common/m8ty_client_common.dart'; import 'package:built_collection/built_collection.dart';Client Setup
Section titled “Client Setup”final trackingClient = M8tyClientTracking();trackingClient.setApiKey(m8tyApiKeyAuth, "myApiKey");API Surface
Section titled “API Surface”TrackingApi
Section titled “TrackingApi”| Method | Description |
|---|---|
createTracking |
Track multiple events |
How to perform different tasks
Section titled “How to perform different tasks”Here some examples how the dart client can be used
Create a tracking event
Section titled “Create a tracking event” final trackingClient = M8tyClientTracking(); trackingClient.setApiKey(m8tyApiKeyAuth, "myApiKey");
final trackingApi = trackingClient.getTrackingApi();
final EventModel eventModel = EventModel((b) => b ..deviceId = "mydeviceid" ..eventName = "button_clicked" ..metadata = MapBuilder({"device_name": "apple phone"}) ..timestamp = DateTime.now());
final trackEventsRequestModel = TrackEventsRequestModel( (final b) => b.events = ListBuilder([eventModel]), );
try { await trackingApi.createTracking(trackEventsRequestModel: trackEventsRequestModel); } on DioException catch (e) { throw Exception( 'Request failed (status: ${e.response?.statusCode}): ${e.response?.data}', ); }© m8ty GmbH 2023 · m8ty.eu
