If you need to get event on the local version on Hawk, follow these steps.
- Go to hawk.mono root
- Run
docker-compose up
- Wait till all containers will run
- Open other terminal tab and run
docker ps
or open Kitematic and press CMD+R to refresh containers list - You should see at least five containers:
hawkmono_collector
hawkmono_garage
rabbitmq:3-management
hawkmono_api
mongo
If you don't see one or several containers, it means they are not running. Probably, some error occurs — you should resolve them first.
- Go to http://localhost:8080
- You should see the Garage
- If you don't authorised, you need to log into your account.
If you already have a workspace and projects, go to some project's settings
(by clicking on project's name or image at the header of main column)
and open an Integrations page. You will find your Integration Token
there.
If you don't have a projects yes, create one:
- Click on the [+] button at the left Workspaces.
- Create a Workspace
- Click on the created workspace at the left column.
- Click on the blue [+] button to add a new Project
- Add a new Project
- Click on the new created project, select a Catcher
- Copy your
Integration Token
from the Catcher Instructions page
- From the
hawk.mono
directory go tocatchers/javascirpt
directory - Make sure you are on
master
branch. Switch tomaster
branch if you are on any other branch. - Open
example/index.html
in your IDE and put an Integration Token to the initialization of HawkCatcher attoken
property:
- Go back to terminal, make sure you are still in the
catchers/javascirpt
directory - Run
yarn
to install dependencies - Run
yarn dev
to run testing page - You should see the testing page on
http://localhost:9000
or something like that.
- On the testing page, open JS Console — there should be no errors
- Go to
Network
tab and make sure there is a WebSocket connection calledws
(not awebsocket
)
Now you can send events to the Collector by clicking on buttons on testing page.
- Click on the
hawk.test()
button.
If the Collector works properly, it should handle the event we just sent and add a new task for processing it to the Registry. So we need to check if there is an unprocessed task in a Registry's queue (that is actual Rabbit MQ queue).
- Open Rabbit MQ GUI: http://localhost:15672
- Authorise using
guest:guest
pair - Go to
Queues
tab - Take a look at the
errors/javascript
queue — there should be at least one message.
If you are interested in, you can discover message details by clicking on errors/javascript
queue and then on Get Message(s)
button.
To handle JavaScript error events you need at least two workers:
JavaScript Worker
will process an event, validate data and structure, then pass prepared event to the Grouper Worker for saving to DB.Grouper Worker
will check for the first-occurrence/repetition logic and save event to the corresponding collection in Events DB.
- Go to
hawk.mono/workers
directory in terminal. - If you did not install dependencies there, run
yarn
- Run
yarn run-js
to run theJavaScript Worker
Now let's see that JavaScript Worker successfully process the event and add a new task to the Grouper Worker.
- Open Rabbit MQ GUI and go to
Queues
tab - Take a look at the
grouper
queue — there should be at least one message waiting for handle.
Ok, let's run the Grouper Worker
- Open new terminal tab (CMD+T) with the same directory (
hawk.mono/workers
) - Run
yarn run-grouper
to run theGrouper Worker
If you will refresh Queues list in RabbitMQ GUI, you should see that the message from grouper
queue has left.
In previous part, the Grouper Worker should save the event to the Events DB. Lets find it there.
- Open one of MongoDB GUI, for example Compass
- Connect to the local mongo (defaults are — host:
localhost
, port:27017
) - Make sure there are
hawk_events
database - Open
hawk_events
database - Open
events:<projectId>
collection - You should see the event we just insert
Open the Garage on Project's page. The testing event Hawk JavaScript Catcher test message.
should be there.