-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
164 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
UnstoppableWallet/UnstoppableWallet/Core/Managers/StatsManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Alamofire | ||
import Foundation | ||
import HsToolKit | ||
|
||
func stat(page: StatPage, section: StatSection? = nil, event: StatEvent, params: [StatParam: Any]? = nil) { | ||
StatsManager.instance.sendStat(page: page, section: section, event: event, params: params) | ||
} | ||
|
||
class StatsManager { | ||
static let instance = StatsManager(networkManager: NetworkManager(logger: Logger(minLogLevel: .debug))) | ||
|
||
private let networkManager: NetworkManager | ||
|
||
init(networkManager: NetworkManager) { | ||
self.networkManager = networkManager | ||
} | ||
|
||
func sendStat(page: StatPage, section: StatSection? = nil, event: StatEvent, params: [StatParam: Any]? = nil) { | ||
Task { | ||
var parameters: Parameters = [ | ||
"page": page.rawValue, | ||
"event": event.rawValue, | ||
] | ||
|
||
if let section { | ||
parameters["section"] = section.rawValue | ||
} | ||
|
||
if let params { | ||
for (key, value) in params { | ||
parameters[key.rawValue] = value | ||
} | ||
} | ||
|
||
_ = try await networkManager.fetchJson(url: "\(AppConfig.marketApiUrl)/v1/stats", method: .head, parameters: parameters) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
enum StatPage: String { | ||
case advancedSearchResults = "advanced_search_results" | ||
case coinPage = "coin_page" | ||
case coinCategory = "coin_category" | ||
case coinRank = "coin_rank" | ||
case globalMetricsMarketCap = "global_metrics_market_cap" | ||
case globalMetricsVolume = "global_metrics_volume" | ||
case globalMetricsDefiCap = "global_metrics_defi_cap" | ||
case globalMetricsTvlInDefi = "global_metrics_tvl_in_defi" | ||
case marketOverview = "market_overview" | ||
case marketSearch = "market_search" | ||
case topCoins = "top_coins" | ||
case topMarketPairs = "top_market_pairs" | ||
case topNftCollections = "top_nft_collections" | ||
case topPlatform = "top_platform" | ||
case topPlatforms = "top_platforms" | ||
case tokenPage = "token_page" | ||
case transactionInfo = "transaction_info" | ||
case watchlist | ||
case widget | ||
} | ||
|
||
enum StatEvent: String { | ||
case coinOpen = "coin_open" | ||
} | ||
|
||
enum StatParam: String { | ||
case coinUid = "coin_uid" | ||
} | ||
|
||
enum StatSection: String { | ||
case topGainers = "top_gainers" | ||
case topLosers = "top_losers" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.