New to Telerik UI for WPF? Download free 30-day trial

Analytics Support

When you are creating an application for a broad audience, integrating some kind of analytics framework is crucial, because you will need to analyze the usage data of the application and its features and most probably you will need to know about any application crashes or other errors that occurred during the execution. Using analytics you will be able to trace certain features of the controls and get statistics about their usage.

The analytics support is implemented through the TraceMonitor static class and its AnalyticsMonitor. To enable this feature, the ITraceMonitor interface should be implemented and assigned to the TraceMonitor.AnalyticsMonitor property.

Implementing ITraceMonitor

The ITraceMonitor interface provides the following set of methods.

  • TrackAtomicFeature: This method is called when an atomic feature is executed.
  • TrackFeatureStart: This method is called when a feature is initiated.
  • TrackFeatureEnd: This method is called when a feature finishes execution.
  • TrackFeatureCancel: This method is called when a feature is canceled.
  • TrackError: Traces an error in a specified feature.
  • TrackValue: This method is called when a value connected with a specific feature is tracked.

The methods are invoked automatically by some of the Telerik controls (the ones supporting the trace monitor). A different method will be called based on the executed action. For all other cases (where Telerik doesn't automatically call the methods), you can call the methods manually on the corresponding action.

Implementing the ITraceMonitor

public class ApplicationTraceMonitor : ITraceMonitor 
{ 
     public void TrackAtomicFeature(string feature) 
     {            
        // The 'feature' parameter of the methods gives the analytics name of the corresponding control along with the action name. For example, if the analytics name of the control is "MyCloseButton" and the executed action is "Click" you will get "MyCloseButton.Click" as the 'feature'. 
 
        // Send the feature information to the analytics service you are using (example: Google Analytics or similar) 
     } 
 
     public void TrackError(string feature, Exception exception) 
     { 
         // Send the feature information to the analytics service you are using (example: Google Analytics or similar) 
     } 
 
     public void TrackFeatureCancel(string feature) 
     { 
         // Send the feature information to the analytics service you are using (example: Google Analytics or similar) 
     } 
 
     public void TrackFeatureEnd(string feature) 
     { 
         // Send the feature information to the analytics service you are using (example: Google Analytics or similar) 
     } 
 
     public void TrackFeatureStart(string feature) 
     { 
         // Send the feature information to the analytics service you are using (example: Google Analytics or similar) 
     } 
 
     public void TrackValue(string feature, long value) 
     { 
         // Send the feature information to the analytics service you are using (example: Google Analytics or similar) 
     } 
} 
To enable the implemented trace monitor, set the static TraceMonitor.AnalyticsMonitor property.

Setting the TraceMonitor.AnalyticsMonitor

public MainWindow() 
{ 
    TraceMonitor.AnalyticsMonitor = new ApplicationTraceMonitor(); 
    InitializeComponent(); 
} 
TraceMonitor.AnalyticsMonitor = New MyMonitor() 

To include a control in the analytics tracking, set the Analytics.Name attached property on it.

Setting Analytics.Name property

<StackPanel Orientation="Horizontal">  
    <telerik:RadComboBox Width="200" telerik:Analytics.Name="ComboBoxSelection">  
        <telerik:RadComboBoxItem Content="WinUI" />  
        <telerik:RadComboBoxItem Content="WPF" />  
        <telerik:RadComboBoxItem Content="Blazor" />  
        <telerik:RadComboBoxItem Content="WinForms" />  
    </telerik:RadComboBox>  
    <telerik:RadButton telerik:Analytics.Name="SelectButton" Content="Select" />  
</StackPanel> 
In the example above, if you click on the RadButton the TrackAtomicFeature method of the ITraceMonitor will be invoked. The feature string will be "SelectButton.Click". Opening and closing the RadComboBox will call the TrackAtomicFeature method with the feature set to "ComboBoxSelection.DropDownOpened" and "ComboBoxSelection.DropDownClosed". The different Telerik controls will report different actions and may use the other methods of the monitor.

To add a feature tracking outside of the features tracked by default, you can manually call the methods of the ITraceMonitor.

Tracking features manually

private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) 
{ 
    string featureContent = "WPFApplication.Exception"; 
    TraceMonitor.AnalyticsMonitor.TrackError(featureContent, e.Exception); 
} 
 
private void RadPasswordBox_PasswordChanged(object sender, RoutedEventArgs e) 
{ 
    string featureContent = "LoginPasswordBox.PasswordChanged"; 
    TraceMonitor.AnalyticsMonitor.TrackAtomicFeature(featureContent); 
} 

Traceable Features in Telerik Controls

Currently, only a few controls support analytics out of the box. Note that only user interactions will be tracked - initial values and values from bindings are not supported.

Supported controls and features

Feature Action Feature Name
RadBusyIndicator
Show ShowIndicator
RadCalendar
SelectionChanged SelectionChanged
RadCarousel
SelectionChanged SelectionChanged
RadColorEditor
SelectionChanged SelectionChanged
RadColorPicker
SelectionChanged SelectionChanged
RadComboBox
SelectionChanged SelectionChanged
DropDownOpened DropDownOpened
DropDownClosed DropDownClosed
RadContextMenu
Open Opened
Close Closed
Click Click
RadDropDownButton
DropDownOpened DropDownOpened
DropDownClosed DropDownClosed
RadExpander
Expanded Expanded
Collapsed Collapsed
RadGridView
Sort Sorted
Group Grouped
Filter Filtered
SelectionChanged SelectionChanged
RadListBox
SelectionChanged SelectionChanged
RadMenu
Click Click
RadRadioButton
Checked Checked
UnChecked UnChecked
RadRibbonView
SelectionChanged SelectionChanged
RadRichTextBox
Open Document Open Document
Save Document Save Document
Print Print
RadSpreadsheet
Open Document Open Document
Save Document Save Document
Load Image LoadImage
Save Image SaveImage
RadTabControl
SelectionChanged SelectionChanged
RadTileView
SelectionChanged SelectionChanged
RadToggleButton
Checked Checked
UnChecked UnChecked
RadTreeListView
Sort Sorted
Group Grouped
Filter Filtered
SelectionChanged SelectionChanged
RadTreeView
SelectionChanged SelectionChanged
RadVirtualGrid
SelectionChanged SelectionChanged

With the discontinuation of the Telerik Platform as of R2 2018 SP1 we've also removed the two dependent assemblies from our suite - EQATEC.Analytics.Monitor.dll and Telerik.Windows.Analytics.dll. The respective NuGet packages have been removed as well. Instead, the ITraceMonitor interface should be used as explained below.

See Also

In this article