feat: Add FCM analytics label support
Fixes #377
Summary
- Accept
analytics_label/analyticsLabelin FCM push data and validate it against Firebase's analytics-label-safe character set and length. - Forward valid labels into Firebase Admin SDK
fcmOptions.analyticsLabelfor Android and APNS-over-FCM payloads. - Keep analytics labels out of user custom payload data and document the new option.
Verification
npx eslint src/FCM.js spec/FCM.spec.js$env:TESTING='1'; npx c8 ./node_modules/.bin/jasmine(167 specs passing)
Summary by CodeRabbit
-
New Features
- Analytics labels are now supported for FCM push notifications on Android and Apple devices with format validation.
-
Documentation
- Added documentation describing analytics label format requirements and example payloads.
๐ Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.
[!TIP]
- Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
- Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
- Group code into logical blocks. Add a short comment before each block to explain its purpose.
- We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
- Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
- Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.
[!NOTE] Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.
[!CAUTION] Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.
This PR adds analytics label support to the Parse Server push adapter's FCM implementation. The change enables developers to include an FCM Analytics Label Support ๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.๐ Walkthrough
Walkthrough
analytics_label field in push requests, which is validated against a regex pattern and then integrated into both APNS and Android FCM payloads under fcmOptions.analyticsLabel.Changes
Layer / File(s)
Summary
Analytics Label Contract and Validation
src/FCM.jsA new
analyticsLabelPattern regex validates labels against ^[a-zA-Z0-9-_.~%]{1,50}$. The getAnalyticsLabel() helper extracts analytics_label or analyticsLabel from the request body or data field, validates it, and throws Parse.Error.PUSH_MISCONFIGURED when invalid.
APNS Payload Integration and Tests
src/FCM.js, spec/FCM.spec.js_APNSToFCMPayload() extracts the analytics label and maps it to apns.fcmOptions.analyticsLabel, while excluding analytics label keys from standard payload processing. Tests verify the label is correctly mapped and not included in the APNS payload body.
Android Payload Integration and Tests
src/FCM.js, spec/FCM.spec.js_GCMToFCMPayload() sets android.fcmOptions.analyticsLabel when present and adjusts data handling to copy the data object, remove analytics label and APNS-specific keys before serialization. Tests verify label mapping, exclusion from user data, and validation error handling for invalid labels.
User Documentation
README.mdNew "Analytics Label" subsection documents the validation pattern, shows how
analytics_label in push data is validated and forwarded to Firebase, and includes an example JSON payload.Estimated code review effort
Suggested reviewers
๐ฅ Pre-merge checks | โ
5 | โ 2
โ Failed checks (1 warning, 1 inconclusive)
Check name
Status
Explanation
Resolution
Docstring Coverage
โ ๏ธ Warning
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Engage In Review Feedback
โ Inconclusive
PR
#569 shows single commit with no evidence of review feedback engagement; unclear if PR is awaiting initial review or feedback has been addressed but not committed yet.Verify whether review feedback was actually given on the PR; if yes, confirm if author engaged in discussion or committed changes addressing feedback.
โ
Passed checks (5 passed)
Check name
Status
Explanation
Description check
โ
Passed
The description addresses the core requirements with summary, verification, and issue reference, though it lacks the template's structured format with explicit Task checkboxes.
Linked Issues check
โ
Passed
The implementation successfully validates analytics labels against the required regex pattern, forwards valid labels to fcmOptions, and documents the feature as specified in issue
#377.
Out of Scope Changes check
โ
Passed
All changes are directly aligned with issue
#377 objectives: validation logic, FCM payload integration, and documentation of the analytics label feature.
Security Check
โ
Passed
No security vulnerabilities detected. Regex is safe from ReDoS, input validation is strict, data properly copied and cleaned before use, and no prototype pollution or type confusion risks.
Title check
โ
Passed
The PR title 'feat: add FCM analytics label support' uses the required 'feat:' prefix and clearly summarizes the main change: adding FCM analytics label support functionality.
โจ Finishing Touches
๐งช Generate unit tests (beta)
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 @coderabbitai help to get the list of available commands and usage tips.
I will reformat the title to use the proper commit message syntax.
Ready for review. I kept the PR focused on FCM analytics label support, added validation coverage, and verified locally with eslint plus the focused Jasmine/c8 suite. The full npm test script is not Windows-shell compatible locally because it uses POSIX env assignment syntax, so I validated the same underlying checks directly.