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

[Fix] Outcomes IndexedDB schema #1087

Merged
merged 8 commits into from
Aug 17, 2023
Merged

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Aug 16, 2023

Description

1 Line Summary

Fix errors saving clicked outcomes due to keyPath value changed incorrectly.

Details

We are doing the following indexedDB table renames in this commit:

  • NotificationClicked -> Outcomes.NotificationClicked
    • Correcting keyPath to "notificationId" in the new table.
  • NotificationReceived -> Outcomes.NotificationReceived

Modiviation

Fixes the notification click direct outcomes feature. Also it is unknown if the indexedDB errors are causing throwing that is resulting in any other side-effect issues due to errors not being caught.

This is done to correct the keyPath for the "NotificationClicked" indexedDB table, you can't change it so a new table must be created.

Background

Table was created with wrong keyPath of "notification.id" for new visitors for versions from 160000.beta4 to 160000. Writes were attempted as "notificationId" in released 160000 however they may have failed if the visitor was new when those releases were in the wild. However those new on 160000.beta4 to 160000.beta8 will have records saved as "notification.id" that will be converted here.

See related tickets below for more details on the history of the issue.

Validation

Tests

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

This makes changing the table name easier in future commits.
This was a change done in a beta version that shouldn't have as you must
make a migration if you want to make a schema change.
Added comment when the code was changed and the two different states the
indexedDB scehma could be in now.
Bumping indexDB to v5 and added a migration.

This commit address the two states NotificationClicked's keyPath can be
in due an older migration being changed when it shouldn't have. See
the previous commit for more details.

We are doing the following indexedDB table renames in this commit:
* NotificationClicked -> Outcomes.NotificationClicked
* NotificationReceived -> Outcomes.NotificationReceived

IndexedDB does not allow changing the keyPath to correct it so instead
we must create a new table. Only "NotificationClicked" needs to be fixed
however we are also renaming "NotificationReceived " and prefixing them
with "Outcomes." so they are consistent.

Comments in code explain in detail the effected versions and what was
wrong with them.
These should have "this" binded to them so they can access class level
properties. Became necessary since the introduction of
this.migrateOutcomesNotificationClickedTableForV5().
src/shared/services/Database.ts Show resolved Hide resolved
src/shared/services/IndexedDb.ts Outdated Show resolved Hide resolved
src/shared/services/IndexedDb.ts Outdated Show resolved Hide resolved
src/shared/services/IndexedDb.ts Outdated Show resolved Hide resolved
@jkasten2 jkasten2 changed the title WIP - [Fix] Outcomes IndexedDB schema [Fix] Outcomes IndexedDB schema Aug 17, 2023
@jkasten2 jkasten2 force-pushed the fix/outcomes_indexeddb_schema branch from cb40c0a to 38e1431 Compare August 17, 2023 19:56
@jkasten2 jkasten2 merged commit 9fe4ddc into main Aug 17, 2023
@jkasten2 jkasten2 deleted the fix/outcomes_indexeddb_schema branch August 17, 2023 19:58
@jkasten2 jkasten2 mentioned this pull request Aug 17, 2023
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