-
Notifications
You must be signed in to change notification settings - Fork 40
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
Staging sync #263
base: prod
Are you sure you want to change the base?
Staging sync #263
Conversation
Updated layout.tsx with meta tag for verification
* Updated activities on landing page (#244) * Fix: Events page header (#245) * Updated activities (#246) * Updated cp desc again (#247) * Added achievements to scrolling animation on main page --------- Co-authored-by: Rudraksha Singh Sengar <[email protected]> Co-authored-by: Alfiya Fatima <[email protected]>
- Events Page
Staging is updated.
Removed robots.txt from root directory
removed sitemap.xml from root directory.
moved files from root directory to public
Added Sitemap and Robots.txt
* images can be directly uploaded to cloudinary * Improved UI of the forms * Added Achievements to scrolling animation on main page (#251) * Updated activities on landing page (#244) * Fix: Events page header (#245) * Updated activities (#246) * Updated cp desc again (#247) * Added achievements to scrolling animation on main page --------- Co-authored-by: Rudraksha Singh Sengar <[email protected]> Co-authored-by: Alfiya Fatima <[email protected]> --------- Co-authored-by: ShreyashSri <[email protected]> Co-authored-by: J R VANISHA <[email protected]> Co-authored-by: Rudraksha Singh Sengar <[email protected]>
Based on the PR, I'm focusing on instrumenting the new API routes for events, particularly the High Priority:
Medium Priority:
Low Priority:
Here are my specific recommendations:
These recommendations provide a comprehensive observability approach for the new API routes, including:
The instrumentation follows best practices by capturing relevant context, properly handling errors, and ensuring spans are always closed even in error cases. |
* Handles file uploads and uploads the file to Cloudinary. | ||
* | ||
* @param {Request} request - The incoming HTTP request | ||
* @returns {Promise<Response>} - A response containing the uploaded image URL or an error message |
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.
* @returns {Promise<Response>} - A response containing the uploaded image URL or an error message | |
import { trace } from '@opentelemetry/api'; | |
import { logger } from '@/lib/logger'; // Assuming logger is available | |
import { trackEvent } from '@/lib/analytics'; // Assuming analytics tracking is available |
* @param {Request} request - The incoming HTTP request | ||
* @returns {Promise<Response>} - A response containing the uploaded image URL or an error message | ||
*/ | ||
/** |
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.
/** | |
const tracer = trace.getTracer('events-api'); | |
const span = tracer.startSpan('events-upload'); | |
logger.info('Processing event upload request'); |
* summary: Upload an image file to Cloudinary | ||
* description: This endpoint handles image file uploads and uploads the file to Cloudinary. | ||
* tags: | ||
* - Events |
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.
* - Events | |
logger.warn('No file provided in upload request'); | |
span.setStatus({ code: SpanStatusCode.ERROR }); | |
span.setAttribute('error.type', 'missing_file'); | |
span.end(); | |
trackEvent('event_upload_error', { error_type: 'missing_file' }); |
* multipart/form-data: | ||
* schema: | ||
* type: object | ||
* properties: |
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.
* properties: | |
logger.warn(`Invalid file type: ${file.type}`); | |
span.setStatus({ code: SpanStatusCode.ERROR }); | |
span.setAttribute('error.type', 'invalid_file_type'); | |
span.setAttribute('file.type', file.type); | |
span.end(); | |
trackEvent('event_upload_error', { error_type: 'invalid_file_type', file_type: file.type }); |
* description: The image file to be uploaded. | ||
* responses: | ||
* 200: | ||
* description: Successfully uploaded the image |
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.
* description: Successfully uploaded the image | |
logger.debug('Processing file upload', { | |
fileName: file.name, | |
fileSize: buffer.length, | |
fileType: file.type | |
}); | |
span.setAttribute('file.name', file.name); | |
span.setAttribute('file.size', buffer.length); | |
span.setAttribute('file.type', file.type); |
* type: object | ||
* properties: | ||
* message: | ||
* type: string |
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.
* type: string | |
logger.info('File successfully uploaded to S3', { | |
location: uploadResponse.Location, | |
key: uploadResponse.Key | |
}); | |
span.setAttribute('s3.location', uploadResponse.Location); | |
span.setAttribute('s3.key', uploadResponse.Key); | |
trackEvent('event_upload_success', { | |
file_type: file.type, | |
file_size: buffer.length | |
}); |
} catch (parseError) { | ||
// Log and handle errors while parsing form data | ||
console.error("Error parsing form data:", parseError); | ||
return NextResponse.json( |
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.
return NextResponse.json( | |
logger.error('Error processing event upload', { | |
error: error instanceof Error ? error.message : String(error) | |
}); | |
span.recordException(error instanceof Error ? error : new Error(String(error))); | |
span.setStatus({ code: SpanStatusCode.ERROR }); | |
trackEvent('event_upload_error', { | |
error_type: 'server_error', | |
error_message: error instanceof Error ? error.message : String(error) | |
}); | |
} finally { | |
span.end(); |
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server"; | |||
import Eventmodel from "@/models/Events"; | |||
import connectMongoDB from "@/lib/dbConnect"; | |||
import { v4 as uuidv4 } from "uuid"; | |||
import { cloudinary } from '@/Cloudinary'; |
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.
import { cloudinary } from '@/Cloudinary'; | |
import { trace } from '@opentelemetry/api'; | |
import { logger } from '@/lib/logger'; // Assuming logger is available | |
import { trackEvent } from '@/lib/analytics'; // Assuming analytics tracking is available |
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server"; | |||
import Eventmodel from "@/models/Events"; | |||
import connectMongoDB from "@/lib/dbConnect"; | |||
import { v4 as uuidv4 } from "uuid"; | |||
import { cloudinary } from '@/Cloudinary'; | |||
/** | |||
* @swagger |
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.
* @swagger | |
const tracer = trace.getTracer('events-api'); | |
const span = tracer.startSpan('get-events'); | |
logger.info('Processing get events request'); |
Summary: What does this PR do?
Which issue(s) this PR fixes:
Changes Made
Describe the changes you've made in this PR:
Type of Change
How Has This Been Tested?
Describe the tests you ran:
Please describe the test cases and expected behavior:
1.
2.
Screenshots (if applicable)
Dependencies
Documentation
Comments:
Reviewer Notes