Implement usage reporting

Application usage statistics are one of the key factors affecting the amount of revenue you obtain. Therefore, we implemented event-based reporting of application usage. Setapp Framework detects events related to the usage of an application and accumulates them in reports, which are sent to the Setapp server once a day. At the end of the month, all reports from every user account get processed to split the payments between the apps that were used.

πŸ“˜

Note

We do not take into account the number of usages of a particular app per month. The terms of revenue distribution are equal for apps used only once and for apps used daily. Read more in Distributing revenue.

Depending on the type of application, Setapp needs to detect different events and their combinations. We distinguish the following types of apps:

  • Regular application (runs in a separate window and requires no additional authorization)
  • App that requires sign-in to give access to its functionality
  • App that operates as a menu bar extra

Most of the events are detected automatically and are common for all types of applications. These events include:

  • launch β€” sent on the launch of the application
  • terminate β€” sent when the application is shut down
  • activate β€” sent when the application window becomes frontmost
  • deactivate β€” sent when the application stops being frontmost
  • heart-beat-active β€” sent periodically when the application is running as the frontmost one
  • heart-beat-inactive β€” sent periodically when the application is running in the background

However, applications with obligatory sign-in and menu bar extras must report additional usage events due to the specifics of their functioning.

For example, an app gives access to its main functionality only after signing in. It means that a user won't get any value after simply launching this app. Thus, receiving the launch event isn't enough to consider the app used. That's why Setapp counts the sign-in event as a fact of usage. In this example, detection of the sign-in event is configured manually, and it is sent repeatedly to cover cases when a user keeps your app open.

Reporting of events that are specific for menu bar extras and applications with obligatory sign-in must be implemented manually.

πŸ“˜

Note

Skip the configuration steps described below if your application belongs neither to applications that require sign-in nor to apps that function as menu bar extras.

To implement the reporting functionality, insert SCReportUsageEvent function calls with the following event types (all appropriate cases must be covered):

  • For apps that require authorization:

    • .signIn (STPUsageEventSignIn in ObjC) – send this event repeatedly right after a user has signed in to your application or right after the app launch if a user is already signed in.
    • .signOut (STPUsageEventSignOut in ObjC) – send this event right after a user has signed out from your application.
  • For menu bar apps:
    * .userInteraction (STPUsageEventUserInteraction in ObjC) – send this event right after a user has activated your app by clicking on its icon in the menu bar.

For example:​

// For example, this method is called when a user successfully signed in.
// Just add the SCReportUsageEvent function call with an appropriate "sign-in" event to this method.
- (void)yourSigninCompletionHandler
{
    ...
    [[STPManager sharedInstance] reportUsageEvent:STPUsageEventSignIn];
}


// This method is called after successful sign-out.
// Likewise, add the SCReportUsageEvent function call with the "sign-out" argument.
- (void)yourSignoutCompletionHandler
{
    ...
    [[STPManager sharedInstance] reportUsageEvent:STPUsageEventSignOut];
}

// This method is called when user interacts with menubar app.
- (void)yourUserInteractionCompletionHandler
{
    ...
    [[STPManager sharedInstance] reportUsageEvent:STPUsageEventUserInteraction];
}
// For example, this method is called when a user successfully signed in.
// Just add the SCReportUsageEvent function call with an appropriate "sign-in" event to this method.
func yourSigninCompletionHandler() {
    ...
    SetappManager.shared.reportUsageEvent(.signIn)
}

// This method is called after successful sign-out.
// Likewise, add the SCReportUsageEvent function call with the "sign-out" argument.
func yourSignoutCompletionHandler() {
    ...
    SetappManager.shared.reportUsageEvent(.signOut)
}

// This method is called when user interacts with menubar app.
func yourUserInteractionCompletionHandler() {
    ...
    SetappManager.shared.reportUsageEvent(.userInteraction)
}