Event Stream: Easy-to-deploy heroku example

Hello @zachary, first of all, I love The Guide. It is awesome.

I was reading the [events streams seciton] (https://docs.particle.io/guide/how-to-build-a-product/web-app/#collecting-data-through-webhooks-or-an-event-stream) and your name popped up next to the magical words “easy-to-deploy heroku example”. That is music to my ears. Is there something you can share with us on that front?

Cheers!

Do you have a programming language in mind? The Javascript client will let you listen to events and get something up and running quickly.

Hi @jvanier, Javascript would be my preference.

This is my first time working with Heroku. So, I was hopping to find an example of somebody using Heroku with Particle to get me started.

My scenario is very simple: I’m trying to create a log of the event stream from my Photons. What is the simplest way to do this?

Thanks!

You can start from the Heroku node.js tutorial application. Add the Particle Javascript library. Open an event stream for your device using the Particle JS library in the index.js of the node.js application (not the best place to do this in the long run, but ok to get started). To save the events to a log, you could write to an SQL table (Heroku provides a free PostgreSQL database). Then add an endpoint to the node.js app to read the table from the database and display it.

Once the application works on your local machine, all it takes to deploy to Heroku is to push your code using git.

On the other hand, if the only thing you want is a log of events, you could just do particle subscribe mine on your local machine and save that to a file, or add a library to your Photon firmware to log events to ThingSpeak.

1 Like

Hey @sazp96! Thanks for reaching out! I just barely got started on the example app I wanted to make when we were deploying the new docs — in a totally unfinished state, it’s here: https://github.com/towynlin/button-dance Feel free to fork/make pull requests.

@jvanier is giving good advice — do what he says :+1:

The one caveat is that heroku doesn’t allow you to run long processes, so when using event streams, deploying on your own server will be a better idea. Webhooks work great with heroku.

1 Like

Thanks for the help guys. I ended up doing a combination of ThingSpeak (love it!) and Particle CLI >> to a file.

For what I’m trying to do right now, this works well. Thanks again :slight_smile:

Another request for the completed example app. Thanks @zachary! Will be checking out the links.

One thing I’m curious about what other services like Heroku exist that play well with even streams.