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

[Feat] Combine user property updates for network call improvements, fix purchase bug #1444

Merged
merged 15 commits into from
Jun 11, 2024

Commits on May 24, 2024

  1. Session data and purchases become Deltas first, not Requests

    * session_count, session_time, and purchases are not model-driven. We were turning their data into `OSRequestUpdateProperties` instances immediately instead of enqueueing as Deltas first. This means they could not be combined with other User Updates in a single request.
    * Now, when they will send their data to the User Manager, it will manually enqueue a Delta onto the Operation Repo.
    
    * Previously, we used a flag to indicate if we should send these requests immediately (meaning the app is backgrounded), but that is no longer needed because the Deltas are enqueued to the Operation Repo, and then the Operation Repo has its own background task to flush.
    nan-li committed May 24, 2024
    Configuration menu
    Copy the full SHA
    4da002e View commit details
    Browse the repository at this point in the history
  2. Update Unattributed Time Processor to use new methods

    * The time processor will not handle its own background task.
    * The ordering will be correct when the app is backgrounded. This time is sent to the user manager who enqueues a delta with the session time. Then the Operation Repo will start its background task and flush deltas.
    nan-li committed May 24, 2024
    Configuration menu
    Copy the full SHA
    58c8c79 View commit details
    Browse the repository at this point in the history
  3. Update Attributed Time Processor to use new methods

    * The attributed time processor needs to send data to two separate places: session_time for Update User and session time for Outcomes.
    * Before sending data to outcomes, it needs to wait 30 seconds to see if the app re-opens in case the SDK will continue on the same session, this is for the outcomes endpoint to know session count for influences.
    * It will now send session_time to the user manager immediately as this does not need to wait for 30 seconds. The ordering will be correct when the app is backgrounded. This time is sent to the user manager who enqueues a delta with the session time. Then the Operation Repo will start its background task and flush deltas.
    * It will only send the elapsed time and does not need to handle unsent active time. This is because previous session times will be their own Delta instances that the operation repo / executor handles with retrying. These previous deltas already encompass the unsent active time.
    * The Attributed Time Processor still has a separate background task that handles sending the outcome, manages the 30 seconds wait time, and maintains a background task for it. It uses unsent active time and resets to 0 when the request is successful.
    nan-li committed May 24, 2024
    Configuration menu
    Copy the full SHA
    394381e View commit details
    Browse the repository at this point in the history
  4. Add concept of supported fields for user updates

    * OSDeltas can be created by Model changes and now manually created by the User Manager to enqueue updates not driven by model changes. These are for session time, session count, and purchases. In the latter scenario, the User Manager can set a value of "session_time" for example, but could potentially set any random string.
    * Introduce an enum OSPropertiesSupportedProperty, that restricts the properties we allow for updating a user.
    nan-li committed May 24, 2024
    Configuration menu
    Copy the full SHA
    6ddd65f View commit details
    Browse the repository at this point in the history

Commits on May 28, 2024

  1. Combine user update deltas

    * When processing the Delta queue and turning them into requests, we now combine deltas into one User Update request.
    nan-li committed May 28, 2024
    Configuration menu
    Copy the full SHA
    ce80822 View commit details
    Browse the repository at this point in the history
  2. Remove no longer used struct OSPropertiesDeltas

    * Also noted that we enqueue only one Properties Delta change at a time - for example, one of session_time, session_count, or purchases - so the struct OSPropertiesDeltas is not needed. It was always being created with only 1 property and the rest being nil.
    * Now that these properties deltas are going to be combined together, we are not using this struct anymore anyways.
    nan-li committed May 28, 2024
    Configuration menu
    Copy the full SHA
    73ce821 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5d39587 View commit details
    Browse the repository at this point in the history
  4. Purchase tracking fix variable type to be string

    * SKProduct.price is an NSDecimalNumber and we had been sending this as is, but the backend expects a String
    * This can be reproduced manually by a creating purchase array and calling `OneSignalUserManagerImpl sendPurchases`
    * It returns a 400 with: "Field deltas.purchases.amount was expecting value of type 'string', received value of type 'number' instead"
    nan-li committed May 28, 2024
    Configuration menu
    Copy the full SHA
    08b84ba View commit details
    Browse the repository at this point in the history
  5. [tests] add Objective-C user module tests

    * Purchases are tracked in Objective-C and data is passed to the user manager to send purchases.
    * It is more accurate to keep purchase tracking tests in Objective-C as well as passing data can be a source of errors
    nan-li committed May 28, 2024
    Configuration menu
    Copy the full SHA
    3b47509 View commit details
    Browse the repository at this point in the history
  6. [tests] Add dictionary sorting to request's parameters

    * There is a need to compare two User Update Requests, with limitations of comparing Objc dictionaries to Swift dictionaries, and the Mock Client not knowing about product-specific OneSignalRequest implementations like OSRequestUpdateUser.
    * So, we can do comparison via their parameters payload.
    * Add logic to stringify the params in alphabetical order to allow streamlined comparison
    nan-li committed May 28, 2024
    Configuration menu
    Copy the full SHA
    434cfd6 View commit details
    Browse the repository at this point in the history
  7. [tests] update tests to show combined operations

    * When a tag and a language are added, they are now set in 1 request containing both updates instead of 2 requests
    nan-li committed May 28, 2024
    Configuration menu
    Copy the full SHA
    a8a4033 View commit details
    Browse the repository at this point in the history

Commits on May 29, 2024

  1. [tests] add testing combining user updates

    * Add a test where many user properties updates are made and check they are all sent in one payload correctly
    * Update an equality checker helper method to handle testing float equality, needed for checking lat and long in the payload.
    nan-li committed May 29, 2024
    Configuration menu
    Copy the full SHA
    5c37734 View commit details
    Browse the repository at this point in the history
  2. [tests] Operation Repo polling is too quick for test

    * Some tests require more time for the user updates to enqueue before the flush
    nan-li committed May 29, 2024
    Configuration menu
    Copy the full SHA
    f1a986d View commit details
    Browse the repository at this point in the history

Commits on Jun 11, 2024

  1. address review comments

    * Rename `SupportedProperty.swift` to `OSPropertiesSupportedProperty.swift` and move to a higher-up folder in the user module
    * Simplify a piece of logic for combining properties by removing unnecessary intermediate step
    * Change a parameter type to an enum for more clarity and control
    nan-li committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    e37e40b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f88eb7d View commit details
    Browse the repository at this point in the history