-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[MBL-870] Fix GraphSchema with an Update to AppTrackingTransparency #1832
Conversation
…/background transitions Also sets up our AppTrackingTransparency for use with `triggerThirdPartyEvents` which is going to be a replacement for `triggerCapiEvents` (once we get the go ahead from Leigh that all the bugs are fixed)
@@ -590,9 +590,10 @@ public enum GraphAPI { | |||
/// - appData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not review this file it's auto generated by bin/apollo-schema-download.sh
KsApi/graphql-schema.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not review this file it's auto generated by bin/apollo-schema-download.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really prevent these - they are small automatic SPM framework updates, but I generally check the release tags of the repo - if for example we go up a couple mid versions ie. 7.6.2 --> 7.8.0 (Kingfisher), to make sure nothing obvious broke/changed.
Generated by 🚫 Danger |
Codecov Report
@@ Coverage Diff @@
## main #1832 +/- ##
==========================================
+ Coverage 84.35% 84.37% +0.02%
==========================================
Files 1276 1276
Lines 115457 115679 +222
Branches 30751 30764 +13
==========================================
+ Hits 97395 97606 +211
- Misses 16994 17007 +13
+ Partials 1068 1066 -2
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@scottkicks Here's a big one! Couldn't be avoided because the schema changes. This PR fix unblocks our test failures on all the other PRs. As soon as this goes in I'll review your outstanding PRs, just assign them to me if ready once tests pass. |
@@ -3,6 +3,8 @@ import Foundation | |||
|
|||
private class MockRemoteConfigValue: RemoteConfigValue { | |||
var bool = false | |||
|
|||
override var boolValue: Bool { self.bool } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this change needs to be made, it is more relevant to my creator dashboard ff related changes . Might be worth removing to maintain a clearer context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea good call out, I noticed that too but some tests need to pass using the MockRemoteConfigClient
and under the hood it uses the RemoteConfigValue
which in our helper classes references .boolValue
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right. ok cool
guard project.sendMetaCapiEvents else { return } | ||
|
||
AppEnvironment.current.appTrackingTransparency.updateAdvertisingIdentifier() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this pattern we need to always remember to updateAdvertisingIdentifier before accessing the identifier and calling the mutation.
Maybe we can mitigate the risk of forgetting by adding a helper method in AppTrackingTransparency
that calls updateAdvertisingIdentifier and then returns the advertisingIdentifier 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that's a good idea - in the cases where to do the check for advertisingIdentifer
before calling triggerCapiEvents
let's do that. Could you add that once we start on triggerThirdPartyEvents
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good. i'll make a note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Developer testing steps look good and everything is working well 👍
left some comments with suggestions, that are not required for approval, for you to consider.
📲 What and 🤔 Why
Firstly - don't be alarmed at the number of changes - that's mostly due to
bin/apollo-schema-download.sh
making automatic updates - there's only about 800 actual lines of application code that changed including tests.There are a few things this PR covers:
triggerThirdPartyEvents
triggerCAPIEvents
mutation changes from runningbin/apollo-schema-download.sh
advertisingIdentifier
can be turned off via Settings - so we need to checkATTrackingManager.trackingAuthorizationStatus
every time we usetriggerCapiEvents
orKSRAnalytics
(Segment tracking)🛠 How this was build out
The structure of
AppTrackingTransparency
It's all basically in
AppTrackingTransparency
which is now aclass
not astruct
- because we want to set theadvertisingIdentifier
internally to the object. We don't want to allow it to be set outside its' own instance.Which makes sense because we have a stack of
Environment
objects that refreshes every time the app is backgrounded/foregrounded. SeedidFinishLaunchingWithOptions
fromStorage
,replaceEnvironment
(many places) andpushEnvironment
(many places). So if by default we haveEnvironment(appTrackingTransparency: AppTrackingTransparency = AppTrackingTransparency())
, then its' easier to set thatadvertisingIdentifier
oninit
than after the fact which is messy.This is much easier in a
class
thanstruct
because astruct
requires making functionsmutating
to change internal properties.Ensuring we represent the latest permissions for tracking from the system
AppDelegateViewModel
requestATTrackingAuthorizationStatus
has also changed to check if the app isactive
after its' launched (which is triggered when the app comes in from a background state).You'll also see that we call a new
updateAdvertisingIdentifier
function before checking theadvertisingIdentifier
wherever it is used. This is way to ensure the permissions are allowed before tracking right before use.That's probably a lot to absorb and it took me about a week to figure all this out, so feel free to ask questions on any details that aren't clear. Here is the official Apple documentation where I started - https://developer.apple.com/documentation/apptrackingtransparency
Passing around the
AppTrackingTransparency
inAppEnvironment
So we might use this class instead of what it was before - just the
advertisingIdentifier
string when we switch totriggerThirdPartyEvents
. We can technically have a setting that can be sent in that mutationapplicationTrackingEnabled
that we set in-app.✅ Acceptance criteria
⏰ TODO
⏰ Developer Testing
triggerCapiEvents
are not being sent.