package Ġuk . n hs . n hs x . analytics logs Ċ Ċ import Ġuk . n hs . n hs x . core . Environment Ċ import Ġuk . n hs . n hs x . core . System Clock Ċ import Ġuk . n hs . n hs x . core . events . Print ing Json Events Ċ import Ġuk . n hs . n hs x . core . headers . Mobile OS Ċ import Ġuk . n hs . n hs x . domain . Country Ċ import Ġuk . n hs . n hs x . domain . Test Kit Ċ import Ġuk . n hs . n hs x . domain . Token Age Range Ċ import Ġjava . time . LocalDate Ċ import Ġjava . time . format . DateTime Formatter ĊĊ Ċ data Ġclass ĠC ta Exchange Stats ( val ĠstartDate : ĠLocalDate , Ġval Ġtest Type : ĠTest Kit , Ġval Ġplatform : ĠMobile OS ?, Ġval Ġtoken Age Range Ġ: ĠToken Age Range , Ġval Ġsource : ĠCountry , Ġval Ġtotal : ĠInt , Ġ Ġval Ġapp Version : ĠString ) Ċ Ċ class ĠC ta Exchange Stats Converter Ġ: ĠConverter < C ta Exchange Stats >() Ġ{ ĊĠĠĠ Ġprivate Ġval ĠdateTime Formatter Pattern Ġ= ĠDateTime Formatter . of Pattern (" yyyy - MM - dd ĠHH : mm : ss . SS S ") ĊĠĠĠ Ġoverride Ġfun Ġconvert ( map : ĠMap < String , ĠString >): ĠC ta Exchange Stats Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠC ta Exchange Stats ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠstartDate Ġ= ĠLocalDate . parse ( map [" start _ date "] Ġ?: Ġerror (" missing Ġstart _ date Ġfield Ġfrom Ġcloud watch Ġlog Ġinsights "), dateTime Formatter Pattern ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Type Ġ= ĠTest Kit . valueOf ( map [" test _ type "] Ġ?: Ġerror (" missing Ġtest _ type Ġfield Ġfrom Ġcloud watch Ġlog Ġinsights ")), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġplatform Ġ= ĠMobile OS . valueOf ( map [" platform "] Ġ?: Ġerror (" missing Ġplatform Ġfield Ġfrom Ġcloud watch Ġlog Ġinsights ")), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtoken Age Range Ġ= ĠToken Age Range . valueOf ( map [" token _ age _ range "] Ġ?: Ġerror (" missing Ġtoken _ age _ range Ġfield Ġfrom Ġcloud watch Ġlog Ġinsights ")), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsource Ġ= ĠCountry . from ( map [" source "] Ġ?: Ġerror (" missing Ġsource Ġfield Ġfrom Ġcloud watch Ġlog Ġinsights ")), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtotal Ġ= Ġmap [" total "] ?. toInt () Ġ?: Ġ 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Version Ġ= Ġmap [" app _ version "] Ġ?: Ġ" UNKNOWN " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠC ta Exchange Analytics Handler Ġ: ĠLog Insights Analytics Handler ( ĊĠĠĠ Ġlog Analytics Service ( ĊĠĠĠĠĠĠĠ ĠEnvironment . from System (), ĊĠĠĠĠĠĠĠ ĠSystem Clock . CLOCK , ĊĠĠĠĠĠĠĠ ĠPrint ing Json Events ( System Clock . CLOCK ), ĊĠĠĠĠĠĠĠ Ġc ta Exchange QueryString , ĊĠĠĠĠĠĠĠ ĠC ta Exchange Stats Converter ()), ĊĠĠĠ ĠPrint ing Json Events ( System Clock . CLOCK ) Ċ ) Ċ Ċ private Ġconst Ġval Ġc ta Exchange QueryString Ġ= Ġ""" fields Ġ@ timestamp , Ġ@ message Ċ | Ġfilter Ġ@ message Ġlike Ġ/ ^\ {/ Ċ | Ġfilter Ġmetadata . name Ġ= Ġ" Successful C ta Exchange " Ċ | Ġsort Ġ@ timestamp Ġdesc Ċ | Ġstats Ġcount () Ġas Ġtotal Ġby Ġbin ( 1 d ) Ġas Ġstart _ date , Ġevent . test Kit Ġas Ġtest _ type , Ġevent . country Ġas Ġsource , Ġevent . mobile OS Ġas Ġplatform , Ġevent . token Age Range Ġas Ġtoken _ age _ range , Ġevent . app Version . sem Ver Ġas Ġapp _ version """ Ċ