How to create a statistic hit?
To create a statistic hit, you will need to get JSON Schema for one of the supported statistic hit type :
- CONNECTION: user connection
- DOWNLOAD: media download
- PLAY: video play
- SEARCH: medias search
- UPLOAD: media upload
- VIEW: media display
1 - Search for JSON Schema corresponding to hit you want to send GET /api/stat/hit-types/CONNECTION/schema
.
Some properties are shared among all statistic hit types:
- date: hit date that corresponds to time of action
- type: fixed hit type value for a given hit type (CONNECTION for connections hits)
- origin: user interface identifier generating statistic hit, user interface are available in resource
GET /api/dam/user-interfaces
, for third party application use -1 value. You can use X-KPK-CLIENT-ID header instead of this field. Origin filed or X-KPK-CLIENT-ID header is required. - sessionId: unique id to track a session, it must be a randomly generated value and cannot be a user identifier
- ip: IP address of user generating statistic hit
- referrer: full referrer path of user while accessing the application
Other properties are generic ones that may be found in various statistic hit types:
- users: list of user generating statistic hit, it may be user identifier available in users resource
GET /api/dam/users
. In anonymous access, application may ask user information to perform an action like downloading a media. In this case, user first name, last name and e-mail address may be send instead of user identifier. This property corresponds to following information in hit types:- CONNECTION: user performing a connection
- DOWNLOAD: user downloading a media
- PLAY: user playing a video
- SEARCH: user performing a search
- UPLOAD: user uploading a media
- VIEW: user displaying a media
- medias: list of medias to associate with statistic hit, it is a list of media identifier. This property corresponds to following information in hit types:
- DOWNLOAD: list of downloaded medias
- PLAY: video medias played
- UPLOAD: uploaded medias
- VIEW: displayed medias
- folders: list of folders associated to statistic hit. This property corresponds to following information in hit types:
- SEARCH: if folder search, folder identifier where search have been performed
Other properties are specific for a given statistic hit type :
- connection:
- mode: connection mode
- CLASSIC: user and password connection
- SSO: access using SSO
- ANONYMOUS: anonymous access
- success: indicates it connection have succeed
- mode: connection mode
- download:
- usage: usage of media if asked to user (optional)
- formatIds: list of export format identifier (optional)
- play: video play
- socialNetwork: social network name generating play event (optional)
- duration: video duration played in seconds (cannot exceed video length)
- ranges: list of played video range with range start time and end time in seconds. For example, if a user play a video from second 0 to 5 and then jumps to second 20 to play 10 seconds more, then ranges should be {"start": 0, "end": 5} and {"start": 20, "end": 30}
- search:
- resultCount: number of media returned by search
- searchType: search type performed by user, possible values are:
- TEXT: text search
- FOLDER: folder tree search
- ADVANCED: advanced search
- upload:
- contributionSpaceType: contribution space type
- FOLDER: upload in a folder
- WALL: upload in import wall
- BASKET: upload in a basket
- contributionSpaceId: folder identifier or basket identifier
- contributionSpaceType: contribution space type
2 - Create a statistic hit with request matching JSON Schema :
POST /api/stat/hits
Content-Type: application/json
{
"date": "2020-07-15T10:00:00",
"type": "CONNECTION",
"origin": 0,
"sessionId": "7e7f6d22f75d2cc4b9ed5fe907dd7461",
"ip": "127.0.0.1",
"users": [
{
"userId": "1"
}
],
"connection": {
"mode": "CLASSIC",
"success": true
}
}
A HTTP OK code indicates success of hit creation.