A Clappy Clicky Thingy for Your Blog ... Without Servers

Managing state is a pain for use cases big or small.

Here's a super simple example illustrating how Sumatra makes state management a whole lot easier.

It's just a little counter. How hard could it be?

Count "likes" on your blog?

As a blogger, it would be nice to add a "like" counter to your articles to showcase engagement.

Ugh, the infrastructure!

You start thinking: I'm going to need a server. Worse, I'm going to need a database! 😳

Let Sumatra handle it

Implement your simple, stateful service in low code with no infrastructure to manage.

Set Up a Stateful Service in Under 5 Minutes

Implementing a click tracker with Sumatra is as easy as pasting a few lines of code into the Sumatra Editor and adding a couple of Javascript snippets to your web site.

1. Define your service in 6 lines of code

To configure the service, simply paste the following snippet into the Sumatra Editor and click "Apply".

event click
path := $.path as string
clicks := Count(by path)                    

event pageload
path := $.path as string
clicks := Latest<click>(clicks by path)

These few lines of Scowl code define stateful aggregates to count clicks and make them available to query in real time.

2. Send Events to Sumatra

On page load, use Sumatra's web SDK to send a query and receive the click count:

sumatra.enrich('pageload', {
  path: window.location.pathname
.then((features) => {

On click, track the event in Sumatra and fetch the result to update in real time:

sumatra.enrich('click', {
  path: window.location.pathname
.then((features) => {

3. There is no Step 3

You did it! That's the end-to-end process for deploying your first real-time, scalable, stateful service with Sumatra.

Give youself a round of applause.

Endless possibilities

Sumatra is a powerful platform, capable of building sophisticated, large-scale decisioning solutions. Yet even to the casual blogger, simple use cases like this one deliver immediate value and open up a whole world of possibilities:

  • Only count unique sessions
  • Filter out bots
  • Prompt a user to subscribe after they like 3 articles
  • ...

To try this recipe, get yourself a Sumatra account. It's free.

Ready to start building stateful real-time services?