fix: Include properties in export/events Payload#282
fix: Include properties in export/events Payload#282wikando-pm wants to merge 1 commit intoOpenpanel-dev:mainfrom
Conversation
|
@wikando-pm is attempting to deploy a commit to the Coderax's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds a new test script that exercises the Export API Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/api/scripts/test-export-api.ts`:
- Around line 104-127: The current test only logs when firstEvent.properties is
missing but doesn't fail the test; update the block that checks
firstEvent.properties (where basicResult and firstEvent are used) to treat a
missing properties field as a test failure by setting process.exitCode = 1 (or
throw a new Error) after logging the error so the CI fails; apply the same
change to the equivalent checks in Tests 2, 3, and 4 (the other result
variables/firstEvent equivalents) so any response missing the properties field
causes the script to exit non‑zero.
🧹 Nitpick comments (2)
apps/api/scripts/test-export-api.ts (2)
16-24: Consider removing non-null assertions for clearer intent.The non-null assertions (
!) on lines 16-18 are misleading since these values can beundefined. The validation on line 21 correctly handles this, but the assertions suggest the values are guaranteed to exist.Suggested improvement
-const CLIENT_ID = process.env.CLIENT_ID!; -const CLIENT_SECRET = process.env.CLIENT_SECRET!; -const PROJECT_ID = process.env.PROJECT_ID!; +const CLIENT_ID = process.env.CLIENT_ID; +const CLIENT_SECRET = process.env.CLIENT_SECRET; +const PROJECT_ID = process.env.PROJECT_ID; const API_BASE_URL = process.env.API_URL || 'http://localhost:3333'; if (!CLIENT_ID || !CLIENT_SECRET || !PROJECT_ID) { console.error('CLIENT_ID, CLIENT_SECRET, and PROJECT_ID must be set'); process.exit(1); } + +// After validation, we can safely assert these are defined +const config = { + clientId: CLIENT_ID, + clientSecret: CLIENT_SECRET, + projectId: PROJECT_ID, + apiBaseUrl: API_BASE_URL, +} as const;
119-120: Consider limiting logged data to avoid exposing sensitive event properties.Logging the full event structure could expose sensitive user data (PII) in CI logs or test output. For a test script, consider logging only the keys or a redacted summary.
Suggested improvement
// Log full first event for inspection - console.log(` First event structure:`, JSON.stringify(firstEvent, null, 2)); + console.log(` First event keys: ${Object.keys(firstEvent).join(', ')}`); + console.log(` Properties keys: ${firstEvent.properties ? Object.keys(firstEvent.properties).join(', ') : 'N/A'}`);
589615e to
5374dc2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/api/scripts/test-export-api.ts`:
- Around line 111-121: The test currently prints the full event payload
(firstEvent) which can expose PII; remove or replace the console.log that
outputs the full event structure and instead log a redacted summary—e.g.,
Object.keys(firstEvent), Object.keys(firstEvent.properties || {}), or a
sanitized JSON with sensitive fields replaced—so update the code around the
firstEvent.properties check and the "First event structure" log to only emit
keys or a redacted summary instead of the full firstEvent object.
🧹 Nitpick comments (1)
apps/api/scripts/test-export-api.ts (1)
64-80: Add a request timeout to prevent hung CI runs.A stalled endpoint will cause this test script to hang indefinitely. Using AbortController with a 15-second timeout improves reliability.
⏱️ Proposed implementation
try { - const response = await fetch(url, { - method, - headers, - }); + const controller = new AbortController(); + const timeout = setTimeout(() => controller.abort(), 15_000); + const response = await fetch(url, { + method, + headers, + signal: controller.signal, + }); + clearTimeout(timeout);
5374dc2 to
76adadd
Compare
Fixes #281
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.