@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
53 lines • 2.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
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
function trackingWrapper(trackCall) {
const track = (event, properties) => {
return trackCall(event, properties, null);
};
return {
// Generate Exchange nonce modal open
startExchangeRequested: ({ provider, exchangeType }) => {
track(`Starts Exchange ${exchangeType} Nonce request`, { provider, exchangeType });
},
// Successfully generated an Exchange app nonce
startExchangeSuccess: ({ provider, exchangeType }) => {
track(`Starts Exchange ${exchangeType} Nonce success`, { provider, exchangeType });
},
// Failed to generate an Exchange app nonce
startExchangeFail: ({ provider, exchangeType }) => {
track(`Starts Exchange ${exchangeType} Nonce fail`, { provider, exchangeType });
},
// No Params to generate an Exchange app nonce
startExchangeNoParams: (manifest) => {
track("Starts Exchange no params", getEventData(manifest));
},
completeExchangeRequested: ({ provider, exchangeType }) => {
track(`Completes Exchange ${exchangeType} requested`, { provider, exchangeType });
},
// Successfully completed an Exchange
completeExchangeSuccess: ({ provider, exchangeType, currency, }) => {
track(`Completes Exchange ${exchangeType} success`, { provider, exchangeType, currency });
},
// Failed to complete an Exchange
completeExchangeFail: ({ provider, exchangeType }) => {
track(`Completes Exchange ${exchangeType} Nonce fail`, { provider, exchangeType });
},
// No Params to complete an Exchange
completeExchangeNoParams: (manifest) => {
track("Completes Exchange no params", getEventData(manifest));
},
};
}
exports.default = trackingWrapper;
//# sourceMappingURL=tracking.js.map