Skip to content

For more details about custom metrics and reports, refer to the Custom Metrics and Reports Guide

Invoking a Metrics Service

When the Flutter SDK is initialized, it automatically collects various standard metrics from a client and the standard metrics will be accessible using the Standard Reports within Volt Foundry Console.

Flutter SDK also provides the ability for a developer to send additional custom metrics from a client app to Volt Foundry back-end to capture additional information. These custom data sets will be accessible using the Custom Reporting feature within Volt Foundry Console, where a business analyst can design and share reports using a combination of standard and custom metrics.

Additionally, the Flutter SDK provides an Events API that allows an app to track user actions within the app to gain insight into the user journey. The developer can send various standard events such as form entry, touch events, service requests, gestures and errors. The developer can also send custom events to capture any app specific scenarios or transactions. These events can be analyzed within Volt Foundry Console by using the Standard Reports or user-defined Custom Reports. For more details, refer to Custom Metrics and Reports Guide.

This section lists all MetricsService object APIs.

setUserId

The setUserID API sets the user ID for the data gathered from an application. The user ID allows the data to be tracked on a user basis for broad analysis, such as how many different users used the application. It also helps to track activities of a specific user, which can help in seeing what activities were done before a crash, or what events led to a transaction not passing through. This user ID allows the same user to be tracked across different devices as well.

// Sample code to set up the user ID of the application user
var voltmxSdkFlutter = VoltmxSdkFlutter();
var userId = "<Your userId here>";
voltmxSdkFlutter.setMetricsUserId(userId, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

Note: UserId is related to metrics. The UserId length cannot exceed 100 characters.

sendEvent

The sendEvent API allows a developer to send event details from an application to the server for analytics and reporting purposes. The event data is added to a buffer and sent to the server as per configuration values set by the developer using the setEventConfig API. The sendEvent API allows sending custom information for the event as metadata.

// Sample code to send reports
var voltmxSdkFlutter = VoltmxSdkFlutter();
var eventType = Eventtype.FORM_ENTRY;
var eventSubType = "<Your eventSubType here>";
var formID = "<Your formID here>";
var widgetID = "<Your widgetID here>";
var flowTag = "<Your flowTag here>";
String metadata = "{\"key\": \"value\"}";
// metadata is an optional parameter
voltmxSdkFlutter.sendEvent(eventType, eventSubType, formID, widgetID, flowTag, metadata, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

The following is the supported list of Event types

  • FORM_ENTRY
  • FORM_EXIT
  • TOUCH
  • SERVICE_REQUEST
  • SERVICE_RESPONSE
  • GESTURE
  • ORIENTATION
  • ERROR
  • HANDLED_EXCEPTION
  • CRASH
  • CUSTOM
  • SERVICE_CALL
  • APP_TRANSITION
  • APP_LOAD
  • COMPONENT

flushEvents

The flushEvents API allows a developer to force events to be sent to the server. The entire current event buffer is loaded and sent to the server for processing. The flushEvents API is used as an override to send event data to server before the configured value or a service call that flushes the buffer.

// Sample code to flush events
var voltmxSdkFlutter = VoltmxSdkFlutter();
voltmxSdkFlutter.flushEvents(onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

eventsInBuffer

The eventsInBuffer returns a list of the buffered events.

// Sample code to get eventsInBuffer
var voltmxSdkFlutter = VoltmxSdkFlutter();
voltmxSdkFlutter.eventsInBuffer(onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

setFlowTag

The setFlowTag API sets an event flow tag to be associated with all new events that are reported by using the sendEvent API. Flow tag is used to ease searching event data in terms of application flows like loginflow, searchflow. The setFlowTag also helps sorting and filtering data while building custom reports or running standard reports for the application events.

// Sample code to get setFlowTag
var voltmxSdkFlutter = VoltmxSdkFlutter();
var flowTag = "<Your flowTag here>";
voltmxSdkFlutter.setFlowTag(flowTag, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

clearFlowTag

The clearFlowTag API clears the currently set event flow tag.

// Sample code to clearFlowTag
var voltmxSdkFlutter = VoltmxSdkFlutter();
voltmxSdkFlutter.clearFlowTag(onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

getFlowTag

The getFlowTag API gets the currently set event flow tag.


// Sample code to getFlowTag
var voltmxSdkFlutter = VoltmxSdkFlutter();
voltmxSdkFlutter.getFlowTag(onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

reportError

The reportError API enables an app to report an error event to metrics server.

// Sample code to reportError
var voltmxSdkFlutter = VoltmxSdkFlutter();
var errorCode = "<Your errorCode here>";
var errorType = "<Your errorType here>";
var errorMessage = "<Your errorMessage here>";
final errorDetails = jsonEncode({
"Key 1": "value 1",
"Key 2": "value 2",
});
// errorDetails only supports JSON String
voltmxSdkFlutter.reportError(errorCode, errorType, errorMessage, errorDetails, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

reportHandledException

The reportHandledException API enables apps to report a handled exception event.

// Sample code to send exception to metrics server
var voltmxSdkFlutter = VoltmxSdkFlutter();
var exceptionCode = "<Your exceptionCode here>";
var exceptionType = "<Your exceptionType here>";
var exceptionMessage = "<Your exceptionMessage here>";
final exceptionDetails = jsonEncode({
"Key 1": "value 1",
"Key 2": "value 2",
});
// exceptionDetails only supports JSON String
voltmxSdkFlutter.reportHandledException(exceptionCode, exceptionType, exceptionMessage, exceptionDetails, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

setEventConfig

The setEventConfig API takes the required values to set the event configuration values. When eventConfigType is - EventConfigType.BUFFER, eventBufferAutoFlushCount and eventBufferMaxCount are considered.

import 'package:voltmx_sdk_flutter/src/event_type.dart';

// Sample code to setEventConfig
var voltmxSdkFlutter = VoltmxSdkFlutter();
var eventConfigType = EventConfigType.BUFFER;
var flushCount = 15;
var maxCount = 1000;
voltmxSdkFlutter.setEventConfig(eventConfigType, flushCount: flushCount, maxCount: maxCount, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

eventConfigType - sets the current configuration type

Note: Only buffer mode is supported for the eventConfigType currently.

  • eventBufferAutoFlushCount - number of events to be buffered before a network call is triggered to post the event data to the server. Possible values are positive integers, and the default value is 15.

  • eventBufferMaxCount - Maximum event buffer count to store the events. Possible values are positive integers, and the default value is 1000.

setBatchSize

The setBatchSize API allows a developer to specify the batch size to be set to flush events. The default batch size is 50.

// Sample code to setBatchSize to flush events
var voltmxSdkFlutter = VoltmxSdkFlutter();
var batchSize = 10;
voltmxSdkFlutter.setBatchSize(batchSize: batchSize, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});

Note: Supported only in the iOS and Android channels

sendCustomMetrics

The sendCustomMetrics API sends a custom metrics event.

// Sample code to send data to the reporting service with the groupId as "formID"
var voltmxSdkFlutter = VoltmxSdkFlutter();
var formID = "<Your formID here>";
Map<String, String> data = {"key": "value"};
voltmxSdkFlutter.sendCustomMetrics(formID, data, onSuccess: (response) {
    // Handle the success case here
},
onFailure: (response) {
    // Handle the failure case here
});