Skip to content

Commit

Permalink
feat(\): identifying Instagram, Twitter, Facebook and Linkedin inApp …
Browse files Browse the repository at this point in the history
…browser user agents for logging
  • Loading branch information
Vrishab Srivatsa committed Apr 22, 2024
1 parent c6f6965 commit 9506592
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/orca-log-catcher/OrcaLogger.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9506592

Please sign in to comment.