Skip to content

Commit

Permalink
Add load events for CustomerSheet (stripe#3500)
Browse files Browse the repository at this point in the history
## Summary
- Log 3 new events for CustomerSheet around load time

## Motivation
Visibility sprint

## Testing
Manual

## Changelog
N/A
  • Loading branch information
porter-stripe authored Apr 12, 2024
1 parent 6beecbb commit 9f2e2f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions StripeCore/StripeCore/Source/Analytics/STPAnalyticEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ import Foundation
case luxeImageSelectorIconFromBundle = "luxe_image_selector_icon_from_bundle"
case luxeImageSelectorIconNotFound = "luxe_image_selector_icon_not_found"

// MARK: - CustomerSheet initialization
case customerSheetLoadStarted = "cs_load_started"
case customerSheetLoadSucceeded = "cs_load_succeeded"
case customerSheetLoadFailed = "cs_load_failed"

// MARK: - Customer Sheet
case cs_add_payment_method_screen_presented = "cs_add_payment_method_screen_presented"
case cs_select_payment_method_screen_presented = "cs_select_payment_method_screen_presented"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class CustomerSheet {
public func present(from presentingViewController: UIViewController,
completion csCompletion: @escaping (CustomerSheetResult) -> Void
) {
let loadingStartDate = Date()
STPAnalyticsClient.sharedClient.logPaymentSheetEvent(event: .customerSheetLoadStarted)
// Retain self when being presented, it is not guaranteed that CustomerSheet instance
// will be retained by caller
let completion: () -> Void = {
Expand Down Expand Up @@ -123,7 +125,12 @@ public class CustomerSheet {
selectedPaymentMethodOption: selectedPaymentMethodOption,
merchantSupportedPaymentMethodTypes: merchantSupportedPaymentMethodTypes,
cbcEligible: elementsSession.cardBrandChoice?.eligible ?? false)
STPAnalyticsClient.sharedClient.logPaymentSheetEvent(event: .customerSheetLoadSucceeded,
duration: Date().timeIntervalSince(loadingStartDate))
case .failure(let error):
STPAnalyticsClient.sharedClient.logPaymentSheetEvent(event: .customerSheetLoadFailed,
duration: Date().timeIntervalSince(loadingStartDate),
error: error)
csCompletion(.error(CustomerSheetError.errorFetchingSavedPaymentMethods(error)))
DispatchQueue.main.async {
self.bottomSheetViewController.dismiss(animated: true)
Expand Down

0 comments on commit 9f2e2f6

Please sign in to comment.