From ab3c3ddfc531c8a3354632adb9a80c1a074e9653 Mon Sep 17 00:00:00 2001 From: Tim Needham Date: Sat, 23 Feb 2019 18:33:24 +0000 Subject: [PATCH] feat: Wire-in some startup timestamps via new Info API. --- lib/Logs.js | 2 +- lib/TymlySDK.js | 12 +++++++----- test/tests.js | 17 +---------------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/Logs.js b/lib/Logs.js index ab41ea8f..a56b203f 100644 --- a/lib/Logs.js +++ b/lib/Logs.js @@ -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) */ diff --git a/lib/TymlySDK.js b/lib/TymlySDK.js index 92b2b209..96a144bd 100644 --- a/lib/TymlySDK.js +++ b/lib/TymlySDK.js @@ -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 @@ -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 } @@ -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: {}, @@ -122,6 +123,7 @@ module.exports = class TymlyClient { }, token: this.options.auth.token }) + this.info.set('lastUserQueryEnd', new Date().toISOString()) return { ...remit.ctx.userRemit, diff --git a/test/tests.js b/test/tests.js index 8baf5583..8ad50653 100644 --- a/test/tests.js +++ b/test/tests.js @@ -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 () => {