Skip to content

Commit 658b083

Browse files
committed
chore: merge main into release for new releases
2 parents 0680e2e + c966652 commit 658b083

File tree

157 files changed

+1587
-6463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+1587
-6463
lines changed

apps/app/instrumentation-client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { initBotId } from 'botid/client/core';
33
initBotId({
44
protect: [
55
{ path: '/api/chat', method: 'POST' },
6-
{ path: '/api/tasks-automations/chat', method: 'POST' },
7-
{ path: '/api/tasks-automations/errors', method: 'POST' },
6+
{
7+
path: `${process.env.NEXT_PUBLIC_ENTERPRISE_API_URL}/api/tasks-automations/chat`,
8+
method: 'POST',
9+
},
10+
{
11+
path: `${process.env.NEXT_PUBLIC_ENTERPRISE_API_URL}/api/tasks-automations/errors`,
12+
method: 'POST',
13+
},
814
],
915
});

apps/app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"@monaco-editor/react": "^4.7.0",
3030
"@nangohq/frontend": "^0.53.2",
3131
"@next/third-parties": "^15.3.1",
32+
"@novu/api": "^1.6.0",
33+
"@novu/nextjs": "^3.10.1",
3234
"@number-flow/react": "^0.5.9",
3335
"@prisma/client": "^6.13.0",
3436
"@prisma/instrumentation": "6.6.0",

apps/app/src/actions/policies/accept-requested-policy-changes.ts

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use server';
22

33
import { db, PolicyStatus } from '@db';
4-
import { sendPolicyNotificationEmail } from '@trycompai/email';
54
import { revalidatePath, revalidateTag } from 'next/cache';
65
import { z } from 'zod';
76
import { authActionClient } from '../safe-action';
@@ -72,6 +71,7 @@ export const acceptRequestedPolicyChangesAction = authActionClient
7271
approverId: null,
7372
signedBy: [], // Clear the signedBy field
7473
lastPublishedAt: new Date(), // Update last published date
74+
reviewDate: new Date(), // Update reviewDate to current date
7575
},
7676
});
7777

@@ -92,56 +92,34 @@ export const acceptRequestedPolicyChangesAction = authActionClient
9292
return roles.includes('employee');
9393
});
9494

95-
// Send notification emails to all employees
96-
// Send emails in batches of 2 per second to respect rate limit
97-
const BATCH_SIZE = 2;
98-
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
99-
100-
const sendEmailsInBatches = async () => {
101-
for (let i = 0; i < employeeMembers.length; i += BATCH_SIZE) {
102-
const batch = employeeMembers.slice(i, i + BATCH_SIZE);
103-
104-
await Promise.all(
105-
batch.map(async (employee) => {
106-
if (!employee.user.email) return;
107-
108-
let notificationType: 'new' | 're-acceptance' | 'updated';
109-
const wasAlreadySigned = policy.signedBy.includes(employee.id);
110-
if (isNewPolicy) {
111-
notificationType = 'new';
112-
} else if (wasAlreadySigned) {
113-
notificationType = 're-acceptance';
114-
} else {
115-
notificationType = 'updated';
116-
}
117-
118-
try {
119-
await sendPolicyNotificationEmail({
120-
email: employee.user.email,
121-
userName: employee.user.name || employee.user.email || 'Employee',
122-
policyName: policy.name,
123-
organizationName: policy.organization.name,
124-
organizationId: session.activeOrganizationId,
125-
notificationType,
126-
});
127-
} catch (emailError) {
128-
console.error(`Failed to send email to ${employee.user.email}:`, emailError);
129-
// Don't fail the whole operation if email fails
130-
}
131-
}),
132-
);
133-
134-
// Only delay if there are more emails to send
135-
if (i + BATCH_SIZE < employeeMembers.length) {
136-
await delay(1000); // wait 1 second between batches
137-
}
138-
}
139-
};
140-
141-
// Fire and forget, but log errors if any
142-
sendEmailsInBatches().catch((error) => {
143-
console.error('Some emails failed to send:', error);
144-
});
95+
// Call /api/send-policy-email to send emails to employees
96+
97+
// Prepare the events array for the API
98+
const events = employeeMembers
99+
.filter((employee) => employee.user.email)
100+
.map((employee) => ({
101+
subscriberId: `${employee.user.id}-${session.activeOrganizationId}`,
102+
email: employee.user.email,
103+
userName: employee.user.name || employee.user.email || 'Employee',
104+
policyName: policy.name,
105+
organizationName: policy.organization.name,
106+
url: `${process.env.NEXT_PUBLIC_APP_URL ?? 'https://app.trycomp.ai'}/${session.activeOrganizationId}/policies/${policy.id}`,
107+
description: `The "${policy.name}" policy has been ${isNewPolicy ? 'created' : 'updated'}.`,
108+
}));
109+
110+
// Call the API route to send the emails
111+
try {
112+
await fetch(`${process.env.BETTER_AUTH_URL ?? ''}/api/send-policy-email`, {
113+
method: 'POST',
114+
headers: {
115+
'Content-Type': 'application/json',
116+
},
117+
body: JSON.stringify(events),
118+
});
119+
} catch (error) {
120+
console.error('Failed to call /api/send-policy-email:', error);
121+
// Don't throw, just log
122+
}
145123

146124
// If a comment was provided, create a comment
147125
if (comment && comment.trim() !== '') {

apps/app/src/ai/constants.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

apps/app/src/ai/secrets.ts

Lines changed: 0 additions & 98 deletions
This file was deleted.

apps/app/src/ai/tools/create-sandbox.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

apps/app/src/ai/tools/create-sandbox.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)