Skip to content

Commit

Permalink
looks good
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiAbdou committed Sep 17, 2024
1 parent e1b73d9 commit d431f3b
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 61 deletions.
23 changes: 16 additions & 7 deletions packages/core/src/infrastructure/bull/bull.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,22 @@ export const SlackBullJob = z.discriminatedUnion('name', [
id: true,
}),
}),
z.object({
name: z.literal('slack.profile_picture.changed'),
data: z.object({
profilePicture: Student.shape.profilePicture,
slackId: Student.shape.slackId.unwrap(),
}),
}),
z.object({
name: z.literal('slack.question.answer.private'),
data: z.object({
channelId: z.string().trim().min(1),
question: z.string().trim().min(1),
threadId: z.string().trim().min(1),
userId: z.string().trim().min(1),
}),
}),
z.object({
name: z.literal('slack.reaction.add'),
data: SlackReaction.pick({
Expand All @@ -504,13 +520,6 @@ export const SlackBullJob = z.discriminatedUnion('name', [
userId: true,
}),
}),
z.object({
name: z.literal('slack.profile_picture.changed'),
data: z.object({
profilePicture: Student.shape.profilePicture,
slackId: Student.shape.slackId.unwrap(),
}),
}),
z.object({
name: z.literal('slack.thread.sync_embedding'),
data: z.object({
Expand Down
12 changes: 9 additions & 3 deletions packages/core/src/modules/mixpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export type MixpanelEvent = {
| 'Resources';
};

'Public Question Answered': {
'# of Threads Found': number;
Question: string;
Where: 'DM';
};

'Resource Added': undefined;
'Resource Link Copied': undefined;
'Resource Tag Added': undefined;
Expand All @@ -66,7 +72,7 @@ export type TrackInput<Event extends keyof MixpanelEvent> = {
event: Event;
properties: MixpanelEvent[Event];
request?: Request;
user: string;
user?: string;
};

export function track<Event extends keyof MixpanelEvent>({
Expand All @@ -83,8 +89,8 @@ export function track<Event extends keyof MixpanelEvent>({
if (!request) {
mixpanel.track(event, {
...properties,
...(user && { distinct_id: user }),
Application: application,
distinct_id: user,
});

return;
Expand All @@ -99,14 +105,14 @@ export function track<Event extends keyof MixpanelEvent>({

mixpanel.track(event, {
...properties,
...(user && { distinct_id: user }),
Application: application,
$browser: result.browser.name,
$browser_version: result.browser.version,
$device: result.device.model,
$referrer: referrer,
$os: result.os.name,
$os_version: result.os.version,
distinct_id: user,
ip,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ export async function sendSlackNotification(input: SendNotificationInput) {

const channel = input.channel || ENV.INTERNAL_SLACK_NOTIFICATIONS_CHANNEL_ID;

await client.chat.postMessage({
const { ts } = await client.chat.postMessage({
channel,
text: input.message,
thread_ts: input.threadId,
});

return ts;
}
Loading

0 comments on commit d431f3b

Please sign in to comment.