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

add mixpanel to w3w #1246

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Example/DApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

Web3Modal.configure(
projectId: InputConfig.projectId,
chainId: Blockchain("eip155:1")!,
metadata: metadata
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
"repositoryURL": "https://github.com/WalletConnect/web3modal-swift",
"state": {
"branch": null,
"revision": "e68c1b1560264965ca13608db44294d301c6404f",
"version": "1.0.9"
"revision": "831410cfd6e68afa7212a5547483fb2d180f0fa7",
"version": "1.0.10"
}
}
]
Expand Down
3 changes: 3 additions & 0 deletions Example/WalletApp/ApplicationLayer/ProfilingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import Mixpanel
import WalletConnectNetworking
import Combine
import Web3Wallet
import WalletConnectNotify

final class ProfilingService {
Expand Down Expand Up @@ -34,6 +35,8 @@ final class ProfilingService {
handleLogs(from: Networking.instance.logsPublisher)
handleLogs(from: Notify.instance.logsPublisher)
handleLogs(from: Push.instance.logsPublisher)
handleLogs(from: Web3Wallet.instance.logsPublisher)

}

private func handleLogs(from publisher: AnyPublisher<Log, Never>) {
Expand Down
4 changes: 4 additions & 0 deletions Sources/WalletConnectPairing/PairingClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient

private let cleanupService: PairingCleanupService

public var logsPublisher: AnyPublisher<Log, Never> {
return logger.logsPublisher
}

init(
pairingStorage: WCPairingStorage,
appPairService: AppPairService,
Expand Down
3 changes: 3 additions & 0 deletions Sources/WalletConnectPairing/PairingClientProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Combine

public protocol PairingClientProtocol {
var logsPublisher: AnyPublisher<Log, Never> {get}
func pair(uri: WalletConnectURI) async throws
func disconnect(topic: String) async throws
func getPairings() -> [Pairing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@ actor WalletPairService {
let kms: KeyManagementServiceProtocol
private let pairingStorage: WCPairingStorage
private let history: RPCHistory
private let logger: ConsoleLogging

init(
networkingInteractor: NetworkInteracting,
kms: KeyManagementServiceProtocol,
pairingStorage: WCPairingStorage,
history: RPCHistory
history: RPCHistory,
logger: ConsoleLogging
) {
self.networkingInteractor = networkingInteractor
self.kms = kms
self.pairingStorage = pairingStorage
self.history = history
self.logger = logger
}

func pair(_ uri: WalletConnectURI) async throws {
logger.debug("Pairing with uri: \(uri)")
guard try !pairingHasPendingRequest(for: uri.topic) else {
logger.debug("Pairing with topic (\(uri.topic)) has pending request")
return
}

Expand All @@ -35,6 +40,7 @@ actor WalletPairService {

let networkConnectionStatus = await resolveNetworkConnectionStatus()
guard networkConnectionStatus == .connected else {
logger.debug("Pairing failed - Network is not connected")
throw Errors.networkNotConnected
}

Expand Down
3 changes: 3 additions & 0 deletions Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ final class ApproveEngine {
}

func approveProposal(proposerPubKey: String, validating sessionNamespaces: [String: SessionNamespace], sessionProperties: [String: String]? = nil) async throws {
logger.debug("Approving session proposal")
guard let payload = try proposalPayloadsStore.get(key: proposerPubKey) else {
throw Errors.wrongRequestParams
}
Expand Down Expand Up @@ -112,6 +113,8 @@ final class ApproveEngine {

_ = try await [proposeResponse, settleRequest]

logger.debug("Session proposal response and settle request have been sent")

pairingRegisterer.activate(
pairingTopic: payload.topic,
peerMetadata: payload.request.proposer.metadata
Expand Down
4 changes: 4 additions & 0 deletions Sources/WalletConnectSign/Sign/SignClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public final class SignClient: SignClientProtocol {
sessionsPublisherSubject.eraseToAnyPublisher()
}

public var logsPublisher: AnyPublisher<Log, Never> {
return logger.logsPublisher
}

/// An object that loggs SDK's errors and info messages
public let logger: ConsoleLogging

Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectSign/Sign/SignClientFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct SignClientFactory {
networkingClient: NetworkingInteractor,
groupIdentifier: String
) -> SignClient {
let logger = ConsoleLogger(loggingLevel: .debug)
let logger = ConsoleLogger(prefix: "📝", loggingLevel: .debug)
guard let keyValueStorage = UserDefaults(suiteName: groupIdentifier) else {
fatalError("Could not instantiate UserDefaults for a group identifier \(groupIdentifier)")
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/WalletConnectSign/Sign/SignClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public protocol SignClientProtocol {
var sessionResponsePublisher: AnyPublisher<Response, Never> { get }
var sessionRejectionPublisher: AnyPublisher<(Session.Proposal, Reason), Never> { get }
var sessionEventPublisher: AnyPublisher<(event: Session.Event, sessionTopic: String, chainId: Blockchain?), Never> { get }

var logsPublisher: AnyPublisher<Log, Never> {get}

func connect(requiredNamespaces: [String: ProposalNamespace], optionalNamespaces: [String: ProposalNamespace]?, sessionProperties: [String: String]?, topic: String) async throws
func request(params: Request) async throws
func approve(proposalId: String, namespaces: [String: SessionNamespace], sessionProperties: [String: String]?) async throws
Expand Down
6 changes: 6 additions & 0 deletions Sources/Web3Wallet/Web3WalletClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public class Web3WalletClient {
signClient.sessionResponsePublisher.eraseToAnyPublisher()
}

public var logsPublisher: AnyPublisher<Log, Never> {
return signClient.logsPublisher
.merge(with: pairingClient.logsPublisher)
.eraseToAnyPublisher()
}

// MARK: - Private Properties
private let authClient: AuthClientProtocol
private let signClient: SignClientProtocol
Expand Down