-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(api): Add missing content type header for Campaign Monitor email signup #16936
fix(api): Add missing content type header for Campaign Monitor email signup #16936
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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
🧹 Outside diff range and nitpick comments (2)
libs/api/domains/email-signup/src/lib/services/campaignMonitor/campaignMonitor.service.ts (2)
38-43
: Consider adding request validationThe current implementation could benefit from additional validation:
- Verify that the URL is not empty before making the request
- Ensure the payload is JSON-serializable
Consider adding these checks:
async subscribeToMailingList( emailSignupModel: EmailSignup, inputFields: EmailSignupInput['inputFields'], ) { const url = (emailSignupModel.configuration?.signupUrl as string) ?? '' + if (!url) { + throw new Error('Campaign Monitor signup URL is required') + } // ... existing code ... const obj = Object.fromEntries(map) + try { + JSON.stringify(obj) // Validate JSON serialization + } catch (e) { + throw new Error('Invalid payload for Campaign Monitor API') + } return axios
Line range hint
44-52
: Enhance error handling and response processingThe current error handling could be improved in several ways:
- The success check logic
response?.data?.result === 'error' ? false : true
is unnecessarily complex- Generic error handling loses valuable debug information
- Missing error logging for monitoring purposes
Consider this improved implementation:
}) .then((response) => { + const isError = response?.data?.result === 'error' + if (isError) { + console.error('Campaign Monitor subscription failed:', response.data) + } return { - subscribed: response?.data?.result === 'error' ? false : true, + subscribed: !isError, } }) - .catch(() => { + .catch((error) => { + console.error('Campaign Monitor API error:', error.message) return { subscribed: false } })🧰 Tools
🪛 Biome
[error] 46-46: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
libs/api/domains/email-signup/src/lib/services/campaignMonitor/campaignMonitor.service.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/api/domains/email-signup/src/lib/services/campaignMonitor/campaignMonitor.service.ts (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (1)
libs/api/domains/email-signup/src/lib/services/campaignMonitor/campaignMonitor.service.ts (1)
38-43
: LGTM: Content-Type header addition is correct
The addition of the 'Content-Type: application/json' header is appropriate for the JSON payload being sent.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16936 +/- ##
=======================================
Coverage 36.43% 36.43%
=======================================
Files 6904 6904
Lines 144701 144701
Branches 41345 41345
=======================================
Hits 52723 52723
Misses 91978 91978
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
|
Datadog ReportBranch report: ✅ 0 Failed, 4 Passed, 0 Skipped, 2.7s Total Time |
Add missing content type header for Campaign Monitor email signup
Summary by CodeRabbit
New Features
Content-Type
header to ensure proper API request formatting.Bug Fixes