From 70f0341815ed4f8ec4048d1c2d7fb60af7ae8888 Mon Sep 17 00:00:00 2001 From: Anurag Ramdasan Date: Sat, 17 Aug 2024 10:20:59 +0530 Subject: [PATCH 1/2] Add a wrapper for sendUsageEvents Adding it as described here https://github.com/Hey-Mantle/mantle-client/blob/00a2f0be22e7f005b8bfc0567e45a609c50cd2b2/src/index.js#L231 --- src/components/core/MantleProvider/MantleProvider.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/core/MantleProvider/MantleProvider.js b/src/components/core/MantleProvider/MantleProvider.js index 6090a14..4b38642 100644 --- a/src/components/core/MantleProvider/MantleProvider.js +++ b/src/components/core/MantleProvider/MantleProvider.js @@ -70,6 +70,13 @@ export const MantleProvider = ({ await mantleClient.sendUsageEvent(usageEvent); }; + /** + * @type {SendUsageEventCallback} + */ + const sendUsageEvents = async (usageEvent) => { + await mantleClient.sendUsageEvents(usageEvent); + }; + /** * @type {GetUsageReportCallback} */ @@ -295,4 +302,4 @@ export const useMantle = () => { * @param {string} params.type - The type of hosted session to create * @param {Object} params.config - The configuration for the hosted session * @returns {Promise} a promise that resolves to the hosted session - */ \ No newline at end of file + */ From e6c1163bc92a846b4c8100efeaef3caa003ea853 Mon Sep 17 00:00:00 2001 From: Anurag Ramdasan Date: Mon, 19 Aug 2024 21:31:57 +0530 Subject: [PATCH 2/2] Update MantleProvider.js --- src/components/core/MantleProvider/MantleProvider.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/core/MantleProvider/MantleProvider.js b/src/components/core/MantleProvider/MantleProvider.js index 4b38642..d5646af 100644 --- a/src/components/core/MantleProvider/MantleProvider.js +++ b/src/components/core/MantleProvider/MantleProvider.js @@ -160,6 +160,7 @@ export const MantleProvider = ({ loading, i18n: { ...Labels, ...i18n }, sendUsageEvent, + sendUsageEvents, getUsageReport, subscribe, cancelSubscription, @@ -221,6 +222,7 @@ export const useMantle = () => { * @property {boolean} loading - Whether the current customer is loading * @property {RefetchCallback} refetch - Refetch the current customer * @property {SendUsageEventCallback} sendUsageEvent - Send a new usage event to Mantle + * @property {SendUsageEventCallback} sendUsageEvents - Send a set of new usage event to Mantle * @property {GetUsageReportCallback} getUsageReport - Get a usage report for a usage metric * @property {SubscribeCallback} subscribe - Subscribe to a new plan * @property {CancelSubscriptionCallback} cancelSubscription - Cancel the current subscription