(context?: Omit<SessionContext, 'started' | 'status'>)
| 11 | * @returns a new `Session` object |
| 12 | */ |
| 13 | export function makeSession(context?: Omit<SessionContext, 'started' | 'status'>): Session { |
| 14 | // Both timestamp and started are in seconds since the UNIX epoch. |
| 15 | const startingTime = timestampInSeconds(); |
| 16 | |
| 17 | const session: Session = { |
| 18 | sid: uuid4(), |
| 19 | init: true, |
| 20 | timestamp: startingTime, |
| 21 | started: startingTime, |
| 22 | duration: 0, |
| 23 | status: 'ok', |
| 24 | errors: 0, |
| 25 | ignoreDuration: false, |
| 26 | toJSON: () => sessionToJSON(session), |
| 27 | }; |
| 28 | |
| 29 | if (context) { |
| 30 | updateSession(session, context); |
| 31 | } |
| 32 | |
| 33 | return session; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Updates a session object with the properties passed in the context. |
no test coverage detected