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

[WEB-970] Add CAPI Events #1798

Merged
merged 28 commits into from
Mar 8, 2023
Merged

[WEB-970] Add CAPI Events #1798

merged 28 commits into from
Mar 8, 2023

Conversation

scottkicks
Copy link
Contributor

@scottkicks scottkicks commented Mar 2, 2023

📲 What

Triggers our new triggerCapiEvent mutation in the following cases

Event Cases:

  • Project page visit
  • Initiate checkout (selects a reward)
  • Add new payment method
  • Purchase (have reached the thank you page)

Events should only trigger if the following is true:

  1. The member has given their consent for KS to track them via AppTrackingTransparencey.trackingAuthorizationRequest
  2. The sendMetaCapiEvents property on the project is true.

🤔 Why

This mutation helps us collect data on those members that have entered the app via a FB ad. Since iOS members can opt out of 3rd party app tracking, our FB pixel could be rendered useless. Facebook's CAPI (Conversions API) allows us to collect tracking data server to server, essentially getting around this issue.

It's important to note that Facebook does some magic on their end to associate the member emails we send to them with ad clicks so it's important that we send this value back whenever possible. There is of course the case where someone has enters from an ad and doesn't not log in/create an account.

🛠 How

Created a new service:

  • AppTrackingTransparency: for getting authorizationStatus and advertisingIdentifier

Then I just made those calls in the correct places according to the cases listed above

Note: We've been using this project for testing. It has its sendMetaCapiEvents property set to true.

@scottkicks scottkicks added this to the release-5.6.2 milestone Mar 2, 2023
@scottkicks scottkicks self-assigned this Mar 2, 2023
@scottkicks scottkicks marked this pull request as ready for review March 2, 2023 17:53
@codecov
Copy link

codecov bot commented Mar 2, 2023

Codecov Report

Merging #1798 (1447d1a) into main (6d05a96) will decrease coverage by 0.05%.
The diff coverage is 52.47%.

❗ Current head 1447d1a differs from pull request most recent head eee1ee4. Consider uploading reports for the commit eee1ee4 to get more accurate results

@@            Coverage Diff             @@
##             main    #1798      +/-   ##
==========================================
- Coverage   85.45%   85.40%   -0.05%     
==========================================
  Files        1282     1283       +1     
  Lines      117291   117469     +178     
  Branches    31042    31073      +31     
==========================================
+ Hits       100226   100323      +97     
- Misses      15990    16068      +78     
- Partials     1075     1078       +3     
Impacted Files Coverage Δ
Library/Tracking/AppTrackingTransparency.swift 0.00% <0.00%> (ø)
Library/Tracking/KSRAnalytics.swift 82.62% <ø> (ø)
Library/Tracking/KSRAnalyticsTests.swift 99.60% <ø> (ø)
...ibrary/ViewModels/RewardsCollectionViewModel.swift 90.29% <33.33%> (-7.33%) ⬇️
...ary/ViewModels/PledgePaymentMethodsViewModel.swift 93.25% <38.70%> (-4.59%) ⬇️
Library/ViewModels/ProjectPageViewModel.swift 93.39% <44.44%> (-4.32%) ⬇️
Library/ViewModels/ThanksViewModel.swift 91.53% <50.00%> (-7.23%) ⬇️
Library/ViewModels/PledgeViewModel.swift 97.70% <60.86%> (-0.82%) ⬇️
...ontroller/PledgePaymentMethodsViewController.swift 46.35% <66.66%> (+0.84%) ⬆️
Kickstarter-iOS/AppDelegateViewModel.swift 93.42% <100.00%> (+1.78%) ⬆️
... and 6 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@scottkicks scottkicks requested a review from msadoon March 2, 2023 20:10
Copy link
Contributor

@msadoon msadoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good first shot at this.
There's a lot of comments of here, but mostly just following existing conventions and reducing the network requests required.

Let's pair on any of this if you have questions.

Kickstarter-iOS/AppDelegateViewModel.swift Show resolved Hide resolved
Kickstarter.xcodeproj/project.pbxproj Show resolved Hide resolved
Library/AppTrackingTransparencyService.swift Outdated Show resolved Hide resolved
Library/FacebookCAPIEventService.swift Outdated Show resolved Hide resolved
Library/FacebookCAPIEventService.swift Outdated Show resolved Hide resolved
Library/AppTrackingTransparencyService.swift Outdated Show resolved Hide resolved
Library/ViewModels/ThanksViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ThanksViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ProjectPageViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ProjectPageViewModel.swift Outdated Show resolved Hide resolved
Copy link
Contributor

@msadoon msadoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting there!

A few more suggestions and its' good to go!

Library/AppTrackingTransparency.swift Outdated Show resolved Hide resolved
Library/ViewModels/ProjectPageViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ProjectPageViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ProjectPageViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ProjectPageViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ProjectPageViewModel.swift Show resolved Hide resolved
Library/ViewModels/ThanksViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/ThanksViewModel.swift Outdated Show resolved Hide resolved
Library/ViewModels/PledgePaymentMethodsViewModel.swift Outdated Show resolved Hide resolved
Copy link
Contributor

@msadoon msadoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok very close, just a few more comments and next pass should be mergeable.

Copy link
Contributor

@msadoon msadoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let tests pass and good to go!

@scottkicks scottkicks merged commit 2733127 into main Mar 8, 2023
@scottkicks scottkicks deleted the web-970-part-2 branch March 8, 2023 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants