Adaptive notification#427
Merged
Merged
Conversation
…pting delivery cadence to recent user activity instead of using a fixed frequency. - Enforce per-notification-type throttling so noisy channels (e.g. messages) don’t overwhelm inactive users. ### Description - Added engagement tracking fields to the notification store: `lastEngagedAt` and `lastNotificationSentAtByType` and persisted them in storage (`src/store/notificationStore.ts`). - Implemented helper actions `recordEngagement()`, `getNotificationThrottleMinutes()` (returns 5/30/180 minutes based on inactivity), and `shouldThrottleNotification(type, now?)` to enforce per-type throttling and update last-sent timestamps (`src/store/notificationStore.ts`). - Wired behavior into notification handling: tapping a notification now calls `recordEngagement()`, and foreground notifications call `shouldThrottleNotification()` and are dropped (with a log) if they fall within the adaptive throttle window (`src/utils/notificationHandlers.ts`). - Added unit test coverage for engagement-aware throttling and updated existing notification store tests to initialize the new fields (`src/__tests__/store/notificationStore.test.ts`, `tests/store/notificationStore.test.ts`). - Documented the thresholds and behavior in `README.md` under "Adaptive Notification Throttling". ### Testing - Attempted to run the modified tests with `npm test -- src/__tests__/store/notificationStore.test.ts src/__tests__/utils/notificationHandlers.test.ts tests/store/notificationStore.test.ts` which failed because the `jest` binary is not available in the environment (error: `sh: 1: jest: not found`). - Attempted to run tests with `npx jest ...` but fetching test runner failed due to registry access being blocked (`npm error code E403`), so tests could not be executed in this environment. - No automated test failures were observed in-repo (tests were added/updated), but the execution attempts above were blocked by the environment and therefore test results are inconclusive. ------ Closes rinafcode#404 feat: adaptive notification throttling based on user engagement
|
@gloskull Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
kindly resolve conflict. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
lastEngagedAtandlastNotificationSentAtByTypeand persisted them in storage (src/store/notificationStore.ts).recordEngagement(),getNotificationThrottleMinutes()(returns 5/30/180 minutes based on inactivity), andshouldThrottleNotification(type, now?)to enforce per-type throttling and update last-sent timestamps (src/store/notificationStore.ts).recordEngagement(), and foreground notifications callshouldThrottleNotification()and are dropped (with a log) if they fall within the adaptive throttle window (src/utils/notificationHandlers.ts).src/__tests__/store/notificationStore.test.ts,tests/store/notificationStore.test.ts).README.mdunder "Adaptive Notification Throttling".Testing
npm test -- src/__tests__/store/notificationStore.test.ts src/__tests__/utils/notificationHandlers.test.ts tests/store/notificationStore.test.tswhich failed because thejestbinary is not available in the environment (error:sh: 1: jest: not found).npx jest ...but fetching test runner failed due to registry access being blocked (npm error code E403), so tests could not be executed in this environment.Closes #404