Prophecy SDK
Prophecy is the growth-intelligence product ($500/month or $5,000/year). The SDK tracks your platform's users, payments, feature use and API requests, scans your codebase locally into a manifest, imports your history, and returns the projection report: forecast with P10/P50/P90 ranges, retention, feature verdicts, API health, security checks, benchmarks, an indicative valuation, scenarios and a ranked 90-day plan. All numbers come from your data and stated formulas.
Version 1.3.0 in every SDK. You need an active Prophecy subscription and a project (Dashboard > Prophecy), which gives you two keys:
- Ingest key (
lj_app_...): write-only, safe in a browser. Tracking, pageviews, the manifest. - Secret key (
ljp_sk_..., shown once): server side only. History import, report, refresh, live counters, embed URLs. The SDKs refuse to use it in a browser.
Install
| Language | Install | Import |
|---|---|---|
| Node.js | npm install https://linearjeph.cc/sdk/linearjeph-sdk-1.3.0.tgz | const { prophecy } = require("@linearjeph/sdk") or import { prophecy } from "@linearjeph/sdk" (also @linearjeph/sdk/prophecy) |
| Python | pip install linearjeph | from linearjeph import prophecy |
| Go | go get github.com/kingtechies/linearjeph-sdk/[email protected] | import "github.com/kingtechies/linearjeph-sdk/go/prophecy" |
| PHP | composer config repositories.linearjeph vcs https://github.com/kingtechies/linearjeph-php && composer require linearjeph/sdk:^1.3 | Linearjeph\Prophecy |
| Ruby | curl -LO https://linearjeph.cc/sdk/linearjeph-1.3.0.gem && gem install ./linearjeph-1.3.0.gem | Linearjeph::Prophecy |
| Browser | <script src="https://linearjeph.cc/sdk/prophecy.js"></script> | window.LinearjephProphecy |
Keys and endpoint can come from the environment: LINEARJEPH_INGEST_KEY, LINEARJEPH_SECRET_KEY, LINEARJEPH_ENDPOINT (default https://linearjeph.cc).
Quick start
Node.js:
const { prophecy } = require("@linearjeph/sdk");
prophecy.init({ ingestKey: process.env.LINEARJEPH_INGEST_KEY, secretKey: process.env.LINEARJEPH_SECRET_KEY });
app.use(prophecy.middleware({ ignorePaths: ["/health"] })); // Express/Connect: route template, method, status, duration
prophecy.signup(user.id, { plan: "free", channel: "ads", country: "NG" });
prophecy.feature("export-csv", user.id);
prophecy.payment(user.id, 29, "USD", { plan: "pro" });
prophecy.subscription(user.id, { plan: "pro", mrr: 29, status: "active" });
prophecy.churn(user.id, "too expensive");
await prophecy.sendManifest(prophecy.scan("."));
const { report } = await prophecy.report();Next.js route handlers: export const GET = prophecy.nextMiddleware(async (req) => Response.json({ ok: true }), { route: "/api/items/:id" }).
Python:
from linearjeph import prophecy
prophecy.init(ingest_key=os.environ["LINEARJEPH_INGEST_KEY"], secret_key=os.environ.get("LINEARJEPH_SECRET_KEY"))
prophecy.signup(user.id, plan="free", channel="ads", country="NG")
prophecy.feature("export-csv", user.id)
prophecy.payment(user.id, 29, "USD", plan="pro")
prophecy.subscription(user.id, plan="pro", mrr=29, status="active")
prophecy.churn(user.id, "too expensive")
prophecy.send_manifest(prophecy.scan("."))
report = prophecy.report()Requests: Django MIDDLEWARE += ["linearjeph.prophecy.django.ProphecyMiddleware"] (route from request.resolver_match.route); Flask prophecy.middleware.init_flask(app) (url_rule); FastAPI and Starlette app.add_middleware(prophecy.middleware.ASGIMiddleware) (route path_format); any WSGI app app.wsgi_app = prophecy.middleware.WSGIMiddleware(app.wsgi_app).
Go, PHP and Ruby use the same function names in their own idiom (Init, Track, Feature, Signup, Payment, Subscription, Churn, Identify, Scan, SendManifest, ImportHistory, Report, Refresh, Live, EmbedURL, Flush, Close).
Browser:
<script src="https://linearjeph.cc/sdk/prophecy.js"></script>
<script>
LinearjephProphecy.init({ ingestKey: "lj_app_..." }); // sends a pageview now and on every History pushState
LinearjephProphecy.feature("pricing-calculator");
LinearjephProphecy.signup(user.id, { plan: "free", channel: "ads" });
</script>The script is under 6 KB, has no dependencies, hashes user ids with SubtleCrypto SHA-256, and refuses keys starting with ljp_sk_.
API
| Node.js | Python | Notes |
|---|---|---|
init({ ingestKey, secretKey?, endpoint?, hashUserIds: true }) | init(ingest_key, secret_key, endpoint, hash_user_ids=True) | Never throws. Returns whether a key is set. |
track(name, { uid, kind, feature, amount, currency, props, ts }) | track(name, uid=, kind=, feature=, amount=, currency=, props=, ts=) | props max 2 KB. |
feature(name, uid?) | feature(name, uid=None) | Shorthand for kind: "feature". |
signup(uid, { plan, channel, country }) | signup(uid, plan=, channel=, country=) | Also sets the customer's signup_at. |
payment(uid, amount, currency?, { plan }) | payment(uid, amount, currency="USD", plan=) | A negative amount is recorded as a refund. |
subscription(uid, { plan, mrr, status }) | subscription(uid, plan, mrr, status="active") | active, cancelled or paused. |
churn(uid, reason?) | churn(uid, reason=None) | |
identify(uid, traits) | identify(uid, traits) | signup_at, plan, mrr, country, channel; other keys go to traits (max 20). |
middleware(opts), nextMiddleware(handler, opts) | WSGI, ASGI, Django, Flask middlewares | Route template, method, status, duration_ms. |
scan(rootDir) | scan(root_dir) | Returns the manifest. |
sendManifest(manifest) | send_manifest(manifest) | Ingest key. Returns true or false. |
importHistory(kind, rows, { onProgress }) | import_history(kind, rows, on_progress=) | Secret key. |
report(section?), refresh(), live(), embedUrl(ttl) | report, refresh, live, embed_url(ttl) | Secret key, server side only. |
flush(), close() | flush(), close() | Also flushed automatically at exit. |
Tracking behaviour: calls never throw into your app (a failure is swallowed and logged once), events wait in a bounded in-memory queue (10,000, then the newest are dropped), are sent every 2 seconds or every 100 events as gzip, retried with backoff on 429 and 5xx, and flushed on exit. payment, signup, subscription and churn need a uid. Secret-key calls (import, report, refresh, live, embed) do throw a clear error when the secret key is missing, the request is refused, or the code runs in a browser.
What to track
kind | Use it for | Fields |
|---|---|---|
signup | A new account | uid, props plan, channel, country |
login, active | Return visits, generic activity (drives DAU/WAU/MAU, stickiness) | uid |
feature | Use of a feature (feature field set) | uid, feature |
payment | Money received | uid, amount > 0, currency, props plan |
refund | Money returned | amount < 0 |
subscription | Plan state | props plan, mrr, status |
churn | A customer left | uid, props reason |
pageview | Page views (browser script) | props path |
request | API traffic (middleware) | props route, method, status, duration_ms |
error | Application errors | props free-form |
custom | Anything else (default) | name, props |
Annual and quarterly payments: put annual/yearly (or quarterly) in the plan name, e.g. pro-annual, or send props interval: "yearly". The payment is then counted as 1/12 (or 1/3) per month over the period it covers, so a yearly customer is not mistaken for churn. If you send subscription events with mrr, those are used instead.
Feature verdicts need at least 30 users on each side of the comparison; below that the verdict is not_enough_data. With little history the forecast range widens and the report says what is missing.
Import your history
The report improves immediately when you backfill past data. Use CSV or JSON, with the CLI or importHistory:
npx @linearjeph/sdk prophecy import events history.csv # Node
python -m linearjeph.prophecy import customers customers.csv # PythonEvents CSV columns: ts,uid,name,kind,feature,amount,currency (optional: props as a JSON string, id as a dedupe key). Customers CSV columns: uid,signup_at,plan,mrr,country,channel. ts and signup_at are ISO-8601 or epoch milliseconds, up to ten years back. Ids are hashed by the SDK the same way as live tracking, so history and live data line up. Rows go in batches of 5,000 (and under 5 MB), with retries on 429 and 5xx; a row with an id is stored once. The result is { accepted, rejected, errors } (the first 20 errors). The Prophecy dashboard also accepts a CSV upload (20 MB).
The scanner
npx @linearjeph/sdk prophecy scan . --send # Node (keys from LINEARJEPH_INGEST_KEY)
python -m linearjeph.prophecy scan . --send # PythonAdd --json to print the manifest and --out manifest.json to save it. The scan runs on your machine or in CI and takes seconds. It reads: languages (by file extension) and lines of code; dependencies and frameworks from package.json, requirements*.txt, pyproject.toml, Pipfile, go.mod, composer.json, Gemfile(.lock), pom.xml, build.gradle (names and versions of top-level dependencies); routes (Express, Fastify, Koa, Next.js app/ and pages/, Django urls.py, Flask, FastAPI, Laravel, Rails, Go net/http, chi, gin); features from route groups, feature-flag calls and top-level modules; integrations; infrastructure files (Docker, compose, Kubernetes, Terraform, serverless, CI, hosting configs); environment variable names; pricing constants near plan names; the first 2 KB of the README with markdown stripped; test counts and frameworks.
It never sends source code, file contents, environment values or secrets. .env files are never opened (their presence, and whether .gitignore covers them, is the only thing recorded). Suspected secrets (cloud keys, live payment keys, tokens, private key headers) are only counted. It skips node_modules, .git, vendor, venv, dist, build and similar, files over 1 MB and symlinks, and stops at 20,000 files. The manifest is capped at 512 KB.
Show the report in your own admin
embedUrl returns a signed, expiring URL for a chromeless report page with no secrets and no personal data. Create it on your server and put it in an iframe:
const url = await prophecy.embedUrl(3600); // ttl seconds, max 86400
res.render("admin", { prophecyUrl: url });<iframe src="<%= prophecyUrl %>" style="width:100%;height:900px;border:0" title="Prophecy"></iframe>The report data is also available as JSON: prophecy.report() returns { report, created_at, stale }, and report("revenue") returns one section (headline, revenue, users, retention, features, api, reliability, security, market, scenarios, recommendations, roadmap, realtime).
REST reference
Ingest (header X-LJ-Key: <ingest key>; 512 KB, gzip accepted, 1,200 requests per minute per app; answers 202 {accepted, rejected}):
POST /ingest/v1/prophecy/eventswith{"events": [{ts, uid?, name, kind?, feature?, amount?, currency?, props?}]}, up to 500 per request.tsis ISO-8601 or epoch ms; more than 5 minutes in the future or older than 400 days is rejected.POST /ingest/v1/prophecy/identifywith{"customers": [{uid, signup_at?, plan?, mrr?, country?, channel?, traits?}]}, up to 500.POST /ingest/v1/prophecy/manifestwith{"manifest": {...}}, up to 512 KB.
Secret-key API (header Authorization: Bearer ljp_sk_...; subscription required):
POST /api/v1/prophecy/sdk/importwith{"kind": "events"|"customers", "rows": [...]}, up to 5,000 rows and 5 MB; answers{job, accepted, rejected, errors}.GET /api/v1/prophecy/sdk/report[?section=revenue]returns{report, created_at, stale}.POST /api/v1/prophecy/sdk/refreshqueues a new report (limited per hour); 202{queued: true}.GET /api/v1/prophecy/sdk/livereturns realtime counters.POST /api/v1/prophecy/sdk/embedwith{"ttl": 3600}(max 86400) returns{url, expires_at}.
Live events are still accepted for 7 days after a subscription ends; after that ingest answers 402.
Privacy
- User ids are replaced with their SHA-256 hash in the SDK before they leave your server or browser (
hashUserIds/hash_user_ids, default on). Turn it off only if you want to see raw ids in your own exports. - The request middlewares record the route template (
/users/:id), method, status and duration. Never bodies, headers, cookies or query strings; unmatched paths have ids replaced by:id. - Keep
propsandtraitsfree of personal data (emails, names, card numbers); they are stored as sent. - The scanner sends a manifest only (see above). The secret key is never needed by a browser, and the SDKs refuse it there.
- Raw events are kept 400 days; daily aggregates are kept after that. Delete a project from the dashboard to remove its data.