add version to tracking header

This commit is contained in:
Benedikt Rötsch
2017-10-04 17:38:13 +02:00
committed by Benedikt Rötsch
parent cf2101b27b
commit d2493528ae

View File

@@ -4,18 +4,19 @@ let cdaClient = null
let cpaClient = null let cpaClient = null
exports.initClient = (options) => { exports.initClient = (options) => {
const { version } = require('../package.json')
const config = options || { const config = options || {
space: process.env.CF_SPACE, space: process.env.CF_SPACE,
cda: process.env.CF_ACCESS_TOKEN, cda: process.env.CF_ACCESS_TOKEN,
cpa: process.env.CF_PREVIEW_ACCESS_TOKEN cpa: process.env.CF_PREVIEW_ACCESS_TOKEN
} }
cdaClient = createClient({ cdaClient = createClient({
application: 'contentful.the-example-app.node', application: `contentful.the-example-app.node/${version}`,
space: config.space, space: config.space,
accessToken: config.cda accessToken: config.cda
}) })
cpaClient = createClient({ cpaClient = createClient({
application: 'contentful.the-example-app.node', application: `contentful.the-example-app.node/${version}`,
space: config.space, space: config.space,
accessToken: config.cpa, accessToken: config.cpa,
host: 'preview.contentful.com' host: 'preview.contentful.com'