tealium 1.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

Tealium Flutter Plugin #

Documentation #

For full documentation, please see the Tealium Learning Community:

Tealium for Flutter

License #

Use of this software is subject to the terms and conditions of the license agreement contained in the file titled "LICENSE.txt". Please read the license before downloading or using any of the files contained in this repository. By downloading or using any of these files, you are agreeing to be bound by and comply with the license agreement.


Copyright (C) 2012-2019, Tealium Inc.

1.2.0 (February 2020) #

  • Added support for Remote Commands
  • Underlying Tealium libraries updated to versions 5.7.0 (Android) and 5.6.6 (iOS)

1.0.1 (August 2019) #

  • Update documentation link

1.0.0 (July 2019) #

  • Initial release
    • Tealium and TealiumLifecycle support for Android and iOS

example/lib/main.dart

import 'dart:ffi';
import 'dart:io' show Platform;

import 'package:flutter/material.dart';

import 'package:tealium/tealium.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  //Sample - minimum initialization for Tealium instance
  //var teal = Tealium.initialize("tealiummobile", "flutter", "dev", null, null);

  //Sample - initialize Tealium + enable Consent Manager
  //var teal = Tealium.initializeWithConsentManager("tealiummobile", "flutter", "dev", null, null);

  //Sample - custom Tealium initialization
  var teal = Tealium.initializeCustom("tealiummobile", "flutter", "dev", null, null,
        "main", true, null, null, null, true); 

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: ListView(
          shrinkWrap: true,
          children: <Widget>[
            ButtonTheme(
              minWidth: 250.0,
              child: RaisedButton(
                  child: Text("Track Event"),
                  onPressed: () {
                    Tealium.trackEvent("event button click");
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Track View"),
                  onPressed: () {
                    Tealium.trackView("View button click");
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Get Visitor ID"),
                  onPressed: () async {
                    String data = await Tealium.getVisitorId();
                    print("Visitor ID: $data");
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Set Volatile Data"),
                  onPressed: () {
                    Tealium.setVolatileData({
                      "volatile_var": "volatile_val",
                      "volatile_var2": ["vol1", "vol2", "vol3"]
                    });
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Set Persistent Data"),
                  onPressed: () {
                    Tealium.setPersistentData({
                      "persistent_var": "persistent_val",
                      "persistent_var2": ["per1", "per2", "per3"]
                    });
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Print Volatile data: volatile_var"),
                  onPressed: () async {
                    var data = await Tealium.getVolatileData("volatile_var");
                    print("Volatile data retrieved: $data");
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Print Persistent data: persistent_var2"),
                  onPressed: () async {
                    var data =
                        await Tealium.getPersistentData("persistent_var2");
                    print("Persistent data retrieved: $data");
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Remove Volatile Data"),
                  onPressed: () {
                    Tealium.removeVolatileData(
                        ["volatile_var", "volatile_var"]);
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Remove Persistent Data"),
                  onPressed: () {
                    Tealium.removePersistentData(
                        ["persistent_var", "persistent_var2"]);
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Consent Manager: Consented Status"),
                  onPressed: () {
                    Tealium.setUserConsentStatus(1);
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Consent Manager: Not Consented Status"),
                  onPressed: () {
                    Tealium.setUserConsentStatus(2);
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Consent Manager: Partial Consent"),
                  onPressed: () {
                    Tealium.setUserConsentCategories(
                        ["email", "personalization"]);
                    Tealium.getUserConsentCategories();
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Get Consent Status"),
                  onPressed: () async {
                    String data = await Tealium.getUserConsentStatus();
                    print("Current Consent status is: $data");
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Get Consent Categories"),
                  onPressed: () async {
                    List data = await Tealium.getUserConsentCategories();
                    if (data != null) {
                      for (var x = 0; x < data.length; x++) {
                        print(data[x]);
                      }
                    } else {
                      print(data);
                    }
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Consent Manager: Reset Preferences"),
                  onPressed: () {
                    Tealium.resetUserConsentPreferences();
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Add Remote Command"),
                  onPressed: () {
                    Tealium.addRemoteCommand("test_command", "test command", (payload) => 
                      print("Remote command payload - test_command: $payload")
                    );
                    Tealium.addRemoteCommand("test_command2", "test command 2", (payload) => 
                      print("Remote command payload - test_command2: $payload")
                    );
                    Tealium.addRemoteCommand("display", "http command", (payload) => 
                      print("Remote command payload - display: $payload")
                    );
                    Tealium.trackEvent("test_event", {"instance": "main"});
                    Tealium.trackEvent("test_event_2", {"instance": "instance-2"});
                    Tealium.trackEvent("display_data");
                  }),
            ),
            ButtonTheme(
              minWidth: 300.0,
              child: RaisedButton(
                  child: Text("Remove Remote Command"),
                  onPressed: () {
                    Tealium.removeRemoteCommand("test_command");
                    Tealium.removeRemoteCommand("test_command2");
                    Tealium.removeRemoteCommand("display");
                  }),
            )
          ],
        )),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  tealium: ^1.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:tealium/tealium.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/tealium.dart.

Run flutter format to format lib/tealium.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
eventify ^0.1.4 0.1.4
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test