Skip to content

feat: Add FCM analytics label support#569

Open
businesscurry123 wants to merge 1 commit into
parse-community:masterfrom
businesscurry123:codex/fcm-analytics-label
Open

feat: Add FCM analytics label support#569
businesscurry123 wants to merge 1 commit into
parse-community:masterfrom
businesscurry123:codex/fcm-analytics-label

Conversation

@businesscurry123
Copy link
Copy Markdown

@businesscurry123 businesscurry123 commented May 24, 2026

Fixes #377

Summary

  • Accept analytics_label / analyticsLabel in FCM push data and validate it against Firebase's analytics-label-safe character set and length.
  • Forward valid labels into Firebase Admin SDK fcmOptions.analyticsLabel for 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.

Review Change Stack

@parse-github-assistant
Copy link
Copy Markdown

parse-github-assistant Bot commented May 24, 2026

🚀 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

📝 Walkthrough

Walkthrough

This PR adds analytics label support to the Parse Server push adapter's FCM implementation. The change enables developers to include an 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

FCM Analytics Label Support

Layer / File(s) Summary
Analytics Label Contract and Validation
src/FCM.js
A 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.md
New "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

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • dplewis
🚥 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@businesscurry123 businesscurry123 changed the title Add FCM analytics label support feat: add FCM analytics label support May 24, 2026
@parse-github-assistant
Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title feat: add FCM analytics label support feat: Add FCM analytics label support May 24, 2026
@businesscurry123
Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Analytics Label Support for FCM Messages in Parse Server Push Adapter

1 participant