From 7521e4870e82c943eb1afa55eb707ef82640461a Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 5 Dec 2017 14:56:47 -0800 Subject: [PATCH] Bugfixes --- .../qml/hifi/commerce/checkout/Checkout.qml | 22 ++---------- .../hifi/commerce/purchases/PurchasedItem.qml | 7 +--- .../qml/hifi/commerce/wallet/Help.qml | 34 ++++++++++++++++++- .../qml/hifi/commerce/wallet/Wallet.qml | 26 +++++++++----- .../qml/hifi/commerce/wallet/WalletSetup.qml | 14 ++------ .../UserActivityLoggerScriptingInterface.cpp | 6 ++-- .../UserActivityLoggerScriptingInterface.h | 6 ++-- scripts/system/marketplaces/marketplaces.js | 1 + 8 files changed, 64 insertions(+), 52 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 7d3c6e3f12..c8a63a4d2d 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -79,23 +79,12 @@ Rectangle { if (result.status !== 'success') { failureErrorText.text = result.message; root.activeView = "checkoutFailure"; - var data = { - "marketplaceID": root.itemId, - "cost": root.itemPrice, - "firstPurchaseOfThisItem": !root.alreadyOwned, - "errorDetails": result.message - } - UserActivityLogger.logAction("commercePurchaseFailure", data); + UserActivityLogger.commercePurchaseFailure(root.itemId, root.itemPrice, !root.alreadyOwned, result.message); } else { root.itemHref = result.data.download_url; root.isWearable = result.data.categories.indexOf("Wearables") > -1; root.activeView = "checkoutSuccess"; - var data = { - "marketplaceID": root.itemId, - "cost": root.itemPrice, - "firstPurchaseOfThisItem": !root.alreadyOwned - } - UserActivityLogger.logAction("commercePurchaseSuccess", data); + UserActivityLogger.commercePurchaseSuccess(root.itemId, root.itemPrice, !root.alreadyOwned); } } @@ -612,12 +601,7 @@ Rectangle { sendToScript({method: 'checkout_rezClicked', itemHref: root.itemHref, isWearable: root.isWearable}); rezzedNotifContainer.visible = true; rezzedNotifContainerTimer.start(); - var data = { - "marketplaceID": root.itemId, - "source": "checkout", - "type": root.isWearable ? "rez" : "wear" - } - UserActivityLogger.logAction("commerceEntityRezzed", data); + UserActivityLogger.commerceEntityRezzed(root.itemId, "checkout", root.isWearable ? "rez" : "wear"); } } RalewaySemiBold { diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index 17e5b21562..f7913e5b1e 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -349,12 +349,7 @@ Item { sendToPurchases({method: 'purchases_rezClicked', itemHref: root.itemHref, isWearable: root.isWearable}); rezzedNotifContainer.visible = true; rezzedNotifContainerTimer.start(); - var data = { - "marketplaceID": root.itemId, - "source": "purchases", - "type": root.isWearable ? "rez" : "wear" - } - UserActivityLogger.logAction("commerceEntityRezzed", data); + UserActivityLogger.commerceEntityRezzed(root.itemId, "purchases", root.isWearable ? "rez" : "wear"); } style: ButtonStyle { diff --git a/interface/resources/qml/hifi/commerce/wallet/Help.qml b/interface/resources/qml/hifi/commerce/wallet/Help.qml index ebba2b87c6..8cccb10533 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Help.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Help.qml @@ -55,6 +55,38 @@ Item { // Style color: hifi.colors.blueHighlight; } + + HifiControlsUit.Button { + id: clearCachedPassphraseButton; + visible: root.showDebugButtons; + color: hifi.buttons.black; + colorScheme: hifi.colorSchemes.dark; + anchors.top: parent.top; + anchors.left: helpTitleText.right; + anchors.leftMargin: 20; + height: 40; + width: 150; + text: "DBG: Clear Pass"; + onClicked: { + commerce.setPassphrase(""); + sendSignalToWallet({method: 'passphraseReset'}); + } + } + HifiControlsUit.Button { + id: resetButton; + visible: root.showDebugButtons; + color: hifi.buttons.red; + colorScheme: hifi.colorSchemes.dark; + anchors.top: clearCachedPassphraseButton.top; + anchors.left: clearCachedPassphraseButton.right; + height: 40; + width: 150; + text: "DBG: RST Wallet"; + onClicked: { + commerce.reset(); + sendSignalToWallet({method: 'walletReset'}); + } + } ListModel { id: helpModel; @@ -147,7 +179,7 @@ Item { text: model.isExpanded ? "-" : "+"; // Anchors anchors.top: parent.top; - anchors.topMargin: model.isExpanded ? -9 : 0; + anchors.topMargin: model.isExpanded ?9 : 0; anchors.bottom: parent.bottom; anchors.left: parent.left; width: 60; diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index 3578485a01..d7e4536fed 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -50,14 +50,8 @@ Rectangle { commerce.resetLocalWalletOnly(); var timestamp = new Date(); walletSetup.startingTimestamp = timestamp; - var data = { - "timestamp": timestamp, - "setupAttemptID": guid(), - "setupFlowVersion": walletSetup.setupFlowVersion, - "referrer": walletSetup.referrer, - "currentDomain": (AddressManager.placename || AddressManager.hostname || '') + (AddressManager.pathname ? AddressManager.pathname.match(/\/[^\/]+/)[0] : '') - } - UserActivityLogger.logAction("commerceWalletSetupStarted", data); + UserActivityLogger.commerceWalletSetupStarted(timestamp, generateUUID(), walletSetup.setupFlowVersion, walletSetup.referrer ? walletSetup.referrer : "wallet app", + (AddressManager.placename || AddressManager.hostname || '') + (AddressManager.pathname ? AddressManager.pathname.match(/\/[^\/]+/)[0] : '')); } } else if (walletStatus === 2) { if (root.activeView !== "passphraseModal") { @@ -711,12 +705,28 @@ Rectangle { case 'updateWalletReferrer': walletSetup.referrer = message.referrer; break; + case 'inspectionCertificate_resetCert': + // NOP + break; default: console.log('Unrecognized message from wallet.js:', JSON.stringify(message)); } } signal sendToScript(var message); + // generateUUID() taken from: + // https://stackoverflow.com/a/8809472 + function generateUUID() { // Public Domain/MIT + var d = new Date().getTime(); + if (typeof performance !== 'undefined' && typeof performance.now === 'function'){ + d += performance.now(); //use high-precision timer if available + } + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = (d + Math.random() * 16) % 16 | 0; + d = Math.floor(d / 16); + return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); + }); + } // // FUNCTION DEFINITIONS END // diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml b/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml index 773407cf8a..9bb578f7d6 100644 --- a/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml +++ b/interface/resources/qml/hifi/commerce/wallet/WalletSetup.qml @@ -73,13 +73,7 @@ Item { onActiveViewChanged: { var timestamp = new Date(); var currentStepNumber = root.activeView.substring(5); - var data = { - "timestamp": timestamp, - "secondsElapsed": (root.startingTimestamp - timestamp), - "currentStepNumber": currentStepNumber, - "currentStepName": root.setupStepNames[currentStepNumber] - } - UserActivityLogger.logAction("commerceWalletSetupProgress", data); + UserActivityLogger.commerceWalletSetupProgress(timestamp, Math.round((timestamp - root.startingTimestamp)/1000), currentStepNumber, root.setupStepNames[currentStepNumber - 1]); } // @@ -747,11 +741,7 @@ Item { sendSignalToWallet({method: 'walletSetup_finished', referrer: root.referrer ? root.referrer : ""}); var timestamp = new Date(); - var data = { - "timestamp": timestamp, - "secondsToComplete": (root.startingTimestamp - timestamp) - } - UserActivityLogger.logAction("commerceWalletSetupFinished", data); + UserActivityLogger.commerceWalletSetupFinished(timestamp, Math.round((timestamp - root.startingTimestamp)/1000)); } } } diff --git a/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp b/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp index ba24d8dcbe..79fa7dad0f 100644 --- a/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp +++ b/libraries/networking/src/UserActivityLoggerScriptingInterface.cpp @@ -114,7 +114,7 @@ void UserActivityLoggerScriptingInterface::commerceEntityRezzed(QString marketpl doLogAction("commerceEntityRezzed", payload); } -void UserActivityLoggerScriptingInterface::commerceWalletSetupStarted(float timestamp, QString setupAttemptID, int setupFlowVersion, QString referrer, QString currentDomain) { +void UserActivityLoggerScriptingInterface::commerceWalletSetupStarted(int timestamp, QString setupAttemptID, int setupFlowVersion, QString referrer, QString currentDomain) { QJsonObject payload; payload["timestamp"] = timestamp; payload["setupAttemptID"] = setupAttemptID; @@ -125,7 +125,7 @@ void UserActivityLoggerScriptingInterface::commerceWalletSetupStarted(float time //doLogAction("commerceWalletSetupStarted", payload); } -void UserActivityLoggerScriptingInterface::commerceWalletSetupProgress(float timestamp, float secondsElapsed, int currentStepNumber, QString currentStepName) { +void UserActivityLoggerScriptingInterface::commerceWalletSetupProgress(int timestamp, int secondsElapsed, int currentStepNumber, QString currentStepName) { QJsonObject payload; payload["timestamp"] = timestamp; payload["secondsElapsed"] = secondsElapsed; @@ -135,7 +135,7 @@ void UserActivityLoggerScriptingInterface::commerceWalletSetupProgress(float tim //doLogAction("commerceWalletSetupProgress", payload); } -void UserActivityLoggerScriptingInterface::commerceWalletSetupFinished(float timestamp, float secondsToComplete) { +void UserActivityLoggerScriptingInterface::commerceWalletSetupFinished(int timestamp, int secondsToComplete) { QJsonObject payload; payload["timestamp"] = timestamp; payload["secondsToComplete"] = secondsToComplete; diff --git a/libraries/networking/src/UserActivityLoggerScriptingInterface.h b/libraries/networking/src/UserActivityLoggerScriptingInterface.h index 3e8002e0aa..aafbbb7df0 100644 --- a/libraries/networking/src/UserActivityLoggerScriptingInterface.h +++ b/libraries/networking/src/UserActivityLoggerScriptingInterface.h @@ -36,9 +36,9 @@ public: Q_INVOKABLE void commercePurchaseSuccess(QString marketplaceID, int cost, bool firstPurchaseOfThisItem); Q_INVOKABLE void commercePurchaseFailure(QString marketplaceID, int cost, bool firstPurchaseOfThisItem, QString errorDetails); Q_INVOKABLE void commerceEntityRezzed(QString marketplaceID, QString source, QString type); - Q_INVOKABLE void commerceWalletSetupStarted(float timestamp, QString setupAttemptID, int setupFlowVersion, QString referrer, QString currentDomain); - Q_INVOKABLE void commerceWalletSetupProgress(float timestamp, float secondsElapsed, int currentStepNumber, QString currentStepName); - Q_INVOKABLE void commerceWalletSetupFinished(float timestamp, float secondsToComplete); + Q_INVOKABLE void commerceWalletSetupStarted(int timestamp, QString setupAttemptID, int setupFlowVersion, QString referrer, QString currentDomain); + Q_INVOKABLE void commerceWalletSetupProgress(int timestamp, int secondsElapsed, int currentStepNumber, QString currentStepName); + Q_INVOKABLE void commerceWalletSetupFinished(int timestamp, int secondsToComplete); private: void doLogAction(QString action, QJsonObject details = {}); }; diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 646e5452df..24b2947bcf 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -399,6 +399,7 @@ referrer: "purchases" }); openWallet(); + break; case 'checkout_walletNotSetUp': wireEventBridge(true); tablet.sendToQml({