Browse Source

Fix experimentId and userId not transmitted

rigwild 10 months ago
parent
commit
64ebe15a51
3 changed files with 12 additions and 10 deletions
  1. 7 2
      server/routes/experimentCollect.js
  2. 4 6
      src/store/actions.js
  3. 1 2
      src/views/HostConfig.vue

+ 7 - 2
server/routes/experimentCollect.js

@@ -50,14 +50,19 @@ router.post('/', asyncMiddleware(async (req, res) => {
   const b = req.body
   checkRequiredParameters(['msgId', 'msg'], b)
 
-  const { msgId, msg } = req.body
+  const {
+    msgId,
+    msg,
+    userId = null,
+    experimentId = null
+  } = req.body
 
   // Check there is no errors with parameters
   if (typeof b.msgId !== 'string')
     throw boom.badRequest('Invalid body parameter(s).', ['"msgId" must be a string.'])
 
   // Add data to the database
-  if (!TEST_MODE) await DataController.add({ msgId, msg })
+  if (!TEST_MODE) await DataController.add({ msgId, msg, userId, experimentId })
 
   res.status(204).send()
 }))

+ 4 - 6
src/store/actions.js

@@ -2,11 +2,9 @@ import router from '../router'
 import { API_ROUTES, serialize } from '../functions'
 
 export default {
-  setGdprValidated({ state, commit }) {
-    if (!state.gdprConsent) {
-      commit('setGdprValidated')
-      router.push('/hostConfig')
-    }
+  setGdprValidated({ commit }) {
+    commit('setGdprValidated')
+    router.push('/hostConfig')
   },
 
   setAppUniqueId({ state, commit }) {
@@ -22,7 +20,7 @@ export default {
   },
 
   async setHostConfig({ commit, dispatch }, hostConfig) {
-    // Timeout after 1s
+    // Timeout after 1.5s
     const controller = new AbortController()
     const signal = controller.signal
     setTimeout(() => controller.abort(), 1500)

+ 1 - 2
src/views/HostConfig.vue

@@ -129,13 +129,12 @@ export default {
       this.loadingMessage = 'Checking host configuration...'
       this.configErrorMessage = null
       try {
-        await this.setHostConfig(this.hostConfig)
         this.setUserExperimentId({ userId: this.id.user, experimentId: this.id.experiment })
+        await this.setHostConfig(this.hostConfig)
       }
       catch (err) {
         console.error(err)
         this.configErrorMessage = err.message
-        return
       }
       finally {
         this.loadingMessage = null