Windowscommunitytoolkit: [Feature] LaunchTracker API

Created on 1 Sep 2020  路  5Comments  路  Source: windows-toolkit/WindowsCommunityToolkit

Describe the problem this feature would solve

In many apps, it is useful to track app launches for scenarios like:

  • Number of times the app was launched (e.g. to show a review dialog after n launches)
  • The last date the app was launched (e.g. to offer the user some incentive to offer if they didn't launch the app for a longer time)
  • Checking if this is the first launch of the app after a version update (e.g. to show a what's new dialog after update)

Especially the first use case is quite common, and it would help avoid re-writing the same code repeatedly.

Describe the solution

Originally created as a PR to Uno Platform and blogged about it here, but realized it would be useful as a general UWP helper, and Uno would get it via Uno.WindowsCommunityToolkit. The code is partially based on VersionTracking API in Xamarin.Essentials, but includes additional properties.

The current LaunchTracker API has the following API surface:

  • static Current - lazily initializes an instance of LaunchTracker
  • Track() - a "no-op" that can be called to ensure the instance is created
  • IsFirstLaunch - checks if the launch is the first ever
  • IsFirstLaunchForCurrentVersion - checks if the launch is the first for current version
  • IsFirstLaunchForCurrentBuild - checks if the launch is first for current build
  • LaunchCount - number of launches
  • CurrentLaunchDate - current launch date
  • PreviousLaunchDate - previous launch date
  • PreviousLaunchedVersion - previous version that was launched
  • PreviousLaunchedBuild - previous build that was launched
  • FirstLaunchedVersion - first version that was launched
  • FirstLaunchedBuild - first build that was launched
  • CurrentVersion - current package version
  • CurrentBuild - current package build
  • VersionHistory - list of versions that were launched
  • BuildHistory - list of builds that were launched
  • IsFirstLaunchForVersion(version) - checks if this is the first launch for given version
  • IsFirstLaunchForBuild(build) - checks if this is the first launch for given build

Some of the APIs could potentially be removed - like the -Build related ones, I don't expect that functionality to be used too often.

Describe alternatives you've considered

Didn't find similar APIs in WCT, hope I didn't miss something :-) .

Additional context & Screenshots

open discussion question

All 5 comments

Hello, 'MartinZikmund! Thanks for submitting a new feature request. I've automatically added a vote 馃憤 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future!

@MartinZikmund we've had helpers in the Toolkit for a while here in the SystemInformation class.

I'm pretty sure these are also ported as part of the Uno fork of the Toolkit here.

Is there anything we're missing that we can unify on here in the Toolkit instead?

Ha :-D ! How did I miss that :-D ?!

What could be added there would be the version history, but since everything else is in place, that probably does not bring that much value.

@michael-hawker Also time to update my blogpost with this newfound knowledge then 馃榾 .

@MartinZikmund no worries! I think the toolkit's gotten to the point where it's probably impossible for one person to know everything that's in it! 馃構

My go to guidance is usually just 'check the toolkit first' now. 馃檪 However, if this was hard to find, we should probably open up an issue on our docs repo and figure out how we can optimize the article here, I could pull in some docs folks over there. Maybe add some info in it like what type of search queries you tried.

Was this page helpful?
0 / 5 - 0 ratings