SmartAssembly 7

Setting up feature usage reporting

Feature usage reporting informs you how many times features in your applications are used, and on what computer configurations. For more information, see Reporting feature usage.

To use feature usage reporting with SmartAssembly: 

  1. Add feature usage reporting to your code.
    To do this, either:
    • Add the attribute ReportUsageAttribute to a method.
      The feature usage counter increments each time the method is hit. The method's name is used for the feature name.

    • Add the attribute ReportUsageAttribute(string)to a method or constructor.
      The feature usage counter increments each time the method or constructor is hit. The supplied string is used for the feature name. The string must be created at compile-time.
    • Add UsageCounter.ReportUsage(string)anywhere in your code.
      The feature usage counter increments each time the line of code is hit. The supplied string is used for the feature name. The string can be created at run-time.
  2. Enable feature usage reporting in SmartAssembly.

When you view feature usage reports, you see the usage count recorded for each different feature name. For more information, see Viewing feature usage reports.

You can't use feature usage reporting for assemblies using any version of Windows Phone 7.x XNA, or Xbox XNA.

1. Adding feature usage reporting to your code

Adding ReportUsageAttribute or ReportUsageAttribute(string) to a method or constructor

To add feature usage reporting to your code by using ReportUsageAttribute:

  1. In Visual Studio, add a reference to %ProgramFiles%\Red Gate\SmartAssembly 7\SDK\bin\SmartAssembly.ReportUsage.dll

    For .NET Core applications, you should use .NET Standard version of the SDK assembly, located in: %ProgramFiles%\Red Gate\SmartAssembly 7\SDK\bin\SmartAssembly.ReportUsage_NetStandard.dll

  2. Add ReportUsageAttribute to the methods or constructors that you are interested in.
  3. If necessary, supply a string to name the feature in the feature usage reports:
    • For constructors, you must supply a string.
    • For methods, by default the name of the method is used for the feature name; you can use ReportUsageAttribute(string) to supply an alternative name, if required.
  4. Add ReportUsageAttribute to a method that is called when your application first starts.
    This ensures that the dialog box requesting the user's permission to participate in feature usage reporting appears on startup.

Adding UsageCounter.ReportUsage to your code

To name the feature at runtime, or to report usage of a feature that is not a method or constructor:

  1. In Visual Studio, add a reference to %ProgramFiles%\Red Gate\SmartAssembly 7\SDK\bin\SmartAssembly.ReportUsage.dll

    For .NET Core applications, you should use .NET Standard version of the SDK assembly, located in: %ProgramFiles%\Red Gate\SmartAssembly 7\SDK\bin\SmartAssembly.ReportUsage_NetStandard.dll

  2. Add UsageCounter.ReportUsage(string) to your code where you want the feature reported and supply the string which will be used for the feature's name.
    This string can be created at run-time. However, ensure that the string is not unique; too many different feature names will slow the feature usage reports download.

2. Enabling feature usage reporting in SmartAssembly

To enable feature usage reporting:

  1. To report feature usage, in the Project Settings window, go to Feature Usage Reporting or click the icon in the toolbar.
  2. Select I want my application to report how it is used.
  3. Choose the template to use.
  4. If error reporting is enabled, the Application name, Company name and Project name defined in the Automated Error Reporting settings are also used by feature usage reporting:

If error reporting is not enabled, complete the Application name, Company name and Project name:

When feature usage reporting is enabled, the coloured bars under the toolbar icon and to the left of the features options are green. If it is disabled, the bars are orange.

Standard templates

SmartAssembly provides three standard templates for feature usage reporting.

To ask for end users' consent to participate in feature usage reporting the first time they use the application, choose With consent dialog box on first run.

You can select With consent dialog box on second run to ask for end users' consent the second time they use the application. This is useful if your application has a setup dialog box that is displayed when the program is first installed, and you do not want to display both on the initial run.

If you do not want the user to have control over whether feature usage reports are sent, select Automatic (without dialog box). The reports will be generated and sent automatically.

For .NET Core applications only "Automatic (without dialog box)" template is available. You can use custom templates if you need to provide your own GUI.


Custom template (SmartAssembly Developer and Professional only)

You can select a customised consent dialog box by using a custom feature reporting template. You create the template in Visual Studio using the sample code provided in the SmartAssembly SDK. For details on how to create and enable a custom template, see Feature usage reporting with the SDK.

Sharing feature usage reports

Feature usage reports are stored in the same location as error reports. To share the reports, see Configuring reporting on multiple computers.

Custom web server (SmartAssembly Developer and Professional only)

You can choose to send feature usage reports to your own server instead of the default server operated by Red Gate Software. For details on how to set up a custom web server, see Setting up a custom web server for reporting.


Didn't find what you were looking for?