From 950659221bf65e74c06da80f6f433eccaaa04d04 Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa Date: Mon, 22 Apr 2024 16:53:36 +0530 Subject: [PATCH] feat(\): identifying Instagram, Twitter, Facebook and Linkedin inApp browser user agents for logging --- src/orca-log-catcher/OrcaLogger.res | 42 ++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/orca-log-catcher/OrcaLogger.res b/src/orca-log-catcher/OrcaLogger.res index c42ca30c2..b13bd5bd9 100644 --- a/src/orca-log-catcher/OrcaLogger.res +++ b/src/orca-log-catcher/OrcaLogger.res @@ -312,7 +312,47 @@ let findVersion = (re, content) => { } let browserDetect = content => { - if RegExp.test("Edg"->RegExp.fromString, content) { + if RegExp.test("Instagram"->RegExp.fromString, content) { + let re = %re("/Instagram\/([\d]+\.[\w]?\.?[\w]+)/ig") + let version = switch findVersion(re, content) + ->Array.get(1) + ->Option.getOr(Nullable.null) + ->Nullable.toOption { + | Some(a) => a + | None => "" + } + `Instagram-${version}` + } else if RegExp.test("FBAV"->RegExp.fromString, content) { + let re = %re("/FBAV\/([\d]+\.[\w]?\.?[\w]+)/ig") + let version = switch findVersion(re, content) + ->Array.get(1) + ->Option.getOr(Nullable.null) + ->Nullable.toOption { + | Some(a) => a + | None => "" + } + `Facebook-${version}` + } else if RegExp.test("Twitter"->RegExp.fromString, content) { + let re = %re("/iPhone\/([\d]+\.[\w]?\.?[\w]+)/ig") + let version = switch findVersion(re, content) + ->Array.get(1) + ->Option.getOr(Nullable.null) + ->Nullable.toOption { + | Some(a) => a + | None => "" + } + `Twitter-${version}` + } else if RegExp.test("LinkedIn"->RegExp.fromString, content) { + let re = %re("/LinkedInApp\/([\d]+\.[\w]?\.?[\w]+)/ig") + let version = switch findVersion(re, content) + ->Array.get(1) + ->Option.getOr(Nullable.null) + ->Nullable.toOption { + | Some(a) => a + | None => "" + } + `LinkedIn-${version}` + } else if RegExp.test("Edg"->RegExp.fromString, content) { let re = %re("/Edg\/([\d]+\.[\w]?\.?[\w]+)/ig") let version = switch findVersion(re, content) ->Array.get(1)