function createContentfulClientOptions({
  pluginConfig,
  reporter,
  syncProgress = { total: 0, tick: a => a },
}) {
  let syncItemCount = 0

  const contentfulClientOptions = {
    space: pluginConfig.get(`spaceId`),
    accessToken: pluginConfig.get(`accessToken`),
    host: pluginConfig.get(`host`),
    environment: pluginConfig.get(`environment`),
    proxy: pluginConfig.get(`proxy`),
    integration: `gatsby-source-contentful`,
    responseLogger: response => {
      function createMetadataLog(response) {
        if (!response.headers) {
          return null
        }
        return [
          response?.headers[`content-length`] &&
            `size: ${response.headers[`content-length`]}B`,
          response?.headers[`x-contentful-request-id`] &&
            `request id: ${response.headers[`x-contentful-request-id`]}`,
          response?.headers[`x-cache`] &&
            `cache: ${response.headers[`x-cache`]}`,
        ]
          .filter(Boolean)
          .join(` `)
      }

      // Sync progress
      if (
        response.config.url === `sync` &&
        !response.isAxiosError &&
        response?.data.items
      ) {
        syncItemCount += response.data.items.length
        syncProgress.total = syncItemCount
        syncProgress.tick(response.data.items.length)
      }

      const metadataLog = createMetadataLog(response)

      reporter.verbose(
        [
          `${response.config.method} /${response.config.url}:`,
          response.status,
          response.statusText,
          metadataLog && `(${metadataLog})`,
        ]
          .filter(Boolean)
          .join(` `)
      )
    },
    // Allow passing of custom configuration to the Contentful SDK like headers
    ...(pluginConfig.get(`contentfulClientConfig`) || {}),
  }

  return contentfulClientOptions
}
Parse stringified error data from message
https://github.com/contentful/contentful-sdk-core/blob/4cfcd452ba0752237a26ce6b79d72a50af84d84e/src/error-handler.ts#L71-L75

@todo properly type this with TS
type {
   status?: number
   statusText?: string
   requestId?: string
   message: string
   !details: Record<string, unknown>
   !request?: Record<string, unknown>
 }