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!: iOS as a source for Data Pipelines #659

Merged
merged 132 commits into from Mar 20, 2024
Merged

Conversation

Shahroz16
Copy link
Contributor

No description provided.

Shahroz16 and others added 30 commits November 27, 2023 16:55
Co-authored-by: Muhammad Rehan <mrehan.official@gmail.com>
Co-authored-by: Muhammad Rehan <mrehan.official@gmail.com>
levibostian and others added 24 commits March 11, 2024 14:13
Based on what types of files we are creating, I suggest that we change the directory of where files are saved.

To help with this decision, here is a summary of the OS directories of their suggested use cases:

.documentDirectory:
* Data stored here is backed up by iTunes and iCloud.
* Suitable for data that the user would not typically manipulate or interact with directly, such as configuration files or cached data.

.applicationSupportDirectory:
* Use this directory for data that is generated by your application and can be re-created or downloaded again.
* Data stored here helps support the functionality of your app but can be replaced without loss of significant data.

.cachesDirectory:
* Data stored in this directory can be purged by the system at any time, so it should not be relied upon for long-term storage.

.libraryDirectory:
* Use this directory for files that are critical to the functioning of your app but are not user-generated. This could include databases, preferences, or other app-related data.
* Data stored here is not visible to the user through the Files app.

commit-id:90e4b304
… events

Part of: https://linear.app/customerio/issue/MBL-95/reduce-time-it-takes-for-test-suite-to-execute-by-replacing-sleep

The EventBus performs a lot of async operations that test functions try to test against. This change tries to increase the performance and reliability of tests that use the EventBus.

The following changes have been made:
* All properties of Mock classes are now atomic for thread-safety. This is required for the EventBus async operations to update values on different threads then the test function.
* Added functions to EventBus that wait for operations to complete. Test functions can use these methods to get notified when async operations are complete.
* Created a data type, TaskBag, that makes it easy for a set of Swift async Task objects can be cancelled when a class is deinitialized. I was noticing that some test functions would finish running, but EventBus async operations were still running. To increase reliability of tests, all EventBus async tasks are cancelled when test function is finished. Giving each test run a clean environment.

commit-id:bc8610c2
Part of: https://linear.app/customerio/issue/MBL-95/improve-test-suite-compatibility-with-async-eventbus-operations

As part of improving test suite compatibility with the EventBus, this refactor reduces flakiness by replacing the async operations in tearDown() with synchronous operations. The async code (`Task {}`) in the synchronous function (`deleteAllPersistentData`) is not guaranteed to complete by the time tearDown() is complete. This can create flaky test results where, for example, the EventBus does not reset before the next test function runs. 

This synchronous solution was chosen because it has another benefit for us: by using this more generic solution, we do not need to reset the data store for just the EventBus, we reset the data stores for all objects. Making the test suite easier to maintain. 

As an alternative solution, we could convert all test classes in the test suite to use `tearDown() async` instead of `tearDown()`. Then, we would guarantee that all async operations would complete before `tearDown()` is complete. 

commit-id:42b484a0
After merging main into cdp branch, cocoapods sample app is not compiling on the CI server. This change got the app to compile on my local dev machine.
Part of: https://linear.app/customerio/issue/MBL-164/cdp-branch-flaky-tests-on-ci

We have been experiencing some flaky tests, only when running on our CI. After reviewing the test functions and the error messages thrown on CI, I think that the issue is because of slow performance when running the test suite on the CI. After doing some research online, others were sharing similar issues, specifically when running tests on Xcode 15.0 and 15.1. Xcode release notes also share known issues when running tests on CI and slow performance.

By updating our CI to macos 14 github action runners, we are installing Xcode 15.2 which has better test performance.

commit-id:ee65f070
Part of: https://linear.app/customerio/issue/MBL-164/cdp-branch-flaky-tests-on-ci

Refactored all of the test functions in the in-app module implementation tests. `MessagingInApp.initialize` creates multiple EventBus observe functions. When an EventBus event is posted in the test functions, we do not know when the in-app EventBus observer function will be called.

Previously, `sleep` or a busy while loop was used to wait for the EventBus event to post and be received in the in-app module. No solution up to this point has been un-flaky. This commit is yet another solution that tries to solve the problem of waiting for async EventBus events to be received by the in-app module.

commit-id:2edb7e5e
Sometimes you will see the error message "Could not install WWDR certificate" on CI when fastlane tries to build one of the sample apps.

Recent versions of fastlane included fixes for this issue. This commit updates fastlane and all of it's dependencies to the latest version.

commit-id:b736b1e9
Part of: https://linear.app/customerio/issue/MBL-164/cdp-branch-flaky-tests-on-ci

There is a set of flaky tests that all have 1 thing in common: They are the only tests that call the functions `runOnBackground` or `runOnMain`. 

From my own personal experience and research online, tests that use GCD can have unexpected/flaky results, especially on simulators. Recent versions of Xcode or Swift may also have changed the behavior to become flaky. 

This commit changes to using swift concurrency instead of GCD to run test functions on background threads. We hope that all of these tests pass on the CI with no more flaky results. 

commit-id:cc25358b
Part of: https://linear.app/customerio/issue/MBL-167/segment-dependency-currently-pointing-to-main-branch

In the iOS SDK today, with the Segment CDP SDK, we are currently specifying the version of the segment SDK as "main branch". Using a git branch as the version of a dependency poses risks, potentially leading to difficulties for customers during SDK updates and app compilation, increasing the chance of crashes or compilation issues.

This change uses a hard-coded git commit. The git commit used is the latest commit on the "main" branch.

There are pros and cons to using a git commit as the version, as specified in the ticket description. We can change to a different version such as a git tag in the future.

commit-id:45c2d17e
Copy link

github-actions bot commented Mar 20, 2024

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.


  • APN-UIKit: main-replica-for-cdp (1710947723)
  • CocoaPods-FCM: main-replica-for-cdp (1710947753)

Copy link

github-actions bot commented Mar 20, 2024

Warnings
⚠️

I noticed file Tests/MessagingInApp/APITest.swift was modified. That could mean that this pull request is introducing a breaking change to the SDK.

If this pull request does introduce a breaking change, make sure the pull request title is in the format:

<type>!: description of breaking change 
// Example:
refactor!: remove onComplete callback from async functions 
⚠️

I noticed file Tests/MessagingPushAPN/APITest.swift was modified. That could mean that this pull request is introducing a breaking change to the SDK.

If this pull request does introduce a breaking change, make sure the pull request title is in the format:

<type>!: description of breaking change 
// Example:
refactor!: remove onComplete callback from async functions 
⚠️

I noticed file Tests/MessagingPushFCM/APITest.swift was modified. That could mean that this pull request is introducing a breaking change to the SDK.

If this pull request does introduce a breaking change, make sure the pull request title is in the format:

<type>!: description of breaking change 
// Example:
refactor!: remove onComplete callback from async functions 

Generated by 🚫 dangerJS against fe0b0f8

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 72.39693% with 395 lines in your changes are missing coverage. Please review.

Project coverage is 53.22%. Comparing base (9dad7f3) to head (5f7aece).
Report is 182 commits behind head on main.

❗ Current head 5f7aece differs from pull request most recent head fe0b0f8. Consider uploading reports for the commit fe0b0f8 to get more accurate results

Files Patch % Lines
...rces/DataPipeline/DataPipelineImplementation.swift 64.03% 73 Missing ⚠️
...ces/Migration/DataPipelineMigrationAssistant.swift 50.00% 50 Missing ⚠️
Sources/DataPipeline/DataPipeline.swift 23.43% 49 Missing ⚠️
...es/MessagingPush/RichPush/RichPushHttpClient.swift 68.96% 36 Missing ⚠️
...ssagingPush/RichPush/RichPushDeliveryTracker.swift 11.53% 23 Missing ⚠️
Sources/Common/Communication/Event.swift 80.51% 15 Missing ⚠️
Sources/Common/Background Queue/Queue.swift 0.00% 14 Missing ⚠️
Sources/DataPipeline/CustomerIO.swift 39.13% 14 Missing ⚠️
Sources/DataPipeline/CustomerIO+Plugins.swift 14.28% 12 Missing ⚠️
Sources/Common/Util/KeyValueStorage.swift 35.29% 11 Missing ⚠️
... and 21 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #659      +/-   ##
==========================================
- Coverage   56.11%   53.22%   -2.89%     
==========================================
  Files         103      139      +36     
  Lines        1153     3870    +2717     
==========================================
+ Hits          647     2060    +1413     
- Misses        506     1810    +1304     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shahroz16 Shahroz16 merged commit 0a68373 into main Mar 20, 2024
6 of 7 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 20, 2024
## [3.0.0](2.12.5...3.0.0) (2024-03-20)

### ⚠ BREAKING CHANGES

* iOS as a source for Data Pipelines (#659)

### Features

* iOS as a source for Data Pipelines ([#659](#659)) ([0a68373](0a68373))
* migration module to cater to all migration tasks  ([#530](#530)) ([2feb1d4](2feb1d4))

### Bug Fixes

* add attributes to properties  ([#649](#649)) ([4b02e92](4b02e92))
* all sdk modules can only be initialized once ([ae46c7f](ae46c7f))
* app crash on identify method ([#458](#458)) ([13e9862](13e9862))
* compilation for test ([f14b773](f14b773))
* compilation issue ([420a61e](420a61e))
* eventbus handler ref ([#469](#469)) ([8c8ef91](8c8ef91))
* journey id in migration payload ([#653](#653)) ([3b649c9](3b649c9))
* prevent duplicate automatic screenview events from being tracked ([fea9ec5](fea9ec5))
* pushEventHandler test ([dc80fc2](dc80fc2))
* remove occurrence of autoTrackDeviceAttributes from all push modules ([#505](#505)) ([8dc6507](8dc6507))
* removed last_used from properties  ([#477](#477)) ([b0b9631](b0b9631))
* sample app issues ([#551](#551)) ([05544b3](05544b3))
* use git commit instead of git branch for segment dependency ([d245015](d245015))
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.

None yet

4 participants