diff --git a/src/orca-log-catcher/OrcaLogger.res b/src/orca-log-catcher/OrcaLogger.res index c73c14a04..9dce6d532 100644 --- a/src/orca-log-catcher/OrcaLogger.res +++ b/src/orca-log-catcher/OrcaLogger.res @@ -194,8 +194,8 @@ type logFile = { category: logCategory, source: string, version: string, - value: string, - internalMetadata: string, + value?: string, + internalMetadata?: string, sessionId: string, merchantId: string, paymentId: string, @@ -205,9 +205,9 @@ type logFile = { browserVersion: string, userAgent: string, eventName: eventName, - latency: string, + latency?: string, firstEvent: bool, - paymentMethod: string, + paymentMethod?: string, metadata: JSON.t, ephemeralKey: string, } @@ -320,8 +320,8 @@ let logFileToObj = logFile => { ), ("source", logFile.source->convertToScreamingSnakeCase->JSON.Encode.string), ("version", logFile.version->JSON.Encode.string), // repoversion of orca-android - ("value", logFile.value->JSON.Encode.string), - ("internal_metadata", logFile.internalMetadata->JSON.Encode.string), + ("value", logFile.value->Option.getOr("")->JSON.Encode.string), + ("internal_metadata", logFile.internalMetadata->Option.getOr("")->JSON.Encode.string), ("session_id", logFile.sessionId->JSON.Encode.string), ("merchant_id", logFile.merchantId->JSON.Encode.string), ("payment_id", logFile.paymentId->JSON.Encode.string), @@ -331,9 +331,12 @@ let logFileToObj = logFile => { ("event_name", logFile.eventName->eventNameToStrMapper->JSON.Encode.string), ("browser_name", logFile.browserName->convertToScreamingSnakeCase->JSON.Encode.string), ("browser_version", logFile.browserVersion->JSON.Encode.string), - ("latency", logFile.latency->JSON.Encode.string), + ("latency", logFile.latency->Option.getOr("")->JSON.Encode.string), ("first_event", (logFile.firstEvent ? "true" : "false")->JSON.Encode.string), - ("payment_method", logFile.paymentMethod->convertToScreamingSnakeCase->JSON.Encode.string), + ( + "payment_method", + logFile.paymentMethod->Option.getOr("")->convertToScreamingSnakeCase->JSON.Encode.string, + ), ] ->Dict.fromArray ->JSON.Encode.object @@ -532,9 +535,9 @@ let make = ( let maxLogsPushedPerEventName = GlobalVars.maxLogsPushedPerEventName let conditionalEventName = switch log.eventName { | INPUT_FIELD_CHANGED => log.value // to enforce rate limiting for each input field independently - | _ => "" + | _ => Some("") } - let eventName = log.eventName->eventNameToStrMapper ++ conditionalEventName + let eventName = log.eventName->eventNameToStrMapper ++ conditionalEventName->Option.getOr("") let counter = eventName->calculateAndUpdateCounterHook if GlobalVars.enableLogging && counter <= maxLogsPushedPerEventName { @@ -677,8 +680,6 @@ let make = ( sessionId: sessionId.contents, source: sourceString, version: GlobalVars.repoVersion, - value: "", - internalMetadata: "", category: USER_EVENT, paymentId: clientSecret.contents->getPaymentId, merchantId: merchantId.contents, @@ -686,9 +687,8 @@ let make = ( browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.Navigator.platform, userAgent: Window.Navigator.userAgent, - appId: "", + appId: Window.Location.hostname, eventName: PAYMENT_METHOD_CHANGED, - latency: "", paymentMethod, firstEvent: true, metadata: metadata.contents, @@ -705,8 +705,6 @@ let make = ( sessionId: sessionId.contents, source: sourceString, version: GlobalVars.repoVersion, - value: "", - internalMetadata: "", category: USER_EVENT, paymentId: clientSecret.contents->getPaymentId, merchantId: merchantId.contents, @@ -714,9 +712,8 @@ let make = ( browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.Navigator.platform, userAgent: Window.Navigator.userAgent, - appId: "", + appId: Window.Location.hostname, eventName: PAYMENT_DATA_FILLED, - latency: "", paymentMethod, firstEvent: true, metadata: metadata.contents, @@ -765,7 +762,7 @@ let make = ( browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.Navigator.platform, userAgent: Window.Navigator.userAgent, - appId: "", + appId: Window.Location.hostname, eventName, latency, paymentMethod, @@ -822,7 +819,7 @@ let make = ( browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.Navigator.platform, userAgent: Window.Navigator.userAgent, - appId: "", + appId: Window.Location.hostname, eventName, latency, paymentMethod, @@ -869,7 +866,7 @@ let make = ( browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.Navigator.platform, userAgent: Window.Navigator.userAgent, - appId: "", + appId: Window.Location.hostname, eventName, latency, paymentMethod, @@ -897,16 +894,14 @@ let make = ( version: GlobalVars.repoVersion, category: USER_EVENT, value: "log initiated", - internalMetadata: "", paymentId: clientSecret.contents->getPaymentId, merchantId: merchantId.contents, browserName: arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"), browserVersion: arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"), platform: Window.Navigator.platform, userAgent: Window.Navigator.userAgent, - appId: "", + appId: Window.Location.hostname, latency, - paymentMethod: "", firstEvent, metadata: metadata.contents, ephemeralKey: ephemeralKey.contents,