Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[User Model] [Fix] Notification Open & Confirm Delivery REST API calls failing #1079

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Aug 10, 2023

Description

1 Line Summary

Notification Open & Confirm Delivery REST API calls were failing due to placeholder player_id being used.

Details

CoreModuleDirector was introduced in v16, and is the place to access the pushSubscriptionId we needed. However CoreModuleDirector does not work in the ServiceWorker context since it uses JS APIs that are not available. This includes localStorage (possibly switch to indexDB in the future) as well as access to window and possibly others. Give the scope of such changes would large and has unknowns to address CoreModuleDirector we added a ModelCacheDirectAccess class to directly access what we needed, on the trade off it duplicates some code.

Validation

Tests

Tested on Chrome on Windows 11. Ensure both notification open and confirm deliveries show on the dashboard.

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable

Both confirm deliveries & notification open were building their REST API
with an old placeholder deviceId value from Database.getSubscription().
To fix the problem we are now using the model cache where we started to
store the subscription id with v16.

This commit is scoped to fixing this deviceId issue with confirm
deliveries & notification open only. A larger change is needed to
clean this up completely.
@jkasten2 jkasten2 requested review from rgomezp and emawby August 10, 2023 01:19
@emawby
Copy link
Contributor

emawby commented Aug 10, 2023

Do we know why CoreModuleDirector doesn't work in the SW context?

@jkasten2
Copy link
Member Author

Do we know why CoreModuleDirector doesn't work in the SW context?

That is a good question, I updated my PR details with an answer to this.

@jkasten2 jkasten2 merged commit d00db6d into user-model/v1 Aug 10, 2023
@jkasten2 jkasten2 deleted the fix/sw-click-and-confirm-delivery-calls branch August 10, 2023 01:28
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.

2 participants