diff --git a/app.js b/app.js index 400e6a0..e0956ae 100644 --- a/app.js +++ b/app.js @@ -94,7 +94,7 @@ app.use(catchErrors(async function (request, response, next) { const space = await getSpace() // Update credentials in cookie when space connection is successful - updateCookie(response, SETTINGS_NAME, settings) + updateCookie(response, SETTINGS_NAME, response.locals.settings) // Get available locales from space response.locals.locales = space.locales diff --git a/lib/settings.js b/lib/settings.js index a20396e..d03daaa 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -36,9 +36,6 @@ module.exports = async function settingsMiddleware (request, response, next) { } /* eslint-enable camelcase */ - // The space id needs to be available in the frontend for our example app - response.cookie('space_id', settings.spaceId) - initClients(settings) response.locals.settings = settings next() diff --git a/views/tracking.pug b/views/tracking.pug index b3098ff..2958ae3 100644 --- a/views/tracking.pug +++ b/views/tracking.pug @@ -28,12 +28,10 @@ script(async). snowplow('enableLinkClickTracking') - const space_id = decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent('space_id').replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; - snowplow('trackSelfDescribingEvent', { schema: 'iglu:com.contentful/app_the_example_app_open/jsonschema/1-0-0', data: { - space_id, + space_id: '#{settings.spaceId}', sdk_language_used: 'javascript', app_framework: 'nodejs' }