Skip to content

Commit

Permalink
Update LogSnag integration to track team name updates and deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
kcoderhtml committed Apr 29, 2024
1 parent 2fee640 commit 68044cb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/pages/settings.astro
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ if (!session) {
});
}
import { LogSnag } from "logsnag";
const logsnag = new LogSnag({
token: "f269dd8e8ec57f9a73737e76c5e0024a",
project: "magicsnap",
});
let error = "";
import { db, like, Organization, Event, User } from "astro:db";
Expand All @@ -54,6 +61,13 @@ if (Astro.request.method === "POST") {
.update(Organization)
.set({ name })
.where(like(Organization.team, session.team));
await logsnag.track({
channel: "actions",
event: "team_name_updated",
icon: "🏷️",
user_id: session.user.id,
});
} else {
error =
"You do not have the necessary permissions to update the team name.";
Expand All @@ -64,6 +78,14 @@ if (Astro.request.method === "POST") {
await db.delete(Event).where(like(Event.team, session.team));
await db.delete(User).where(like(User.team, session.team));
await logsnag.track({
channel: "actions",
event: "team_deleted",
icon: "🗑️",
user_id: session.user.id,
notify: true,
});
return new Response(null, {
status: 302,
headers: new Headers({
Expand Down

0 comments on commit 68044cb

Please sign in to comment.