-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add logging for trials #1954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughA new Changes
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
lib/utils.ts (1)
64-88: logStore implementation is functionally sound; consider tightening the API surfaceThe control flow looks correct and safe for a logging helper: it short‑circuits to console logging in dev / when the webhook URL is absent, and otherwise best‑effort POSTs and logs failures without throwing. This is consistent with how
logbehaves.A couple of small API/typing cleanups you might consider (non‑blocking):
- The current return type ends up as
Promise<void | Response | undefined>, but callers (e.g. the trial handler) don’t use theResponse. You could simplify by not returning the network call result and justawaitit, making this a pure side‑effect helper with an implicitPromise<void>return:try { if (process.env.PPMK_STORE_WEBHOOK_URL) { await fetch(process.env.PPMK_STORE_WEBHOOK_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(object), }); } } catch (e) { console.error("Error logging store:", e); }- The parameter shape
({ object }: { object: any })forces a slightly awkward call‑site. If you don’t need that extra nesting, you could make the helper generic and accept any serializable payload directly:and call it asexport const logStore = async <T>(payload: T) => { /* ... JSON.stringify(payload) ... */ };await logStore({ teamId, email, fullName, ... }).These changes would make the helper easier to re‑use and reason about without altering behavior for existing call sites that just
awaitit.pages/api/teams/[teamId]/datarooms/trial.ts (1)
16-16: Structured trial logging via logStore looks good; consider making it non‑blockingImporting
logStoreand pushing a structured payload (teamId, email, fullName, companyName, useCase, companySize, tools) is a nice complement to the existing Slack log and should make downstream analysis much easier.One thing to consider: both
logandlogStoreare awaited on the request path. Since logStore has built-in error handling (catches and logs errors internally), you could reduce latency and coupling by not blocking on it:
Fire‑and‑forget:
logStore({ object: { teamId, email, fullName, companyName, useCase, companySize, tools }, });(or
void logStore(...);if your lint rules require explicit acknowledgement)Or, if you already have a background task mechanism, run the store logging there alongside the scheduled emails so a slow/unavailable store can't delay the API response.
Also, this payload includes several user identifiers (email, fullName, company/companySize). Make sure the target behind
PPMK_STORE_WEBHOOK_URLis treated as a trusted, compliant destination for that PII and is covered by your data‑retention policies.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lib/utils.ts(1 hunks)pages/api/teams/[teamId]/datarooms/trial.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pages/api/teams/[teamId]/datarooms/trial.ts (1)
lib/utils.ts (1)
logStore(64-88)
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.