@lightupai/polaris 0.0.41 → 0.0.42

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/.env.example CHANGED
@@ -15,3 +15,6 @@ SLACK_APP_TOKEN=xapp-...
15
15
 
16
16
  # Long message mode: snippet, thread, or inline
17
17
  POLARIS_LONG_MSG=snippet
18
+
19
+ # Signup notifications — posts to #alerts-mql-stream via Slack bot token (xoxb-...)
20
+ SIGNUP_SLACK_BOT_TOKEN=
@@ -45,6 +45,7 @@ services:
45
45
  SLACK_CLIENT_ID: ${SLACK_CLIENT_ID}
46
46
  SLACK_CLIENT_SECRET: ${SLACK_CLIENT_SECRET}
47
47
  SLACK_REDIRECT_URI: https://app.withpolaris.ai/slack/callback
48
+ SIGNUP_SLACK_BOT_TOKEN: ${SIGNUP_SLACK_BOT_TOKEN:-}
48
49
  depends_on:
49
50
  postgres:
50
51
  condition: service_healthy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightupai/polaris",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "polaris": "bin/polaris",
package/src/web/app.ts CHANGED
@@ -30,6 +30,28 @@ import {
30
30
  mockDevices,
31
31
  } from "./fixtures";
32
32
 
33
+ // --- Signup notifications ---
34
+
35
+ const SIGNUP_CHANNEL = "#alerts-mql-stream";
36
+
37
+ function notifySignup(opts: { name: string; email: string; domain: string; orgName: string; isNewOrg: boolean }): void {
38
+ const botToken = process.env.SIGNUP_SLACK_BOT_TOKEN;
39
+ if (!botToken) return;
40
+
41
+ const emoji = opts.isNewOrg ? ":tada:" : ":wave:";
42
+ const action = opts.isNewOrg ? "signed up (new org)" : "joined";
43
+ const text = `${emoji} *${opts.name}* (${opts.email}) ${action} — ${opts.orgName} (${opts.domain})`;
44
+
45
+ fetch("https://slack.com/api/chat.postMessage", {
46
+ method: "POST",
47
+ headers: {
48
+ Authorization: `Bearer ${botToken}`,
49
+ "Content-Type": "application/json",
50
+ },
51
+ body: JSON.stringify({ channel: SIGNUP_CHANNEL, text }),
52
+ }).catch(() => {});
53
+ }
54
+
33
55
  // --- Google OAuth ---
34
56
 
35
57
  function getGoogle(): Google {
@@ -129,6 +151,20 @@ export function createApp(sql: Sql) {
129
151
  const userId = crypto.randomUUID();
130
152
  const participantId = `user:${name.toLowerCase().replace(/\s+/g, ".")}`;
131
153
  await createUser(sql, userId, email, name, existingOrg.id, participantId);
154
+
155
+ // Notify org's Slack system channel
156
+ postSystemEvent({
157
+ sql,
158
+ orgId: existingOrg.id,
159
+ sender: participantId,
160
+ text: `:wave: *${name}* (${email}) joined the team`,
161
+ botToken: existingOrg.slack_bot_token ?? undefined,
162
+ channelId: existingOrg.slack_system_channel_id ?? undefined,
163
+ }).catch(() => {});
164
+
165
+ // Notify internal team
166
+ notifySignup({ name, email, domain, orgName: existingOrg.name, isNewOrg: false });
167
+
132
168
  const token = await createToken({ sub: userId, email, name, org_id: existingOrg.id, participant_id: participantId });
133
169
  return authRedirect(c, state, token);
134
170
  }
@@ -144,6 +180,10 @@ export function createApp(sql: Sql) {
144
180
  const userId = crypto.randomUUID();
145
181
  const participantId = `user:${name.toLowerCase().replace(/\s+/g, ".")}`;
146
182
  await createUser(sql, userId, email, name, orgId, participantId);
183
+
184
+ // Notify internal team
185
+ notifySignup({ name, email, domain, orgName, isNewOrg: true });
186
+
147
187
  const token = await createToken({ sub: userId, email, name, org_id: orgId, participant_id: participantId });
148
188
  return authRedirect(c, state, token);
149
189
  });