Skip to content

Daily

Get a morning count of new users and orders

Each morning you see how many documents yesterday added to each collection, next to the day before.

Runs
Daily
Apps
Firebase
AI
Not needed
Access
read

Send this to your assistant

Create a ClickRuntime automation: every day at 7am, count the documents created yesterday in my Firestore 'users' and 'orders' collections and email me both numbers with the change from the previous day.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

Founders of small apps usually know their numbers only roughly. Someone opens the Firebase console, scrolls a collection, and guesses that signups were up this week. The console does not show how many documents were created yesterday, so tracking growth means writing a script, and the script never gets written. Without a daily figure, a marketing push that doubled signups looks the same as a quiet Tuesday, and a broken checkout that halved orders goes unnoticed for days.

Each morning, ClickRuntime runs aggregation count queries against Firestore for the previous day, one for new users and one for new orders, and emails you the totals with a comparison against earlier days. The counts are made by Firestore itself, so no documents are downloaded.

It is useful for solo founders and small product teams who want a daily pulse without building a dashboard.

What you get out of it

  • Notice a broken signup flow quickly

    If new users drop from sixty to three overnight, the email shows it the next morning. A bug in the registration form is found and fixed in a day instead of lingering through a whole week of lost growth.

  • Measure what marketing really did

    A campaign launch or a mention in a newsletter shows up as a jump in the count. You learn which efforts bring real users and which only bring clicks, and budgets follow the evidence.

  • Skip building a custom dashboard

    A small team can spend a week wiring a dashboard and still end up with a number nobody reads. A morning email with the two figures that matter costs nothing to maintain and gets read daily.

  • Keep costs low for large collections

    Count aggregation is computed inside Firestore and is billed far below the cost of reading every document. Even with a million records, you get yesterday's total without a surprising bill at the month's end.

  • Build a simple growth record

    Saved emails or the stored trend give a running history of daily creation. Investors, partners and your own planning all benefit from being able to say how many orders you had in each week.

How it works

What happens, step by step

  1. Every morning ClickRuntime counts the documents added yesterday to each Firestore collection you chose, such as users and orders.

  2. It compares each count with the day before.

  3. You get an email with the numbers and the change for each collection.

Before it runs live

  • Connect Firebase

What you get

RunsDaily
Get a morning count of new users and orderstoday, 9:00Succeeded
Email · Daily countsusers: 64 (+11 vs the day before) orders: 152 (-4 vs the day before)

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Firebase steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
get_a_daily_count_of_new_documents.pyexample
from datetime import date, timedelta
from clickruntime import on_trigger, credentials, http, notify

PROJECT = "acme-prod"
FS = f"https://firestore.googleapis.com/v1/projects/{PROJECT}/databases/(default)/documents"

def fs_headers():
    return {"Authorization": f"Bearer {credentials.connection('google', 'work')}"}

def val(field):
    return next(iter(field.values())) if field else None

def count(collection, start, end):
    filters = [{"fieldFilter": {"field": {"fieldPath": "createdAt"}, "op": op, "value": {"timestampValue": f"{d}T00:00:00Z"}}}
               for op, d in (("GREATER_THAN_OR_EQUAL", start), ("LESS_THAN", end))]
    body = {"structuredAggregationQuery": {"aggregations": [{"alias": "n", "count": {}}], "structuredQuery": {
        "from": [{"collectionId": collection}], "where": {"compositeFilter": {"op": "AND", "filters": filters}}}}}
    result = http.post(f"{FS}:runAggregationQuery", json=body, headers=fs_headers()).json()[0]["result"]
    return int(result["aggregateFields"]["n"]["integerValue"])

@on_trigger
def run(event):
    today = date.today()
    y, d2 = today - timedelta(days=1), today - timedelta(days=2)
    lines = []
    for c in ("users", "orders"):
        now, before = count(c, y, today), count(c, d2, y)
        lines.append(f"{c}: {now} ({now - before:+d} vs the day before)")
    notify.email_me(f"Firestore new documents {y}", "\n".join(lines))
    return {"lines": lines}

FAQ

Common questions

How does it work out yesterday's documents?
It filters on a timestamp field, such as createdAt, between midnight yesterday and midnight today in your chosen time zone. This means each document needs a creation timestamp for the count to be accurate. Time zones matter here.
Can I count more than users and orders?
Yes. Any collection with a creation date can be counted, such as comments, uploads or support requests. List the collections you want, and each one is added as a line in the email with its own total.
Does it cost much to run each morning?
Firestore bills aggregation counts at a small fraction of a read for each batch of index entries, so a daily count over large collections stays cheap. You can check the cost of a run in Google Cloud billing.
What permissions does it need?
read. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (daily). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Get a morning count of new users and orders” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.