function ownstatsPlugin(pluginConfig) {
  // Initialize segment client
  const ownstatsConfig = {
    ...pluginConfig
  }
  const client = new OwnstatsClient(ownstatsConfig.endpoint)
  return {
    name: 'ownstats',
    config: ownstatsConfig,
    /* page view */
    page: ({ payload }) => {
      let host
      // Derive host (with eventual port number)
      const hostWithPort = payload.properties.url
        .replace('https://', '')
        .replace('http://', '')
        .split('/')[0]
      // Derive host
      if (hostWithPort.split(':').length === 2) {
        host = hostWithPort.split(':')[0]
      } else {
        host = hostWithPort
      }
      const data = {
        t: 'pv',
        ts: payload.meta.timestamp,
        u: payload.properties.url,
        hn: host,
        pa: payload.properties.path,
        iw: payload.properties.width,
        ih: payload.properties.height,
        ti: payload.properties.title
      }
      client.send(data)
    }
  }
}
Ownstats analytics plugin
@link https://getanalytics.io/plugins/ownstats/
@link https://ownstats.cloud
@param {object}  pluginConfig - Plugin settings
@param {string}  pluginConfig.endpoint - Your Ownstats endpoint
@return {object} Analytics plugin
@example

ownstatsPlugin({
  endpoint: 'my.ownstats.cloud'
})