Find when a Number Field value crossed a threshold via History API (script)

With the recent introduction of History API, we were able to solve a problem deemed too messy to solve before. I thought we might as well share the solution in case anyone faces a similar challenge.

Problem to solve

For each entity in a Database, understand when the value of a certain Number Field crossed a threshold.

For example, for each Event, understand when the number of registrations crossed the 100 people mark — the point when an Event typically breaks even and is worth organizing.

Story behind it

Over the last three years, the conversion from sign-up to purchase has increased ~8x here at Fibery. Which is freaking fantastic but also somewhat misleading. Some purchases are, in fact, extended trials — with the newly acquired “customer” cancelling soon after the purchase.

So, not to look gleefully at the wrong metric, we decided to measure the conversion from sign-up to second paid seat. This would also leave out solo purchases which are outside of our B2B focus.

Road to solution

For every workspace, we need to understand if they 2-seats-converted within 28 days from the sign-up. We already have the sign-up date (obviously), so all we need is the second-seat-purchased date and a formula to subtract the two.

For new purchases, we set up an automation Rule:

But what about the historical data? We’d need some baseline!

Solution (History API script)

Before vibe coding agentic engineering and History API, we’d probably have to torture Historical Reports, export them to CSV, create a pivot table in Excel, and hope for the best.

Now, with a little help from Claude Code, we’ve created (and tested) a few scripts:

  1. Find threshold crossings (e.g., when Subscription.Users became ≥ 2).
  2. Enrich them (in our case, the Number Field was on Subscriptions DB but the Date Field should be on Workspaces DB, so we had to map IDs).
  3. Set the dates (→ Workspace.[Second Purchase Date]).

Here are the scripts in our fibery-community repository together with some instructions on how to run them:

Feel free to use this suite as is, fork it, or simply provide to your coding agent as an example when working with History API.

If you have any questions, please let me know!

P.S. It turned out, our conversion is still pretty good, even when measured meaningfully :smiling_face_with_tear:. That being bragged, what we’d love to see is more nerds who run orgs that know about Fibery. If you know one, please tell them about the product!

1 Like