fix: complete TypeScript wrapper cleanup - #53
Conversation
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
Co-authored-by: Fadi George <fadi-george@users.noreply.github.com>
sherwinski
left a comment
There was a problem hiding this comment.
Review of the branch against main. Verdict: ship with small fixes.
The branch adds a tested classifyNotificationResponse helper to all three demos, fixes race conditions in the React useOneSignal hook, deduplicates tooltip initialization, replaces the source-hash tarball cache in examples/setup.sh with a content compare, and forwards target_branch to the shared prep-release workflow.
I checked these points:
- The
demoanddemo_podscopies are identical. - The shared
prep-release.ymlin sdk-shared acceptstarget_branch. vp pm packwrites fixed mtimes and a zero gzip timestamp, so thecmp -scompare insetup.shworks.
The should-fix items are inline. Small items and questions are below.
Small items
examples/setup.sh:33: if the globonesignal-capacitor-plugin-*.tgzdoes not match, the array holds the literal pattern. The script still fails underset -e, but the error fromcmpormvis not clear. A[[ -f "${new_tarball[0]}" ]]check with a message would help.examples/setup.sh:27: the script now runsvp run buildandvp pm packon every setup. The old stamp skipped both. The pack step is fast and the tarball compare keepsvp addcached, so this is fine. Please note the tradeoff in the header comment at line 11.examples/demo/src/hooks/useOneSignal.ts:246: the handler incrementsrequestSequenceRef, thenfetchUserDataFromApiincrements it again. The first increment only matters on thenullonesignalId path. A short comment would help the next reader.- Commit
4244d60says "preserve keys". TheObject.fromEntrieschange has the same behavior as the old loop, so the message overstates the change.
Questions
- Do the new example tests run in CI? The root
vite.config.tsincludes**/*.test.ts, so a localvp testruns theexamples/**tests. No workflow in.github/workflowsrunsvp test. Is that the plan? - Can the API return a partial success body for one subscription id? Example:
{"id":"x","recipients":1,"errors":{"invalid_player_ids":[...]}}. The classifier returnstransient-failureand retries a send that already went out. I expect this cannot happen with a singleinclude_subscription_idsentry, but I could not confirm it. - A missing
idwith a recognized error now maps tofailure, nottransient-failure. The old code treated a missing id as transient. The test for{}shows this is deliberate. Has the v1 endpoint ever returned a recognized indexing error with noidkey?
| # Build & test output | ||
| dist/ | ||
| coverage/ | ||
| .capacitor-sdk-source.stamp |
There was a problem hiding this comment.
Developers who ran the old script still have .capacitor-sdk-source.stamp on disk. After this change, git status shows the file as untracked for them.
Two options:
- Keep this ignore line for a while.
- Add
rm -f "$SDK_ROOT/.capacitor-sdk-source.stamp"toexamples/setup.shso the script removes the old stamp.
| } | ||
|
|
||
| if (isTransientSendFailure(response.data)) { | ||
| const disposition = classifyNotificationResponse(response.data); |
There was a problem hiding this comment.
The comment at line 96 still says: "Treat any 200 response with no real id, populated errors, or recipients=0 as transient." The classifier now retries only on recognized subscription-indexing errors. Please update the comment so a later reader does not widen the rule again.
The same comment exists in examples/demo_pods/src/services/OneSignalApiService.ts:96.
| } | ||
|
|
||
| if (isTransientSendFailure(response.data)) { | ||
| const disposition = classifyNotificationResponse(response.data); |
There was a problem hiding this comment.
The comment at line 110 describes the old retry rule. The classifier now retries only on recognized subscription-indexing errors. Please update the comment to match.
|
|
||
| const data: unknown = await response.json(); | ||
| if (!data || typeof data !== 'object' || Array.isArray(data)) { | ||
| window.alert('Send Failed\n\nInvalid notification response.'); |
There was a problem hiding this comment.
This check only confirms that the body is an object. A body like {"id":"","errors":["All included players are not subscribed"]} passes, and the user sees no alert. The other demos treat that body as a failure.
At minimum, check for a non-empty id and no errors key. If the no-location demo is intentionally minimal, a short comment that says so is enough.
|
Remaking this PR with a GitHub PAT instead of the Cursor GitHub App. |
Description
One Line Summary
Combine the Capacitor TypeScript wrapper release, demo validation, response handling, tooltip, cache, and lifecycle cleanup.
Details
Motivation
Linear: SDK-5125, SDK-5118, SDK-5122, SDK-5123, SDK-5124.
This consolidates all applicable Capacitor work from the React Native reference audits into one repository branch and PR.
Scope
target_branchto the shared release preparation workflow while preserving themaindefault.__proto__.References: OneSignal/react-native-onesignal#1981, #1982, #1983, #1984, #1985, #1988.
Testing
vp test run: 14 files and 224 tests pass; coverage thresholds pass.vp check: all 18 changed TypeScript/TSX files pass formatting, lint, and type checking.bash -n examples/setup.sh: pass.demo,demo_pods,demo_cap7, anddemo-no-location.vp checkhas an unchanged baselineREADME.mdformatting failure; the combined diff does not modify that generated file.Affected code checklist
Checklist