/**
 * Obtain Event data from WalletAPI App manifest
 *
 * @param {AppManifest} manifest
 * @returns Object - event data
 */
function getEventData(manifest) {
    return { walletAPI: manifest.name };
}
/**
 * Wrap call to underlying trackCall function.
 * @param trackCall
 * @returns a dictionary of event to trigger.
 */
// Disabling explicit module boundary types as we're using const
// in order to get the exact type matching the tracking wrapper API
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function trackingWrapper(trackCall) {
    const track = (event, properties) => trackCall(event, properties, null);
    return {
        // Failed to load the iframe
        load: (manifest) => {
            track("WalletAPI Load", getEventData(manifest));
        },
        // Failed to load the iframe
        reload: (manifest) => {
            track("WalletAPI Reload", getEventData(manifest));
        },
        // Failed to load the iframe
        loadFail: (manifest) => {
            // TODO: handle iframe failed
            track("WalletAPI Load Fail", getEventData(manifest));
        },
        // Successfully loaded the iframe
        loadSuccess: (manifest) => {
            track("WalletAPI Load Success", getEventData(manifest));
        },
        // Sign transaction modal open
        signTransactionRequested: (manifest, isEmbeddedSwap, partner) => {
            const properties = {
                ...getEventData(manifest),
                ...(isEmbeddedSwap !== undefined && { isEmbeddedSwap: String(isEmbeddedSwap) }),
                ...(partner !== undefined && { partner }),
            };
            track("WalletAPI SignTransaction", properties);
        },
        // Failed to sign transaction (cancel or error)
        signTransactionFail: (manifest, isEmbeddedSwap, partner) => {
            const properties = {
                ...getEventData(manifest),
                ...(isEmbeddedSwap !== undefined && { isEmbeddedSwap: String(isEmbeddedSwap) }),
                ...(partner !== undefined && { partner }),
            };
            track("WalletAPI SignTransaction Fail", properties);
        },
        // Successfully signed transaction
        signTransactionSuccess: (manifest, isEmbeddedSwap, partner) => {
            const properties = {
                ...getEventData(manifest),
                ...(isEmbeddedSwap !== undefined && { isEmbeddedSwap: String(isEmbeddedSwap) }),
                ...(partner !== undefined && { partner }),
            };
            track("WalletAPI SignTransaction Success", properties);
        },
        // Sign Raw transaction modal open
        signRawTransactionRequested: (manifest) => {
            track("WalletAPI SignRawTransaction", getEventData(manifest));
        },
        // Failed to sign raw transaction (cancel or error)
        signRawTransactionFail: (manifest) => {
            track("WalletAPI SignRawTransaction Fail", getEventData(manifest));
        },
        // Successfully signed raw transaction
        signRawTransactionSuccess: (manifest) => {
            track("WalletAPI SignRawTransaction Success", getEventData(manifest));
        },
        // Select account modal open
        requestAccountRequested: (manifest) => {
            track("WalletAPI RequestAccount", getEventData(manifest));
        },
        // Failed to select account (cancel or error)
        requestAccountFail: (manifest) => {
            track("WalletAPI RequestAccount Fail", getEventData(manifest));
        },
        // The user successfully selected an account
        requestAccountSuccess: (manifest) => {
            track("WalletAPI RequestAccount Success", getEventData(manifest));
        },
        // Select account modal open
        receiveRequested: (manifest) => {
            track("WalletAPI Receive", getEventData(manifest));
        },
        // Failed to select account (cancel or error)
        receiveFail: (manifest) => {
            track("WalletAPI Receive Fail", getEventData(manifest));
        },
        // The user successfully selected an account
        receiveSuccess: (manifest) => {
            track("WalletAPI Receive Success", getEventData(manifest));
        },
        // Failed to broadcast a signed transaction
        broadcastFail: (manifest, isEmbeddedSwap, partner) => {
            const properties = {
                ...getEventData(manifest),
                ...(isEmbeddedSwap !== undefined && { isEmbeddedSwap: String(isEmbeddedSwap) }),
                ...(partner !== undefined && { partner }),
            };
            track("WalletAPI Broadcast Fail", properties);
        },
        // Successfully broadcast a signed transaction
        broadcastSuccess: (manifest, isEmbeddedSwap, partner) => {
            const properties = {
                ...getEventData(manifest),
                ...(isEmbeddedSwap !== undefined && { isEmbeddedSwap: String(isEmbeddedSwap) }),
                ...(partner !== undefined && { partner }),
            };
            track("WalletAPI Broadcast Success", properties);
        },
        // Successfully broadcast a signed transaction
        broadcastOperationDetailsClick: (manifest) => {
            track("WalletAPI Broadcast OpD Clicked", getEventData(manifest));
        },
        // Generate Exchange nonce modal open
        startExchangeRequested: (manifest) => {
            track("WalletAPI start Exchange Nonce request", getEventData(manifest));
        },
        // Successfully generated an Exchange app nonce
        startExchangeSuccess: (manifest) => {
            track("WalletAPI start Exchange Nonce success", getEventData(manifest));
        },
        // Failed to generate an Exchange app nonce
        startExchangeFail: (manifest) => {
            track("WalletAPI start Exchange Nonce fail", getEventData(manifest));
        },
        completeExchangeRequested: (manifest) => {
            track("WalletAPI complete Exchange requested", getEventData(manifest));
        },
        // Successfully completed an Exchange
        completeExchangeSuccess: (manifest) => {
            track("WalletAPI complete Exchange success", getEventData(manifest));
        },
        // Failed to complete an Exchange
        completeExchangeFail: (manifest) => {
            track("WalletAPI complete Exchange Nonce fail", getEventData(manifest));
        },
        signMessageRequested: (manifest) => {
            track("WalletAPI sign message requested", getEventData(manifest));
        },
        signMessageSuccess: (manifest) => {
            track("WalletAPI sign message success", getEventData(manifest));
        },
        signMessageFail: (manifest) => {
            track("WalletAPI sign message fail", getEventData(manifest));
        },
        signMessageUserRefused: (manifest) => {
            track("WalletAPI sign message user refused", getEventData(manifest));
        },
        deviceTransportRequested: (manifest) => {
            track("WalletAPI device transport requested", getEventData(manifest));
        },
        deviceTransportSuccess: (manifest) => {
            track("WalletAPI device transport success", getEventData(manifest));
        },
        deviceTransportFail: (manifest) => {
            track("WalletAPI device transport fail", getEventData(manifest));
        },
        deviceSelectRequested: (manifest) => {
            track("WalletAPI device select requested", getEventData(manifest));
        },
        deviceSelectSuccess: (manifest) => {
            track("WalletAPI device select success", getEventData(manifest));
        },
        deviceSelectFail: (manifest) => {
            track("WalletAPI device select fail", getEventData(manifest));
        },
        deviceOpenRequested: (manifest) => {
            track("WalletAPI device open requested", getEventData(manifest));
        },
        deviceExchangeRequested: (manifest) => {
            track("WalletAPI device exchange requested", getEventData(manifest));
        },
        deviceExchangeSuccess: (manifest) => {
            track("WalletAPI device exchange success", getEventData(manifest));
        },
        deviceExchangeFail: (manifest) => {
            track("WalletAPI device exchange fail", getEventData(manifest));
        },
        deviceCloseRequested: (manifest) => {
            track("WalletAPI device close requested", getEventData(manifest));
        },
        deviceCloseSuccess: (manifest) => {
            track("WalletAPI device close success", getEventData(manifest));
        },
        deviceCloseFail: (manifest) => {
            track("WalletAPI device close fail", getEventData(manifest));
        },
        bitcoinFamilyAccountAddressRequested: (manifest) => {
            track("WalletAPI bitcoin family account address requested", getEventData(manifest));
        },
        bitcoinFamilyAccountAddressFail: (manifest) => {
            track("WalletAPI bitcoin family account address fail", getEventData(manifest));
        },
        bitcoinFamilyAccountAddressSuccess: (manifest) => {
            track("WalletAPI bitcoin family account address success", getEventData(manifest));
        },
        bitcoinFamilyAccountPublicKeyRequested: (manifest) => {
            track("WalletAPI bitcoin family account publicKey requested", getEventData(manifest));
        },
        bitcoinFamilyAccountPublicKeyFail: (manifest) => {
            track("WalletAPI bitcoin family account publicKey fail", getEventData(manifest));
        },
        bitcoinFamilyAccountPublicKeySuccess: (manifest) => {
            track("WalletAPI bitcoin family account publicKey success", getEventData(manifest));
        },
        bitcoinFamilyAccountXpubRequested: (manifest) => {
            track("WalletAPI bitcoin family account xpub requested", getEventData(manifest));
        },
        bitcoinFamilyAccountXpubFail: (manifest) => {
            track("WalletAPI bitcoin family account xpub fail", getEventData(manifest));
        },
        bitcoinFamilyAccountXpubSuccess: (manifest) => {
            track("WalletAPI bitcoin family account xpub success", getEventData(manifest));
        },
        // currency.list handler tracking
        currencyListRequested: (manifest) => {
            track("WalletAPI CurrencyList requested", getEventData(manifest));
        },
        currencyListSuccess: (manifest) => {
            track("WalletAPI CurrencyList success", getEventData(manifest));
        },
        currencyListFail: (manifest) => {
            track("WalletAPI CurrencyList fail", getEventData(manifest));
        },
        // account.list handler tracking
        accountListRequested: (manifest) => {
            track("WalletAPI AccountList requested", getEventData(manifest));
        },
        accountListSuccess: (manifest) => {
            track("WalletAPI AccountList success", getEventData(manifest));
        },
        accountListFail: (manifest) => {
            track("WalletAPI AccountList fail", getEventData(manifest));
        },
        dappSendTransactionRequested: (manifest, trackingData) => {
            track("dApp SendTransaction requested", { ...getEventData(manifest), ...trackingData });
        },
        dappSendTransactionSuccess: (manifest, trackingData) => {
            track("dApp SendTransaction success", { ...getEventData(manifest), ...trackingData });
        },
        dappSendTransactionFail: (manifest, trackingData) => {
            track("dApp SendTransaction fail", { ...getEventData(manifest), ...(trackingData || {}) });
        },
        dappPersonalSignRequested: (manifest) => {
            track("dApp PersonalSign requested", getEventData(manifest));
        },
        dappPersonalSignSuccess: (manifest) => {
            track("dApp PersonalSign success", getEventData(manifest));
        },
        dappPersonalSignFail: (manifest) => {
            track("dApp PersonalSign fail", getEventData(manifest));
        },
        dappSignTypedDataRequested: (manifest) => {
            track("dApp SignTypedData requested", getEventData(manifest));
        },
        dappSignTypedDataSuccess: (manifest) => {
            track("dApp SignTypedData success", getEventData(manifest));
        },
        dappSignTypedDataFail: (manifest) => {
            track("dApp SignTypedData fail", getEventData(manifest));
        },
    };
}
//# sourceMappingURL=tracking.js.map