feat: Add `apns-id` header to client return value
This exposes the apns-id header that is returned to identify a notification for debugging and tracking.
Summary by CodeRabbit
-
New Features
- APNs notification IDs returned by the server are now captured, surfaced with results, and included in subsequent request headers when available.
-
Tests
- Test suite expanded to verify APNs ID extraction/merging into results and correct request/connection behavior under concurrent requests.
βοΈ Tip: You can customize this high-level summary in your review settings.
π Thanks for opening this pull request!
π Walkthrough
Walkthrough
Client now captures apns-id from response headers into a local notificationId, threads it through the request flow, and updated createHeaderObject to accept notificationId so outgoing requests include an apns-id header when available.
Changes
| Cohort / File(s) | Summary |
|---|---|
Client logic lib/client.js |
Introduce local notificationId in request flow; parse apns-id from response headers and store it; pass notificationId into createHeaderObject; update Client.prototype.createHeaderObject(uniqueId, requestId, channelId, notificationId) and header construction to include apns-id when present. |
Tests test/client.js |
Add tests asserting server apns-id response headers are merged into returned results for device and channel flows and that concurrent requests and connection reuse behavior remain unchanged. |
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~25 minutes
π₯ Pre-merge checks | β 3
β Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title clearly and specifically describes the main change: exposing the APNs apns-id header in the client return value, which matches the core objective of the PR. |
| Docstring Coverage | β Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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.
:white_check_mark: Snyk checks have passed. No issues have been found so far.
| Status | Scanner | Total (0) | ||||
|---|---|---|---|---|---|---|
| :white_check_mark: | Open Source Security | 0 | 0 | 0 | 0 | 0 issues |
:computer: Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 95.86%. Comparing base (0d8bc6b) to head (9ea743a).
:warning: Report is 2 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #195 +/- ##
==========================================
+ Coverage 95.84% 95.86% +0.01%
==========================================
Files 23 23
Lines 842 846 +4
==========================================
+ Hits 807 811 +4
Misses 35 35
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
I added the header to existing tests, hope that is satisfactory. The other propagated headers are also tested indirectly but are more directly linked to a specific type of api call. In my understanding the apns-id header should be returned for every type of remote notification creation (generated by server if not provided).
If you'd want a separate test for this specific header I'll do that.
@RedPhoenixQ Thanks, we generally ask for not modifying existing tests if not necessary and add a new, specific test with an identifier that describes what it tests. So could you please revert the changes (unless necessary for existing tests to pass) and add a distinct test like it('returns APNs notification ID in response') or whether best describes it?
I misunderstood the purpose of the ManageChannelsClient tests and there indeed doesn't need to be a separate test there as is also uses the Client. I removed the duplicate
@RedPhoenixQ could you rebase the PR and see the test in https://github.com/parse-community/node-apn/pull/195#discussion_r2747487085 for ways to simplify your suggested test.
Thank you for taking the time. I've simplified the test as per the recommendation (amending the commit) and rebased on master
π This change has been released in version 7.1.0