How to use the @optimizely/optimizely-sdk/lib/plugins/event_dispatcher/index.node.js.dispatchEvent function in @optimizely/optimizely-sdk

To help you get started, we’ve selected a few @optimizely/optimizely-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github optimizely / javascript-sdk / packages / eet_validation / src / EventDispatcher.ts View on Github external
if (this.config.url) {
      event.url = this.config.url
    }

    event = await (this.config.interactive ? editEvent(event) : Promise.resolve(event))

    if (!event) {
      cli.info('Event is empty; Aborting dispatch')
      return
    }

    cli.action.start('Dispatching event')
    cli.styledHeader('Event')
    cli.styledJSON(event)

    defaultEventDispatcher.dispatchEvent(event, (resp: any) => {
      callback()
      cli.action.stop()
      if (resp) {
        cli.styledHeader('Response')
        cli.styledObject(
          {
            status: resp.statusCode,
            headers: resp.headers
          },
          ['status', 'headers']
        )
      }
    })
  }
}