How-to: Activate the KPIs & Alerting feature

To active the /wiki/spaces/EN/pages/98897520 on your app, all the configuration steps described below must completed. 




1. Configuring MnoHub!

  1. **The app must be connected to a KPI enabled tenant. A KPI enabled tenant with the following metadata attribute:

    tenant[:metadata][:kpi_enabled] = true

    ** Note this switch is only relevant to v1 dashboard KPIs (v2 widget KPIs are unaffected by this).

2. Configuring Connec!

  1. A Connec! Webhook needs to be created, this can be done by /wiki/spaces/DEV/pages/90439768 or by directly creating one via the Rails Console (the object name is 'Entity::Webhook')

    1. It is important that the Webhook object is configured with the correct tenant / master tenant credentials (as api_key & api_secret) and the relevant Impac! API endpoint.

    2. The Webhook must be subscribed to receive "Journals", but currently the recommended entity subscriptions are "Accounts", "Journals", "Company", "Invoices", "Contacts" (pluralized entity names).

    3. The Webhook must have detailed_notifications set to true
    4. Setting the Webhook period to 0 will make webhooks run in real-time, which can be handy for development so you don't have to wait 60 seconds for notifications to batch, and be sent. 
# An example of a valid webhook configured for Impac! KPIs & Alerting
<Entity::Webhook _id: 5a980040d2ef70cccdc94b89, name: "Impac v2", endpoint: "http://localhost:4000/api/v2/maestrano/finance/notifications", api_key: "tenant_key", api_secret: "tenant_secret", detailed_notifications: true, subscribed_entities: ["Accounts", "Journals", "Company", "Invoices", "Contacts"], period: 0, max_size: 60, timeout: 5>


3. Configuring Impac!

  1. Update your Bolt with the relevant subscribed_entities 

    b = Bolt.find(an_id)
    # Snake-case & pluralised connec! entity names
    b.subscribed_entities = ["accounts", "journals", "companies", "invoices", "contacts"]
  2. Pusher (websockets service) & Sparkpost (email delivery service) keys are configured in Impac! API (config/application.yml):

    SPARKPOST_API_KEY: 'CHANGEME'
    PUSHER_APP_ID: 'CHANGEME'
    PUSHER_KEY: 'CHANGEME'
    PUSHER_SECRET: 'CHANGEME'
  3. Add Maestrano Master Tenant (SystemIdentity) credentials to Impac! API (config/application.yml). This is used as the basic authentication when Impac! queries MnoHub to retrieve KPIs.

    ROOT_KEY: YOUR_ROOT_KEY
    ROOT_SECRET: YOUR_ROOT_SECRET

4. Configuring the Frontend (Express / MnoEnterprise Angular)

  1. Impac! Angular needs to be provided with a Pusher Key to connect to the Pusher websockets service from the client. There are 2 ways to do this:
    1. MnoEnterprise Angular now provides this automatically to Impac! Angular by passing an environment variable configured in Nex! or the MnoEnterprise Express application.

      impac_pusher_key: PUSHER_KEY
    2. Manually by configuring the Impac! Angular ImpacLinkingSvc

      // Link required and optional data in on sweep.
      ImpacLinkingSvc.linkData({ user: ..., organizations: ..., pusher_key: 'KEY' })
      // OR:
      ImpacLinkingSvc.linkOptionalData({pusher_key: 'KEY'})


  2. Configured Impac! Angular's Theming Provider, enabling the feature.

    options = {
      	dhbKpisConfig:
        	enableKpis: true
    	alertsConfig:
    		enableAlerts: true
    }
    
    ImpacTheming.configure(options)