@lightupai/polaris 0.0.42 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightupai/polaris",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "polaris": "bin/polaris",
package/src/service/db.ts CHANGED
@@ -194,6 +194,17 @@ export async function listUsers(sql: Sql, orgId: string): Promise<User[]> {
194
194
  return rows.map((r) => ({ ...r, created_at: r.created_at.toISOString() }) as User);
195
195
  }
196
196
 
197
+ export async function getRecentSignups(sql: Sql, since: Date, limit = 10): Promise<Array<User & { org_name: string }>> {
198
+ const rows = await sql`
199
+ SELECT u.*, o.name as org_name
200
+ FROM users u JOIN orgs o ON u.org_id = o.id
201
+ WHERE u.created_at >= ${since.toISOString()}
202
+ ORDER BY u.created_at DESC
203
+ LIMIT ${limit}
204
+ `;
205
+ return rows.map((r) => ({ ...r, created_at: r.created_at.toISOString(), org_name: r.org_name }) as User & { org_name: string });
206
+ }
207
+
197
208
  // --- Projects (org-scoped) ---
198
209
 
199
210
  export async function createProject(sql: Sql, orgId: string, name: string): Promise<Project> {
package/src/web/app.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  listSessions,
15
15
  getSessionPromptCounts,
16
16
  getProjectEvents,
17
+ getRecentSignups,
17
18
  type Sql,
18
19
  } from "../service/db";
19
20
  import { layout, nav } from "./layout";
@@ -52,6 +53,33 @@ function notifySignup(opts: { name: string; email: string; domain: string; orgNa
52
53
  }).catch(() => {});
53
54
  }
54
55
 
56
+ function startSignupRollup(sql: Sql): void {
57
+ const HOUR = 60 * 60 * 1000;
58
+
59
+ async function postRollup(): Promise<void> {
60
+ const botToken = process.env.SIGNUP_SLACK_BOT_TOKEN;
61
+ if (!botToken) return;
62
+
63
+ const since = new Date(Date.now() - HOUR);
64
+ const signups = await getRecentSignups(sql, since, 10);
65
+ if (signups.length === 0) return;
66
+
67
+ const lines = signups.map((s) => `• *${s.name}* (${s.email}) — ${s.org_name}`);
68
+ const text = `:chart_with_upwards_trend: *${signups.length} signup${signups.length === 1 ? "" : "s"} in the last hour*\n${lines.join("\n")}`;
69
+
70
+ fetch("https://slack.com/api/chat.postMessage", {
71
+ method: "POST",
72
+ headers: {
73
+ Authorization: `Bearer ${botToken}`,
74
+ "Content-Type": "application/json",
75
+ },
76
+ body: JSON.stringify({ channel: SIGNUP_CHANNEL, text }),
77
+ }).catch(() => {});
78
+ }
79
+
80
+ setInterval(postRollup, HOUR);
81
+ }
82
+
55
83
  // --- Google OAuth ---
56
84
 
57
85
  function getGoogle(): Google {
@@ -88,6 +116,9 @@ setInterval(() => {
88
116
  export function createApp(sql: Sql) {
89
117
  const app = new Hono();
90
118
 
119
+ // Start hourly signup rollup
120
+ startSignupRollup(sql);
121
+
91
122
  // --- Landing page ---
92
123
 
93
124
  app.get("/", (c) => {