Giter Site home page Giter Site logo

ahoy_flutter's Introduction

Flutter Ahoy

A straightforward and efficient first party analytics and visit tracking library, designed to seamlessly integrate with your Rails Ahoy backend highly inspired by Ahoy iOS Library.

Key Features

  • ๐ŸŒ– Comprehensive user visit tracking
  • ๐Ÿ“ฅ Attribution of visits through UTM & referrer parameters
  • ๐Ÿ“† Easy-to-use, in-house event tracking

Getting Started


To integrate Flutter Ahoy into your project, add the following dependency to your pubspec.yaml file:

dependencies:
 flutter_ahoy: ^latest_version

Replace latest_version with the most recent version of the package.

How to Use

To begin using Flutter Ahoy, you'll need to create an instance of the Ahoy client. This requires a configuration object that includes a baseUrl and an ApplicationEnvironment object.

import 'package:flutter_ahoy/flutter_ahoy.dart';

final ahoy = Ahoy(
 configuration: AhoyConfiguration(
    environment: ApplicationEnvironment(
      platform: Platform.operatingSystem,
      appVersion: "1.0.2",
      osVersion: Platform.operatingSystemVersion,
    ),
    baseUrl: "https://your-server.com",
 ),
);

Configuration Options

The configuration object offers sensible defaults, but you can customize various settings:

  • visitDuration (30 minutes)
  • urlRequestHandler (Client())
  • Routing
  • ahoyPath ("ahoy")
  • visitsPath ("visits")
  • eventsPath ("events")

For additional customization, you can provide your own AhoyTokenManager and RequestInterceptors during initialization.

Tracking Visits

To track a visit, initialize your Ahoy client and then call the trackVisit method. This is typically done at the application's startup.

ahoy.trackVisit().then((visit) => print(visit));

Sending Events

Once a visit is successfully tracked, you can start sending events to your server.

// For batch event tracking, use the `trackEvents` function
var eventsToSend = [
 Event(name: "ride_details.update_driver_rating", properties: {"driver_id": 4}),
 Event(name: "ride_details.increase_tip", properties: {"driver_id": 4}),
];

ahoy.trackEvents(eventsToSend).then((_) => eventsToSend.clear());

// For individual event tracking, use the `trackEvent` method
ahoy.trackEvent("ride_details.update_driver_rating", properties: {"driver_id": 4});

// If an event doesn't require properties, you can omit them
ahoy.trackEvent("ride_details.update_driver_rating");

Additional Features

You can access the current visit directly through the currentVisit property of your Ahoy client. Additionally, the headers property allows you to include Ahoy-Visitor and Ahoy-Visit tokens in your requests as needed.

ahoy_flutter's People

Contributors

erknvl avatar selawik avatar

Watchers

 avatar

Forkers

selawik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.