When the .NET SDK is initialized, it automatically collects various standard metrics from a client and the standard metrics will be accessible using the Standard Reports within Kony Fabric Console.
The .NET SDK also provides the ability for a developer to send additional custom metrics from a client app to Kony Fabric back-end to capture additional information. These custom data sets will be accessible using the Custom Reporting feature within Kony Fabric Console where a business analyst can design and share reports using a combination of standard and custom metrics.
Additionally, the .NET 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 Kony Fabric Console by using the Standard Reports or user defined Custom Reports. For more details, refer to Custom Metrics and Reports Guide.
You must initialize the MetricsService class before using any functionality related to analytics of the app built in .NET SDK.
// Sample code to fetch the metrics service object. Kony.MetricsService metricsSvc; try { metricsSvc = sdkObject.GetMetricsService(); } catch (Exception e) { Console.WriteLine("Invalid Service"); }
This section describes the methods of the Metrics Service.
The ClearFlowTag method clears the set flow tag.
ClearFlowTag();
None
None
// Sample code for ClearFlowTag var metricsServiceObj = servicesOjb.GetMetricsService(); metricsSericeObj.ClearFlowTag();
The FlushEvents method allows a developer to send events collected in buffer form from the device to the server. The entire current event buffer is loaded and sent to the server for processing. The FlushEvents method is used as an override to send event data to the server before the configured value or a service call that flushes the buffer.
FlushEvents()
None
None
//Sample code for FlushEvents var metricsServiceObj = servicesObj.GetMetricsService(); metricsServiceObj.FlushEvents();
The GetFlowTag method gets the set flow tag.
Syntax:
GetFlowTag(flowTag);
None
None
// Sample code for GetFlowTag string getflowtag; var metricsServiceObj = servicesOjb.GetMetricsService(); getflowtag = metricsSericeObj.GetFlowTag();
The ReportError method enables an app to report an error event to metrics server.
ReportError(string errorCode, stsring errorType, string errorMessage, string errorDetails)
errorCode - string. Can be null if not applicable.
errorType - string. Can be null if not applicable.
errorMessage - string. Can be null if not applicable.
errorDetails - json string. This param is a json string that can have key-value pairs for the following keys: errfile, errmethod, errline, errstacktrace, errcustommsg, errcrashreport, formID, widgetID, and flowTag.
//Sample code for ReportError var metricsServiceObj = servicesObj.GetMetricsService() metricsServiceObj.ReportError("1234", "SpecificError", "custom error message", "{errfile:file.js}");
The ReportHandledException method enables apps to report a handled exception event.
ReportHandledException(string exceptionCode, string exceptionType, string ExceptionMessage, string exceptionDetails)
//Sample code to send exception to metrics server var metricsServiceObj = servicesObj.GetMetricsService() metricsServiceObj.ReportHandledException("1234", "SpecificException", "custom exception message", "{errfile:file.js}");
The SendCustomMetrics method allows the developer to send custom metrics from the application. The custom metrics should already be registered in Kony Fabric Console for the application before data is sent from the application.
SendCustomMetrics(formId, reportingData);
formId - string. Specifies the name of the form to which the custom metrics is to be sent. Cannot be more than 250 characters.
reportingData- Dictionary<string, string> of key/value pairs. Key is the custom metric name and value is the value given for that specific instant. For example: Rating, Excellent.
//Sample code for SendCustomMetrics var metricsServiceObj = servicesObj.GetMetricsService(); Dictionary < object, object > reportingData = new Dictionary < object, object > (); reportingData.Add("Rating", "Excellent"); metricsServiceObj.SendCustomMetrics(formId, reportingData);
The SendEvent method 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 method.
//Sample code for SendCustomMetrics var metricsServiceObj = servicesObj.GetMetricsService(); Dictionary < object, object > reportingData = new Dictionary < object, object > (); reportingData.Add("Rating", "Excellent"); metricsServiceObj.SendCustomMetrics(formId, reportingData);//Sample code to send reports var metricsServiceObj = servicesObj.GetMetricsService() string eventSubType = "subTypeSample"; string formID = "sampleFormID"; string widgetID = "sampleWidgetID"; string flowTag = "sampleFlowTag"; JObject metaData = new JObject(); metaData.Add("formdur", "100"); try { metricsServiceObj.SendEvent(EventType.Custom, eventSubType, formID, widgetID, flowTag, metaData); } catch () {}
The SetEventConfig method sets the event config param. Based on the autoFlushCount param, there will be an automatic flush from the device to the server.
SetEventConfig(eventConfigType, autoFlushCount, maxBufferCount);
eventConfigType - sets the current configuration type. Only buffer mode is supported.
autoFlushCount - the number of events to be buffered before a network call is triggered to post the event data to the server. Possible value is any positive integer. Default value is 15.
maxBufferCount - the maximum numnber of event buffers to store the events. Possible value is any positive integer. Default value is 1000.
// Sample code for SetEventConfig int autoFlushCount = 20; int maxBufferCount = 800; try { metricsClient.SetEventConfig(EventConfigType.BUFFER, autoFlashCount, maxBufferCount); } catch (Exception e) {}
The SetFlowTag method sets the flow tag.
SetFlowTag(flowTag);
flowTag - string that specifies the flow tag.
// Sample code for SetFlowTag string flowtag = "SampleFlowTag"; var metricsServiceObj = servicesOjb.GetMetricsService(); metricsSericeObj.SetFlowTag(flowtag);
The SetUserId method sets the user ID.
SetUserId(userid);
userid - string that specifies the user ID.
// Sample code for SetUserId string userid = "SampleUserID"; var metricsServiceObj = servicesObj.GetMetricsService(); metricsServiceObj.SetUserId(userid);
For more details about custom metrics and reports, refer to Custom Metrics and Reports Guide.
For all event details, ts and SID values are automatically filled by MBaaS Client SDK, as part of the reportEvent, reportError and reportHandledException API calls. In case of automatically captured events, flowTag is also automatically filled with the currently set flowTag. Following are event specific details to be used while interfacing with MBaaS SDK.
GESTURETYPE_NUMBEROFINPUTS_DIRECTION
Copyright © 2020 Kony, Inc. All rights reserved. |