This code is currently written for Sitecore 9.0 Initial Release. There is a tag for version 8.2 update 4.
The analytics DTO exposes the current user's profile data in a JSON format.
There are two APIs available:
Outputs the aggregation of the user's profile.
Clears the user's session is Sitecore. This has the same effect as timing the user's sessions out. This causes the session to be written to Mongo.
An example of the output https://gist.github.com/dnstommy/734691e550b2578c4335a292b5ff15ca
Pull the version from releases that matches your version. Install as an update package.