import { posthogHelper } from '@botpress/common'
import { INTEGRATION_NAME, INTEGRATION_VERSION } from 'integration.definition'
import actions from './actions'
import channels from './channels'
import { register, unregister } from './setup'
import { handler } from './webhook'
import * as bp from '.botpress'

const integrationConfig: bp.IntegrationProps = {
  register,
  unregister,
  actions,
  channels,
  handler,
}

export default posthogHelper.wrapIntegration(
  {
    integrationName: INTEGRATION_NAME,
    key: bp.secrets.POSTHOG_KEY,
    integrationVersion: INTEGRATION_VERSION,
    rateLimitByFunction: { handler: 1 / 1000 },
  },
  integrationConfig
)
