flutter_smartlook 3.0.6 copy "flutter_smartlook: ^3.0.6" to clipboard
flutter_smartlook: ^3.0.6 copied to clipboard

outdated

Smartlook SDK wrapper for Flutter

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter_smartlook/flutter_smartlook.dart';
import 'dart:collection';

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

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

class CustomIntegrationListener implements IntegrationListener {
  void onSessionReady(String? dashboardSessionUrl) {
    print("DashboardUrl:");
    print(dashboardSessionUrl);
  }

  void onVisitorReady(String? dashboardVisitorUrl) {
    print("DashboardVisitorUrl:");
    print(dashboardVisitorUrl);
  }
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  String _timeString = "";

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

    _timeString =
        "${DateTime.now().hour} : ${DateTime.now().minute} :${DateTime.now().second}";
    Timer.periodic(Duration(seconds: 1), (Timer t) => _getCurrentTime());

    SetupOptions options =
        (new SetupOptionsBuilder('a934b945c51eceb563df7a727bc56b828fda9191')
              ..Fps = 2
              ..StartNewSession = true)
            .build();

    Smartlook.setupAndStartRecording(options);

    Smartlook.setEventTrackingMode(EventTrackingMode.FULL_TRACKING);
    List<EventTrackingMode> eventTrackingModes = [
      EventTrackingMode.FULL_TRACKING,
      EventTrackingMode.IGNORE_USER_INTERACTION
    ];
    Smartlook.setEventTrackingModes(eventTrackingModes);
    Smartlook.registerIntegrationListener(new CustomIntegrationListener());
    Smartlook.setUserIdentifier('FlutterLul', {"flutter-usr-prop": "valueX"});
    Smartlook.setGlobalEventProperty("key_", "value_", true);
    Smartlook.setGlobalEventProperties({"A": "B"}, false);
    Smartlook.removeGlobalEventProperty("A");
    Smartlook.removeAllGlobalEventProperties();
    Smartlook.setGlobalEventProperty("flutter_global", "value_", true);
    Smartlook.enableWebviewRecording(true);
    Smartlook.enableWebviewRecording(false);
    Smartlook.enableCrashlytics(true);
    Smartlook.setReferrer("referer", "source");
    Smartlook.getDashboardSessionUrl(true);
  }

  void _getCurrentTime() {
    setState(() {
      _timeString =
          "${DateTime.now().hour} : ${DateTime.now().minute} :${DateTime.now().second}";
    });
  }

  @override
  Widget build(BuildContext context) {
    return SmartlookHelperWidget(
        child: MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          //child: Text('Running on: $_platformVersion\n'),

          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Image.asset("lib/Smartlook.png"),
              Text(
                _timeString,
                style: TextStyle(fontSize: 18),
              ),
              const SizedBox(height: 15),
              RaisedButton(
                onPressed: () {
                  Smartlook.stopRecording();
                },
                child: Text('Stop recording'),
              ),
              RaisedButton(
                onPressed: () {
                  Smartlook.startRecording();
                },
                child: Text('Start recording'),
              ),
              const SizedBox(height: 15),
              RaisedButton(
                onPressed: () {
                  Smartlook.startTimedCustomEvent("timed-event");
                },
                child: Text('Start timed event'),
              ),
              RaisedButton(
                onPressed: () {
                  Smartlook.trackCustomEvent(
                      "timed-event", {"property1": "value1"});
                },
                child: Text('Track event'),
              ),
              const SizedBox(height: 15),
              RaisedButton(
                onPressed: () {
                  Smartlook.startFullscreenSensitiveMode();
                },
                child: Text('Start Sensitive Mode'),
              ),
              RaisedButton(
                onPressed: () {
                  Smartlook.stopFullscreenSensitiveMode();
                },
                child: Text('Stop Sensitive Mode'),
              ),
              const SizedBox(height: 15),
              RaisedButton(
                onPressed: () {
                  Smartlook.trackNavigationEvent(
                      "nav-event", SmartlookNavigationEventType.enter);
                },
                child: Text('Enter Navigation Event'),
              ),
              RaisedButton(
                onPressed: () {
                  Smartlook.trackNavigationEvent(
                      "nav-event", SmartlookNavigationEventType.exit);
                },
                child: Text('Exit Navigation Event'),
              ),
            ],
          ),
        ),
      ),
    ));
  }
}
43
likes
0
pub points
96%
popularity

Publisher

verified publishersmartlook.com

Smartlook SDK wrapper for Flutter

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_smartlook