Technical Documentation_Logging - super-idesign/designpatternrecognizer Wiki

When this extension is used (if the option is turned on, it is turned off by default) some data is logged.

This is done for future research. Currently, only Build events (build, rebuild, clean, deploy solution/project) are being logged. The data which gets added to the database is an action, this contains:

-The ID of the action

-A session Guid (this currently will always be the same session, as no actions that start a session are logged yet)

-The time during which the action happened

-The specific action type (so currently build, rebuild, clean or deploy solution/project)

-The mode which is being used (currently Default or StepByStep)



To create the database, type "update-database" in the package manager console (have default and starting project as LoggingAPI).

API endpoints

POST /api/Logging/Sessions

Adds a session to the database

Request body:

	extensionVersion*		integer($int32)
	startSession*	        string($date-time)
	endSession		        string($date-time)
	timeZone*	    	    integer($int32)

PUT /api/Logging/Sessions/EndSession/{id}

Ends a session (so adds an endSession (which is a datetime) to the session)

Put the id of the session which is ending in the path, and in the query put a date-time string.

POST /api/Logging/Actions

Adds an Action to the Database

Request body:

	commitID		string (nullable)
	exerciseID		integer($int32)
	time*	        string($date-time)
	sessionID*		string($uuid)
	actionTypeID*	string
	modeID*	        string

POST /api/Logging/ActionTypes

Adds an actiontype to the database

Request body:

	id*		string

(the id is also the name, so for example for a test action, the id would be "Test")

POST /api/Logging/Modes

Adds a mode to the database

Request body:

	id*		string

(the id is also the name)

POST /api/Logging/ExtensionErrors

Adds an extension error to the database (this is for logging errors caused by the extension)

Request body:

	message	        string (nullable)
	actionID*		integer($int32)

PUT /api/Logging/ExtensionErrors/{id}

Updates information in an extension error entity

Request body:

	id*			integer($int32)
	message		string (nullable)
	actionID*	integer($int32)


To recognize when a user builds, rebuilds, cleans or deploys a solution or project we use BuildEvents. There are multiple BuildEvents we can use but currently we only use the OnBuildDone event. This event fires everytime a user executes one of the above mentioned actions.

The OnBuildDone event uses the BuildEvents Interface that's in the EnvDTE namespace. Before you can use the EnvDTE namespace you first have to make an DTE object. This can be done by using the GetService(Type serviceType) method and cast that to an DTE object. An example:

DTE dte = (DTE)GetService(typeof(DTE));

Do note that you can only get a valid DTE object in a class that implements or inherits a Package or AsyncPackage.


The SubcribeBuildEvents class handles the implementation of the OnBuildDone event. The implementation consists of two steps:

  1. The method that will be executed when the event fires
private static async void BuildEvents_OnBuildDone(EnvDTE.vsBuildScope Scope, EnvDTE.vsBuildAction Action) {
    if (package.DoLogData) {
        try { await LoggingApiClient.PostActionAsync(Action); }
        catch (Exception ex) { }
  1. The subscription to the eventhandler
dte.Events.BuildEvents.OnBuildDone += BuildEvents_OnBuildDone;

When adding a new BuildEvent the same steps can be followed.