Skip to content

Commit

Permalink
feat: Wire-in some startup timestamps via new Info API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Needham committed Feb 23, 2019
1 parent eb3c092 commit ab3c3dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/Logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const LOG_LEVELS = ['FATAL', 'ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE']
module.exports = class Logs {
/**
* Constructor for Logs class, instantiated within the constructor for Tymly SDK. Inspired by https://www.tutorialspoint.com/log4j/log4j_logging_levels.htm
* @param {Client} client Instance of Tymly SDK to talk to
* @param {object} client Instance of Tymly SDK to talk to
* @example
this.logs = new Logs(this)
*/
Expand Down
12 changes: 7 additions & 5 deletions lib/TymlySDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const USER_QUERY_KEYS = [
module.exports = class TymlyClient {
constructor (options) {
this.options = options
const {indexedDB, IDBKeyRange} = options.globalVars
this.db = database({indexedDB, IDBKeyRange})
const { indexedDB, IDBKeyRange } = options.globalVars
this.db = database({ indexedDB, IDBKeyRange })
this.info = new Info(this)
options.auth.init(this)

this.logs = new Logs(this)
this.route = new Route(this)
this.ready = false
Expand All @@ -38,12 +38,12 @@ module.exports = class TymlyClient {
@returns {object} Returns the UUID.
*/
async init (options) {
this.info = new Info(this)
this.info.set('lastInitStart', new Date().toISOString())
const initOptions = options || {}
const userQueryStrategy = initOptions.userQueryStrategy || 'onlyIfNoTemplates'

if (!this.options.auth.token) {
const {value} = await this.db.auth.get('token')
const { value } = await this.db.auth.get('token')
this.options.auth.token = value
}

Expand Down Expand Up @@ -101,6 +101,7 @@ module.exports = class TymlyClient {
* Gets user query from server.
*/
async getUserQuery () {
this.info.set('lastUserQueryStart', new Date().toISOString())
const watching = await this.executions.execute({
stateMachineName: 'tymly_getWatchedBoards_1_0',
input: {},
Expand All @@ -122,6 +123,7 @@ module.exports = class TymlyClient {
},
token: this.options.auth.token
})
this.info.set('lastUserQueryEnd', new Date().toISOString())

return {
...remit.ctx.userRemit,
Expand Down
17 changes: 1 addition & 16 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,7 @@ describe('Info tests', function () {

it('should get all info in an array', async () => {
const value = await sdk.info.getAll()
expect(value).to.eql(
[
{
id: 'name',
value: 'Marge Simpson'
},
{
id: 'details',
value: {
alive: true,
age: 36,
hairColor: 'Blue'
}
}
]
)
expect(value.length).to.be.gt(2)
})

it('should delete by id', async () => {
Expand Down

0 comments on commit ab3c3dd

Please sign in to comment.