Pusher is a hosted service that enables us to easily push real-time data to our application (using WebSockets). It is needed to get the most out of the "KPI & Alerting" Impac! feature, which send real-time Alerts to the front-end notifying Users when their KPI's (key performance indicators) have been reached.
For the JavaScript client (Impac! Angular) to receive notifications from our server (Impac!) via the Pusher servers, a "Client Key" must be provided, and it must match the "Client Key" configured. For Impac! to send notifications to the client via Pusher, Impac! must be configured with an "Api Key", "Api Secret" & "Client Key.
This document will guide you through setting up a Pusher account, and configuring the Maestrano products to enable the use of Pusher.
1 - Creating a Pusher Account & Generating API Keys
- First go to https://dashboard.pusher.com/accounts/sign_up and sign up
- Once you create an account, this should be the first screen you see. Fill in the fields (5 & 6 not important).
- We recommend the "create apps for multiple environments" option
- Select the "Your Apps" menu icon on the left sidebar, and select the correct application / application environment
- Then on the app top-bar menu, select "App Keys"
- Now you should see all the app keys required
2 - Configuring Impac! API with the Pusher API Keys
Impac! API stores the Pusher API Keys as environment variables. Below are the recommended options to configure these variables.
2.1 - Option 1 (Nex!):
nex-cli apps:vars impac-app-name --add PUSHER_APP_ID=app-id-key,PUSHER_KEY=key,PUSHER_SECRET=secret
2.2 - Option 2 (Ansible):
- To add an ENV variable to Impac!, you need to add it here: https://github.com/maestrano/mno-deploy/blob/develop/ansible/roles/impac/templates/application.yml
- As these are secret keys, it will need to be added to the encrypted using Ansible Vault (https://github.com/maestrano/mno-deploy/blob/develop/ansible/vars/example_secrets.yml)
3 - Configuring Express with the Pusher Client Key
The Maestrano Enterprise application's back-end can configured with the pusher client key in it's environment variables, which then gets provided to the front-end (Impac! Angular) during Angular configuration phases. Otherwise, Impac! Angular can be configured directly by following Option 2 below.
3.1 - Option 1 (Nex!):
Add the pusher client key as an environment variable of your app through Nex!.
nex-cli apps:var app-name --add impac_pusher_key=the-pusher-client-key
3.2 - Option 2 (manual front-end configuration):
Add the pusher client key to your Express project's front-end Impac! configuration file (frontend/src/app/impac.config.coffee).
angular.module('mnoEnterpriseAngular').run((ImpacLinking)-> ImpacLinking.linkData({ pusher_key: 'pusher-client-key' }) )