Skip to content

Commit

Permalink
Make sure code is compatible for older OS versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed May 23, 2024
1 parent 7901586 commit 6557f80
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/TelemetryClient/Presets/TelemetryDeck+Purchases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ extension TelemetryDeck {
let priceValueInNativeCurrency = NSDecimalNumber(decimal: transaction.price ?? Decimal()).doubleValue

let priceValueInUSD: Double
if transaction.currency == Locale.Currency("USD") {
if transaction.currencyCode == "USD" {
priceValueInUSD = priceValueInNativeCurrency
} else if
let currency = transaction.currency,
let oneUSDExchangeRate = self.currencyCodeToOneUSDExchangeRate[currency.identifier]
let currencyCode = transaction.currencyCode,
let oneUSDExchangeRate = self.currencyCodeToOneUSDExchangeRate[currencyCode]
{
priceValueInUSD = priceValueInNativeCurrency / oneUSDExchangeRate
} else {
Expand All @@ -35,11 +35,11 @@ extension TelemetryDeck {

var purchaseParameters: [String: String] = [
"TelemetryDeck.Purchase.type": transaction.subscriptionGroupID != nil ? "subscription" : "one-time-purchase",
"TelemetryDeck.Purchase.countryCode": transaction.storefront.countryCode,
"TelemetryDeck.Purchase.countryCode": transaction.storefrontCountryCode,
]

if let currency = transaction.currency {
purchaseParameters["TelemetryDeck.Purchase.currencyCode"] = currency.identifier
if let currencyCode = transaction.currencyCode {
purchaseParameters["TelemetryDeck.Purchase.currencyCode"] = currencyCode
}

self.signal(
Expand Down

0 comments on commit 6557f80

Please sign in to comment.