#!/usr/bin/env python3 """Writes a fictional Graphley workspace folder (workspace.json and data.json) for App Store screenshots. Usage: python3 design/app-store/make-demo-workspace.py Debug builds read it with GRAPHLEY_DEMO_WORKSPACE=. Every site, app and review here is made up, so screenshots never show real numbers. Nothing here ships in the app. The newest day is yesterday. """ import datetime as dt import json import math import pathlib import random import sys ANCHOR = dt.date.today() - dt.timedelta(days=1) # newest day: yesterday DAYS = 180 # 90 days on screen plus the 90 before, so every delta has a previous period random.seed(20261126) # id, name, url, colour index, visitors per day now, visitors per day 180 days ago, weekend factor, # page views per session, key events (event -> share of visitors), top pages SITES = [ ("harbor-notes", "Harbor Notes", "https://harbornotes.app", 0, 410, 260, 0.72, 2.1, {"mac_installer_download": 0.031, "app_store_click": 0.022}, ["/", "/download", "/features", "/pricing-free", "/help/sync", "/changelog", "/blog/quiet-notes", "/privacy"]), ("field-guide", "Field Guide", "https://fieldguide.blog", 1, 270, 210, 1.25, 1.6, {"newsletter_click": 0.018}, ["/", "/trails/coastal-loop", "/gear/rain-shells", "/trails/ridge-walk", "/guides/first-overnight", "/about", "/trails/tide-flats", "/newsletter"]), ("tidepool", "Tidepool", "https://tidepool.app", 2, 150, 35, 1.10, 1.8, {"app_store_click": 0.064}, ["/", "/tide-tables", "/widgets", "/support", "/press", "/privacy", "/stations", "/changelog"]), ("lantern-docs", "Lantern Docs", "https://lanterndocs.dev", 3, 118, 130, 0.45, 3.4, {"source_click": 0.04}, ["/", "/docs/getting-started", "/docs/config", "/docs/cli", "/docs/themes", "/docs/deploy", "/blog/v2", "/docs/faq"]), ("driftwood", "Driftwood", "https://driftwood.studio", 4, 52, 30, 0.80, 2.0, {"mac_installer_download": 0.058}, ["/", "/download", "/gallery", "/shortcuts", "/help", "/changelog", "/privacy", "/press"]), ] # Short bursts on top of the trend: (site, days ago the burst starts, extra visitors on day one, decay per day) BURSTS = [("tidepool", 44, 520, 0.72), ("field-guide", 19, 900, 0.55), ("harbor-notes", 72, 380, 0.65), ("driftwood", 9, 140, 0.6)] # id, name, site, platforms, downloads per day now, share per platform, rating, ratings count now APPS = [ ("6400000101", "Tidepool: Tide Times & Charts", "tidepool", ["iPhone", "iPad"], 34, {"iPhone": 0.76, "iPad": 0.24}, 4.8, 212), ("6400000102", "Harbor Notes: Quiet Notebook", "harbor-notes", ["iPhone", "iPad", "Mac", "Mac (website)"], 21, {"iPhone": 0.48, "iPad": 0.14, "Mac": 0.38}, 4.6, 148), ("mac-driftwood", "Driftwood", "driftwood", ["Mac (website)"], 0, {}, None, 0), ] CHANNELS = [("Organic Search", 0.41), ("Direct", 0.27), ("Referral", 0.14), ("Organic Social", 0.11), ("Email", 0.04), ("Unassigned", 0.03)] SOURCES = [("google / organic", 0.36), ("(direct) / (none)", 0.27), ("duckduckgo / organic", 0.05), ("news.ycombinator.com / referral", 0.06), ("reddit.com / referral", 0.05), ("bing / organic", 0.04), ("mastodon.social / referral", 0.04), ("newsletter / email", 0.04)] REVIEWS = [ ("6400000101", 5, "Finally a calm tide app", "Opens straight to today's tides for my beach. The widget is perfect.", "jmoss", 3), ("6400000101", 5, "Beautiful charts", "Clear, quick and no clutter. Exactly what I wanted on the boat.", "Kelp & Co", 11), ("6400000102", 4, "Lovely on the Mac", "Syncs between my Mac and iPad without a fuss. Wish it had tags.", "pmw", 6), ("6400000101", 5, "Great for surf checks", "I check it every morning before work.", "dawnpatrol", 21), ("6400000102", 5, "Quiet in the best way", "Notes that get out of the way. Fast search.", "ellen.r", 27), ] def day(offset): return (ANCHOR - dt.timedelta(days=offset)).isoformat() def wobble(scale): return random.gauss(1.0, scale) def visitors(site, offset): sid, _, _, _, now, then, weekend, *_ = site t = 1 - offset / (DAYS - 1) # 0 at the oldest day, 1 at the newest base = then + (now - then) * (t ** 1.3) weekday = (ANCHOR - dt.timedelta(days=offset)).weekday() if weekday >= 5: base *= weekend base *= 1 + 0.05 * math.sin(offset / 6.5) for bid, start, extra, decay in BURSTS: if bid == sid and offset <= start: base += extra * decay ** (start - offset) return max(3, round(base * wobble(0.08))) def main(): points = [] def add(d, subject, metric, value, breakdown=None, event=None): p = {"day": d, "subject": subject, "metric": metric, "value": float(value)} if breakdown: p["breakdown"] = breakdown if event: p["event"] = event points.append(p) sites_json = [] for site in SITES: sid, name, url, color, _, _, _, ppv, events, pages = site sites_json.append({"id": sid, "name": name, "url": url, "colorIndex": color, "archived": False}) last30_views = 0 for offset in range(DAYS - 1, -1, -1): d = day(offset) users = visitors(site, offset) sessions = round(users * random.uniform(1.18, 1.36)) views = round(sessions * ppv * wobble(0.06)) add(d, sid, "users", users) add(d, sid, "newUsers", round(users * random.uniform(0.62, 0.78))) add(d, sid, "sessions", sessions) add(d, sid, "pageViews", views) add(d, sid, "engagedSessions", round(sessions * random.uniform(0.48, 0.62))) for event, share in events.items(): n = sum(1 for _ in range(users) if random.random() < share) if n: add(d, sid, "keyEvent", n, event=event) if offset < 30: last30_views += views # Window totals (last 30 days), stored on the newest day like a real refresh. weights = [1 / (i + 1.4) ** 1.05 for i in range(len(pages))] for path, w in zip(pages, weights): add(day(0), sid, "pageViews", round(last30_views * w / sum(weights) * 0.92), breakdown="page:" + path) sessions30 = sum(p["value"] for p in points if p["subject"] == sid and p["metric"] == "sessions" and "breakdown" not in p and p["day"] >= day(29)) for label, share in CHANNELS: add(day(0), sid, "sessions", round(sessions30 * share * wobble(0.12)), breakdown="channel:" + label) for label, share in SOURCES: add(day(0), sid, "sessions", round(sessions30 * share * wobble(0.15)), breakdown="source:" + label) apps_json = [] for aid, name, site, platforms, per_day, shares, rating, count in APPS: app = {"id": aid, "name": name, "siteID": site, "platforms": platforms, "onAppStore": not aid.startswith("mac-")} apps_json.append(app) if not shares: continue for offset in range(DAYS - 1, -1, -1): d = day(offset) t = 1 - offset / (DAYS - 1) base = per_day * (0.35 + 0.65 * t) for bid, start, extra, decay in BURSTS: if bid == site and offset <= start: base += extra * 0.04 * decay ** (start - offset) total = 0 for platform, share in shares.items(): n = max(0, round(base * share * wobble(0.22))) total += n add(d, aid, "appDownloads", n, breakdown="platform:" + platform) add(d, aid, "appDownloads", total) add(d, aid, "appRedownloads", max(0, round(total * random.uniform(0.08, 0.16)))) if offset % 7 == 0: # ratings are read once a day; weekly is plenty here add(d, aid, "ratingCount", round(count * (0.55 + 0.45 * t))) add(d, aid, "rating", round(rating - 0.1 * (1 - t), 2)) reviews_json = [{ "id": f"demo-review-{i}", "appID": aid, "appName": next(a[1] for a in APPS if a[0] == aid), "country": "us", "stars": stars, "title": title, "text": text, "version": "2.3", "author": author, "date": day(ago), "firstSeen": day(ago), "url": "https://graphley.ai", } for i, (aid, stars, title, text, author, ago) in enumerate(REVIEWS)] def widget(wid, title, kind, metric="users", days=30, breakdown=None, event=None, wide=None, items=None, subtitle=None): w = {"id": wid, "title": title, "kind": kind, "metric": metric, "subjects": [], "days": days} for k, v in (("breakdown", breakdown), ("event", event), ("wide", wide), ("items", items), ("subtitle", subtitle)): if v is not None: w[k] = v return w dashboards = [ {"id": "overview", "name": "Portfolio", "widgets": [ widget("kpis", "Last 30 days", "kpiRow", items=["visitors", "appDownloads", "macInstaller", "appStoreButton"], subtitle="Each vs the 30 days before"), widget("visitors", "Visitors, all sites", "stackedArea", subtitle="Stacked by site"), widget("downloads", "App Store downloads", "stackedBars", "appDownloads", breakdown="platform", wide=False, subtitle="By platform"), widget("installer", "Mac installer downloads", "stackedBars", "keyEvent", event="mac_installer_download", wide=False, subtitle="Real .dmg downloads, by site"), ]}, {"id": "app-store", "name": "App downloads", "widgets": [ widget("platforms", "Downloads by app and platform", "appPlatforms", "appDownloads", subtitle="App Store Connect, plus the Mac installer from each app's site"), widget("per-day", "App Store downloads per day", "stackedBars", "appDownloads", breakdown="platform", wide=False), widget("ratings", "Ratings and reviews", "ratings", "rating", wide=False, subtitle="Every storefront"), ]}, ] refreshed = dt.datetime.now(dt.timezone.utc).replace(microsecond=0) - dt.timedelta(hours=1) workspace = { "sites": sites_json, "apps": apps_json, "socials": [], "dashboards": dashboards, "agentLog": [], "reviews": reviews_json, "settings": {"refreshHour": 9, "agentsCanWrite": True, "agentsCanSetKeys": False, "shareWithIPhone": True, "lastRefreshAt": refreshed.isoformat().replace("+00:00", "Z")}, } out = pathlib.Path(sys.argv[1]) out.mkdir(parents=True, exist_ok=True) (out / "workspace.json").write_text(json.dumps(workspace, sort_keys=True)) (out / "data.json").write_text(json.dumps(points, separators=(",", ":"), sort_keys=True)) print(f"wrote {out}: {len(points)} points") if __name__ == "__main__": main()