@grabjs/superapp-sdk 1.7.8 → 1.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).SuperAppSDK={})}(this,function(e){"use strict";function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function n(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,a,i=(function(e,t){function u(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)return!1;var o=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return t.every(function(e){return 0<=o.indexOf(e)})}function c(r,e){var a=e.callbackNameFunc,i=e.funcToWrap;return function(e){return{subscribe:e,then:function(o,r){return new Promise(function(){try{var t=null,n=!1;t=e({next:function(e){o&&o(e),t&&t.unsubscribe(),n=!0}}),n&&t&&t.unsubscribe()}catch(e){r&&r(e)}})}}}(function(n){var t,o=a();return r[o]=function(e){if(u(e,"status_code"))if(u(e.result,"event"))switch(e.result.event){case s.StreamEvent.STREAM_TERMINATED:t.unsubscribe()}else n&&n.next&&n.next(e)},i(o),t=function(e){var t=!1;return{isUnsubscribed:function(){return t},unsubscribe:function(){t||(delete r[o],n&&n.complete&&n.complete(),t=!0)}}}()})}var s;((s=t).StreamEvent||(s.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",s.wrapModule=function(a,i){a[function(e){return"Wrapped"+e}(i)]=function(e,o,t){var r={};return{invoke:function(t,n){return function(e,t){return t.funcNameToWrap,c(e,function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]])}return n}(t,["funcNameToWrap"]))}(e,{funcNameToWrap:t,callbackNameFunc:function(){var e=r[t]||0;return r[t]=e+1,function(e){var t=e.moduleName,n=e.funcName,o=e.requestID;return t+"_"+n+"Callback"+(null!==o?"_"+o:"")}({moduleName:o,requestID:e,funcName:t})},funcToWrap:function(e){return function(e){if(a[i])a[i][e.method](JSON.stringify(e));else{if(!(a.webkit&&a.webkit.messageHandlers&&a.webkit.messageHandlers[i]))throw new Error("Unexpected method '"+e.method+"' for module '"+i+"'");a.webkit.messageHandlers[i].postMessage(e)}}({callback:e,method:t,module:o,parameters:null!=n?n:{}})}})}}}(a,i)},Object.defineProperty(s,"__esModule",{value:!0})}(r={exports:{}},r.exports),r.exports),u=(a=i)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,c=function(){function e(){t(this,e),u.wrapModule(window,"CheckoutModule")}return n(e,[{key:"triggerCheckout",value:function(e){return window.WrappedCheckoutModule.invoke("triggerCheckout",e)}}]),e}(),s=require("@grabjs/mobile-kit-bridge-sdk"),v={STARTED:"STARTED",PAYMENT_STATUS_UPDATED:"PAYMENT_STATUS_UPDATED",ERROR_OCCURRED:"ERROR_OCCURRED",CUSTOM:"CUSTOM"},d={WARNING:"WARNING",ERROR:"ERROR",CRITICAL:"CRITICAL"},f={SUCCESS:"SUCCESS",FAILURE:"FAILURE",CANCEL:"CANCEL",PROCESSING:"PROCESSING"},p=function(){function e(){t(this,e),s.wrapModule(window,"ContainerModule")}return n(e,[{key:"setBackgroundColor",value:function(e){return window.WrappedContainerModule.invoke("setBackgroundColor",{backgroundColor:e})}},{key:"setTitle",value:function(e){return window.WrappedContainerModule.invoke("setTitle",{title:e})}},{key:"hideBackButton",value:function(){return window.WrappedContainerModule.invoke("hideBackButton")}},{key:"showBackButton",value:function(){return window.WrappedContainerModule.invoke("showBackButton")}},{key:"hideRefreshButton",value:function(){return window.WrappedContainerModule.invoke("hideRefreshButton")}},{key:"showRefreshButton",value:function(){return window.WrappedContainerModule.invoke("showRefreshButton")}},{key:"close",value:function(){return window.WrappedContainerModule.invoke("close")}},{key:"onContentLoaded",value:function(){return window.WrappedContainerModule.invoke("onContentLoaded")}},{key:"openExternalLink",value:function(e){return window.WrappedContainerModule.invoke("openExternalLink",{url:e})}},{key:"sendAnalyticsEvent",value:function(e){var t=this._validateAnalyticsEvent(e);return t?{then:function(e){return e({result:null,error:t})}}:window.WrappedContainerModule.invoke("sendAnalyticsEvent",{url:e.url,sessionId:e.sessionId,viewName:e.viewName,eventName:e.eventName,eventData:JSON.stringify(e.eventData)})}},{key:"_validateAnalyticsEvent",value:function(e){for(var t=0,n=["eventName"];t<n.length;t++){var o=n[t];if(!e[o])return"Missing required field: ".concat(o)}if(e.url&&"string"!=typeof e.url)return"url must be a string";if(e.sessionId&&"string"!=typeof e.sessionId)return"sessionId must be a string";if(e.viewName&&"string"!=typeof e.viewName)return"viewName must be a string";var r=Object.values(v);if(!r.includes(e.eventName))return"Invalid eventName. Must be one of: ".concat(r.join(", "));switch(e.eventName){case v.STARTED:return this._validateStartedEvent(e.eventData);case v.PAYMENT_STATUS_UPDATED:return this._validatePaymentStatusUpdatedEvent(e.eventData);case v.ERROR_OCCURRED:return this._validateErrorOccurredEvent(e.eventData);case v.CUSTOM:return this._validateCustomEvent(e.eventData)}return null}},{key:"_validateStartedEvent",value:function(e){return null!=e?"".concat(v.STARTED," event should have empty eventData"):null}},{key:"_validatePaymentStatusUpdatedEvent",value:function(e){if(!e)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires eventData to be an object");var t=["transactionId","statusCode","statusMessage","products","amount","currency","promoCodes"],n=Object.keys(e).filter(function(e){return!t.includes(e)});if(0<n.length)return"".concat(v.PAYMENT_STATUS_UPDATED," event does not allow additional fields in eventData: ").concat(n.join(", "));if(e.transactionId&&"string"!=typeof e.transactionId)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires transactionId in eventData to be a string");if(!e.statusCode)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be defined");if("string"!=typeof e.statusCode)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be a string");var o=Object.values(f);if(!o.includes(e.statusCode))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusCode in eventData to be one of: ").concat(o.join(", "));if(e.statusMessage&&"string"!=typeof e.statusMessage)return"".concat(v.PAYMENT_STATUS_UPDATED," event requires statusMessage in eventData to be a string");if(e.products){if(!Array.isArray(e.products))return"".concat(v.PAYMENT_STATUS_UPDATED," event requires products in eventData to be an array");var r=!0,a=!1,i=void 0;try{for(var u,c=function(){var e=u.value,t=["id","quantity"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event does not allow additional fields in eventData.products item: ").concat(n.join(", "))}:e.id?"string"!=typeof e.id?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires id in eventData.products item to be a string")}:e.quantity&&"number"!=typeof e.quantity?{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires quantity in eventData.products item to be a number")}:void 0:{v:"".concat(v.PAYMENT_STATUS_UPDATED," event requires id in eventData.products item to be defined")}},s=e.products[Symbol.iterator]();!(r=(u=s.next()).done);r=!0){var d=c();if("object"===l(d))return d.v}}catch(e){a=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(a)throw i}}}return e.amount&&"number"!=typeof e.amount?"".concat(v.PAYMENT_STATUS_UPDATED," event requires amount in eventData to be a number"):e.currency&&"string"!=typeof e.currency?"".concat(v.PAYMENT_STATUS_UPDATED," event requires currency in eventData to be a string"):!e.promoCodes||Array.isArray(e.promoCodes)&&e.promoCodes.every(function(e){return"string"==typeof e})?null:"".concat(v.PAYMENT_STATUS_UPDATED," event requires promoCodes in eventData to be an array of strings")}},{key:"_validateErrorOccurredEvent",value:function(e){if(!e)return"".concat(v.ERROR_OCCURRED," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.ERROR_OCCURRED," event requires eventData to be an object");var t=["errorCode","errorMessage","errorSeverity"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?"".concat(v.ERROR_OCCURRED," event does not allow additional fields in eventData: ").concat(n.join(", ")):e.errorCode?"string"!=typeof e.errorCode?"".concat(v.ERROR_OCCURRED," event requires errorCode in eventData to be a string"):e.errorMessage&&"string"!=typeof e.errorMessage?"".concat(v.ERROR_OCCURRED," event requires errorMessage in eventData to be a string"):e.errorSeverity&&!Object.values(d).includes(e.errorSeverity)?"".concat(v.ERROR_OCCURRED," event requires errorSeverity in eventData to be one of: ").concat(Object.values(d).join(", ")):null:"".concat(v.ERROR_OCCURRED," event requires errorCode in eventData to be defined")}},{key:"_validateCustomEvent",value:function(e){if(!e)return"".concat(v.CUSTOM," event requires eventData");if("object"!==l(e)||Array.isArray(e))return"".concat(v.CUSTOM," event requires eventData to be an object");var t=["customEventName","customEventData"],n=Object.keys(e).filter(function(e){return!t.includes(e)});return 0<n.length?"".concat(v.CUSTOM," event does not allow additional fields in eventData: ").concat(n.join(", ")):e.customEventName?"string"!=typeof e.customEventName?"".concat(v.CUSTOM," event requires customEventName in eventData to be a string"):null:"".concat(v.CUSTOM," event requires customEventName in eventData to be defined")}}]),e}(),y=function(){function e(){t(this,e),u.wrapModule(window,"LocaleModule")}return n(e,[{key:"getLanguageLocaleIdentifier",value:function(){return window.WrappedLocaleModule.invoke("getLanguageLocaleIdentifier")}}]),e}(),w=function(){function e(){t(this,e),u.wrapModule(window,"LocationModule")}return n(e,[{key:"getCoordinate",value:function(){return window.WrappedLocationModule.invoke("getCoordinate")}},{key:"observeLocationChange",value:function(){return window.WrappedLocationModule.invoke("observeLocationChange")}}]),e}(),T=function(){function e(){t(this,e),u.wrapModule(window,"MediaModule")}return n(e,[{key:"playDRMContent",value:function(e){return window.WrappedMediaModule.invoke("playDRMContent",{data:e})}}]),e}(),b=require("@grabjs/mobile-kit-bridge-sdk"),S=function(){function e(){t(this,e),b.wrapModule(window,"PlatformModule")}return n(e,[{key:"back",value:function(){return window.WrappedPlatformModule.invoke("back")}}]),e}(),k=function(){function e(){t(this,e),u.wrapModule(window,"ScopeModule")}return n(e,[{key:"hasAccessTo",value:function(e,t){return window.WrappedScopeModule.invoke("hasAccessTo",{module:e,method:t})}},{key:"reloadScopes",value:function(){return window.WrappedScopeModule.invoke("reloadScopes")}}]),e}(),M=require("@grabjs/mobile-kit-bridge-sdk"),E=function(){function e(){t(this,e),M.wrapModule(window,"StorageModule")}return n(e,[{key:"setBoolean",value:function(e,t){return window.WrappedStorageModule.invoke("setBoolean",{key:e,value:t})}},{key:"getBoolean",value:function(e){return window.WrappedStorageModule.invoke("getBoolean",{key:e})}},{key:"setInt",value:function(e,t){return window.WrappedStorageModule.invoke("setInt",{key:e,value:t})}},{key:"getInt",value:function(e){return window.WrappedStorageModule.invoke("getInt",{key:e})}},{key:"setString",value:function(e,t){return window.WrappedStorageModule.invoke("setString",{key:e,value:t})}},{key:"getString",value:function(e){return window.WrappedStorageModule.invoke("getString",{key:e})}},{key:"setDouble",value:function(e,t){return window.WrappedStorageModule.invoke("setDouble",{key:e,value:t})}},{key:"getDouble",value:function(e){return window.WrappedStorageModule.invoke("getDouble",{key:e})}},{key:"remove",value:function(e){return window.WrappedStorageModule.invoke("remove",{key:e})}},{key:"removeAll",value:function(){return window.WrappedStorageModule.invoke("removeAll")}}]),e}(),m=function(){function e(){t(this,e),u.wrapModule(window,"SystemWebViewKitModule")}return n(e,[{key:"redirectToSystemWebView",value:function(e){return window.WrappedSystemWebViewKitModule.invoke("redirectToSystemWebView",e)}}]),e}();e.CheckoutModule=c,e.ContainerModule=p,e.LocaleModule=y,e.LocationModule=w,e.MediaModule=T,e.PlatformModule=S,e.ScopeModule=k,e.StorageModule=E,e.SystemWebViewKitModule=m,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).SuperAppSDK={})}(this,function(e){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function o(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function r(e,n,t){return n&&o(e.prototype,n),t&&o(e,t),e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var u,i,a=(function(e,n){function a(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];if(!e)return!1;var o=function(e){return Object.keys(e).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(e)))}(e);return n.every(function(e){return 0<=o.indexOf(e)})}function l(r,e){var u=e.callbackNameFunc,i=e.funcToWrap;return function(e){return{subscribe:e,then:function(o,r){return new Promise(function(){try{var n=null,t=!1;n=e({next:function(e){o&&o(e),n&&n.unsubscribe(),t=!0}}),t&&n&&n.unsubscribe()}catch(e){r&&r(e)}})}}}(function(t){var n,o=u();return r[o]=function(e){if(a(e,"status_code"))if(a(e.result,"event"))switch(e.result.event){case d.StreamEvent.STREAM_TERMINATED:n.unsubscribe()}else t&&t.next&&t.next(e)},i(o),n=function(e){var n=!1;return{isUnsubscribed:function(){return n},unsubscribe:function(){n||(delete r[o],t&&t.complete&&t.complete(),n=!0)}}}()})}var d;((d=n).StreamEvent||(d.StreamEvent={})).STREAM_TERMINATED="STREAM_TERMINATED",d.wrapModule=function(u,i){u[function(e){return"Wrapped"+e}(i)]=function(e,o,n){var r={};return{invoke:function(n,t){return function(e,n){return n.funcNameToWrap,l(e,function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&(t[o[r]]=e[o[r]])}return t}(n,["funcNameToWrap"]))}(e,{funcNameToWrap:n,callbackNameFunc:function(){var e=r[n]||0;return r[n]=e+1,function(e){var n=e.moduleName,t=e.funcName,o=e.requestID;return n+"_"+t+"Callback"+(null!==o?"_"+o:"")}({moduleName:o,requestID:e,funcName:n})},funcToWrap:function(e){return function(e){if(u[i])u[i][e.method](JSON.stringify(e));else{if(!(u.webkit&&u.webkit.messageHandlers&&u.webkit.messageHandlers[i]))throw new Error("Unexpected method '"+e.method+"' for module '"+i+"'");u.webkit.messageHandlers[i].postMessage(e)}}({callback:e,method:n,module:o,parameters:null!=t?t:{}})}})}}}(u,i)},Object.defineProperty(d,"__esModule",{value:!0})}(u={exports:{}},u.exports),u.exports),l=(i=a)&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i,d=function(){function e(){t(this,e),l.wrapModule(window,"CheckoutModule")}return r(e,[{key:"triggerCheckout",value:function(e){return window.WrappedCheckoutModule.invoke("triggerCheckout",e)}}]),e}(),c=require("@grabjs/mobile-kit-bridge-sdk"),f=function(){function e(){t(this,e),c.wrapModule(window,"ContainerModule")}return r(e,[{key:"setBackgroundColor",value:function(e){return window.WrappedContainerModule.invoke("setBackgroundColor",{backgroundColor:e})}},{key:"setTitle",value:function(e){return window.WrappedContainerModule.invoke("setTitle",{title:e})}},{key:"hideBackButton",value:function(){return window.WrappedContainerModule.invoke("hideBackButton")}},{key:"showBackButton",value:function(){return window.WrappedContainerModule.invoke("showBackButton")}},{key:"hideRefreshButton",value:function(){return window.WrappedContainerModule.invoke("hideRefreshButton")}},{key:"showRefreshButton",value:function(){return window.WrappedContainerModule.invoke("showRefreshButton")}},{key:"close",value:function(){return window.WrappedContainerModule.invoke("close")}},{key:"onContentLoaded",value:function(){return window.WrappedContainerModule.invoke("onContentLoaded")}},{key:"openExternalLink",value:function(e){return window.WrappedContainerModule.invoke("openExternalLink",{url:e})}},{key:"sendAnalyticsEvent",value:function(e){var n=this._validateAnalyticsEvent(e);return n?{then:function(e){return e({status_code:400,error:n})}}:window.WrappedContainerModule.invoke("sendAnalyticsEvent",{state:e.state,name:e.name,data:e.data?JSON.stringify(e.data):null})}},{key:"_validateAnalyticsEvent",value:function(e){return null==e.name?"name is required":"string"!=typeof e.name?"name must be a string":null==e.state?"state is required":"string"!=typeof e.state?"state must be a string":null!=e.data&&"object"!==n(e.data)?"data must be undefined or an object":null}}]),e}(),s=function(){function e(){t(this,e),l.wrapModule(window,"LocaleModule")}return r(e,[{key:"getLanguageLocaleIdentifier",value:function(){return window.WrappedLocaleModule.invoke("getLanguageLocaleIdentifier")}}]),e}(),p=function(){function e(){t(this,e),l.wrapModule(window,"LocationModule")}return r(e,[{key:"getCoordinate",value:function(){return window.WrappedLocationModule.invoke("getCoordinate")}},{key:"observeLocationChange",value:function(){return window.WrappedLocationModule.invoke("observeLocationChange")}}]),e}(),w=function(){function e(){t(this,e),l.wrapModule(window,"MediaModule")}return r(e,[{key:"playDRMContent",value:function(e){return window.WrappedMediaModule.invoke("playDRMContent",{data:e})}}]),e}(),v=require("@grabjs/mobile-kit-bridge-sdk"),k=function(){function e(){t(this,e),v.wrapModule(window,"PlatformModule")}return r(e,[{key:"back",value:function(){return window.WrappedPlatformModule.invoke("back")}}]),e}(),y=function(){function e(){t(this,e),l.wrapModule(window,"ScopeModule")}return r(e,[{key:"hasAccessTo",value:function(e,n){return window.WrappedScopeModule.invoke("hasAccessTo",{module:e,method:n})}},{key:"reloadScopes",value:function(){return window.WrappedScopeModule.invoke("reloadScopes")}}]),e}(),M=require("@grabjs/mobile-kit-bridge-sdk"),b=function(){function e(){t(this,e),M.wrapModule(window,"StorageModule")}return r(e,[{key:"setBoolean",value:function(e,n){return window.WrappedStorageModule.invoke("setBoolean",{key:e,value:n})}},{key:"getBoolean",value:function(e){return window.WrappedStorageModule.invoke("getBoolean",{key:e})}},{key:"setInt",value:function(e,n){return window.WrappedStorageModule.invoke("setInt",{key:e,value:n})}},{key:"getInt",value:function(e){return window.WrappedStorageModule.invoke("getInt",{key:e})}},{key:"setString",value:function(e,n){return window.WrappedStorageModule.invoke("setString",{key:e,value:n})}},{key:"getString",value:function(e){return window.WrappedStorageModule.invoke("getString",{key:e})}},{key:"setDouble",value:function(e,n){return window.WrappedStorageModule.invoke("setDouble",{key:e,value:n})}},{key:"getDouble",value:function(e){return window.WrappedStorageModule.invoke("getDouble",{key:e})}},{key:"remove",value:function(e){return window.WrappedStorageModule.invoke("remove",{key:e})}},{key:"removeAll",value:function(){return window.WrappedStorageModule.invoke("removeAll")}}]),e}(),g=function(){function e(){t(this,e),l.wrapModule(window,"SystemWebViewKitModule")}return r(e,[{key:"redirectToSystemWebView",value:function(e){return window.WrappedSystemWebViewKitModule.invoke("redirectToSystemWebView",e)}}]),e}();e.CheckoutModule=d,e.ContainerAnalyticsEventData={TRANSACTION_AMOUNT:"transaction_amount",TRANSACTION_CURRENCY:"transaction_currency",PAGE:"page"},e.ContainerAnalyticsEventName={DEFAULT:"DEFAULT"},e.ContainerAnalyticsEventState={HOMEPAGE:"HOMEPAGE",CHECKOUT_PAGE:"CHECKOUT_PAGE",BOOKING_COMPLETION:"BOOKING_COMPLETION",CUSTOM:"CUSTOM"},e.ContainerModule=f,e.LocaleModule=s,e.LocationModule=p,e.MediaModule=w,e.PlatformModule=k,e.ScopeModule=y,e.StorageModule=b,e.SystemWebViewKitModule=g,Object.defineProperty(e,"__esModule",{value:!0})});
@@ -242,9 +242,9 @@ Call this method to tell client to open the link in external browser
242
242
 
243
243
  **Arguments**
244
244
 
245
- | Name | Type | Required | Description |
246
- | ----- | ------ | -------- | ----------------- |
247
- | url | String | Yes | URL to open |
245
+ | Name | Type | Required | Description |
246
+ | ---- | ------ | -------- | ----------- |
247
+ | url | String | Yes | URL to open |
248
248
 
249
249
  **Return type**
250
250
 
@@ -273,159 +273,86 @@ containerModule.openExternalLink("https://grab.com").then(({ result, error }) =>
273
273
 
274
274
  **Arguments**
275
275
 
276
- An object, containing the following properties:
277
-
278
- | Name | Type | Required | Description |
279
- | ----------- | ------ | -------- | -------------------------------------------------------------- |
280
- | `url` | String | No | The URL associated with the event |
281
- | `sessionId` | String | No | A unique identifier for the user's session |
282
- | `viewName` | String | No | The name of the page or screen displayed when the event occurs |
283
- | `eventName` | String | Yes | Name of the event |
284
- | `eventData` | Any | No | The event data (can be any type) |
276
+ | Name | Type | Required | Description |
277
+ | ------------ | ------ | -------- | ------------------------------------------------------- |
278
+ | eventDetails | Object | Yes | Event details containing state, name, and data |
285
279
 
286
- **Events**
280
+ **EventDetails Object Properties**
287
281
 
288
- The following events are available:
282
+ | Property | Type | Required | Description |
283
+ | -------- | ------ | -------- | ----------------------------------------------------------------- |
284
+ | state | String | Yes | State of the event (cf. Predefined ContainerAnalyticsEventState) |
285
+ | name | String | Yes | Name of the event (cf. Predefined ContainerAnalyticsEventName) |
286
+ | data | Object | No | Additional data for the event (cf. Predefined ContainerAnalyticsEventData) |
289
287
 
290
- - `STARTED`
288
+ **Predefined ContainerAnalyticsEventState**
291
289
 
292
- - **Description**: Triggered when the MiniApp is initialized.
293
- - **Requirements for eventData**:
294
- - Must be empty
290
+ - 'HOMEPAGE'
291
+ - 'CHECKOUT_PAGE'
292
+ - 'BOOKING_COMPLETION'
293
+ - 'CUSTOM'
295
294
 
296
- - `PAYMENT_STATUS_UPDATED`
295
+ **Predefined ContainerAnalyticsEventName**
297
296
 
298
- - **Description**: Triggered when a payment status is updated.
299
- - **Requirements for eventData**:
300
- - `transactionId` (String, optional): The transaction identifier provided by the GrabPay SDK
301
- - `statusCode` (String, required): The status of the payment. Must be one of: 'SUCCESS', 'FAILURE', 'CANCEL', 'PROCESSING' (case-sensitive)
302
- - `statusMessage` (String, optional): A message describing the status update
303
- - `products` (Array of objects, optional): The products that are being purchased
304
- - Each product must have:
305
- - `id` (String, required): The product's unique identifier
306
- - `quantity` (Number, optional): The quantity of the product
307
- - `amount` (Number, optional): The total amount of the transaction
308
- - `currency` (String, optional): The currency used for the transaction
309
- - `promoCodes` (Array of string, optional): Any promo codes applied to this transaction
297
+ - 'DEFAULT'
310
298
 
311
- - `ERROR_OCCURRED`
299
+ **Predefined ContainerAnalyticsEventData**
312
300
 
313
- - **Description**: Triggered when an error occurs within the MiniApp.
314
- - **Requirements for eventData**:
315
- - `errorCode` (String, required): A code or type identifying the error
316
- - `errorMessage` (String, optional): A message describing the error
317
- - `errorSeverity` (String, optional): The severity level of the error. Must be one of: 'WARNING', 'ERROR', 'CRITICAL' (case-sensitive)
318
-
319
- - `CUSTOM`
320
- - **Description**: Triggered when a custom event should be tracked within the MiniApp.
321
- - **Requirements for eventData**:
322
- - `customEventName` (String, required): The name of the custom event
323
- - `customEventData` (Any, optional): An object containing the custom event data
301
+ - 'TRANSACTION_AMOUNT': 'transaction_amount'
302
+ - 'TRANSACTION_CURRENCY': 'transaction_currency'
303
+ - 'PAGE': 'page'
324
304
 
325
305
  **Return type**
326
306
 
327
307
  `None`
328
308
 
329
- **Validation**
330
-
331
- The SDK performs strict validation on all events:
332
-
333
- - All required fields must be present
334
- - Field types must match their specifications exactly
335
- - No additional fields are allowed beyond those specified
336
- - Validation errors will be returned in the `error` field of the response
337
-
338
309
  **Code example**
339
310
 
340
311
  ```javascript
341
- import {
342
- ContainerModule,
343
- AnalyticsEventName,
344
- PaymentStatusCode,
345
- ErrorSeverity,
346
- } from "@grabjs/superapp-sdk";
312
+ import { ContainerModule, ContainerAnalyticsEventState, ContainerAnalyticsEventName, ContainerAnalyticsEventData } from "@grabjs/superapp-sdk";
347
313
 
348
- // Ideally, initialize this only one and reuse across app.
349
314
  const containerModule = new ContainerModule();
350
315
 
351
- // Example for STARTED event
352
- containerModule
353
- .sendAnalyticsEvent({
354
- url: "https://www.grab.com/sg/",
355
- sessionId: "e48553f4-625a-431d-adae-56d7801c083c",
356
- viewName: "Home",
357
- eventName: AnalyticsEventName.STARTED,
358
- eventData: null,
359
- })
360
- .then(({ result, error }) => {
361
- if (error) {
362
- // Some error happened.
363
- }
364
- });
365
-
366
- // Example for PAYMENT_STATUS_UPDATED event
367
- containerModule
368
- .sendAnalyticsEvent({
369
- url: "https://www.grab.com/sg/",
370
- sessionId: "e48553f4-625a-431d-adae-56d7801c083c",
371
- viewName: "Payment",
372
- eventName: AnalyticsEventName.PAYMENT_STATUS_UPDATED,
373
- eventData: {
374
- transactionId: "txn_123456",
375
- statusCode: PaymentStatusCode.SUCCESS,
376
- statusMessage: "Payment completed successfully",
377
- products: [
378
- { id: "product_1", quantity: 2 },
379
- { id: "product_2", quantity: 1 },
380
- ],
381
- amount: 100.5,
382
- currency: "SGD",
383
- promoCodes: ["10%OFF"],
384
- },
385
- })
386
- .then(({ result, error }) => {
387
- if (error) {
388
- // Some error happened.
389
- }
390
- });
391
-
392
- // Example for ERROR_OCCURRED event
393
- containerModule
394
- .sendAnalyticsEvent({
395
- url: "https://www.grab.com/sg/",
396
- sessionId: "e48553f4-625a-431d-adae-56d7801c083c",
397
- viewName: "Payment",
398
- eventName: AnalyticsEventName.ERROR_OCCURRED,
399
- eventData: {
400
- errorCode: "PAYMENT_FAILED",
401
- errorMessage: "Failed to process payment due to insufficient funds",
402
- errorSeverity: ErrorSeverity.ERROR,
403
- },
404
- })
405
- .then(({ result, error }) => {
406
- if (error) {
407
- // Some error happened.
408
- }
409
- });
410
-
411
- // Example for CUSTOM event
412
- containerModule
413
- .sendAnalyticsEvent({
414
- url: "https://www.grab.com/sg/",
415
- sessionId: "e48553f4-625a-431d-adae-56d7801c083c",
416
- viewName: "Home",
417
- eventName: AnalyticsEventName.CUSTOM,
418
- eventData: {
419
- customEventName: "USER_ACTION",
420
- customEventData: {
421
- action: "button_click",
422
- buttonId: "submit_order",
423
- },
424
- },
425
- })
426
- .then(({ result, error }) => {
427
- if (error) {
428
- // Some error happened.
429
- }
430
- });
316
+ // Example: Send a DEFAULT event for HOMEPAGE state
317
+ containerModule.sendAnalyticsEvent({
318
+ state: ContainerAnalyticsEventState.HOMEPAGE,
319
+ name: ContainerAnalyticsEventName.DEFAULT,
320
+ }).then(({ result, error }) => {
321
+ if (error) {
322
+ // Handle validation or other errors
323
+ }
324
+ });
325
+
326
+ // Example: Send a BOOK event for CHECKOUT_PAGE state
327
+ containerModule.sendAnalyticsEvent({
328
+ state: ContainerAnalyticsEventState.CHECKOUT_PAGE,
329
+ name: 'BOOK',
330
+ data: {
331
+ [ContainerAnalyticsEventData.TRANSACTION_AMOUNT]: 100,
332
+ [ContainerAnalyticsEventData.TRANSACTION_CURRENCY]: "SGD"
333
+ }
334
+ }).then(({ result, error }) => {
335
+ if (error) {
336
+ // Handle validation or other errors
337
+ }
338
+ });
339
+
340
+ // Example: Send a CLICK_RIDE event for CUSTOM state
341
+ containerModule.sendAnalyticsEvent({
342
+ state: ContainerAnalyticsEventState.CUSTOM,
343
+ name: 'CLICK_RIDE',
344
+ data: {
345
+ [ContainerAnalyticsEventData.PAGE]: "LIST_RIDES",
346
+ departure_time: "2025-06-01 08:00:00",
347
+ arrival_time: "2025-06-01 10:30:00",
348
+ departure_address: "6 Bayfront Ave, Singapore 018974",
349
+ arrival_address: "Petronas Twin Tower, Kuala Lumpur City Centre, 50088 Kuala Lumpur, Malaysia",
350
+ }
351
+
352
+ }).then(({ result, error }) => {
353
+ if (error) {
354
+ // Handle validation or other errors
355
+ }
356
+ });
431
357
  ```
358
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grabjs/superapp-sdk",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "SDK for Grab SuperApp WebView.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {