You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hf-data/tutorial.md
+30-71Lines changed: 30 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
You can try the live version of the app [here](link-to-gh-pages).
5
5
6
-
All you need to run this app is to download [index.html](index.html), [script.js](script.js) files, [js/](js) and [assets](assets) folders and open **index.html** with your browser.
6
+
All you need to run this app is to download [index.html](index.html), [script.js](script.js) files, [js/](js) and [assets](assets) folders and open [index.html](index.html) with your browser.
7
7
8
8
This is a data collection and sharing web app that first displays a welcome message and a button to initiate the authentication process.
9
9
<palign="center">
@@ -44,7 +44,7 @@ The sharing link enables the recipient to consult the list of trackings, along w
44
44
45
45
## Authenticate your app
46
46
47
-
For this application, we have used the [Pryv JavaScript library](https://github.com/pryv/lib-js), loading it for [the browser](https://github.com/pryv/lib-js#browser) as following:
47
+
For this application, we have used the [Pryv JavaScript library](https://github.com/pryv/lib-js), loading it for [the browser](https://github.com/pryv/lib-js#browser) as following in [index.html](index.html):
@@ -56,86 +56,43 @@ For authentication, we will use the [Pryv.io consent process](https://github.com
56
56
<spanid="pryv-button"></span>
57
57
```
58
58
59
-
The [auth request parameters](https://api.pryv.com/reference/#auth-request) and callback are defined in the separate [script.js](script.js) file:
59
+
The [auth request parameters](https://api.pryv.com/reference/#auth-request) and callback are defined in the separate [connection.js](js/connection.js) file:
The root stream of the `requestedPermissions` array is created if it doesn't exist yet. It will then be populated with events data from the tracking test.
83
+
The root stream "**HF**" of the `requestedPermissions` array is created if it doesn't exist yet. It will then be populated with events data from the tracking test.
98
84
99
85
The auth request is done on page load, except when the shared data is loaded by a third-party.
100
86
101
87
## Collect HF data
102
88
103
89
Data collected from the mouse movement (desktop version) or device orientation (accelerometer version) will be stored in the form of [HF series](https://api.pryv.com/reference/#data-structure-high-frequency-series) which are collections of homogenous data points in Pryv.io.
104
90
105
-
```javascript
106
-
var pryvHF = {
107
-
pryvConn:null,
108
-
measures: {
109
-
mouseX: {
110
-
event:null,
111
-
buffer: []
112
-
},
113
-
mouseY: {
114
-
event:null,
115
-
buffer: []
116
-
},
117
-
orientationGamma: {
118
-
event:null,
119
-
buffer: []
120
-
},
121
-
orientationBeta: {
122
-
event:null,
123
-
buffer: []
124
-
},
125
-
orientationAlpha: {
126
-
event:null,
127
-
buffer: []
128
-
}
129
-
}
130
-
131
-
};
132
-
```
133
-
134
91
### Collect HF data using the Desktop version
135
92
136
93
Once the user is signed in (Desktop version), he can perform the test using the mouse tracker. The code for the mouse tracker is contained in the file [desktop.js](./js/desktop.js).
137
-
138
94
Data collected from the mouse movement (X and Y positions) will be stored in the form of [HF series](https://api.pryv.com/reference/#data-structure-high-frequency-series) in a dedicated stream.
95
+
139
96
Connection with Pryv is established to store collected measures in the stream "**HF demo**" (see file [connection.js](js/connection.js)):
140
97
```javascript
141
98
asyncfunctionsetupStreamStructure(connection) {
@@ -157,7 +114,7 @@ async function setupStreamStructure(connection) {
157
114
resultHandlers.push(null);
158
115
}
159
116
```
160
-
As both X and Y positions will be captured during the recording, two substreams are created - "**Mouse-X**" and "**Mouse-Y**" - to hold events related to measured positions:
117
+
As both X and Y positions will be captured during the recording, two substreams "**Mouse-X**" and "**Mouse-Y**" are created to hold events related to measured positions:
161
118
```javascript
162
119
if (!hasDesktopStream) {
163
120
apiCalls.push(
@@ -248,8 +205,9 @@ function sendHfPoints(connection, measures) {
248
205
249
206
The tracking task is also available in a mobile version that allows to collect the device orientation in three dimensions. The code for the mobile accelerometer is contained in the file [mobile.js](js/mobile.js).
250
207
251
-
Similarly as for the [Desktop version](#collect-hf-data-using-the-desktop-version), connection with Pryv is established to store collected measures in the stream "**HF demo**" (see [connection.js](js/connection.js)).
252
-
In the mobile version, as three different angles will be captured during the recording, three substreams are created - "**Orientation-Alpha**", "**Orientation-Beta**" and "**Orientation-Gamma**" - to hold events related to measured angles:
208
+
Similarly as for the [Desktop version](#collect-hf-data-using-the-desktop-version), connection with Pryv is established to store collected measures in the stream "**HF demo**" (see [connection.js](js/connection.js)).
209
+
210
+
In the mobile version, as three different angles will be captured during the recording, three substreams "**Orientation-Alpha**", "**Orientation-Beta**" and "**Orientation-Gamma**" are created to hold events related to measured angles:
253
211
254
212
```javascript
255
213
if (!hasMobileStream) {
@@ -360,7 +318,7 @@ function sendHfPoints(connection, measures) {
360
318
361
319
Once data from the tracking task has been collected, the app is designed to allow the user to share his data with a third-party.
362
320
363
-
The functions from the file [sharing.js](hf-data/js/sharing.js) enable the user to create a sharing that consists of a URL link with a Pryv apiEndpoint that displays the visualization from the tracking test.
321
+
The functions from the file [sharing.js](hf-data/js/sharing.js) enable the user to create a sharing that consists of a URL link (with a Pryv API endpoint) that displays the visualization from the tracking test.
364
322
365
323
In order to create a sharing, we add a listener to the *Create* button:
366
324
@@ -371,7 +329,7 @@ function buildSharing() {
371
329
}
372
330
```
373
331
374
-
The *sharing* is translated into the creation of a [shared access](https://api.pryv.com/concepts/#accesses) in Pryv.io. Values for the scope of the sharing ('streamId' and 'level' for permissions) are fetched, in our case "read" level on the stream "**HF Demo**":
332
+
The sharing is translated into the creation of a [shared access](https://api.pryv.com/concepts/#accesses) in Pryv.io. Values for the scope of the sharing ('streamId' and 'level' for permissions) are fetched, in our case "read" level on the stream "**HF Demo**":
375
333
376
334
```javascript
377
335
asyncfunctioncreateSharing() {
@@ -444,16 +402,17 @@ async function deleteSharing(accessId) {
444
402
445
403
## Display the sharing (view-only mode)
446
404
447
-
Once the sharing has been created, it should enable third parties to consult data from the user in a "view-only" mode. In this mode, a table containing all performed tests is displayed, along with the date of the test and the tracking method.
Once the sharing has been created, it should enable third parties to consult data from the user in a "view-only" mode. In this mode, a table containing all performed tests is displayed, along with the date of the test and the tracking method.
The recipient of the link can open the data visualization by clicking on the chosen test:
451
410
- the **Desktop version** contains the drawing performed with the mouse tracker
452
411
- the **Mobile version** displays the recording of the phone orientation
453
412
454
413
The code for the visualization mode is contained in the [js/view_only.js](js/view_only.js).
455
414
456
-
This will load the app already authenticated, by passing the `pryvApiEndpoint` parameter in the function *buildVisualizationOnly(apiEndpoint, urlParams)*.
415
+
This will load the app already authenticated, by passing the `apiEndpoint` parameter in the function buildVisualizationOnly(apiEndpoint, urlParams).
0 commit comments