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

Feature/add trigger session #31

Merged
merged 43 commits into from
May 27, 2022
Merged

Feature/add trigger session #31

merged 43 commits into from
May 27, 2022

Conversation

yusuftor
Copy link
Collaborator

@yusuftor yusuftor commented May 19, 2022

DON'T MERGE YET, CREATING FOR TESTING PURPOSES

Changes in this pull request

  • Added TriggerSession and AppSession with tests.
  • Determines app session duration from the config.
  • Removed all references to v1 triggers.
  • Consolidates Experiment models.
  • Stops PaywallInfo from being optional internally. 3.0 will include a breaking change to pass that on to users.
  • Parses expressionJs in a trigger rule (merged from Feature/parse expression js #33).
  • Updates SDK documentation (merged from Feature/change internal documentation #34)
  • Prices are represented as decimals instead of doubles and sent in the postback as strings (merged from Feature/pricing decimal representation #32)

Checklist

  • All tests pass. Demo project builds and runs.
  • I added tests, an experiment, or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have reviewed the contributing guide

I've added tests but this needs thorough real-life testing!

How it works

It creates the “pending sessions” from the config (one for each trigger + default paywall). These get enqueued and sent back to the server. Then when it gets to the relevant part it activates the session. Any activation/changes to the session get queued to be sent back to the server. I’ve given each tracking change it’s own function and grouped into relevant parts. Any preloading going on of paywalls/products/responses shouldn’t interfere with the active session because it (mostly) checks the IDs of the paywall that’s being preloaded first. As it’s sending off requests, it stores the last 20 sessions in memory which is then saved to disk when the app resigns active. When the app first opens up it checks to see if any of these are there and sends them off to the server and then clears the cache.
When the app session is changed, it automatically updates all pending and active sessions with the latest app session and sends these off to the server.

Things to look out for:

  • endAt dates. For example, App Session has an endAt date when a transaction occurs because the app leaves the foreground.
  • Checking out for preloaded products/paywall responses/webviews.

The environment is reverted to the production environment - to test, you'll need to change that to dev.

- Added isoString conversion in encoder, rather than storing strings in paywallsession model. In the future we should make all dates use this. Using the old date formatter way of creating iso strings.
- Added in experimentGroupId to trigger rule, and changed experimentId key.
- Added in more variables to paywallsession.
Removed all optionality of paywallInfo in callbacks and updated docs to reflect that.

**NOTE**: This is a breaking change and still requires a changelog entry.

This solves: https://linear.app/superwall/issue/SW-517/remove-nullability-from-paywallinfo
Cherry picked a commit that's destined for 3.0. This removes the optionality of PaywallInfo. This commit reverses the breaking changes exposed to the developer by keeping paywallInfo optional in public.
- Config wasn't getting decoded properly
- Bugfix for v2 trigger treatment
- Temporarily setting to network env to developer and enabling debug mode **This needs to be turned off before merging**
Tracking the time when products fail to load.
Made TriggerSession codable and enueue and save the latest 20 to disk with each trigger session update.
When the app is opened the next time, it fires off the last 20 triggersessions to the server.
- Fixed schema issue when sending triggersessions.
- The app session now times out after 1 hour or according to the timeout sent via config.
- A new id is created for a new app session, rather than just setting startAt.
- Last 20 sessions saved to disk on resigning active rather than every time a session is enqueued.
- Fixed and updated tests
- Logging partial success of events/session events endpoints.
- Added and fixed tests.
- Changed trigger sessions to create pending trigger sessions on config. These then get used when the trigger is fired.
- When loading the webview/products/paywallresponse, it now checks for the ID of the paywall before it tracks it. This is so that any preloading paywalls that are the ones to display (especially on session_start etc) can be logged. This negates the use of an `isPreloading` flag.
- Fixes issue with session_start not getting fired.
It is recommended to use Decimal over Double for prices (Apple's prices come back as NSDecimalNumber, which is an interchangeable reference semantic version of a Decimal). However, the encoder doesn't like encoding Decimal values so we're now sending them off as strings in the postback.
@yusuftor yusuftor mentioned this pull request May 23, 2022
4 tasks
- Updated both SDK documentation as well as function documentation.
- Removed docs referring to presenting.
- Removed unused public structs.
The sample apps now iterate over error codes to determine whether the presentation has indeed failed, or whether the user is in a holdout or noRuleMatch.
Also removed guide for presenting in the readmes for the sample apps
…mentation

Feature/change internal documentation
…esentation

Feature/pricing decimal representation
@jakemor jakemor merged commit bb45383 into develop May 27, 2022
@yusuftor yusuftor deleted the feature/add_paywall_session branch November 15, 2022 15:18
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