Lifecycle & Recording

SDK setup (on application start)

Smartlook SDK setup needs to be called only once during an application’s lifetime and it should be called on application startup. There is no need to stop recording explicitly on application closure, SDK will stop itself automatically.

import 'package:smartlook/smartlook.dart';


class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    final SetupOptions options = SetupOptionsBuilder('API_KEY').build();
    Smartlook.setupAndStartRecording(options);
  }
}

The easiest way of setting up the SDK is with setupAndStartRecording() method:

Smartlook.setupAndStartRecording(SetupOptions options);

It will set the SDK up and also start the recording. SDK can be setup without starting the recording using the following:

Smartlook.setup(SetupOptions options);

And then the recording can be started by calling:

Smartlook.startRecording();

Setup configuration

Some recording parameters can be configured on setup:

ParameterRequiredDefault valueDescription
apiKeyyes""Unique 40-character key identifying your app (can be found in the dashboard).
fpsno2Recorded video frame rate (allowed values between 2 and 10). Note that by setting this value settings from the dashboard will be overridden!
startNewSessionnofalseIf set to true SDK forces start of new session on setup.
startNewSessionAndUsernofalseIf set to true SDK forces start of new session and creates new visitor on setup.

Full SDK setup configuration can be done with optional fps method parameter.

final SetupOptions options = (SetupOptionsBuilder('API_KEY')
    ..Fps = 2
    ..StartNewSession = true
  ).build();
Smartlook.setupAndStartRecording(options);

Start and stop recording

Recording can be started or stopped at any time, the only requirement is that the SDK is set up.

Smartlook.startRecording();
Smartlook.stopRecording();

🚧

stopRecording()

doesn't need to be called on application closure. Recording is stopped automatically.

Check if SDK is recording

Check if SDK is currently recording can be handy when using startRecording() and stopRecording() methods. Simply call:

Smartlook.isRecording();