We've added a Netlify Function that logs all tickets to Convex database, even if printing fails.
Go to your Convex dashboard and create a mutation in convex/mutations.js:
import { mutation } from "./_generated/server";
export const addTicket = mutation({
args: {
from_name: v.string(),
question: v.string(),
timestamp: v.string(),
},
handler: async (ctx, args) => {
return await ctx.db.insert("tickets", {
from_name: args.from_name,
question: args.question,
timestamp: args.timestamp,
});
},
});Create/edit convex/schema.js:
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
export default defineSchema({
tickets: defineTable({
from_name: v.string(),
question: v.string(),
timestamp: v.string(),
}),
});- Go to Netlify Dashboard
- Site Settings → Environment Variables
- Add:
CONVEX_DEPLOYMENT=https://your-project.convex.site- Replace
your-projectwith your actual Convex deployment URL
- Replace
Push to GitHub, Netlify will auto-deploy!
When user clicks "Print Ticket":
- Ticket data is sent to your Raspberry Pi backend for printing
- In parallel, ticket data is also logged to Convex database
- If printing fails, you still have the data saved
- Database logging errors won't block printing
Log into your Convex dashboard to see all submitted tickets.