ai.0.22.9-build00167.js 196 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524
  1. var Microsoft;
  2. (function (Microsoft) {
  3. var ApplicationInsights;
  4. (function (ApplicationInsights) {
  5. (function (LoggingSeverity) {
  6. LoggingSeverity[LoggingSeverity["CRITICAL"] = 0] = "CRITICAL";
  7. LoggingSeverity[LoggingSeverity["WARNING"] = 1] = "WARNING";
  8. })(ApplicationInsights.LoggingSeverity || (ApplicationInsights.LoggingSeverity = {}));
  9. var LoggingSeverity = ApplicationInsights.LoggingSeverity;
  10. (function (_InternalMessageId) {
  11. _InternalMessageId[_InternalMessageId["NONUSRACT_BrowserDoesNotSupportLocalStorage"] = 0] = "NONUSRACT_BrowserDoesNotSupportLocalStorage";
  12. _InternalMessageId[_InternalMessageId["NONUSRACT_BrowserCannotReadLocalStorage"] = 1] = "NONUSRACT_BrowserCannotReadLocalStorage";
  13. _InternalMessageId[_InternalMessageId["NONUSRACT_BrowserCannotReadSessionStorage"] = 2] = "NONUSRACT_BrowserCannotReadSessionStorage";
  14. _InternalMessageId[_InternalMessageId["NONUSRACT_BrowserCannotWriteLocalStorage"] = 3] = "NONUSRACT_BrowserCannotWriteLocalStorage";
  15. _InternalMessageId[_InternalMessageId["NONUSRACT_BrowserCannotWriteSessionStorage"] = 4] = "NONUSRACT_BrowserCannotWriteSessionStorage";
  16. _InternalMessageId[_InternalMessageId["NONUSRACT_BrowserFailedRemovalFromLocalStorage"] = 5] = "NONUSRACT_BrowserFailedRemovalFromLocalStorage";
  17. _InternalMessageId[_InternalMessageId["NONUSRACT_BrowserFailedRemovalFromSessionStorage"] = 6] = "NONUSRACT_BrowserFailedRemovalFromSessionStorage";
  18. _InternalMessageId[_InternalMessageId["NONUSRACT_CannotSendEmptyTelemetry"] = 7] = "NONUSRACT_CannotSendEmptyTelemetry";
  19. _InternalMessageId[_InternalMessageId["NONUSRACT_ClientPerformanceMathError"] = 8] = "NONUSRACT_ClientPerformanceMathError";
  20. _InternalMessageId[_InternalMessageId["NONUSRACT_ErrorParsingAISessionCookie"] = 9] = "NONUSRACT_ErrorParsingAISessionCookie";
  21. _InternalMessageId[_InternalMessageId["NONUSRACT_ErrorPVCalc"] = 10] = "NONUSRACT_ErrorPVCalc";
  22. _InternalMessageId[_InternalMessageId["NONUSRACT_ExceptionWhileLoggingError"] = 11] = "NONUSRACT_ExceptionWhileLoggingError";
  23. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedAddingTelemetryToBuffer"] = 12] = "NONUSRACT_FailedAddingTelemetryToBuffer";
  24. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedMonitorAjaxAbort"] = 13] = "NONUSRACT_FailedMonitorAjaxAbort";
  25. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedMonitorAjaxDur"] = 14] = "NONUSRACT_FailedMonitorAjaxDur";
  26. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedMonitorAjaxOpen"] = 15] = "NONUSRACT_FailedMonitorAjaxOpen";
  27. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedMonitorAjaxRSC"] = 16] = "NONUSRACT_FailedMonitorAjaxRSC";
  28. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedMonitorAjaxSend"] = 17] = "NONUSRACT_FailedMonitorAjaxSend";
  29. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedToAddHandlerForOnBeforeUnload"] = 18] = "NONUSRACT_FailedToAddHandlerForOnBeforeUnload";
  30. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedToSendQueuedTelemetry"] = 19] = "NONUSRACT_FailedToSendQueuedTelemetry";
  31. _InternalMessageId[_InternalMessageId["NONUSRACT_FailedToReportDataLoss"] = 20] = "NONUSRACT_FailedToReportDataLoss";
  32. _InternalMessageId[_InternalMessageId["NONUSRACT_FlushFailed"] = 21] = "NONUSRACT_FlushFailed";
  33. _InternalMessageId[_InternalMessageId["NONUSRACT_MessageLimitPerPVExceeded"] = 22] = "NONUSRACT_MessageLimitPerPVExceeded";
  34. _InternalMessageId[_InternalMessageId["NONUSRACT_MissingRequiredFieldSpecification"] = 23] = "NONUSRACT_MissingRequiredFieldSpecification";
  35. _InternalMessageId[_InternalMessageId["NONUSRACT_NavigationTimingNotSupported"] = 24] = "NONUSRACT_NavigationTimingNotSupported";
  36. _InternalMessageId[_InternalMessageId["NONUSRACT_OnError"] = 25] = "NONUSRACT_OnError";
  37. _InternalMessageId[_InternalMessageId["NONUSRACT_SessionRenewalDateIsZero"] = 26] = "NONUSRACT_SessionRenewalDateIsZero";
  38. _InternalMessageId[_InternalMessageId["NONUSRACT_SenderNotInitialized"] = 27] = "NONUSRACT_SenderNotInitialized";
  39. _InternalMessageId[_InternalMessageId["NONUSRACT_StartTrackEventFailed"] = 28] = "NONUSRACT_StartTrackEventFailed";
  40. _InternalMessageId[_InternalMessageId["NONUSRACT_StopTrackEventFailed"] = 29] = "NONUSRACT_StopTrackEventFailed";
  41. _InternalMessageId[_InternalMessageId["NONUSRACT_StartTrackFailed"] = 30] = "NONUSRACT_StartTrackFailed";
  42. _InternalMessageId[_InternalMessageId["NONUSRACT_StopTrackFailed"] = 31] = "NONUSRACT_StopTrackFailed";
  43. _InternalMessageId[_InternalMessageId["NONUSRACT_TelemetrySampledAndNotSent"] = 32] = "NONUSRACT_TelemetrySampledAndNotSent";
  44. _InternalMessageId[_InternalMessageId["NONUSRACT_TrackEventFailed"] = 33] = "NONUSRACT_TrackEventFailed";
  45. _InternalMessageId[_InternalMessageId["NONUSRACT_TrackExceptionFailed"] = 34] = "NONUSRACT_TrackExceptionFailed";
  46. _InternalMessageId[_InternalMessageId["NONUSRACT_TrackMetricFailed"] = 35] = "NONUSRACT_TrackMetricFailed";
  47. _InternalMessageId[_InternalMessageId["NONUSRACT_TrackPVFailed"] = 36] = "NONUSRACT_TrackPVFailed";
  48. _InternalMessageId[_InternalMessageId["NONUSRACT_TrackPVFailedCalc"] = 37] = "NONUSRACT_TrackPVFailedCalc";
  49. _InternalMessageId[_InternalMessageId["NONUSRACT_TrackTraceFailed"] = 38] = "NONUSRACT_TrackTraceFailed";
  50. _InternalMessageId[_InternalMessageId["NONUSRACT_TransmissionFailed"] = 39] = "NONUSRACT_TransmissionFailed";
  51. _InternalMessageId[_InternalMessageId["USRACT_CannotSerializeObject"] = 40] = "USRACT_CannotSerializeObject";
  52. _InternalMessageId[_InternalMessageId["USRACT_CannotSerializeObjectNonSerializable"] = 41] = "USRACT_CannotSerializeObjectNonSerializable";
  53. _InternalMessageId[_InternalMessageId["USRACT_CircularReferenceDetected"] = 42] = "USRACT_CircularReferenceDetected";
  54. _InternalMessageId[_InternalMessageId["USRACT_ClearAuthContextFailed"] = 43] = "USRACT_ClearAuthContextFailed";
  55. _InternalMessageId[_InternalMessageId["USRACT_ExceptionTruncated"] = 44] = "USRACT_ExceptionTruncated";
  56. _InternalMessageId[_InternalMessageId["USRACT_IllegalCharsInName"] = 45] = "USRACT_IllegalCharsInName";
  57. _InternalMessageId[_InternalMessageId["USRACT_ItemNotInArray"] = 46] = "USRACT_ItemNotInArray";
  58. _InternalMessageId[_InternalMessageId["USRACT_MaxAjaxPerPVExceeded"] = 47] = "USRACT_MaxAjaxPerPVExceeded";
  59. _InternalMessageId[_InternalMessageId["USRACT_MessageTruncated"] = 48] = "USRACT_MessageTruncated";
  60. _InternalMessageId[_InternalMessageId["USRACT_NameTooLong"] = 49] = "USRACT_NameTooLong";
  61. _InternalMessageId[_InternalMessageId["USRACT_SampleRateOutOfRange"] = 50] = "USRACT_SampleRateOutOfRange";
  62. _InternalMessageId[_InternalMessageId["USRACT_SetAuthContextFailed"] = 51] = "USRACT_SetAuthContextFailed";
  63. _InternalMessageId[_InternalMessageId["USRACT_SetAuthContextFailedAccountName"] = 52] = "USRACT_SetAuthContextFailedAccountName";
  64. _InternalMessageId[_InternalMessageId["USRACT_StringValueTooLong"] = 53] = "USRACT_StringValueTooLong";
  65. _InternalMessageId[_InternalMessageId["USRACT_StartCalledMoreThanOnce"] = 54] = "USRACT_StartCalledMoreThanOnce";
  66. _InternalMessageId[_InternalMessageId["USRACT_StopCalledWithoutStart"] = 55] = "USRACT_StopCalledWithoutStart";
  67. _InternalMessageId[_InternalMessageId["USRACT_TelemetryInitializerFailed"] = 56] = "USRACT_TelemetryInitializerFailed";
  68. _InternalMessageId[_InternalMessageId["USRACT_TrackArgumentsNotSpecified"] = 57] = "USRACT_TrackArgumentsNotSpecified";
  69. _InternalMessageId[_InternalMessageId["USRACT_UrlTooLong"] = 58] = "USRACT_UrlTooLong";
  70. })(ApplicationInsights._InternalMessageId || (ApplicationInsights._InternalMessageId = {}));
  71. var _InternalMessageId = ApplicationInsights._InternalMessageId;
  72. var _InternalLogMessage = (function () {
  73. function _InternalLogMessage(msgId, msg, properties) {
  74. this.message = _InternalMessageId[msgId].toString();
  75. this.messageId = msgId;
  76. var diagnosticText = (msg ? " message:" + _InternalLogMessage.sanitizeDiagnosticText(msg) : "") +
  77. (properties ? " props:" + _InternalLogMessage.sanitizeDiagnosticText(JSON.stringify(properties)) : "");
  78. this.message += diagnosticText;
  79. }
  80. _InternalLogMessage.sanitizeDiagnosticText = function (text) {
  81. return "\"" + text.replace(/\"/g, "") + "\"";
  82. };
  83. return _InternalLogMessage;
  84. })();
  85. ApplicationInsights._InternalLogMessage = _InternalLogMessage;
  86. var _InternalLogging = (function () {
  87. function _InternalLogging() {
  88. }
  89. _InternalLogging.throwInternalNonUserActionable = function (severity, message) {
  90. if (this.enableDebugExceptions()) {
  91. throw message;
  92. }
  93. else {
  94. if (typeof (message) !== "undefined" && !!message) {
  95. if (typeof (message.message) !== "undefined") {
  96. message.message = this.AiNonUserActionablePrefix + message.message;
  97. this.warnToConsole(message.message);
  98. this.logInternalMessage(severity, message);
  99. }
  100. }
  101. }
  102. };
  103. _InternalLogging.throwInternalUserActionable = function (severity, message) {
  104. if (this.enableDebugExceptions()) {
  105. throw message;
  106. }
  107. else {
  108. if (typeof (message) !== "undefined" && !!message) {
  109. if (typeof (message.message) !== "undefined") {
  110. message.message = this.AiUserActionablePrefix + message.message;
  111. this.warnToConsole(message.message);
  112. this.logInternalMessage(severity, message);
  113. }
  114. }
  115. }
  116. };
  117. _InternalLogging.warnToConsole = function (message) {
  118. if (typeof console !== "undefined" && !!console) {
  119. if (typeof console.warn === "function") {
  120. console.warn(message);
  121. }
  122. else if (typeof console.log === "function") {
  123. console.log(message);
  124. }
  125. }
  126. };
  127. _InternalLogging.resetInternalMessageCount = function () {
  128. this._messageCount = 0;
  129. };
  130. _InternalLogging.clearInternalMessageLoggedTypes = function () {
  131. if (ApplicationInsights.Util.canUseSessionStorage()) {
  132. var sessionStorageKeys = ApplicationInsights.Util.getSessionStorageKeys();
  133. for (var i = 0; i < sessionStorageKeys.length; i++) {
  134. if (sessionStorageKeys[i].indexOf(_InternalLogging.AIInternalMessagePrefix) === 0) {
  135. ApplicationInsights.Util.removeSessionStorage(sessionStorageKeys[i]);
  136. }
  137. }
  138. }
  139. };
  140. _InternalLogging.setMaxInternalMessageLimit = function (limit) {
  141. if (!limit) {
  142. throw new Error('limit cannot be undefined.');
  143. }
  144. this.MAX_INTERNAL_MESSAGE_LIMIT = limit;
  145. };
  146. _InternalLogging.logInternalMessage = function (severity, message) {
  147. if (this._areInternalMessagesThrottled()) {
  148. return;
  149. }
  150. var logMessage = true;
  151. if (ApplicationInsights.Util.canUseSessionStorage()) {
  152. var storageMessageKey = _InternalLogging.AIInternalMessagePrefix + _InternalMessageId[message.messageId];
  153. var internalMessageTypeLogRecord = ApplicationInsights.Util.getSessionStorage(storageMessageKey);
  154. if (internalMessageTypeLogRecord) {
  155. logMessage = false;
  156. }
  157. else {
  158. ApplicationInsights.Util.setSessionStorage(storageMessageKey, "1");
  159. }
  160. }
  161. if (logMessage) {
  162. if (this.verboseLogging() || severity === LoggingSeverity.CRITICAL) {
  163. this.queue.push(message);
  164. this._messageCount++;
  165. }
  166. if (this._messageCount == this.MAX_INTERNAL_MESSAGE_LIMIT) {
  167. var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
  168. var throttleMessage = new _InternalLogMessage(_InternalMessageId.NONUSRACT_MessageLimitPerPVExceeded, throttleLimitMessage);
  169. this.queue.push(throttleMessage);
  170. this.warnToConsole(throttleLimitMessage);
  171. }
  172. }
  173. };
  174. _InternalLogging._areInternalMessagesThrottled = function () {
  175. return this._messageCount >= this.MAX_INTERNAL_MESSAGE_LIMIT;
  176. };
  177. _InternalLogging.AiUserActionablePrefix = "AI: ";
  178. _InternalLogging.AIInternalMessagePrefix = "AITR_";
  179. _InternalLogging.AiNonUserActionablePrefix = "AI (Internal): ";
  180. _InternalLogging.enableDebugExceptions = function () { return false; };
  181. _InternalLogging.verboseLogging = function () { return false; };
  182. _InternalLogging.queue = [];
  183. _InternalLogging.MAX_INTERNAL_MESSAGE_LIMIT = 25;
  184. _InternalLogging._messageCount = 0;
  185. return _InternalLogging;
  186. })();
  187. ApplicationInsights._InternalLogging = _InternalLogging;
  188. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  189. })(Microsoft || (Microsoft = {}));
  190. /// <reference path="./logging.ts" />
  191. var Microsoft;
  192. (function (Microsoft) {
  193. var ApplicationInsights;
  194. (function (ApplicationInsights) {
  195. var StorageType;
  196. (function (StorageType) {
  197. StorageType[StorageType["LocalStorage"] = 0] = "LocalStorage";
  198. StorageType[StorageType["SessionStorage"] = 1] = "SessionStorage";
  199. })(StorageType || (StorageType = {}));
  200. var Util = (function () {
  201. function Util() {
  202. }
  203. Util._getLocalStorageObject = function () {
  204. return Util._getVerifiedStorageObject(StorageType.LocalStorage);
  205. };
  206. Util._getVerifiedStorageObject = function (storageType) {
  207. var storage = null;
  208. var fail;
  209. var uid;
  210. try {
  211. uid = new Date;
  212. storage = storageType === StorageType.LocalStorage ? window.localStorage : window.sessionStorage;
  213. storage.setItem(uid, uid);
  214. fail = storage.getItem(uid) != uid;
  215. storage.removeItem(uid);
  216. if (fail) {
  217. storage = null;
  218. }
  219. }
  220. catch (exception) {
  221. storage = null;
  222. }
  223. return storage;
  224. };
  225. Util.canUseLocalStorage = function () {
  226. return !!Util._getLocalStorageObject();
  227. };
  228. Util.getStorage = function (name) {
  229. var storage = Util._getLocalStorageObject();
  230. if (storage !== null) {
  231. try {
  232. return storage.getItem(name);
  233. }
  234. catch (e) {
  235. var message = new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_BrowserCannotReadLocalStorage, "Browser failed read of local storage. " + Util.getExceptionName(e), { exception: Util.dump(e) });
  236. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, message);
  237. }
  238. }
  239. return null;
  240. };
  241. Util.setStorage = function (name, data) {
  242. var storage = Util._getLocalStorageObject();
  243. if (storage !== null) {
  244. try {
  245. storage.setItem(name, data);
  246. return true;
  247. }
  248. catch (e) {
  249. var message = new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_BrowserCannotWriteLocalStorage, "Browser failed write to local storage. " + Util.getExceptionName(e), { exception: Util.dump(e) });
  250. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, message);
  251. }
  252. }
  253. return false;
  254. };
  255. Util.removeStorage = function (name) {
  256. var storage = Util._getLocalStorageObject();
  257. if (storage !== null) {
  258. try {
  259. storage.removeItem(name);
  260. return true;
  261. }
  262. catch (e) {
  263. var message = new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_BrowserFailedRemovalFromLocalStorage, "Browser failed removal of local storage item. " + Util.getExceptionName(e), { exception: Util.dump(e) });
  264. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, message);
  265. }
  266. }
  267. return false;
  268. };
  269. Util._getSessionStorageObject = function () {
  270. return Util._getVerifiedStorageObject(StorageType.SessionStorage);
  271. };
  272. Util.canUseSessionStorage = function () {
  273. return !!Util._getSessionStorageObject();
  274. };
  275. Util.getSessionStorageKeys = function () {
  276. var keys = [];
  277. if (Util.canUseSessionStorage()) {
  278. for (var key in window.sessionStorage) {
  279. keys.push(key);
  280. }
  281. }
  282. return keys;
  283. };
  284. Util.getSessionStorage = function (name) {
  285. var storage = Util._getSessionStorageObject();
  286. if (storage !== null) {
  287. try {
  288. return storage.getItem(name);
  289. }
  290. catch (e) {
  291. var message = new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + Util.getExceptionName(e), { exception: Util.dump(e) });
  292. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, message);
  293. }
  294. }
  295. return null;
  296. };
  297. Util.setSessionStorage = function (name, data) {
  298. var storage = Util._getSessionStorageObject();
  299. if (storage !== null) {
  300. try {
  301. storage.setItem(name, data);
  302. return true;
  303. }
  304. catch (e) {
  305. var message = new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + Util.getExceptionName(e), { exception: Util.dump(e) });
  306. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, message);
  307. }
  308. }
  309. return false;
  310. };
  311. Util.removeSessionStorage = function (name) {
  312. var storage = Util._getSessionStorageObject();
  313. if (storage !== null) {
  314. try {
  315. storage.removeItem(name);
  316. return true;
  317. }
  318. catch (e) {
  319. var message = new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_BrowserFailedRemovalFromSessionStorage, "Browser failed removal of session storage item. " + Util.getExceptionName(e), { exception: Util.dump(e) });
  320. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, message);
  321. }
  322. }
  323. return false;
  324. };
  325. Util.setCookie = function (name, value, domain) {
  326. var domainAttrib = "";
  327. if (domain) {
  328. domainAttrib = ";domain=" + domain;
  329. }
  330. Util.document.cookie = name + "=" + value + domainAttrib + ";path=/";
  331. };
  332. Util.stringToBoolOrDefault = function (str) {
  333. if (!str) {
  334. return false;
  335. }
  336. return str.toString().toLowerCase() === "true";
  337. };
  338. Util.getCookie = function (name) {
  339. var value = "";
  340. if (name && name.length) {
  341. var cookieName = name + "=";
  342. var cookies = Util.document.cookie.split(";");
  343. for (var i = 0; i < cookies.length; i++) {
  344. var cookie = cookies[i];
  345. cookie = Util.trim(cookie);
  346. if (cookie && cookie.indexOf(cookieName) === 0) {
  347. value = cookie.substring(cookieName.length, cookies[i].length);
  348. break;
  349. }
  350. }
  351. }
  352. return value;
  353. };
  354. Util.deleteCookie = function (name) {
  355. Util.document.cookie = name + "=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";
  356. };
  357. Util.trim = function (str) {
  358. if (typeof str !== "string")
  359. return str;
  360. return str.replace(/^\s+|\s+$/g, "");
  361. };
  362. Util.newId = function () {
  363. var base64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  364. var result = "";
  365. var random = Math.random() * 1073741824;
  366. while (random > 0) {
  367. var char = base64chars.charAt(random % 64);
  368. result += char;
  369. random = Math.floor(random / 64);
  370. }
  371. return result;
  372. };
  373. Util.isArray = function (obj) {
  374. return Object.prototype.toString.call(obj) === "[object Array]";
  375. };
  376. Util.isError = function (obj) {
  377. return Object.prototype.toString.call(obj) === "[object Error]";
  378. };
  379. Util.isDate = function (obj) {
  380. return Object.prototype.toString.call(obj) === "[object Date]";
  381. };
  382. Util.toISOStringForIE8 = function (date) {
  383. if (Util.isDate(date)) {
  384. if (Date.prototype.toISOString) {
  385. return date.toISOString();
  386. }
  387. else {
  388. function pad(number) {
  389. var r = String(number);
  390. if (r.length === 1) {
  391. r = "0" + r;
  392. }
  393. return r;
  394. }
  395. return date.getUTCFullYear()
  396. + "-" + pad(date.getUTCMonth() + 1)
  397. + "-" + pad(date.getUTCDate())
  398. + "T" + pad(date.getUTCHours())
  399. + ":" + pad(date.getUTCMinutes())
  400. + ":" + pad(date.getUTCSeconds())
  401. + "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
  402. + "Z";
  403. }
  404. }
  405. };
  406. Util.getIEVersion = function (userAgentStr) {
  407. if (userAgentStr === void 0) { userAgentStr = null; }
  408. var myNav = userAgentStr ? userAgentStr.toLowerCase() : navigator.userAgent.toLowerCase();
  409. return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : null;
  410. };
  411. Util.msToTimeSpan = function (totalms) {
  412. if (isNaN(totalms) || totalms < 0) {
  413. totalms = 0;
  414. }
  415. var ms = "" + totalms % 1000;
  416. var sec = "" + Math.floor(totalms / 1000) % 60;
  417. var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
  418. var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
  419. ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
  420. sec = sec.length < 2 ? "0" + sec : sec;
  421. min = min.length < 2 ? "0" + min : min;
  422. hour = hour.length < 2 ? "0" + hour : hour;
  423. return hour + ":" + min + ":" + sec + "." + ms;
  424. };
  425. Util.isCrossOriginError = function (message, url, lineNumber, columnNumber, error) {
  426. return (message === "Script error." || message === "Script error") && error === null;
  427. };
  428. Util.dump = function (object) {
  429. var objectTypeDump = Object.prototype.toString.call(object);
  430. var propertyValueDump = JSON.stringify(object);
  431. if (objectTypeDump === "[object Error]") {
  432. propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
  433. }
  434. return objectTypeDump + propertyValueDump;
  435. };
  436. Util.getExceptionName = function (object) {
  437. var objectTypeDump = Object.prototype.toString.call(object);
  438. if (objectTypeDump === "[object Error]") {
  439. return object.name;
  440. }
  441. return "";
  442. };
  443. Util.addEventHandler = function (eventName, callback) {
  444. if (!window || typeof eventName !== 'string' || typeof callback !== 'function') {
  445. return false;
  446. }
  447. var verbEventName = 'on' + eventName;
  448. if (window.addEventListener) {
  449. window.addEventListener(eventName, callback, false);
  450. }
  451. else if (window["attachEvent"]) {
  452. window["attachEvent"].call(verbEventName, callback);
  453. }
  454. else {
  455. return false;
  456. }
  457. return true;
  458. };
  459. Util.document = typeof document !== "undefined" ? document : {};
  460. Util.NotSpecified = "not_specified";
  461. return Util;
  462. })();
  463. ApplicationInsights.Util = Util;
  464. var UrlHelper = (function () {
  465. function UrlHelper() {
  466. }
  467. UrlHelper.parseUrl = function (url) {
  468. if (!UrlHelper.htmlAnchorElement) {
  469. UrlHelper.htmlAnchorElement = UrlHelper.document.createElement('a');
  470. }
  471. UrlHelper.htmlAnchorElement.href = url;
  472. return UrlHelper.htmlAnchorElement;
  473. };
  474. UrlHelper.getAbsoluteUrl = function (url) {
  475. var result;
  476. var a = UrlHelper.parseUrl(url);
  477. if (a) {
  478. result = a.href;
  479. }
  480. return result;
  481. };
  482. UrlHelper.getPathName = function (url) {
  483. var result;
  484. var a = UrlHelper.parseUrl(url);
  485. if (a) {
  486. result = a.pathname;
  487. }
  488. return result;
  489. };
  490. UrlHelper.document = typeof document !== "undefined" ? document : {};
  491. return UrlHelper;
  492. })();
  493. ApplicationInsights.UrlHelper = UrlHelper;
  494. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  495. })(Microsoft || (Microsoft = {}));
  496. /// <reference path="../logging.ts" />
  497. /// <reference path="../util.ts" />
  498. var Microsoft;
  499. (function (Microsoft) {
  500. var ApplicationInsights;
  501. (function (ApplicationInsights) {
  502. "use strict";
  503. var extensions = (function () {
  504. function extensions() {
  505. }
  506. extensions.IsNullOrUndefined = function (obj) {
  507. return typeof (obj) === "undefined" || obj === null;
  508. };
  509. return extensions;
  510. })();
  511. ApplicationInsights.extensions = extensions;
  512. var stringUtils = (function () {
  513. function stringUtils() {
  514. }
  515. stringUtils.GetLength = function (strObject) {
  516. var res = 0;
  517. if (!extensions.IsNullOrUndefined(strObject)) {
  518. var stringified = "";
  519. try {
  520. stringified = strObject.toString();
  521. }
  522. catch (ex) {
  523. }
  524. res = stringified.length;
  525. res = isNaN(res) ? 0 : res;
  526. }
  527. return res;
  528. };
  529. return stringUtils;
  530. })();
  531. ApplicationInsights.stringUtils = stringUtils;
  532. var dateTime = (function () {
  533. function dateTime() {
  534. }
  535. dateTime.Now = (window.performance && window.performance.now) ?
  536. function () {
  537. return performance.now();
  538. }
  539. :
  540. function () {
  541. return new Date().getTime();
  542. };
  543. dateTime.GetDuration = function (start, end) {
  544. var result = null;
  545. if (start !== 0 && end !== 0 && !extensions.IsNullOrUndefined(start) && !extensions.IsNullOrUndefined(end)) {
  546. result = end - start;
  547. }
  548. return result;
  549. };
  550. return dateTime;
  551. })();
  552. ApplicationInsights.dateTime = dateTime;
  553. var EventHelper = (function () {
  554. function EventHelper() {
  555. }
  556. EventHelper.AttachEvent = function (obj, eventNameWithoutOn, handlerRef) {
  557. var result = false;
  558. if (!extensions.IsNullOrUndefined(obj)) {
  559. if (!extensions.IsNullOrUndefined(obj.attachEvent)) {
  560. obj.attachEvent("on" + eventNameWithoutOn, handlerRef);
  561. result = true;
  562. }
  563. else {
  564. if (!extensions.IsNullOrUndefined(obj.addEventListener)) {
  565. obj.addEventListener(eventNameWithoutOn, handlerRef, false);
  566. result = true;
  567. }
  568. }
  569. }
  570. return result;
  571. };
  572. EventHelper.DetachEvent = function (obj, eventNameWithoutOn, handlerRef) {
  573. if (!extensions.IsNullOrUndefined(obj)) {
  574. if (!extensions.IsNullOrUndefined(obj.detachEvent)) {
  575. obj.detachEvent("on" + eventNameWithoutOn, handlerRef);
  576. }
  577. else {
  578. if (!extensions.IsNullOrUndefined(obj.removeEventListener)) {
  579. obj.removeEventListener(eventNameWithoutOn, handlerRef, false);
  580. }
  581. }
  582. }
  583. };
  584. return EventHelper;
  585. })();
  586. ApplicationInsights.EventHelper = EventHelper;
  587. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  588. })(Microsoft || (Microsoft = {}));
  589. /// <reference path="../logging.ts" />
  590. /// <reference path="../util.ts" />
  591. /// <reference path="./ajaxUtils.ts" />
  592. var Microsoft;
  593. (function (Microsoft) {
  594. var ApplicationInsights;
  595. (function (ApplicationInsights) {
  596. "use strict";
  597. var XHRMonitoringState = (function () {
  598. function XHRMonitoringState() {
  599. this.openDone = false;
  600. this.setRequestHeaderDone = false;
  601. this.sendDone = false;
  602. this.abortDone = false;
  603. this.onreadystatechangeCallbackAttached = false;
  604. }
  605. return XHRMonitoringState;
  606. })();
  607. ApplicationInsights.XHRMonitoringState = XHRMonitoringState;
  608. var ajaxRecord = (function () {
  609. function ajaxRecord(id) {
  610. this.completed = false;
  611. this.requestHeadersSize = null;
  612. this.ttfb = null;
  613. this.responseReceivingDuration = null;
  614. this.callbackDuration = null;
  615. this.ajaxTotalDuration = null;
  616. this.aborted = null;
  617. this.pageUrl = null;
  618. this.requestUrl = null;
  619. this.requestSize = 0;
  620. this.method = null;
  621. this.status = null;
  622. this.requestSentTime = null;
  623. this.responseStartedTime = null;
  624. this.responseFinishedTime = null;
  625. this.callbackFinishedTime = null;
  626. this.endTime = null;
  627. this.originalOnreadystatechage = null;
  628. this.xhrMonitoringState = new XHRMonitoringState();
  629. this.clientFailure = 0;
  630. this.CalculateMetrics = function () {
  631. var self = this;
  632. self.ajaxTotalDuration = ApplicationInsights.dateTime.GetDuration(self.requestSentTime, self.responseFinishedTime);
  633. };
  634. this.id = id;
  635. }
  636. ajaxRecord.prototype.getAbsoluteUrl = function () {
  637. return this.requestUrl ? ApplicationInsights.UrlHelper.getAbsoluteUrl(this.requestUrl) : null;
  638. };
  639. ajaxRecord.prototype.getPathName = function () {
  640. return this.requestUrl ? ApplicationInsights.UrlHelper.getPathName(this.requestUrl) : null;
  641. };
  642. return ajaxRecord;
  643. })();
  644. ApplicationInsights.ajaxRecord = ajaxRecord;
  645. ;
  646. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  647. })(Microsoft || (Microsoft = {}));
  648. ;
  649. /// <reference path="../logging.ts" />
  650. /// <reference path="../util.ts" />
  651. /// <reference path="./ajaxUtils.ts" />
  652. /// <reference path="./ajaxRecord.ts" />
  653. var Microsoft;
  654. (function (Microsoft) {
  655. var ApplicationInsights;
  656. (function (ApplicationInsights) {
  657. "use strict";
  658. var AjaxMonitor = (function () {
  659. function AjaxMonitor(appInsights) {
  660. this.currentWindowHost = window.location.host;
  661. this.appInsights = appInsights;
  662. this.initialized = false;
  663. this.Init();
  664. }
  665. AjaxMonitor.prototype.Init = function () {
  666. if (this.supportsMonitoring()) {
  667. this.instrumentOpen();
  668. this.instrumentSend();
  669. this.instrumentAbort();
  670. this.initialized = true;
  671. }
  672. };
  673. AjaxMonitor.prototype.isMonitoredInstance = function (xhr, excludeAjaxDataValidation) {
  674. return this.initialized
  675. && (excludeAjaxDataValidation === true || !ApplicationInsights.extensions.IsNullOrUndefined(xhr.ajaxData))
  676. && xhr[AjaxMonitor.DisabledPropertyName] !== true;
  677. };
  678. AjaxMonitor.prototype.supportsMonitoring = function () {
  679. var result = false;
  680. if (!ApplicationInsights.extensions.IsNullOrUndefined(XMLHttpRequest)) {
  681. result = true;
  682. }
  683. return result;
  684. };
  685. AjaxMonitor.prototype.instrumentOpen = function () {
  686. var originalOpen = XMLHttpRequest.prototype.open;
  687. var ajaxMonitorInstance = this;
  688. XMLHttpRequest.prototype.open = function (method, url, async) {
  689. try {
  690. if (ajaxMonitorInstance.isMonitoredInstance(this, true) &&
  691. (!this.ajaxData ||
  692. !this.ajaxData.xhrMonitoringState.openDone)) {
  693. ajaxMonitorInstance.openHandler(this, method, url, async);
  694. }
  695. }
  696. catch (e) {
  697. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedMonitorAjaxOpen, "Failed to monitor XMLHttpRequest.open, monitoring data for this ajax call may be incorrect.", {
  698. ajaxDiagnosticsMessage: AjaxMonitor.getFailedAjaxDiagnosticsMessage(this),
  699. exception: Microsoft.ApplicationInsights.Util.dump(e)
  700. }));
  701. }
  702. return originalOpen.apply(this, arguments);
  703. };
  704. };
  705. AjaxMonitor.prototype.openHandler = function (xhr, method, url, async) {
  706. var ajaxData = new ApplicationInsights.ajaxRecord(ApplicationInsights.Util.newId());
  707. ajaxData.method = method;
  708. ajaxData.requestUrl = url;
  709. ajaxData.xhrMonitoringState.openDone = true;
  710. xhr.ajaxData = ajaxData;
  711. this.attachToOnReadyStateChange(xhr);
  712. };
  713. AjaxMonitor.getFailedAjaxDiagnosticsMessage = function (xhr) {
  714. var result = "";
  715. try {
  716. if (!ApplicationInsights.extensions.IsNullOrUndefined(xhr) &&
  717. !ApplicationInsights.extensions.IsNullOrUndefined(xhr.ajaxData) &&
  718. !ApplicationInsights.extensions.IsNullOrUndefined(xhr.ajaxData.requestUrl)) {
  719. result += "(url: '" + xhr.ajaxData.requestUrl + "')";
  720. }
  721. }
  722. catch (e) { }
  723. return result;
  724. };
  725. AjaxMonitor.prototype.instrumentSend = function () {
  726. var originalSend = XMLHttpRequest.prototype.send;
  727. var ajaxMonitorInstance = this;
  728. XMLHttpRequest.prototype.send = function (content) {
  729. try {
  730. if (ajaxMonitorInstance.isMonitoredInstance(this) && !this.ajaxData.xhrMonitoringState.sendDone) {
  731. ajaxMonitorInstance.sendHandler(this, content);
  732. }
  733. }
  734. catch (e) {
  735. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedMonitorAjaxSend, "Failed to monitor XMLHttpRequest, monitoring data for this ajax call may be incorrect.", {
  736. ajaxDiagnosticsMessage: AjaxMonitor.getFailedAjaxDiagnosticsMessage(this),
  737. exception: Microsoft.ApplicationInsights.Util.dump(e)
  738. }));
  739. }
  740. return originalSend.apply(this, arguments);
  741. };
  742. };
  743. AjaxMonitor.prototype.sendHandler = function (xhr, content) {
  744. xhr.ajaxData.requestSentTime = ApplicationInsights.dateTime.Now();
  745. if (!this.appInsights.config.disableCorrelationHeaders && (ApplicationInsights.UrlHelper.parseUrl(xhr.ajaxData.getAbsoluteUrl()).host == this.currentWindowHost)) {
  746. xhr.setRequestHeader("x-ms-request-id", xhr.ajaxData.id);
  747. }
  748. xhr.ajaxData.xhrMonitoringState.sendDone = true;
  749. };
  750. AjaxMonitor.prototype.instrumentAbort = function () {
  751. var originalAbort = XMLHttpRequest.prototype.abort;
  752. var ajaxMonitorInstance = this;
  753. XMLHttpRequest.prototype.abort = function () {
  754. try {
  755. if (ajaxMonitorInstance.isMonitoredInstance(this) && !this.ajaxData.xhrMonitoringState.abortDone) {
  756. this.ajaxData.aborted = 1;
  757. this.ajaxData.xhrMonitoringState.abortDone = true;
  758. }
  759. }
  760. catch (e) {
  761. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedMonitorAjaxAbort, "Failed to monitor XMLHttpRequest.abort, monitoring data for this ajax call may be incorrect.", {
  762. ajaxDiagnosticsMessage: AjaxMonitor.getFailedAjaxDiagnosticsMessage(this),
  763. exception: Microsoft.ApplicationInsights.Util.dump(e)
  764. }));
  765. }
  766. return originalAbort.apply(this, arguments);
  767. };
  768. };
  769. AjaxMonitor.prototype.attachToOnReadyStateChange = function (xhr) {
  770. var ajaxMonitorInstance = this;
  771. xhr.ajaxData.xhrMonitoringState.onreadystatechangeCallbackAttached = ApplicationInsights.EventHelper.AttachEvent(xhr, "readystatechange", function () {
  772. try {
  773. if (ajaxMonitorInstance.isMonitoredInstance(xhr)) {
  774. if (xhr.readyState === 4) {
  775. ajaxMonitorInstance.onAjaxComplete(xhr);
  776. }
  777. }
  778. }
  779. catch (e) {
  780. var exceptionText = Microsoft.ApplicationInsights.Util.dump(e);
  781. if (!exceptionText || exceptionText.toLowerCase().indexOf("c00c023f") == -1) {
  782. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedMonitorAjaxRSC, "Failed to monitor XMLHttpRequest 'readystatechange' event handler, monitoring data for this ajax call may be incorrect.", {
  783. ajaxDiagnosticsMessage: AjaxMonitor.getFailedAjaxDiagnosticsMessage(xhr),
  784. exception: Microsoft.ApplicationInsights.Util.dump(e)
  785. }));
  786. }
  787. }
  788. });
  789. };
  790. AjaxMonitor.prototype.onAjaxComplete = function (xhr) {
  791. xhr.ajaxData.responseFinishedTime = ApplicationInsights.dateTime.Now();
  792. xhr.ajaxData.status = xhr.status;
  793. xhr.ajaxData.CalculateMetrics();
  794. if (xhr.ajaxData.ajaxTotalDuration < 0) {
  795. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedMonitorAjaxDur, "Failed to calculate the duration of the ajax call, monitoring data for this ajax call won't be sent.", {
  796. ajaxDiagnosticsMessage: AjaxMonitor.getFailedAjaxDiagnosticsMessage(xhr),
  797. requestSentTime: xhr.ajaxData.requestSentTime,
  798. responseFinishedTime: xhr.ajaxData.responseFinishedTime
  799. }));
  800. }
  801. else {
  802. this.appInsights.trackAjax(xhr.ajaxData.id, xhr.ajaxData.getAbsoluteUrl(), xhr.ajaxData.getPathName(), xhr.ajaxData.ajaxTotalDuration, (+(xhr.ajaxData.status)) >= 200 && (+(xhr.ajaxData.status)) < 400, +xhr.ajaxData.status);
  803. xhr.ajaxData = null;
  804. }
  805. };
  806. AjaxMonitor.instrumentedByAppInsightsName = "InstrumentedByAppInsights";
  807. AjaxMonitor.DisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
  808. return AjaxMonitor;
  809. })();
  810. ApplicationInsights.AjaxMonitor = AjaxMonitor;
  811. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  812. })(Microsoft || (Microsoft = {}));
  813. var Microsoft;
  814. (function (Microsoft) {
  815. var ApplicationInsights;
  816. (function (ApplicationInsights) {
  817. var HashCodeScoreGenerator = (function () {
  818. function HashCodeScoreGenerator() {
  819. }
  820. HashCodeScoreGenerator.prototype.getHashCodeScore = function (key) {
  821. var score = this.getHashCode(key) / HashCodeScoreGenerator.INT_MAX_VALUE;
  822. return score * 100;
  823. };
  824. HashCodeScoreGenerator.prototype.getHashCode = function (input) {
  825. if (input == "") {
  826. return 0;
  827. }
  828. while (input.length < HashCodeScoreGenerator.MIN_INPUT_LENGTH) {
  829. input = input.concat(input);
  830. }
  831. var hash = 5381;
  832. for (var i = 0; i < input.length; ++i) {
  833. hash = ((hash << 5) + hash) + input.charCodeAt(i);
  834. hash = hash & hash;
  835. }
  836. return Math.abs(hash);
  837. };
  838. HashCodeScoreGenerator.INT_MAX_VALUE = 2147483647;
  839. HashCodeScoreGenerator.MIN_INPUT_LENGTH = 8;
  840. return HashCodeScoreGenerator;
  841. })();
  842. ApplicationInsights.HashCodeScoreGenerator = HashCodeScoreGenerator;
  843. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  844. })(Microsoft || (Microsoft = {}));
  845. /// <reference path="logging.ts" />
  846. /// <reference path="util.ts" />
  847. var Microsoft;
  848. (function (Microsoft) {
  849. var ApplicationInsights;
  850. (function (ApplicationInsights) {
  851. "use strict";
  852. (function (FieldType) {
  853. FieldType[FieldType["Default"] = 0] = "Default";
  854. FieldType[FieldType["Required"] = 1] = "Required";
  855. FieldType[FieldType["Array"] = 2] = "Array";
  856. FieldType[FieldType["Hidden"] = 4] = "Hidden";
  857. })(ApplicationInsights.FieldType || (ApplicationInsights.FieldType = {}));
  858. var FieldType = ApplicationInsights.FieldType;
  859. ;
  860. var Serializer = (function () {
  861. function Serializer() {
  862. }
  863. Serializer.serialize = function (input) {
  864. var output = Serializer._serializeObject(input, "root");
  865. return JSON.stringify(output);
  866. };
  867. Serializer._serializeObject = function (source, name) {
  868. var circularReferenceCheck = "__aiCircularRefCheck";
  869. var output = {};
  870. if (!source) {
  871. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_CannotSerializeObject, "cannot serialize object because it is null or undefined", { name: name }));
  872. return output;
  873. }
  874. if (source[circularReferenceCheck]) {
  875. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_CircularReferenceDetected, "Circular reference detected while serializing object", { name: name }));
  876. return output;
  877. }
  878. if (!source.aiDataContract) {
  879. if (name === "measurements") {
  880. output = Serializer._serializeStringMap(source, "number", name);
  881. }
  882. else if (name === "properties") {
  883. output = Serializer._serializeStringMap(source, "string", name);
  884. }
  885. else if (name === "tags") {
  886. output = Serializer._serializeStringMap(source, "string", name);
  887. }
  888. else if (ApplicationInsights.Util.isArray(source)) {
  889. output = Serializer._serializeArray(source, name);
  890. }
  891. else {
  892. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_CannotSerializeObjectNonSerializable, "Attempting to serialize an object which does not implement ISerializable", { name: name }));
  893. try {
  894. JSON.stringify(source);
  895. output = source;
  896. }
  897. catch (e) {
  898. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, e && typeof e.toString === 'function' ? e.toString() : "Error serializing object");
  899. }
  900. }
  901. return output;
  902. }
  903. source[circularReferenceCheck] = true;
  904. for (var field in source.aiDataContract) {
  905. var contract = source.aiDataContract[field];
  906. var isRequired = (typeof contract === "function") ? (contract() & FieldType.Required) : (contract & FieldType.Required);
  907. var isHidden = (typeof contract === "function") ? (contract() & FieldType.Hidden) : (contract & FieldType.Hidden);
  908. var isArray = contract & FieldType.Array;
  909. var isPresent = source[field] !== undefined;
  910. var isObject = typeof source[field] === "object" && source[field] !== null;
  911. if (isRequired && !isPresent && !isArray) {
  912. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_MissingRequiredFieldSpecification, "Missing required field specification. The field is required but not present on source", { field: field, name: name }));
  913. continue;
  914. }
  915. if (isHidden) {
  916. continue;
  917. }
  918. var value;
  919. if (isObject) {
  920. if (isArray) {
  921. value = Serializer._serializeArray(source[field], field);
  922. }
  923. else {
  924. value = Serializer._serializeObject(source[field], field);
  925. }
  926. }
  927. else {
  928. value = source[field];
  929. }
  930. if (value !== undefined) {
  931. output[field] = value;
  932. }
  933. }
  934. delete source[circularReferenceCheck];
  935. return output;
  936. };
  937. Serializer._serializeArray = function (sources, name) {
  938. var output = undefined;
  939. if (!!sources) {
  940. if (!ApplicationInsights.Util.isArray(sources)) {
  941. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_ItemNotInArray, "This field was specified as an array in the contract but the item is not an array.\r\n", { name: name }));
  942. }
  943. else {
  944. output = [];
  945. for (var i = 0; i < sources.length; i++) {
  946. var source = sources[i];
  947. var item = Serializer._serializeObject(source, name + "[" + i + "]");
  948. output.push(item);
  949. }
  950. }
  951. }
  952. return output;
  953. };
  954. Serializer._serializeStringMap = function (map, expectedType, name) {
  955. var output = undefined;
  956. if (map) {
  957. output = {};
  958. for (var field in map) {
  959. var value = map[field];
  960. if (expectedType === "string") {
  961. if (value === undefined) {
  962. output[field] = "undefined";
  963. }
  964. else if (value === null) {
  965. output[field] = "null";
  966. }
  967. else if (!value.toString) {
  968. output[field] = "invalid field: toString() is not defined.";
  969. }
  970. else {
  971. output[field] = value.toString();
  972. }
  973. }
  974. else if (expectedType === "number") {
  975. if (value === undefined) {
  976. output[field] = "undefined";
  977. }
  978. else if (value === null) {
  979. output[field] = "null";
  980. }
  981. else {
  982. var num = parseFloat(value);
  983. if (isNaN(num)) {
  984. output[field] = "NaN";
  985. }
  986. else {
  987. output[field] = num;
  988. }
  989. }
  990. }
  991. else {
  992. output[field] = "invalid field: " + name + " is of unknown type.";
  993. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, output[field]);
  994. }
  995. }
  996. }
  997. return output;
  998. };
  999. return Serializer;
  1000. })();
  1001. ApplicationInsights.Serializer = Serializer;
  1002. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1003. })(Microsoft || (Microsoft = {}));
  1004. var Microsoft;
  1005. (function (Microsoft) {
  1006. var Telemetry;
  1007. (function (Telemetry) {
  1008. "use strict";
  1009. var Base = (function () {
  1010. function Base() {
  1011. }
  1012. return Base;
  1013. })();
  1014. Telemetry.Base = Base;
  1015. })(Telemetry = Microsoft.Telemetry || (Microsoft.Telemetry = {}));
  1016. })(Microsoft || (Microsoft = {}));
  1017. /// <reference path="Base.ts" />
  1018. var Microsoft;
  1019. (function (Microsoft) {
  1020. var Telemetry;
  1021. (function (Telemetry) {
  1022. "use strict";
  1023. var Envelope = (function () {
  1024. function Envelope() {
  1025. this.ver = 1;
  1026. this.sampleRate = 100.0;
  1027. this.tags = {};
  1028. }
  1029. return Envelope;
  1030. })();
  1031. Telemetry.Envelope = Envelope;
  1032. })(Telemetry = Microsoft.Telemetry || (Microsoft.Telemetry = {}));
  1033. })(Microsoft || (Microsoft = {}));
  1034. /// <reference path="../../Contracts/Generated/Envelope.ts" />
  1035. /// <reference path="../../Contracts/Generated/Base.ts" />
  1036. /// <reference path="../../Util.ts"/>
  1037. var __extends = (this && this.__extends) || function (d, b) {
  1038. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1039. function __() { this.constructor = d; }
  1040. __.prototype = b.prototype;
  1041. d.prototype = new __();
  1042. };
  1043. var Microsoft;
  1044. (function (Microsoft) {
  1045. var ApplicationInsights;
  1046. (function (ApplicationInsights) {
  1047. var Telemetry;
  1048. (function (Telemetry) {
  1049. var Common;
  1050. (function (Common) {
  1051. "use strict";
  1052. var Envelope = (function (_super) {
  1053. __extends(Envelope, _super);
  1054. function Envelope(data, name) {
  1055. var _this = this;
  1056. _super.call(this);
  1057. this.name = name;
  1058. this.data = data;
  1059. this.time = ApplicationInsights.Util.toISOStringForIE8(new Date());
  1060. this.aiDataContract = {
  1061. time: ApplicationInsights.FieldType.Required,
  1062. iKey: ApplicationInsights.FieldType.Required,
  1063. name: ApplicationInsights.FieldType.Required,
  1064. sampleRate: function () {
  1065. return (_this.sampleRate == 100) ? ApplicationInsights.FieldType.Hidden : ApplicationInsights.FieldType.Required;
  1066. },
  1067. tags: ApplicationInsights.FieldType.Required,
  1068. data: ApplicationInsights.FieldType.Required
  1069. };
  1070. }
  1071. return Envelope;
  1072. })(Microsoft.Telemetry.Envelope);
  1073. Common.Envelope = Envelope;
  1074. })(Common = Telemetry.Common || (Telemetry.Common = {}));
  1075. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  1076. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1077. })(Microsoft || (Microsoft = {}));
  1078. /// <reference path="../../Contracts/Generated/Base.ts"/>
  1079. var Microsoft;
  1080. (function (Microsoft) {
  1081. var ApplicationInsights;
  1082. (function (ApplicationInsights) {
  1083. var Telemetry;
  1084. (function (Telemetry) {
  1085. var Common;
  1086. (function (Common) {
  1087. "use strict";
  1088. var Base = (function (_super) {
  1089. __extends(Base, _super);
  1090. function Base() {
  1091. _super.apply(this, arguments);
  1092. this.aiDataContract = {};
  1093. }
  1094. return Base;
  1095. })(Microsoft.Telemetry.Base);
  1096. Common.Base = Base;
  1097. })(Common = Telemetry.Common || (Telemetry.Common = {}));
  1098. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  1099. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1100. })(Microsoft || (Microsoft = {}));
  1101. var AI;
  1102. (function (AI) {
  1103. "use strict";
  1104. var ContextTagKeys = (function () {
  1105. function ContextTagKeys() {
  1106. this.applicationVersion = "ai.application.ver";
  1107. this.applicationBuild = "ai.application.build";
  1108. this.applicationTypeId = "ai.application.typeId";
  1109. this.applicationId = "ai.application.applicationId";
  1110. this.deviceId = "ai.device.id";
  1111. this.deviceIp = "ai.device.ip";
  1112. this.deviceLanguage = "ai.device.language";
  1113. this.deviceLocale = "ai.device.locale";
  1114. this.deviceModel = "ai.device.model";
  1115. this.deviceNetwork = "ai.device.network";
  1116. this.deviceNetworkName = "ai.device.networkName";
  1117. this.deviceOEMName = "ai.device.oemName";
  1118. this.deviceOS = "ai.device.os";
  1119. this.deviceOSVersion = "ai.device.osVersion";
  1120. this.deviceRoleInstance = "ai.device.roleInstance";
  1121. this.deviceRoleName = "ai.device.roleName";
  1122. this.deviceScreenResolution = "ai.device.screenResolution";
  1123. this.deviceType = "ai.device.type";
  1124. this.deviceMachineName = "ai.device.machineName";
  1125. this.deviceVMName = "ai.device.vmName";
  1126. this.locationIp = "ai.location.ip";
  1127. this.operationId = "ai.operation.id";
  1128. this.operationName = "ai.operation.name";
  1129. this.operationParentId = "ai.operation.parentId";
  1130. this.operationRootId = "ai.operation.rootId";
  1131. this.operationSyntheticSource = "ai.operation.syntheticSource";
  1132. this.operationIsSynthetic = "ai.operation.isSynthetic";
  1133. this.operationCorrelationVector = "ai.operation.correlationVector";
  1134. this.sessionId = "ai.session.id";
  1135. this.sessionIsFirst = "ai.session.isFirst";
  1136. this.sessionIsNew = "ai.session.isNew";
  1137. this.userAccountAcquisitionDate = "ai.user.accountAcquisitionDate";
  1138. this.userAccountId = "ai.user.accountId";
  1139. this.userAgent = "ai.user.userAgent";
  1140. this.userId = "ai.user.id";
  1141. this.userStoreRegion = "ai.user.storeRegion";
  1142. this.userAuthUserId = "ai.user.authUserId";
  1143. this.userAnonymousUserAcquisitionDate = "ai.user.anonUserAcquisitionDate";
  1144. this.userAuthenticatedUserAcquisitionDate = "ai.user.authUserAcquisitionDate";
  1145. this.sampleRate = "ai.sample.sampleRate";
  1146. this.cloudName = "ai.cloud.name";
  1147. this.cloudRoleVer = "ai.cloud.roleVer";
  1148. this.cloudEnvironment = "ai.cloud.environment";
  1149. this.cloudLocation = "ai.cloud.location";
  1150. this.cloudDeploymentUnit = "ai.cloud.deploymentUnit";
  1151. this.serverDeviceOS = "ai.serverDevice.os";
  1152. this.serverDeviceOSVer = "ai.serverDevice.osVer";
  1153. this.internalSdkVersion = "ai.internal.sdkVersion";
  1154. this.internalAgentVersion = "ai.internal.agentVersion";
  1155. this.internalDataCollectorReceivedTime = "ai.internal.dataCollectorReceivedTime";
  1156. this.internalProfileId = "ai.internal.profileId";
  1157. this.internalProfileClassId = "ai.internal.profileClassId";
  1158. this.internalAccountId = "ai.internal.accountId";
  1159. this.internalApplicationName = "ai.internal.applicationName";
  1160. this.internalInstrumentationKey = "ai.internal.instrumentationKey";
  1161. this.internalTelemetryItemId = "ai.internal.telemetryItemId";
  1162. this.internalApplicationType = "ai.internal.applicationType";
  1163. this.internalRequestSource = "ai.internal.requestSource";
  1164. this.internalFlowType = "ai.internal.flowType";
  1165. this.internalIsAudit = "ai.internal.isAudit";
  1166. this.internalTrackingSourceId = "ai.internal.trackingSourceId";
  1167. this.internalTrackingType = "ai.internal.trackingType";
  1168. this.internalIsDiagnosticExample = "ai.internal.isDiagnosticExample";
  1169. }
  1170. return ContextTagKeys;
  1171. })();
  1172. AI.ContextTagKeys = ContextTagKeys;
  1173. })(AI || (AI = {}));
  1174. var Microsoft;
  1175. (function (Microsoft) {
  1176. var ApplicationInsights;
  1177. (function (ApplicationInsights) {
  1178. var Context;
  1179. (function (Context) {
  1180. "use strict";
  1181. var Application = (function () {
  1182. function Application() {
  1183. }
  1184. return Application;
  1185. })();
  1186. Context.Application = Application;
  1187. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1188. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1189. })(Microsoft || (Microsoft = {}));
  1190. var Microsoft;
  1191. (function (Microsoft) {
  1192. var ApplicationInsights;
  1193. (function (ApplicationInsights) {
  1194. var Context;
  1195. (function (Context) {
  1196. "use strict";
  1197. var Device = (function () {
  1198. function Device() {
  1199. this.id = "browser";
  1200. this.type = "Browser";
  1201. }
  1202. return Device;
  1203. })();
  1204. Context.Device = Device;
  1205. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1206. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1207. })(Microsoft || (Microsoft = {}));
  1208. var Microsoft;
  1209. (function (Microsoft) {
  1210. var ApplicationInsights;
  1211. (function (ApplicationInsights) {
  1212. var Context;
  1213. (function (Context) {
  1214. "use strict";
  1215. var Internal = (function () {
  1216. function Internal() {
  1217. this.sdkVersion = "JavaScript:" + ApplicationInsights.Version;
  1218. }
  1219. return Internal;
  1220. })();
  1221. Context.Internal = Internal;
  1222. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1223. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1224. })(Microsoft || (Microsoft = {}));
  1225. var Microsoft;
  1226. (function (Microsoft) {
  1227. var ApplicationInsights;
  1228. (function (ApplicationInsights) {
  1229. var Context;
  1230. (function (Context) {
  1231. "use strict";
  1232. var Location = (function () {
  1233. function Location() {
  1234. }
  1235. return Location;
  1236. })();
  1237. Context.Location = Location;
  1238. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1239. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1240. })(Microsoft || (Microsoft = {}));
  1241. /// <reference path="../util.ts" />
  1242. var Microsoft;
  1243. (function (Microsoft) {
  1244. var ApplicationInsights;
  1245. (function (ApplicationInsights) {
  1246. var Context;
  1247. (function (Context) {
  1248. "use strict";
  1249. var Operation = (function () {
  1250. function Operation() {
  1251. this.id = ApplicationInsights.Util.newId();
  1252. if (window && window.location && window.location.pathname) {
  1253. this.name = window.location.pathname;
  1254. }
  1255. }
  1256. return Operation;
  1257. })();
  1258. Context.Operation = Operation;
  1259. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1260. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1261. })(Microsoft || (Microsoft = {}));
  1262. /// <reference path="./HashCodeScoreGenerator.ts" />
  1263. var Microsoft;
  1264. (function (Microsoft) {
  1265. var ApplicationInsights;
  1266. (function (ApplicationInsights) {
  1267. var SamplingScoreGenerator = (function () {
  1268. function SamplingScoreGenerator() {
  1269. this.hashCodeGeneragor = new ApplicationInsights.HashCodeScoreGenerator();
  1270. }
  1271. SamplingScoreGenerator.prototype.getSamplingScore = function (envelope) {
  1272. var tagKeys = new AI.ContextTagKeys();
  1273. var score = 0;
  1274. if (envelope.tags[tagKeys.userId]) {
  1275. score = this.hashCodeGeneragor.getHashCodeScore(envelope.tags[tagKeys.userId]);
  1276. }
  1277. else if (envelope.tags[tagKeys.operationId]) {
  1278. score = this.hashCodeGeneragor.getHashCodeScore(envelope.tags[tagKeys.operationId]);
  1279. }
  1280. else {
  1281. score = Math.random();
  1282. }
  1283. return score;
  1284. };
  1285. return SamplingScoreGenerator;
  1286. })();
  1287. ApplicationInsights.SamplingScoreGenerator = SamplingScoreGenerator;
  1288. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1289. })(Microsoft || (Microsoft = {}));
  1290. /// <reference path="../SamplingScoreGenerator.ts" />
  1291. var Microsoft;
  1292. (function (Microsoft) {
  1293. var ApplicationInsights;
  1294. (function (ApplicationInsights) {
  1295. var Context;
  1296. (function (Context) {
  1297. "use strict";
  1298. var Sample = (function () {
  1299. function Sample(sampleRate) {
  1300. this.INT_MAX_VALUE = 2147483647;
  1301. if (sampleRate > 100 || sampleRate < 0) {
  1302. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_SampleRateOutOfRange, "Sampling rate is out of range (0..100). Sampling will be disabled, you may be sending too much data which may affect your AI service level.", { samplingRate: sampleRate }));
  1303. this.sampleRate = 100;
  1304. }
  1305. this.sampleRate = sampleRate;
  1306. this.samplingScoreGenerator = new ApplicationInsights.SamplingScoreGenerator();
  1307. }
  1308. Sample.prototype.isSampledIn = function (envelope) {
  1309. if (this.sampleRate == 100)
  1310. return true;
  1311. var score = this.samplingScoreGenerator.getSamplingScore(envelope);
  1312. return score < this.sampleRate;
  1313. };
  1314. return Sample;
  1315. })();
  1316. Context.Sample = Sample;
  1317. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1318. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1319. })(Microsoft || (Microsoft = {}));
  1320. var AI;
  1321. (function (AI) {
  1322. "use strict";
  1323. (function (SessionState) {
  1324. SessionState[SessionState["Start"] = 0] = "Start";
  1325. SessionState[SessionState["End"] = 1] = "End";
  1326. })(AI.SessionState || (AI.SessionState = {}));
  1327. var SessionState = AI.SessionState;
  1328. })(AI || (AI = {}));
  1329. /// <reference path="../util.ts" />
  1330. /// <reference path="../Contracts/Generated/SessionState.ts"/>
  1331. var Microsoft;
  1332. (function (Microsoft) {
  1333. var ApplicationInsights;
  1334. (function (ApplicationInsights) {
  1335. var Context;
  1336. (function (Context) {
  1337. "use strict";
  1338. var Session = (function () {
  1339. function Session() {
  1340. }
  1341. return Session;
  1342. })();
  1343. Context.Session = Session;
  1344. var _SessionManager = (function () {
  1345. function _SessionManager(config) {
  1346. if (!config) {
  1347. config = {};
  1348. }
  1349. if (!(typeof config.sessionExpirationMs === "function")) {
  1350. config.sessionExpirationMs = function () { return _SessionManager.acquisitionSpan; };
  1351. }
  1352. if (!(typeof config.sessionRenewalMs === "function")) {
  1353. config.sessionRenewalMs = function () { return _SessionManager.renewalSpan; };
  1354. }
  1355. this.config = config;
  1356. this.automaticSession = new Session();
  1357. }
  1358. _SessionManager.prototype.update = function () {
  1359. if (!this.automaticSession.id) {
  1360. this.initializeAutomaticSession();
  1361. }
  1362. var now = +new Date;
  1363. var acquisitionExpired = now - this.automaticSession.acquisitionDate > this.config.sessionExpirationMs();
  1364. var renewalExpired = now - this.automaticSession.renewalDate > this.config.sessionRenewalMs();
  1365. if (acquisitionExpired || renewalExpired) {
  1366. this.automaticSession.isFirst = undefined;
  1367. this.renew();
  1368. }
  1369. else {
  1370. this.automaticSession.renewalDate = +new Date;
  1371. this.setCookie(this.automaticSession.id, this.automaticSession.acquisitionDate, this.automaticSession.renewalDate);
  1372. }
  1373. };
  1374. _SessionManager.prototype.backup = function () {
  1375. this.setStorage(this.automaticSession.id, this.automaticSession.acquisitionDate, this.automaticSession.renewalDate);
  1376. };
  1377. _SessionManager.prototype.initializeAutomaticSession = function () {
  1378. var cookie = ApplicationInsights.Util.getCookie('ai_session');
  1379. if (cookie && typeof cookie.split === "function") {
  1380. this.initializeAutomaticSessionWithData(cookie);
  1381. }
  1382. else {
  1383. var storage = ApplicationInsights.Util.getStorage('ai_session');
  1384. if (storage) {
  1385. this.initializeAutomaticSessionWithData(storage);
  1386. }
  1387. }
  1388. if (!this.automaticSession.id) {
  1389. this.automaticSession.isFirst = true;
  1390. this.renew();
  1391. }
  1392. };
  1393. _SessionManager.prototype.initializeAutomaticSessionWithData = function (sessionData) {
  1394. var params = sessionData.split("|");
  1395. if (params.length > 0) {
  1396. this.automaticSession.id = params[0];
  1397. }
  1398. try {
  1399. if (params.length > 1) {
  1400. var acq = +params[1];
  1401. this.automaticSession.acquisitionDate = +new Date(acq);
  1402. this.automaticSession.acquisitionDate = this.automaticSession.acquisitionDate > 0 ? this.automaticSession.acquisitionDate : 0;
  1403. }
  1404. if (params.length > 2) {
  1405. var renewal = +params[2];
  1406. this.automaticSession.renewalDate = +new Date(renewal);
  1407. this.automaticSession.renewalDate = this.automaticSession.renewalDate > 0 ? this.automaticSession.renewalDate : 0;
  1408. }
  1409. }
  1410. catch (e) {
  1411. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_ErrorParsingAISessionCookie, "Error parsing ai_session cookie, session will be reset: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  1412. }
  1413. if (this.automaticSession.renewalDate == 0) {
  1414. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_SessionRenewalDateIsZero, "AI session renewal date is 0, session will be reset."));
  1415. }
  1416. };
  1417. _SessionManager.prototype.renew = function () {
  1418. var now = +new Date;
  1419. this.automaticSession.id = ApplicationInsights.Util.newId();
  1420. this.automaticSession.acquisitionDate = now;
  1421. this.automaticSession.renewalDate = now;
  1422. this.setCookie(this.automaticSession.id, this.automaticSession.acquisitionDate, this.automaticSession.renewalDate);
  1423. if (!ApplicationInsights.Util.canUseLocalStorage()) {
  1424. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_BrowserDoesNotSupportLocalStorage, "Browser does not support local storage. Session durations will be inaccurate."));
  1425. }
  1426. };
  1427. _SessionManager.prototype.setCookie = function (guid, acq, renewal) {
  1428. var acquisitionExpiry = acq + this.config.sessionExpirationMs();
  1429. var renewalExpiry = renewal + this.config.sessionRenewalMs();
  1430. var cookieExpiry = new Date();
  1431. var cookie = [guid, acq, renewal];
  1432. if (acquisitionExpiry < renewalExpiry) {
  1433. cookieExpiry.setTime(acquisitionExpiry);
  1434. }
  1435. else {
  1436. cookieExpiry.setTime(renewalExpiry);
  1437. }
  1438. var cookieDomnain = this.config.cookieDomain ? this.config.cookieDomain() : null;
  1439. ApplicationInsights.Util.setCookie('ai_session', cookie.join('|') + ';expires=' + cookieExpiry.toUTCString(), cookieDomnain);
  1440. };
  1441. _SessionManager.prototype.setStorage = function (guid, acq, renewal) {
  1442. ApplicationInsights.Util.setStorage('ai_session', [guid, acq, renewal].join('|'));
  1443. };
  1444. _SessionManager.acquisitionSpan = 86400000;
  1445. _SessionManager.renewalSpan = 1800000;
  1446. return _SessionManager;
  1447. })();
  1448. Context._SessionManager = _SessionManager;
  1449. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1450. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1451. })(Microsoft || (Microsoft = {}));
  1452. /// <reference path="../util.ts" />
  1453. var Microsoft;
  1454. (function (Microsoft) {
  1455. var ApplicationInsights;
  1456. (function (ApplicationInsights) {
  1457. var Context;
  1458. (function (Context) {
  1459. "use strict";
  1460. var User = (function () {
  1461. function User(config) {
  1462. var cookie = ApplicationInsights.Util.getCookie(User.userCookieName);
  1463. if (cookie) {
  1464. var params = cookie.split(User.cookieSeparator);
  1465. if (params.length > 0) {
  1466. this.id = params[0];
  1467. }
  1468. }
  1469. this.config = config;
  1470. if (!this.id) {
  1471. this.id = ApplicationInsights.Util.newId();
  1472. var date = new Date();
  1473. var acqStr = ApplicationInsights.Util.toISOStringForIE8(date);
  1474. this.accountAcquisitionDate = acqStr;
  1475. date.setTime(date.getTime() + 31536000000);
  1476. var newCookie = [this.id, acqStr];
  1477. var cookieDomain = this.config.cookieDomain ? this.config.cookieDomain() : undefined;
  1478. ApplicationInsights.Util.setCookie(User.userCookieName, newCookie.join(User.cookieSeparator) + ';expires=' + date.toUTCString(), cookieDomain);
  1479. ApplicationInsights.Util.removeStorage('ai_session');
  1480. }
  1481. this.accountId = config.accountId ? config.accountId() : undefined;
  1482. var authCookie = ApplicationInsights.Util.getCookie(User.authUserCookieName);
  1483. if (authCookie) {
  1484. authCookie = decodeURI(authCookie);
  1485. var authCookieString = authCookie.split(User.cookieSeparator);
  1486. if (authCookieString[0]) {
  1487. this.authenticatedId = authCookieString[0];
  1488. }
  1489. if (authCookieString.length > 1 && authCookieString[1]) {
  1490. this.accountId = authCookieString[1];
  1491. }
  1492. }
  1493. }
  1494. User.prototype.setAuthenticatedUserContext = function (authenticatedUserId, accountId) {
  1495. var isInvalidInput = !this.validateUserInput(authenticatedUserId) || (accountId && !this.validateUserInput(accountId));
  1496. if (isInvalidInput) {
  1497. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_SetAuthContextFailedAccountName, "Setting auth user context failed. " +
  1498. "User auth/account id should be of type string, and not contain commas, semi-colons, equal signs, spaces, or vertical-bars."));
  1499. return;
  1500. }
  1501. this.authenticatedId = authenticatedUserId;
  1502. var authCookie = this.authenticatedId;
  1503. if (accountId) {
  1504. this.accountId = accountId;
  1505. authCookie = [this.authenticatedId, this.accountId].join(User.cookieSeparator);
  1506. }
  1507. ApplicationInsights.Util.setCookie(User.authUserCookieName, encodeURI(authCookie), this.config.cookieDomain());
  1508. };
  1509. User.prototype.clearAuthenticatedUserContext = function () {
  1510. this.authenticatedId = null;
  1511. this.accountId = null;
  1512. ApplicationInsights.Util.deleteCookie(User.authUserCookieName);
  1513. };
  1514. User.prototype.validateUserInput = function (id) {
  1515. if (typeof id !== 'string' ||
  1516. !id ||
  1517. id.match(/,|;|=| |\|/)) {
  1518. return false;
  1519. }
  1520. return true;
  1521. };
  1522. User.cookieSeparator = '|';
  1523. User.userCookieName = 'ai_user';
  1524. User.authUserCookieName = 'ai_authUser';
  1525. return User;
  1526. })();
  1527. Context.User = User;
  1528. })(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
  1529. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1530. })(Microsoft || (Microsoft = {}));
  1531. var Microsoft;
  1532. (function (Microsoft) {
  1533. var ApplicationInsights;
  1534. (function (ApplicationInsights) {
  1535. "use strict";
  1536. var DataLossAnalyzer = (function () {
  1537. function DataLossAnalyzer() {
  1538. }
  1539. DataLossAnalyzer.reset = function () {
  1540. if (DataLossAnalyzer.isEnabled()) {
  1541. ApplicationInsights.Util.setSessionStorage(DataLossAnalyzer.ITEMS_QUEUED_KEY, "0");
  1542. }
  1543. };
  1544. DataLossAnalyzer.isEnabled = function () {
  1545. return DataLossAnalyzer.enabled &&
  1546. DataLossAnalyzer.appInsights != null &&
  1547. ApplicationInsights.Util.canUseSessionStorage();
  1548. };
  1549. DataLossAnalyzer.getIssuesReported = function () {
  1550. var result = (!DataLossAnalyzer.isEnabled() || isNaN(+ApplicationInsights.Util.getSessionStorage(DataLossAnalyzer.ISSUES_REPORTED_KEY))) ?
  1551. 0 :
  1552. +ApplicationInsights.Util.getSessionStorage(DataLossAnalyzer.ISSUES_REPORTED_KEY);
  1553. return result;
  1554. };
  1555. DataLossAnalyzer.incrementItemsQueued = function () {
  1556. try {
  1557. if (DataLossAnalyzer.isEnabled()) {
  1558. var itemsQueued = DataLossAnalyzer.getNumberOfLostItems();
  1559. ++itemsQueued;
  1560. ApplicationInsights.Util.setSessionStorage(DataLossAnalyzer.ITEMS_QUEUED_KEY, itemsQueued.toString());
  1561. }
  1562. }
  1563. catch (e) { }
  1564. };
  1565. DataLossAnalyzer.decrementItemsQueued = function (countOfItemsSentSuccessfully) {
  1566. try {
  1567. if (DataLossAnalyzer.isEnabled()) {
  1568. var itemsQueued = DataLossAnalyzer.getNumberOfLostItems();
  1569. itemsQueued -= countOfItemsSentSuccessfully;
  1570. if (itemsQueued < 0)
  1571. itemsQueued = 0;
  1572. ApplicationInsights.Util.setSessionStorage(DataLossAnalyzer.ITEMS_QUEUED_KEY, itemsQueued.toString());
  1573. }
  1574. }
  1575. catch (e) { }
  1576. };
  1577. DataLossAnalyzer.getNumberOfLostItems = function () {
  1578. var result = 0;
  1579. try {
  1580. if (DataLossAnalyzer.isEnabled()) {
  1581. result = isNaN(+ApplicationInsights.Util.getSessionStorage(DataLossAnalyzer.ITEMS_QUEUED_KEY)) ?
  1582. 0 :
  1583. +ApplicationInsights.Util.getSessionStorage(DataLossAnalyzer.ITEMS_QUEUED_KEY);
  1584. }
  1585. }
  1586. catch (e) {
  1587. result = 0;
  1588. }
  1589. return result;
  1590. };
  1591. DataLossAnalyzer.reportLostItems = function () {
  1592. try {
  1593. if (DataLossAnalyzer.isEnabled() &&
  1594. DataLossAnalyzer.getIssuesReported() < DataLossAnalyzer.LIMIT_PER_SESSION &&
  1595. DataLossAnalyzer.getNumberOfLostItems() > 0) {
  1596. DataLossAnalyzer.appInsights.trackTrace("AI (Internal): Internal report DATALOSS: "
  1597. + DataLossAnalyzer.getNumberOfLostItems(), null);
  1598. DataLossAnalyzer.appInsights.flush();
  1599. var issuesReported = DataLossAnalyzer.getIssuesReported();
  1600. ++issuesReported;
  1601. ApplicationInsights.Util.setSessionStorage(DataLossAnalyzer.ISSUES_REPORTED_KEY, issuesReported.toString());
  1602. }
  1603. }
  1604. catch (e) {
  1605. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedToReportDataLoss, "Failed to report data loss: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  1606. }
  1607. finally {
  1608. try {
  1609. DataLossAnalyzer.reset();
  1610. }
  1611. catch (e) { }
  1612. }
  1613. };
  1614. DataLossAnalyzer.enabled = false;
  1615. DataLossAnalyzer.LIMIT_PER_SESSION = 10;
  1616. DataLossAnalyzer.ITEMS_QUEUED_KEY = "AI_itemsQueued";
  1617. DataLossAnalyzer.ISSUES_REPORTED_KEY = "AI_lossIssuesReported";
  1618. return DataLossAnalyzer;
  1619. })();
  1620. ApplicationInsights.DataLossAnalyzer = DataLossAnalyzer;
  1621. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1622. })(Microsoft || (Microsoft = {}));
  1623. /// <reference path="serializer.ts" />
  1624. /// <reference path="Telemetry/Common/Envelope.ts"/>
  1625. /// <reference path="Telemetry/Common/Base.ts" />
  1626. /// <reference path="Contracts/Generated/ContextTagKeys.ts"/>
  1627. /// <reference path="Context/Application.ts"/>
  1628. /// <reference path="Context/Device.ts"/>
  1629. /// <reference path="Context/Internal.ts"/>
  1630. /// <reference path="Context/Location.ts"/>
  1631. /// <reference path="Context/Operation.ts"/>
  1632. /// <reference path="Context/Sample.ts"/>
  1633. /// <reference path="Context/Session.ts"/>
  1634. /// <reference path="Context/User.ts"/>
  1635. /// <reference path="ajax/ajax.ts"/>
  1636. /// <reference path="./DataLossAnalyzer.ts"/>
  1637. ;
  1638. var Microsoft;
  1639. (function (Microsoft) {
  1640. var ApplicationInsights;
  1641. (function (ApplicationInsights) {
  1642. "use strict";
  1643. var Sender = (function () {
  1644. function Sender(config) {
  1645. this._buffer = [];
  1646. this._lastSend = 0;
  1647. this._config = config;
  1648. this._sender = null;
  1649. if (typeof XMLHttpRequest != "undefined") {
  1650. var testXhr = new XMLHttpRequest();
  1651. if ("withCredentials" in testXhr) {
  1652. this._sender = this._xhrSender;
  1653. }
  1654. else if (typeof XDomainRequest !== "undefined") {
  1655. this._sender = this._xdrSender;
  1656. }
  1657. }
  1658. }
  1659. Sender.prototype.send = function (envelope) {
  1660. var _this = this;
  1661. try {
  1662. if (this._config.disableTelemetry()) {
  1663. return;
  1664. }
  1665. if (!envelope) {
  1666. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_CannotSendEmptyTelemetry, "Cannot send empty telemetry"));
  1667. return;
  1668. }
  1669. if (!this._sender) {
  1670. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_SenderNotInitialized, "Sender was not initialized"));
  1671. return;
  1672. }
  1673. var payload = ApplicationInsights.Serializer.serialize(envelope);
  1674. if (this._getSizeInBytes(this._buffer) + payload.length > this._config.maxBatchSizeInBytes()) {
  1675. this.triggerSend();
  1676. }
  1677. this._buffer.push(payload);
  1678. if (!this._timeoutHandle) {
  1679. this._timeoutHandle = setTimeout(function () {
  1680. _this._timeoutHandle = null;
  1681. _this.triggerSend();
  1682. }, this._config.maxBatchInterval());
  1683. }
  1684. ApplicationInsights.DataLossAnalyzer.incrementItemsQueued();
  1685. }
  1686. catch (e) {
  1687. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedAddingTelemetryToBuffer, "Failed adding telemetry to the sender's buffer, some telemetry will be lost: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  1688. }
  1689. };
  1690. Sender.prototype._getSizeInBytes = function (list) {
  1691. var size = 0;
  1692. if (list && list.length) {
  1693. for (var i = 0; i < list.length; i++) {
  1694. var item = list[i];
  1695. if (item && item.length) {
  1696. size += item.length;
  1697. }
  1698. }
  1699. }
  1700. return size;
  1701. };
  1702. Sender.prototype.triggerSend = function (async) {
  1703. var isAsync = true;
  1704. if (typeof async === 'boolean') {
  1705. isAsync = async;
  1706. }
  1707. try {
  1708. if (!this._config.disableTelemetry()) {
  1709. if (this._buffer.length) {
  1710. var batch = this._config.emitLineDelimitedJson() ?
  1711. this._buffer.join("\n") :
  1712. "[" + this._buffer.join(",") + "]";
  1713. this._sender(batch, isAsync, this._buffer.length);
  1714. }
  1715. this._lastSend = +new Date;
  1716. }
  1717. this._buffer.length = 0;
  1718. clearTimeout(this._timeoutHandle);
  1719. this._timeoutHandle = null;
  1720. }
  1721. catch (e) {
  1722. if (!ApplicationInsights.Util.getIEVersion() || ApplicationInsights.Util.getIEVersion() > 9) {
  1723. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TransmissionFailed, "Telemetry transmission failed, some telemetry will be lost: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  1724. }
  1725. }
  1726. };
  1727. Sender.prototype._xhrSender = function (payload, isAsync, countOfItemsInPayload) {
  1728. var xhr = new XMLHttpRequest();
  1729. xhr[ApplicationInsights.AjaxMonitor.DisabledPropertyName] = true;
  1730. xhr.open("POST", this._config.endpointUrl(), isAsync);
  1731. xhr.setRequestHeader("Content-type", "application/json");
  1732. xhr.onreadystatechange = function () { return Sender._xhrReadyStateChange(xhr, payload, countOfItemsInPayload); };
  1733. xhr.onerror = function (event) { return Sender._onError(payload, xhr.responseText || xhr.response || "", event); };
  1734. xhr.send(payload);
  1735. };
  1736. Sender.prototype._xdrSender = function (payload, isAsync) {
  1737. var xdr = new XDomainRequest();
  1738. xdr.onload = function () { return Sender._xdrOnLoad(xdr, payload); };
  1739. xdr.onerror = function (event) { return Sender._onError(payload, xdr.responseText || "", event); };
  1740. xdr.open('POST', this._config.endpointUrl());
  1741. xdr.send(payload);
  1742. };
  1743. Sender._xhrReadyStateChange = function (xhr, payload, countOfItemsInPayload) {
  1744. if (xhr.readyState === 4) {
  1745. if ((xhr.status < 200 || xhr.status >= 300) && xhr.status !== 0) {
  1746. Sender._onError(payload, xhr.responseText || xhr.response || "");
  1747. }
  1748. else {
  1749. Sender._onSuccess(payload, countOfItemsInPayload);
  1750. }
  1751. }
  1752. };
  1753. Sender._xdrOnLoad = function (xdr, payload) {
  1754. if (xdr && (xdr.responseText + "" === "200" || xdr.responseText === "")) {
  1755. Sender._onSuccess(payload, 0);
  1756. }
  1757. else {
  1758. Sender._onError(payload, xdr && xdr.responseText || "");
  1759. }
  1760. };
  1761. Sender._onError = function (payload, message, event) {
  1762. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_OnError, "Failed to send telemetry.", { message: message }));
  1763. };
  1764. Sender._onSuccess = function (payload, countOfItemsInPayload) {
  1765. ApplicationInsights.DataLossAnalyzer.decrementItemsQueued(countOfItemsInPayload);
  1766. };
  1767. return Sender;
  1768. })();
  1769. ApplicationInsights.Sender = Sender;
  1770. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1771. })(Microsoft || (Microsoft = {}));
  1772. /// <reference path="./HashCodeScoreGenerator.ts" />
  1773. var Microsoft;
  1774. (function (Microsoft) {
  1775. var ApplicationInsights;
  1776. (function (ApplicationInsights) {
  1777. "use strict";
  1778. var SplitTest = (function () {
  1779. function SplitTest() {
  1780. this.hashCodeGeneragor = new ApplicationInsights.HashCodeScoreGenerator();
  1781. }
  1782. SplitTest.prototype.isEnabled = function (key, percentEnabled) {
  1783. return this.hashCodeGeneragor.getHashCodeScore(key) < percentEnabled;
  1784. };
  1785. return SplitTest;
  1786. })();
  1787. ApplicationInsights.SplitTest = SplitTest;
  1788. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1789. })(Microsoft || (Microsoft = {}));
  1790. var Microsoft;
  1791. (function (Microsoft) {
  1792. var Telemetry;
  1793. (function (Telemetry) {
  1794. "use strict";
  1795. var Domain = (function () {
  1796. function Domain() {
  1797. }
  1798. return Domain;
  1799. })();
  1800. Telemetry.Domain = Domain;
  1801. })(Telemetry = Microsoft.Telemetry || (Microsoft.Telemetry = {}));
  1802. })(Microsoft || (Microsoft = {}));
  1803. var AI;
  1804. (function (AI) {
  1805. "use strict";
  1806. (function (SeverityLevel) {
  1807. SeverityLevel[SeverityLevel["Verbose"] = 0] = "Verbose";
  1808. SeverityLevel[SeverityLevel["Information"] = 1] = "Information";
  1809. SeverityLevel[SeverityLevel["Warning"] = 2] = "Warning";
  1810. SeverityLevel[SeverityLevel["Error"] = 3] = "Error";
  1811. SeverityLevel[SeverityLevel["Critical"] = 4] = "Critical";
  1812. })(AI.SeverityLevel || (AI.SeverityLevel = {}));
  1813. var SeverityLevel = AI.SeverityLevel;
  1814. })(AI || (AI = {}));
  1815. /// <reference path="Domain.ts" />
  1816. /// <reference path="SeverityLevel.ts" />
  1817. var AI;
  1818. (function (AI) {
  1819. "use strict";
  1820. var MessageData = (function (_super) {
  1821. __extends(MessageData, _super);
  1822. function MessageData() {
  1823. this.ver = 2;
  1824. this.properties = {};
  1825. _super.call(this);
  1826. }
  1827. return MessageData;
  1828. })(Microsoft.Telemetry.Domain);
  1829. AI.MessageData = MessageData;
  1830. })(AI || (AI = {}));
  1831. /// <reference path="../../logging.ts" />
  1832. /// <reference path="../../Util.ts"/>
  1833. var Microsoft;
  1834. (function (Microsoft) {
  1835. var ApplicationInsights;
  1836. (function (ApplicationInsights) {
  1837. var Telemetry;
  1838. (function (Telemetry) {
  1839. var Common;
  1840. (function (Common) {
  1841. "use strict";
  1842. var DataSanitizer = (function () {
  1843. function DataSanitizer() {
  1844. }
  1845. DataSanitizer.sanitizeKeyAndAddUniqueness = function (key, map) {
  1846. var origLength = key.length;
  1847. var field = DataSanitizer.sanitizeKey(key);
  1848. if (field.length !== origLength) {
  1849. var i = 0;
  1850. var uniqueField = field;
  1851. while (map[uniqueField] !== undefined) {
  1852. i++;
  1853. uniqueField = field.substring(0, DataSanitizer.MAX_NAME_LENGTH - 3) + DataSanitizer.padNumber(i);
  1854. }
  1855. field = uniqueField;
  1856. }
  1857. return field;
  1858. };
  1859. DataSanitizer.sanitizeKey = function (name) {
  1860. if (name) {
  1861. name = ApplicationInsights.Util.trim(name.toString());
  1862. if (name.search(/[^0-9a-zA-Z-._()\/ ]/g) >= 0) {
  1863. name = name.replace(/[^0-9a-zA-Z-._()\/ ]/g, "_");
  1864. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_IllegalCharsInName, "name contains illegal characters. Illegal characters have been replaced with '_'.", { newName: name }));
  1865. }
  1866. if (name.length > DataSanitizer.MAX_NAME_LENGTH) {
  1867. name = name.substring(0, DataSanitizer.MAX_NAME_LENGTH);
  1868. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_NameTooLong, "name is too long. It has been truncated to " + DataSanitizer.MAX_NAME_LENGTH + " characters.", { name: name }));
  1869. }
  1870. }
  1871. return name;
  1872. };
  1873. DataSanitizer.sanitizeString = function (value) {
  1874. if (value) {
  1875. value = ApplicationInsights.Util.trim(value);
  1876. if (value.toString().length > DataSanitizer.MAX_STRING_LENGTH) {
  1877. value = value.toString().substring(0, DataSanitizer.MAX_STRING_LENGTH);
  1878. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_StringValueTooLong, "string value is too long. It has been truncated to " + DataSanitizer.MAX_STRING_LENGTH + " characters.", { value: value }));
  1879. }
  1880. }
  1881. return value;
  1882. };
  1883. DataSanitizer.sanitizeUrl = function (url) {
  1884. if (url) {
  1885. if (url.length > DataSanitizer.MAX_URL_LENGTH) {
  1886. url = url.substring(0, DataSanitizer.MAX_URL_LENGTH);
  1887. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_UrlTooLong, "url is too long, it has been trucated to " + DataSanitizer.MAX_URL_LENGTH + " characters.", { url: url }));
  1888. }
  1889. }
  1890. return url;
  1891. };
  1892. DataSanitizer.sanitizeMessage = function (message) {
  1893. if (message) {
  1894. if (message.length > DataSanitizer.MAX_MESSAGE_LENGTH) {
  1895. message = message.substring(0, DataSanitizer.MAX_MESSAGE_LENGTH);
  1896. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_MessageTruncated, "message is too long, it has been trucated to " + DataSanitizer.MAX_MESSAGE_LENGTH + " characters.", { message: message }));
  1897. }
  1898. }
  1899. return message;
  1900. };
  1901. DataSanitizer.sanitizeException = function (exception) {
  1902. if (exception) {
  1903. if (exception.length > DataSanitizer.MAX_EXCEPTION_LENGTH) {
  1904. exception = exception.substring(0, DataSanitizer.MAX_EXCEPTION_LENGTH);
  1905. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_ExceptionTruncated, "exception is too long, it has been trucated to " + DataSanitizer.MAX_EXCEPTION_LENGTH + " characters.", { exception: exception }));
  1906. }
  1907. }
  1908. return exception;
  1909. };
  1910. DataSanitizer.sanitizeProperties = function (properties) {
  1911. if (properties) {
  1912. var tempProps = {};
  1913. for (var prop in properties) {
  1914. var value = DataSanitizer.sanitizeString(properties[prop]);
  1915. prop = DataSanitizer.sanitizeKeyAndAddUniqueness(prop, tempProps);
  1916. tempProps[prop] = value;
  1917. }
  1918. properties = tempProps;
  1919. }
  1920. return properties;
  1921. };
  1922. DataSanitizer.sanitizeMeasurements = function (measurements) {
  1923. if (measurements) {
  1924. var tempMeasurements = {};
  1925. for (var measure in measurements) {
  1926. var value = measurements[measure];
  1927. measure = DataSanitizer.sanitizeKeyAndAddUniqueness(measure, tempMeasurements);
  1928. tempMeasurements[measure] = value;
  1929. }
  1930. measurements = tempMeasurements;
  1931. }
  1932. return measurements;
  1933. };
  1934. DataSanitizer.padNumber = function (num) {
  1935. var s = "00" + num;
  1936. return s.substr(s.length - 3);
  1937. };
  1938. DataSanitizer.MAX_NAME_LENGTH = 150;
  1939. DataSanitizer.MAX_STRING_LENGTH = 1024;
  1940. DataSanitizer.MAX_URL_LENGTH = 2048;
  1941. DataSanitizer.MAX_MESSAGE_LENGTH = 32768;
  1942. DataSanitizer.MAX_EXCEPTION_LENGTH = 32768;
  1943. return DataSanitizer;
  1944. })();
  1945. Common.DataSanitizer = DataSanitizer;
  1946. })(Common = Telemetry.Common || (Telemetry.Common = {}));
  1947. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  1948. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1949. })(Microsoft || (Microsoft = {}));
  1950. /// <reference path="../Contracts/Generated/MessageData.ts" />
  1951. /// <reference path="./Common/DataSanitizer.ts"/>
  1952. var Microsoft;
  1953. (function (Microsoft) {
  1954. var ApplicationInsights;
  1955. (function (ApplicationInsights) {
  1956. var Telemetry;
  1957. (function (Telemetry) {
  1958. "use strict";
  1959. var Trace = (function (_super) {
  1960. __extends(Trace, _super);
  1961. function Trace(message, properties) {
  1962. _super.call(this);
  1963. this.aiDataContract = {
  1964. ver: ApplicationInsights.FieldType.Required,
  1965. message: ApplicationInsights.FieldType.Required,
  1966. severityLevel: ApplicationInsights.FieldType.Default,
  1967. measurements: ApplicationInsights.FieldType.Default,
  1968. properties: ApplicationInsights.FieldType.Default
  1969. };
  1970. message = message || ApplicationInsights.Util.NotSpecified;
  1971. this.message = Telemetry.Common.DataSanitizer.sanitizeMessage(message);
  1972. this.properties = Telemetry.Common.DataSanitizer.sanitizeProperties(properties);
  1973. }
  1974. Trace.envelopeType = "Microsoft.ApplicationInsights.{0}.Message";
  1975. Trace.dataType = "MessageData";
  1976. return Trace;
  1977. })(AI.MessageData);
  1978. Telemetry.Trace = Trace;
  1979. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  1980. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  1981. })(Microsoft || (Microsoft = {}));
  1982. /// <reference path="Domain.ts" />
  1983. var AI;
  1984. (function (AI) {
  1985. "use strict";
  1986. var EventData = (function (_super) {
  1987. __extends(EventData, _super);
  1988. function EventData() {
  1989. this.ver = 2;
  1990. this.properties = {};
  1991. this.measurements = {};
  1992. _super.call(this);
  1993. }
  1994. return EventData;
  1995. })(Microsoft.Telemetry.Domain);
  1996. AI.EventData = EventData;
  1997. })(AI || (AI = {}));
  1998. /// <reference path="../Contracts/Generated/EventData.ts" />
  1999. /// <reference path="./Common/DataSanitizer.ts"/>
  2000. var Microsoft;
  2001. (function (Microsoft) {
  2002. var ApplicationInsights;
  2003. (function (ApplicationInsights) {
  2004. var Telemetry;
  2005. (function (Telemetry) {
  2006. "use strict";
  2007. var Event = (function (_super) {
  2008. __extends(Event, _super);
  2009. function Event(name, properties, measurements) {
  2010. _super.call(this);
  2011. this.aiDataContract = {
  2012. ver: ApplicationInsights.FieldType.Required,
  2013. name: ApplicationInsights.FieldType.Required,
  2014. properties: ApplicationInsights.FieldType.Default,
  2015. measurements: ApplicationInsights.FieldType.Default
  2016. };
  2017. this.name = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeString(name);
  2018. this.properties = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeProperties(properties);
  2019. this.measurements = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeMeasurements(measurements);
  2020. }
  2021. Event.envelopeType = "Microsoft.ApplicationInsights.{0}.Event";
  2022. Event.dataType = "EventData";
  2023. return Event;
  2024. })(AI.EventData);
  2025. Telemetry.Event = Event;
  2026. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2027. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2028. })(Microsoft || (Microsoft = {}));
  2029. var AI;
  2030. (function (AI) {
  2031. "use strict";
  2032. var ExceptionDetails = (function () {
  2033. function ExceptionDetails() {
  2034. this.hasFullStack = true;
  2035. this.parsedStack = [];
  2036. }
  2037. return ExceptionDetails;
  2038. })();
  2039. AI.ExceptionDetails = ExceptionDetails;
  2040. })(AI || (AI = {}));
  2041. /// <reference path="Domain.ts" />
  2042. /// <reference path="SeverityLevel.ts" />
  2043. /// <reference path="ExceptionDetails.ts"/>
  2044. var AI;
  2045. (function (AI) {
  2046. "use strict";
  2047. var ExceptionData = (function (_super) {
  2048. __extends(ExceptionData, _super);
  2049. function ExceptionData() {
  2050. this.ver = 2;
  2051. this.exceptions = [];
  2052. this.properties = {};
  2053. this.measurements = {};
  2054. _super.call(this);
  2055. }
  2056. return ExceptionData;
  2057. })(Microsoft.Telemetry.Domain);
  2058. AI.ExceptionData = ExceptionData;
  2059. })(AI || (AI = {}));
  2060. var AI;
  2061. (function (AI) {
  2062. "use strict";
  2063. var StackFrame = (function () {
  2064. function StackFrame() {
  2065. }
  2066. return StackFrame;
  2067. })();
  2068. AI.StackFrame = StackFrame;
  2069. })(AI || (AI = {}));
  2070. /// <reference path="../Contracts/Generated/ExceptionData.ts" />
  2071. /// <reference path="../Contracts/Generated/StackFrame.ts" />
  2072. /// <reference path="./Common/DataSanitizer.ts"/>
  2073. var Microsoft;
  2074. (function (Microsoft) {
  2075. var ApplicationInsights;
  2076. (function (ApplicationInsights) {
  2077. var Telemetry;
  2078. (function (Telemetry) {
  2079. "use strict";
  2080. var Exception = (function (_super) {
  2081. __extends(Exception, _super);
  2082. function Exception(exception, handledAt, properties, measurements) {
  2083. _super.call(this);
  2084. this.aiDataContract = {
  2085. ver: ApplicationInsights.FieldType.Required,
  2086. handledAt: ApplicationInsights.FieldType.Required,
  2087. exceptions: ApplicationInsights.FieldType.Required,
  2088. severityLevel: ApplicationInsights.FieldType.Default,
  2089. properties: ApplicationInsights.FieldType.Default,
  2090. measurements: ApplicationInsights.FieldType.Default
  2091. };
  2092. this.properties = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeProperties(properties);
  2093. this.measurements = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeMeasurements(measurements);
  2094. this.handledAt = handledAt || "unhandled";
  2095. this.exceptions = [new _ExceptionDetails(exception)];
  2096. }
  2097. Exception.CreateSimpleException = function (message, typeName, assembly, fileName, details, line, handledAt) {
  2098. return {
  2099. handledAt: handledAt || "unhandled",
  2100. exceptions: [
  2101. {
  2102. hasFullStack: true,
  2103. message: message,
  2104. stack: details,
  2105. typeName: typeName,
  2106. parsedStack: [
  2107. {
  2108. level: 0,
  2109. assembly: assembly,
  2110. fileName: fileName,
  2111. line: line,
  2112. method: "unknown"
  2113. }
  2114. ]
  2115. }
  2116. ]
  2117. };
  2118. };
  2119. Exception.envelopeType = "Microsoft.ApplicationInsights.{0}.Exception";
  2120. Exception.dataType = "ExceptionData";
  2121. return Exception;
  2122. })(AI.ExceptionData);
  2123. Telemetry.Exception = Exception;
  2124. var _ExceptionDetails = (function (_super) {
  2125. __extends(_ExceptionDetails, _super);
  2126. function _ExceptionDetails(exception) {
  2127. _super.call(this);
  2128. this.aiDataContract = {
  2129. id: ApplicationInsights.FieldType.Default,
  2130. outerId: ApplicationInsights.FieldType.Default,
  2131. typeName: ApplicationInsights.FieldType.Required,
  2132. message: ApplicationInsights.FieldType.Required,
  2133. hasFullStack: ApplicationInsights.FieldType.Default,
  2134. stack: ApplicationInsights.FieldType.Default,
  2135. parsedStack: ApplicationInsights.FieldType.Array
  2136. };
  2137. this.typeName = Telemetry.Common.DataSanitizer.sanitizeString(exception.name || ApplicationInsights.Util.NotSpecified);
  2138. this.message = Telemetry.Common.DataSanitizer.sanitizeMessage(exception.message || ApplicationInsights.Util.NotSpecified);
  2139. var stack = exception["stack"];
  2140. this.parsedStack = this.parseStack(stack);
  2141. this.stack = Telemetry.Common.DataSanitizer.sanitizeException(stack);
  2142. this.hasFullStack = ApplicationInsights.Util.isArray(this.parsedStack) && this.parsedStack.length > 0;
  2143. }
  2144. _ExceptionDetails.prototype.parseStack = function (stack) {
  2145. var parsedStack = undefined;
  2146. if (typeof stack === "string") {
  2147. var frames = stack.split('\n');
  2148. parsedStack = [];
  2149. var level = 0;
  2150. var totalSizeInBytes = 0;
  2151. for (var i = 0; i <= frames.length; i++) {
  2152. var frame = frames[i];
  2153. if (_StackFrame.regex.test(frame)) {
  2154. var parsedFrame = new _StackFrame(frames[i], level++);
  2155. totalSizeInBytes += parsedFrame.sizeInBytes;
  2156. parsedStack.push(parsedFrame);
  2157. }
  2158. }
  2159. var exceptionParsedStackThreshold = 32 * 1024;
  2160. if (totalSizeInBytes > exceptionParsedStackThreshold) {
  2161. var left = 0;
  2162. var right = parsedStack.length - 1;
  2163. var size = 0;
  2164. var acceptedLeft = left;
  2165. var acceptedRight = right;
  2166. while (left < right) {
  2167. var lSize = parsedStack[left].sizeInBytes;
  2168. var rSize = parsedStack[right].sizeInBytes;
  2169. size += lSize + rSize;
  2170. if (size > exceptionParsedStackThreshold) {
  2171. var howMany = acceptedRight - acceptedLeft + 1;
  2172. parsedStack.splice(acceptedLeft, howMany);
  2173. break;
  2174. }
  2175. acceptedLeft = left;
  2176. acceptedRight = right;
  2177. left++;
  2178. right--;
  2179. }
  2180. }
  2181. }
  2182. return parsedStack;
  2183. };
  2184. return _ExceptionDetails;
  2185. })(AI.ExceptionDetails);
  2186. var _StackFrame = (function (_super) {
  2187. __extends(_StackFrame, _super);
  2188. function _StackFrame(frame, level) {
  2189. _super.call(this);
  2190. this.sizeInBytes = 0;
  2191. this.aiDataContract = {
  2192. level: ApplicationInsights.FieldType.Required,
  2193. method: ApplicationInsights.FieldType.Required,
  2194. assembly: ApplicationInsights.FieldType.Default,
  2195. fileName: ApplicationInsights.FieldType.Default,
  2196. line: ApplicationInsights.FieldType.Default
  2197. };
  2198. this.level = level;
  2199. this.method = "<no_method>";
  2200. this.assembly = ApplicationInsights.Util.trim(frame);
  2201. var matches = frame.match(_StackFrame.regex);
  2202. if (matches && matches.length >= 5) {
  2203. this.method = ApplicationInsights.Util.trim(matches[2]) || this.method;
  2204. this.fileName = ApplicationInsights.Util.trim(matches[4]);
  2205. this.line = parseInt(matches[5]) || 0;
  2206. }
  2207. this.sizeInBytes += this.method.length;
  2208. this.sizeInBytes += this.fileName.length;
  2209. this.sizeInBytes += this.assembly.length;
  2210. this.sizeInBytes += _StackFrame.baseSize;
  2211. this.sizeInBytes += this.level.toString().length;
  2212. this.sizeInBytes += this.line.toString().length;
  2213. }
  2214. _StackFrame.regex = /^([\s]+at)?(.*?)(\@|\s\(|\s)([^\(\@\n]+):([0-9]+):([0-9]+)(\)?)$/;
  2215. _StackFrame.baseSize = 58;
  2216. return _StackFrame;
  2217. })(AI.StackFrame);
  2218. Telemetry._StackFrame = _StackFrame;
  2219. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2220. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2221. })(Microsoft || (Microsoft = {}));
  2222. /// <reference path="Domain.ts" />
  2223. var AI;
  2224. (function (AI) {
  2225. "use strict";
  2226. var MetricData = (function (_super) {
  2227. __extends(MetricData, _super);
  2228. function MetricData() {
  2229. this.ver = 2;
  2230. this.metrics = [];
  2231. this.properties = {};
  2232. _super.call(this);
  2233. }
  2234. return MetricData;
  2235. })(Microsoft.Telemetry.Domain);
  2236. AI.MetricData = MetricData;
  2237. })(AI || (AI = {}));
  2238. var AI;
  2239. (function (AI) {
  2240. "use strict";
  2241. (function (DataPointType) {
  2242. DataPointType[DataPointType["Measurement"] = 0] = "Measurement";
  2243. DataPointType[DataPointType["Aggregation"] = 1] = "Aggregation";
  2244. })(AI.DataPointType || (AI.DataPointType = {}));
  2245. var DataPointType = AI.DataPointType;
  2246. })(AI || (AI = {}));
  2247. /// <reference path="DataPointType.ts" />
  2248. var AI;
  2249. (function (AI) {
  2250. "use strict";
  2251. var DataPoint = (function () {
  2252. function DataPoint() {
  2253. this.kind = AI.DataPointType.Measurement;
  2254. }
  2255. return DataPoint;
  2256. })();
  2257. AI.DataPoint = DataPoint;
  2258. })(AI || (AI = {}));
  2259. /// <reference path="../../Contracts/Generated/DataPoint.ts"/>
  2260. var Microsoft;
  2261. (function (Microsoft) {
  2262. var ApplicationInsights;
  2263. (function (ApplicationInsights) {
  2264. var Telemetry;
  2265. (function (Telemetry) {
  2266. var Common;
  2267. (function (Common) {
  2268. "use strict";
  2269. var DataPoint = (function (_super) {
  2270. __extends(DataPoint, _super);
  2271. function DataPoint() {
  2272. _super.apply(this, arguments);
  2273. this.aiDataContract = {
  2274. name: ApplicationInsights.FieldType.Required,
  2275. kind: ApplicationInsights.FieldType.Default,
  2276. value: ApplicationInsights.FieldType.Required,
  2277. count: ApplicationInsights.FieldType.Default,
  2278. min: ApplicationInsights.FieldType.Default,
  2279. max: ApplicationInsights.FieldType.Default,
  2280. stdDev: ApplicationInsights.FieldType.Default
  2281. };
  2282. }
  2283. return DataPoint;
  2284. })(AI.DataPoint);
  2285. Common.DataPoint = DataPoint;
  2286. })(Common = Telemetry.Common || (Telemetry.Common = {}));
  2287. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2288. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2289. })(Microsoft || (Microsoft = {}));
  2290. /// <reference path="../Contracts/Generated/MetricData.ts" />
  2291. /// <reference path="./Common/DataSanitizer.ts" />
  2292. /// <reference path="./Common/DataPoint.ts" />
  2293. var Microsoft;
  2294. (function (Microsoft) {
  2295. var ApplicationInsights;
  2296. (function (ApplicationInsights) {
  2297. var Telemetry;
  2298. (function (Telemetry) {
  2299. "use strict";
  2300. var Metric = (function (_super) {
  2301. __extends(Metric, _super);
  2302. function Metric(name, value, count, min, max, properties) {
  2303. _super.call(this);
  2304. this.aiDataContract = {
  2305. ver: ApplicationInsights.FieldType.Required,
  2306. metrics: ApplicationInsights.FieldType.Required,
  2307. properties: ApplicationInsights.FieldType.Default
  2308. };
  2309. var dataPoint = new Microsoft.ApplicationInsights.Telemetry.Common.DataPoint();
  2310. dataPoint.count = count > 0 ? count : undefined;
  2311. dataPoint.max = isNaN(max) || max === null ? undefined : max;
  2312. dataPoint.min = isNaN(min) || min === null ? undefined : min;
  2313. dataPoint.name = Telemetry.Common.DataSanitizer.sanitizeString(name);
  2314. dataPoint.value = value;
  2315. this.metrics = [dataPoint];
  2316. this.properties = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeProperties(properties);
  2317. }
  2318. Metric.envelopeType = "Microsoft.ApplicationInsights.{0}.Metric";
  2319. Metric.dataType = "MetricData";
  2320. return Metric;
  2321. })(AI.MetricData);
  2322. Telemetry.Metric = Metric;
  2323. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2324. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2325. })(Microsoft || (Microsoft = {}));
  2326. /// <reference path="EventData.ts" />
  2327. var AI;
  2328. (function (AI) {
  2329. "use strict";
  2330. var PageViewData = (function (_super) {
  2331. __extends(PageViewData, _super);
  2332. function PageViewData() {
  2333. this.ver = 2;
  2334. this.properties = {};
  2335. this.measurements = {};
  2336. _super.call(this);
  2337. }
  2338. return PageViewData;
  2339. })(AI.EventData);
  2340. AI.PageViewData = PageViewData;
  2341. })(AI || (AI = {}));
  2342. /// <reference path="../Contracts/Generated/PageViewData.ts" />
  2343. /// <reference path="./Common/DataSanitizer.ts"/>
  2344. var Microsoft;
  2345. (function (Microsoft) {
  2346. var ApplicationInsights;
  2347. (function (ApplicationInsights) {
  2348. var Telemetry;
  2349. (function (Telemetry) {
  2350. "use strict";
  2351. var PageView = (function (_super) {
  2352. __extends(PageView, _super);
  2353. function PageView(name, url, durationMs, properties, measurements) {
  2354. _super.call(this);
  2355. this.aiDataContract = {
  2356. ver: ApplicationInsights.FieldType.Required,
  2357. name: ApplicationInsights.FieldType.Default,
  2358. url: ApplicationInsights.FieldType.Default,
  2359. duration: ApplicationInsights.FieldType.Default,
  2360. properties: ApplicationInsights.FieldType.Default,
  2361. measurements: ApplicationInsights.FieldType.Default
  2362. };
  2363. this.url = Telemetry.Common.DataSanitizer.sanitizeUrl(url);
  2364. this.name = Telemetry.Common.DataSanitizer.sanitizeString(name || ApplicationInsights.Util.NotSpecified);
  2365. if (!isNaN(durationMs)) {
  2366. this.duration = ApplicationInsights.Util.msToTimeSpan(durationMs);
  2367. }
  2368. this.properties = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeProperties(properties);
  2369. this.measurements = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeMeasurements(measurements);
  2370. }
  2371. PageView.envelopeType = "Microsoft.ApplicationInsights.{0}.Pageview";
  2372. PageView.dataType = "PageviewData";
  2373. return PageView;
  2374. })(AI.PageViewData);
  2375. Telemetry.PageView = PageView;
  2376. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2377. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2378. })(Microsoft || (Microsoft = {}));
  2379. /// <reference path="PageViewData.ts" />
  2380. var AI;
  2381. (function (AI) {
  2382. "use strict";
  2383. var PageViewPerfData = (function (_super) {
  2384. __extends(PageViewPerfData, _super);
  2385. function PageViewPerfData() {
  2386. this.ver = 2;
  2387. this.properties = {};
  2388. this.measurements = {};
  2389. _super.call(this);
  2390. }
  2391. return PageViewPerfData;
  2392. })(AI.PageViewData);
  2393. AI.PageViewPerfData = PageViewPerfData;
  2394. })(AI || (AI = {}));
  2395. /// <reference path="../Contracts/Generated/PageViewPerfData.ts"/>
  2396. /// <reference path="./Common/DataSanitizer.ts"/>
  2397. /// <reference path="../Util.ts"/>
  2398. var Microsoft;
  2399. (function (Microsoft) {
  2400. var ApplicationInsights;
  2401. (function (ApplicationInsights) {
  2402. var Telemetry;
  2403. (function (Telemetry) {
  2404. "use strict";
  2405. var PageViewPerformance = (function (_super) {
  2406. __extends(PageViewPerformance, _super);
  2407. function PageViewPerformance(name, url, unused, properties, measurements) {
  2408. _super.call(this);
  2409. this.aiDataContract = {
  2410. ver: ApplicationInsights.FieldType.Required,
  2411. name: ApplicationInsights.FieldType.Default,
  2412. url: ApplicationInsights.FieldType.Default,
  2413. duration: ApplicationInsights.FieldType.Default,
  2414. perfTotal: ApplicationInsights.FieldType.Default,
  2415. networkConnect: ApplicationInsights.FieldType.Default,
  2416. sentRequest: ApplicationInsights.FieldType.Default,
  2417. receivedResponse: ApplicationInsights.FieldType.Default,
  2418. domProcessing: ApplicationInsights.FieldType.Default,
  2419. properties: ApplicationInsights.FieldType.Default,
  2420. measurements: ApplicationInsights.FieldType.Default
  2421. };
  2422. this.isValid = false;
  2423. var timing = PageViewPerformance.getPerformanceTiming();
  2424. if (timing) {
  2425. var total = PageViewPerformance.getDuration(timing.navigationStart, timing.loadEventEnd);
  2426. var network = PageViewPerformance.getDuration(timing.navigationStart, timing.connectEnd);
  2427. var request = PageViewPerformance.getDuration(timing.requestStart, timing.responseStart);
  2428. var response = PageViewPerformance.getDuration(timing.responseStart, timing.responseEnd);
  2429. var dom = PageViewPerformance.getDuration(timing.responseEnd, timing.loadEventEnd);
  2430. if (total == 0) {
  2431. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_ErrorPVCalc, "error calculating page view performance.", { total: total, network: network, request: request, response: response, dom: dom }));
  2432. }
  2433. else if (total < Math.floor(network) + Math.floor(request) + Math.floor(response) + Math.floor(dom)) {
  2434. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_ClientPerformanceMathError, "client performance math error.", { total: total, network: network, request: request, response: response, dom: dom }));
  2435. }
  2436. else {
  2437. this.durationMs = total;
  2438. this.perfTotal = this.duration = ApplicationInsights.Util.msToTimeSpan(total);
  2439. this.networkConnect = ApplicationInsights.Util.msToTimeSpan(network);
  2440. this.sentRequest = ApplicationInsights.Util.msToTimeSpan(request);
  2441. this.receivedResponse = ApplicationInsights.Util.msToTimeSpan(response);
  2442. this.domProcessing = ApplicationInsights.Util.msToTimeSpan(dom);
  2443. this.isValid = true;
  2444. }
  2445. }
  2446. this.url = Telemetry.Common.DataSanitizer.sanitizeUrl(url);
  2447. this.name = Telemetry.Common.DataSanitizer.sanitizeString(name || ApplicationInsights.Util.NotSpecified);
  2448. this.properties = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeProperties(properties);
  2449. this.measurements = ApplicationInsights.Telemetry.Common.DataSanitizer.sanitizeMeasurements(measurements);
  2450. }
  2451. PageViewPerformance.prototype.getIsValid = function () {
  2452. return this.isValid;
  2453. };
  2454. PageViewPerformance.prototype.getDurationMs = function () {
  2455. return this.durationMs;
  2456. };
  2457. PageViewPerformance.getPerformanceTiming = function () {
  2458. if (typeof window != "undefined" && window.performance && window.performance.timing) {
  2459. return window.performance.timing;
  2460. }
  2461. return null;
  2462. };
  2463. PageViewPerformance.isPerformanceTimingSupported = function () {
  2464. return typeof window != "undefined" && window.performance && window.performance.timing;
  2465. };
  2466. PageViewPerformance.isPerformanceTimingDataReady = function () {
  2467. var timing = window.performance.timing;
  2468. return timing.domainLookupStart > 0
  2469. && timing.navigationStart > 0
  2470. && timing.responseStart > 0
  2471. && timing.requestStart > 0
  2472. && timing.loadEventEnd > 0
  2473. && timing.responseEnd > 0
  2474. && timing.connectEnd > 0
  2475. && timing.domLoading > 0;
  2476. };
  2477. PageViewPerformance.getDuration = function (start, end) {
  2478. var duration = 0;
  2479. if (!(isNaN(start) || isNaN(end))) {
  2480. duration = Math.max(end - start, 0);
  2481. }
  2482. return duration;
  2483. };
  2484. PageViewPerformance.envelopeType = "Microsoft.ApplicationInsights.{0}.PageviewPerformance";
  2485. PageViewPerformance.dataType = "PageviewPerformanceData";
  2486. return PageViewPerformance;
  2487. })(AI.PageViewPerfData);
  2488. Telemetry.PageViewPerformance = PageViewPerformance;
  2489. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2490. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2491. })(Microsoft || (Microsoft = {}));
  2492. /// <reference path="sender.ts"/>
  2493. /// <reference path="telemetry/trace.ts" />
  2494. /// <reference path="telemetry/event.ts" />
  2495. /// <reference path="telemetry/exception.ts" />
  2496. /// <reference path="telemetry/metric.ts" />
  2497. /// <reference path="telemetry/pageview.ts" />
  2498. /// <reference path="telemetry/pageviewperformance.ts" />
  2499. /// <reference path="./Util.ts"/>
  2500. /// <reference path="./Contracts/Generated/SessionState.ts"/>
  2501. var Microsoft;
  2502. (function (Microsoft) {
  2503. var ApplicationInsights;
  2504. (function (ApplicationInsights) {
  2505. "use strict";
  2506. var TelemetryContext = (function () {
  2507. function TelemetryContext(config) {
  2508. this._config = config;
  2509. this._sender = new ApplicationInsights.Sender(config);
  2510. if (typeof window !== 'undefined') {
  2511. this._sessionManager = new ApplicationInsights.Context._SessionManager(config);
  2512. this.application = new ApplicationInsights.Context.Application();
  2513. this.device = new ApplicationInsights.Context.Device();
  2514. this.internal = new ApplicationInsights.Context.Internal();
  2515. this.location = new ApplicationInsights.Context.Location();
  2516. this.user = new ApplicationInsights.Context.User(config);
  2517. this.operation = new ApplicationInsights.Context.Operation();
  2518. this.session = new ApplicationInsights.Context.Session();
  2519. this.sample = new ApplicationInsights.Context.Sample(config.sampleRate());
  2520. }
  2521. }
  2522. TelemetryContext.prototype.addTelemetryInitializer = function (telemetryInitializer) {
  2523. this.telemetryInitializers = this.telemetryInitializers || [];
  2524. this.telemetryInitializers.push(telemetryInitializer);
  2525. };
  2526. TelemetryContext.prototype.track = function (envelope) {
  2527. if (!envelope) {
  2528. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_TrackArgumentsNotSpecified, "cannot call .track() with a null or undefined argument"));
  2529. }
  2530. else {
  2531. if (envelope.name === ApplicationInsights.Telemetry.PageView.envelopeType) {
  2532. ApplicationInsights._InternalLogging.resetInternalMessageCount();
  2533. }
  2534. if (this.session) {
  2535. if (typeof this.session.id !== "string") {
  2536. this._sessionManager.update();
  2537. }
  2538. }
  2539. this._track(envelope);
  2540. }
  2541. return envelope;
  2542. };
  2543. TelemetryContext.prototype._track = function (envelope) {
  2544. if (this.session) {
  2545. if (typeof this.session.id === "string") {
  2546. this._applySessionContext(envelope, this.session);
  2547. }
  2548. else {
  2549. this._applySessionContext(envelope, this._sessionManager.automaticSession);
  2550. }
  2551. }
  2552. this._applyApplicationContext(envelope, this.application);
  2553. this._applyDeviceContext(envelope, this.device);
  2554. this._applyInternalContext(envelope, this.internal);
  2555. this._applyLocationContext(envelope, this.location);
  2556. this._applySampleContext(envelope, this.sample);
  2557. this._applyUserContext(envelope, this.user);
  2558. this._applyOperationContext(envelope, this.operation);
  2559. envelope.iKey = this._config.instrumentationKey();
  2560. var doNotSendItem = false;
  2561. try {
  2562. this.telemetryInitializers = this.telemetryInitializers || [];
  2563. var telemetryInitializersCount = this.telemetryInitializers.length;
  2564. for (var i = 0; i < telemetryInitializersCount; ++i) {
  2565. var telemetryInitializer = this.telemetryInitializers[i];
  2566. if (telemetryInitializer) {
  2567. if (telemetryInitializer.apply(null, [envelope]) === false) {
  2568. doNotSendItem = true;
  2569. break;
  2570. }
  2571. }
  2572. }
  2573. }
  2574. catch (e) {
  2575. doNotSendItem = true;
  2576. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  2577. }
  2578. if (!doNotSendItem) {
  2579. if (envelope.name === ApplicationInsights.Telemetry.Metric.envelopeType ||
  2580. this.sample.isSampledIn(envelope)) {
  2581. var iKeyNoDashes = this._config.instrumentationKey().replace(/-/g, "");
  2582. envelope.name = envelope.name.replace("{0}", iKeyNoDashes);
  2583. this._sender.send(envelope);
  2584. }
  2585. else {
  2586. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TelemetrySampledAndNotSent, "Telemetry is sampled and not sent to the AI service.", { SampleRate: this.sample.sampleRate }));
  2587. }
  2588. }
  2589. return envelope;
  2590. };
  2591. TelemetryContext.prototype._applyApplicationContext = function (envelope, appContext) {
  2592. if (appContext) {
  2593. var tagKeys = new AI.ContextTagKeys();
  2594. if (typeof appContext.ver === "string") {
  2595. envelope.tags[tagKeys.applicationVersion] = appContext.ver;
  2596. }
  2597. if (typeof appContext.build === "string") {
  2598. envelope.tags[tagKeys.applicationBuild] = appContext.build;
  2599. }
  2600. }
  2601. };
  2602. TelemetryContext.prototype._applyDeviceContext = function (envelope, deviceContext) {
  2603. var tagKeys = new AI.ContextTagKeys();
  2604. if (deviceContext) {
  2605. if (typeof deviceContext.id === "string") {
  2606. envelope.tags[tagKeys.deviceId] = deviceContext.id;
  2607. }
  2608. if (typeof deviceContext.ip === "string") {
  2609. envelope.tags[tagKeys.deviceIp] = deviceContext.ip;
  2610. }
  2611. if (typeof deviceContext.language === "string") {
  2612. envelope.tags[tagKeys.deviceLanguage] = deviceContext.language;
  2613. }
  2614. if (typeof deviceContext.locale === "string") {
  2615. envelope.tags[tagKeys.deviceLocale] = deviceContext.locale;
  2616. }
  2617. if (typeof deviceContext.model === "string") {
  2618. envelope.tags[tagKeys.deviceModel] = deviceContext.model;
  2619. }
  2620. if (typeof deviceContext.network !== "undefined") {
  2621. envelope.tags[tagKeys.deviceNetwork] = deviceContext.network;
  2622. }
  2623. if (typeof deviceContext.oemName === "string") {
  2624. envelope.tags[tagKeys.deviceOEMName] = deviceContext.oemName;
  2625. }
  2626. if (typeof deviceContext.os === "string") {
  2627. envelope.tags[tagKeys.deviceOS] = deviceContext.os;
  2628. }
  2629. if (typeof deviceContext.osversion === "string") {
  2630. envelope.tags[tagKeys.deviceOSVersion] = deviceContext.osversion;
  2631. }
  2632. if (typeof deviceContext.resolution === "string") {
  2633. envelope.tags[tagKeys.deviceScreenResolution] = deviceContext.resolution;
  2634. }
  2635. if (typeof deviceContext.type === "string") {
  2636. envelope.tags[tagKeys.deviceType] = deviceContext.type;
  2637. }
  2638. }
  2639. };
  2640. TelemetryContext.prototype._applyInternalContext = function (envelope, internalContext) {
  2641. if (internalContext) {
  2642. var tagKeys = new AI.ContextTagKeys();
  2643. if (typeof internalContext.agentVersion === "string") {
  2644. envelope.tags[tagKeys.internalAgentVersion] = internalContext.agentVersion;
  2645. }
  2646. if (typeof internalContext.sdkVersion === "string") {
  2647. envelope.tags[tagKeys.internalSdkVersion] = internalContext.sdkVersion;
  2648. }
  2649. }
  2650. };
  2651. TelemetryContext.prototype._applyLocationContext = function (envelope, locationContext) {
  2652. if (locationContext) {
  2653. var tagKeys = new AI.ContextTagKeys();
  2654. if (typeof locationContext.ip === "string") {
  2655. envelope.tags[tagKeys.locationIp] = locationContext.ip;
  2656. }
  2657. }
  2658. };
  2659. TelemetryContext.prototype._applyOperationContext = function (envelope, operationContext) {
  2660. if (operationContext) {
  2661. var tagKeys = new AI.ContextTagKeys();
  2662. if (typeof operationContext.id === "string") {
  2663. envelope.tags[tagKeys.operationId] = operationContext.id;
  2664. }
  2665. if (typeof operationContext.name === "string") {
  2666. envelope.tags[tagKeys.operationName] = operationContext.name;
  2667. }
  2668. if (typeof operationContext.parentId === "string") {
  2669. envelope.tags[tagKeys.operationParentId] = operationContext.parentId;
  2670. }
  2671. if (typeof operationContext.rootId === "string") {
  2672. envelope.tags[tagKeys.operationRootId] = operationContext.rootId;
  2673. }
  2674. if (typeof operationContext.syntheticSource === "string") {
  2675. envelope.tags[tagKeys.operationSyntheticSource] = operationContext.syntheticSource;
  2676. }
  2677. }
  2678. };
  2679. TelemetryContext.prototype._applySampleContext = function (envelope, sampleContext) {
  2680. if (sampleContext) {
  2681. envelope.sampleRate = sampleContext.sampleRate;
  2682. }
  2683. };
  2684. TelemetryContext.prototype._applySessionContext = function (envelope, sessionContext) {
  2685. if (sessionContext) {
  2686. var tagKeys = new AI.ContextTagKeys();
  2687. if (typeof sessionContext.id === "string") {
  2688. envelope.tags[tagKeys.sessionId] = sessionContext.id;
  2689. }
  2690. if (typeof sessionContext.isFirst !== "undefined") {
  2691. envelope.tags[tagKeys.sessionIsFirst] = sessionContext.isFirst;
  2692. }
  2693. }
  2694. };
  2695. TelemetryContext.prototype._applyUserContext = function (envelope, userContext) {
  2696. if (userContext) {
  2697. var tagKeys = new AI.ContextTagKeys();
  2698. if (typeof userContext.accountId === "string") {
  2699. envelope.tags[tagKeys.userAccountId] = userContext.accountId;
  2700. }
  2701. if (typeof userContext.agent === "string") {
  2702. envelope.tags[tagKeys.userAgent] = userContext.agent;
  2703. }
  2704. if (typeof userContext.id === "string") {
  2705. envelope.tags[tagKeys.userId] = userContext.id;
  2706. }
  2707. if (typeof userContext.authenticatedId === "string") {
  2708. envelope.tags[tagKeys.userAuthUserId] = userContext.authenticatedId;
  2709. }
  2710. if (typeof userContext.storeRegion === "string") {
  2711. envelope.tags[tagKeys.userStoreRegion] = userContext.storeRegion;
  2712. }
  2713. }
  2714. };
  2715. return TelemetryContext;
  2716. })();
  2717. ApplicationInsights.TelemetryContext = TelemetryContext;
  2718. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2719. })(Microsoft || (Microsoft = {}));
  2720. /// <reference path="Base.ts" />
  2721. var Microsoft;
  2722. (function (Microsoft) {
  2723. var Telemetry;
  2724. (function (Telemetry) {
  2725. "use strict";
  2726. var Data = (function (_super) {
  2727. __extends(Data, _super);
  2728. function Data() {
  2729. _super.call(this);
  2730. }
  2731. return Data;
  2732. })(Microsoft.Telemetry.Base);
  2733. Telemetry.Data = Data;
  2734. })(Telemetry = Microsoft.Telemetry || (Microsoft.Telemetry = {}));
  2735. })(Microsoft || (Microsoft = {}));
  2736. /// <reference path="../../Contracts/Generated/Data.ts"/>
  2737. var Microsoft;
  2738. (function (Microsoft) {
  2739. var ApplicationInsights;
  2740. (function (ApplicationInsights) {
  2741. var Telemetry;
  2742. (function (Telemetry) {
  2743. var Common;
  2744. (function (Common) {
  2745. "use strict";
  2746. var Data = (function (_super) {
  2747. __extends(Data, _super);
  2748. function Data(type, data) {
  2749. _super.call(this);
  2750. this.aiDataContract = {
  2751. baseType: ApplicationInsights.FieldType.Required,
  2752. baseData: ApplicationInsights.FieldType.Required
  2753. };
  2754. this.baseType = type;
  2755. this.baseData = data;
  2756. }
  2757. return Data;
  2758. })(Microsoft.Telemetry.Data);
  2759. Common.Data = Data;
  2760. })(Common = Telemetry.Common || (Telemetry.Common = {}));
  2761. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2762. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2763. })(Microsoft || (Microsoft = {}));
  2764. /// <reference path="../Contracts/Generated/PageViewData.ts" />
  2765. /// <reference path="./Common/DataSanitizer.ts"/>
  2766. var Microsoft;
  2767. (function (Microsoft) {
  2768. var ApplicationInsights;
  2769. (function (ApplicationInsights) {
  2770. var Telemetry;
  2771. (function (Telemetry) {
  2772. "use strict";
  2773. var PageViewManager = (function () {
  2774. function PageViewManager(appInsights, overridePageViewDuration) {
  2775. this.pageViewPerformanceSent = false;
  2776. this.overridePageViewDuration = false;
  2777. this.overridePageViewDuration = overridePageViewDuration;
  2778. this.appInsights = appInsights;
  2779. }
  2780. PageViewManager.prototype.trackPageView = function (name, url, properties, measurements, duration) {
  2781. var _this = this;
  2782. if (typeof name !== "string") {
  2783. name = window.document && window.document.title || "";
  2784. }
  2785. if (typeof url !== "string") {
  2786. url = window.location && window.location.href || "";
  2787. }
  2788. var pageViewSent = false;
  2789. var customDuration = 0;
  2790. if (Telemetry.PageViewPerformance.isPerformanceTimingSupported()) {
  2791. var start = Telemetry.PageViewPerformance.getPerformanceTiming().navigationStart;
  2792. customDuration = Telemetry.PageViewPerformance.getDuration(start, +new Date);
  2793. }
  2794. else {
  2795. this.appInsights.sendPageViewInternal(name, url, !isNaN(duration) ? duration : 0, properties, measurements);
  2796. this.appInsights.flush();
  2797. pageViewSent = true;
  2798. }
  2799. if (this.overridePageViewDuration || !isNaN(duration)) {
  2800. this.appInsights.sendPageViewInternal(name, url, !isNaN(duration) ? duration : customDuration, properties, measurements);
  2801. this.appInsights.flush();
  2802. pageViewSent = true;
  2803. }
  2804. var maxDurationLimit = 60000;
  2805. if (!Telemetry.PageViewPerformance.isPerformanceTimingSupported()) {
  2806. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_NavigationTimingNotSupported, "trackPageView: navigation timing API used for calculation of page duration is not supported in this browser. This page view will be collected without duration and timing info."));
  2807. return;
  2808. }
  2809. var handle = setInterval(function () {
  2810. try {
  2811. if (Telemetry.PageViewPerformance.isPerformanceTimingDataReady()) {
  2812. clearInterval(handle);
  2813. var pageViewPerformance = new Telemetry.PageViewPerformance(name, url, null, properties, measurements);
  2814. if (!pageViewPerformance.getIsValid() && !pageViewSent) {
  2815. _this.appInsights.sendPageViewInternal(name, url, customDuration, properties, measurements);
  2816. _this.appInsights.flush();
  2817. }
  2818. else {
  2819. if (!pageViewSent) {
  2820. _this.appInsights.sendPageViewInternal(name, url, pageViewPerformance.getDurationMs(), properties, measurements);
  2821. }
  2822. if (!_this.pageViewPerformanceSent) {
  2823. _this.appInsights.sendPageViewPerformanceInternal(pageViewPerformance);
  2824. _this.pageViewPerformanceSent = true;
  2825. }
  2826. _this.appInsights.flush();
  2827. }
  2828. }
  2829. else if (Telemetry.PageViewPerformance.getDuration(start, +new Date) > maxDurationLimit) {
  2830. clearInterval(handle);
  2831. if (!pageViewSent) {
  2832. _this.appInsights.sendPageViewInternal(name, url, maxDurationLimit, properties, measurements);
  2833. _this.appInsights.flush();
  2834. }
  2835. }
  2836. }
  2837. catch (e) {
  2838. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TrackPVFailedCalc, "trackPageView failed on page load calculation: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  2839. }
  2840. }, 100);
  2841. };
  2842. return PageViewManager;
  2843. })();
  2844. Telemetry.PageViewManager = PageViewManager;
  2845. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2846. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2847. })(Microsoft || (Microsoft = {}));
  2848. /// <reference path="../AppInsights.ts" />
  2849. var Microsoft;
  2850. (function (Microsoft) {
  2851. var ApplicationInsights;
  2852. (function (ApplicationInsights) {
  2853. var Telemetry;
  2854. (function (Telemetry) {
  2855. "use strict";
  2856. var PageVisitTimeManager = (function () {
  2857. function PageVisitTimeManager(pageVisitTimeTrackingHandler) {
  2858. this.prevPageVisitDataKeyName = "prevPageVisitData";
  2859. this.pageVisitTimeTrackingHandler = pageVisitTimeTrackingHandler;
  2860. }
  2861. PageVisitTimeManager.prototype.trackPreviousPageVisit = function (currentPageName, currentPageUrl) {
  2862. try {
  2863. var prevPageVisitTimeData = this.restartPageVisitTimer(currentPageName, currentPageUrl);
  2864. if (prevPageVisitTimeData) {
  2865. this.pageVisitTimeTrackingHandler(prevPageVisitTimeData.pageName, prevPageVisitTimeData.pageUrl, prevPageVisitTimeData.pageVisitTime);
  2866. }
  2867. }
  2868. catch (e) {
  2869. ApplicationInsights._InternalLogging.warnToConsole("Auto track page visit time failed, metric will not be collected: " + ApplicationInsights.Util.dump(e));
  2870. }
  2871. };
  2872. PageVisitTimeManager.prototype.restartPageVisitTimer = function (pageName, pageUrl) {
  2873. try {
  2874. var prevPageVisitData = this.stopPageVisitTimer();
  2875. this.startPageVisitTimer(pageName, pageUrl);
  2876. return prevPageVisitData;
  2877. }
  2878. catch (e) {
  2879. ApplicationInsights._InternalLogging.warnToConsole("Call to restart failed: " + ApplicationInsights.Util.dump(e));
  2880. return null;
  2881. }
  2882. };
  2883. PageVisitTimeManager.prototype.startPageVisitTimer = function (pageName, pageUrl) {
  2884. try {
  2885. if (ApplicationInsights.Util.canUseSessionStorage()) {
  2886. if (ApplicationInsights.Util.getSessionStorage(this.prevPageVisitDataKeyName) != null) {
  2887. throw new Error("Cannot call startPageVisit consecutively without first calling stopPageVisit");
  2888. }
  2889. var currPageVisitData = new PageVisitData(pageName, pageUrl);
  2890. var currPageVisitDataStr = JSON.stringify(currPageVisitData);
  2891. ApplicationInsights.Util.setSessionStorage(this.prevPageVisitDataKeyName, currPageVisitDataStr);
  2892. }
  2893. }
  2894. catch (e) {
  2895. ApplicationInsights._InternalLogging.warnToConsole("Call to start failed: " + ApplicationInsights.Util.dump(e));
  2896. }
  2897. };
  2898. PageVisitTimeManager.prototype.stopPageVisitTimer = function () {
  2899. try {
  2900. if (ApplicationInsights.Util.canUseSessionStorage()) {
  2901. var pageVisitEndTime = Date.now();
  2902. var pageVisitDataJsonStr = ApplicationInsights.Util.getSessionStorage(this.prevPageVisitDataKeyName);
  2903. if (pageVisitDataJsonStr) {
  2904. var prevPageVisitData = JSON.parse(pageVisitDataJsonStr);
  2905. prevPageVisitData.pageVisitTime = pageVisitEndTime - prevPageVisitData.pageVisitStartTime;
  2906. ApplicationInsights.Util.removeSessionStorage(this.prevPageVisitDataKeyName);
  2907. return prevPageVisitData;
  2908. }
  2909. else {
  2910. return null;
  2911. }
  2912. }
  2913. return null;
  2914. }
  2915. catch (e) {
  2916. ApplicationInsights._InternalLogging.warnToConsole("Stop page visit timer failed: " + ApplicationInsights.Util.dump(e));
  2917. return null;
  2918. }
  2919. };
  2920. return PageVisitTimeManager;
  2921. })();
  2922. Telemetry.PageVisitTimeManager = PageVisitTimeManager;
  2923. var PageVisitData = (function () {
  2924. function PageVisitData(pageName, pageUrl) {
  2925. this.pageVisitStartTime = Date.now();
  2926. this.pageName = pageName;
  2927. this.pageUrl = pageUrl;
  2928. }
  2929. return PageVisitData;
  2930. })();
  2931. Telemetry.PageVisitData = PageVisitData;
  2932. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  2933. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  2934. })(Microsoft || (Microsoft = {}));
  2935. var AI;
  2936. (function (AI) {
  2937. "use strict";
  2938. (function (DependencyKind) {
  2939. DependencyKind[DependencyKind["SQL"] = 0] = "SQL";
  2940. DependencyKind[DependencyKind["Http"] = 1] = "Http";
  2941. DependencyKind[DependencyKind["Other"] = 2] = "Other";
  2942. })(AI.DependencyKind || (AI.DependencyKind = {}));
  2943. var DependencyKind = AI.DependencyKind;
  2944. })(AI || (AI = {}));
  2945. var AI;
  2946. (function (AI) {
  2947. "use strict";
  2948. (function (DependencySourceType) {
  2949. DependencySourceType[DependencySourceType["Undefined"] = 0] = "Undefined";
  2950. DependencySourceType[DependencySourceType["Aic"] = 1] = "Aic";
  2951. DependencySourceType[DependencySourceType["Apmc"] = 2] = "Apmc";
  2952. })(AI.DependencySourceType || (AI.DependencySourceType = {}));
  2953. var DependencySourceType = AI.DependencySourceType;
  2954. })(AI || (AI = {}));
  2955. /// <reference path="Domain.ts" />
  2956. /// <reference path="DataPointType.ts" />
  2957. /// <reference path="DependencyKind.ts" />
  2958. /// <reference path="DependencySourceType.ts" />
  2959. var AI;
  2960. (function (AI) {
  2961. "use strict";
  2962. var RemoteDependencyData = (function (_super) {
  2963. __extends(RemoteDependencyData, _super);
  2964. function RemoteDependencyData() {
  2965. this.ver = 2;
  2966. this.kind = AI.DataPointType.Aggregation;
  2967. this.dependencyKind = AI.DependencyKind.Other;
  2968. this.success = true;
  2969. this.dependencySource = AI.DependencySourceType.Apmc;
  2970. this.properties = {};
  2971. _super.call(this);
  2972. }
  2973. return RemoteDependencyData;
  2974. })(Microsoft.Telemetry.Domain);
  2975. AI.RemoteDependencyData = RemoteDependencyData;
  2976. })(AI || (AI = {}));
  2977. /// <reference path="../Contracts/Generated/PageViewData.ts" />
  2978. /// <reference path="./Common/DataSanitizer.ts"/>
  2979. /// <reference path="../Contracts/Generated/RemoteDependencyData.ts"/>
  2980. var Microsoft;
  2981. (function (Microsoft) {
  2982. var ApplicationInsights;
  2983. (function (ApplicationInsights) {
  2984. var Telemetry;
  2985. (function (Telemetry) {
  2986. "use strict";
  2987. var RemoteDependencyData = (function (_super) {
  2988. __extends(RemoteDependencyData, _super);
  2989. function RemoteDependencyData(id, name, commandName, value, success, resultCode) {
  2990. _super.call(this);
  2991. this.aiDataContract = {
  2992. id: ApplicationInsights.FieldType.Required,
  2993. ver: ApplicationInsights.FieldType.Required,
  2994. name: ApplicationInsights.FieldType.Default,
  2995. kind: ApplicationInsights.FieldType.Required,
  2996. value: ApplicationInsights.FieldType.Default,
  2997. count: ApplicationInsights.FieldType.Default,
  2998. min: ApplicationInsights.FieldType.Default,
  2999. max: ApplicationInsights.FieldType.Default,
  3000. stdDev: ApplicationInsights.FieldType.Default,
  3001. dependencyKind: ApplicationInsights.FieldType.Default,
  3002. success: ApplicationInsights.FieldType.Default,
  3003. async: ApplicationInsights.FieldType.Default,
  3004. dependencySource: ApplicationInsights.FieldType.Default,
  3005. commandName: ApplicationInsights.FieldType.Default,
  3006. dependencyTypeName: ApplicationInsights.FieldType.Default,
  3007. properties: ApplicationInsights.FieldType.Default,
  3008. resultCode: ApplicationInsights.FieldType.Default
  3009. };
  3010. this.id = id;
  3011. this.name = name;
  3012. this.commandName = commandName;
  3013. this.value = value;
  3014. this.success = success;
  3015. this.resultCode = resultCode + "";
  3016. this.dependencyKind = AI.DependencyKind.Http;
  3017. this.dependencyTypeName = "Ajax";
  3018. }
  3019. RemoteDependencyData.envelopeType = "Microsoft.ApplicationInsights.{0}.RemoteDependency";
  3020. RemoteDependencyData.dataType = "RemoteDependencyData";
  3021. return RemoteDependencyData;
  3022. })(AI.RemoteDependencyData);
  3023. Telemetry.RemoteDependencyData = RemoteDependencyData;
  3024. })(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
  3025. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  3026. })(Microsoft || (Microsoft = {}));
  3027. /// <reference path="telemetrycontext.ts" />
  3028. /// <reference path="./Telemetry/Common/Data.ts"/>
  3029. /// <reference path="./Util.ts"/>
  3030. /// <reference path="./Contracts/Generated/SessionState.ts"/>
  3031. /// <reference path="./Telemetry/PageViewManager.ts"/>
  3032. /// <reference path="./Telemetry/PageVisitTimeManager.ts"/>
  3033. /// <reference path="./Telemetry/RemoteDependencyData.ts"/>
  3034. /// <reference path="./ajax/ajax.ts"/>
  3035. /// <reference path="./DataLossAnalyzer.ts"/>
  3036. /// <reference path="./SplitTest.ts"/>
  3037. var Microsoft;
  3038. (function (Microsoft) {
  3039. var ApplicationInsights;
  3040. (function (ApplicationInsights) {
  3041. "use strict";
  3042. ApplicationInsights.Version = "0.22.9";
  3043. var AppInsights = (function () {
  3044. function AppInsights(config) {
  3045. var _this = this;
  3046. this._trackAjaxAttempts = 0;
  3047. this.config = config || {};
  3048. var defaults = AppInsights.defaultConfig;
  3049. if (defaults !== undefined) {
  3050. for (var field in defaults) {
  3051. if (this.config[field] === undefined) {
  3052. this.config[field] = defaults[field];
  3053. }
  3054. }
  3055. }
  3056. ApplicationInsights._InternalLogging.verboseLogging = function () { return _this.config.verboseLogging; };
  3057. ApplicationInsights._InternalLogging.enableDebugExceptions = function () { return _this.config.enableDebug; };
  3058. var configGetters = {
  3059. instrumentationKey: function () { return _this.config.instrumentationKey; },
  3060. accountId: function () { return _this.config.accountId; },
  3061. sessionRenewalMs: function () { return _this.config.sessionRenewalMs; },
  3062. sessionExpirationMs: function () { return _this.config.sessionExpirationMs; },
  3063. endpointUrl: function () { return _this.config.endpointUrl; },
  3064. emitLineDelimitedJson: function () { return _this.config.emitLineDelimitedJson; },
  3065. maxBatchSizeInBytes: function () { return _this.config.maxBatchSizeInBytes; },
  3066. maxBatchInterval: function () { return _this.config.maxBatchInterval; },
  3067. disableTelemetry: function () { return _this.config.disableTelemetry; },
  3068. sampleRate: function () { return _this.config.samplingPercentage; },
  3069. cookieDomain: function () { return _this.config.cookieDomain; }
  3070. };
  3071. this.context = new ApplicationInsights.TelemetryContext(configGetters);
  3072. this._pageViewManager = new Microsoft.ApplicationInsights.Telemetry.PageViewManager(this, this.config.overridePageViewDuration);
  3073. this._eventTracking = new Timing("trackEvent");
  3074. this._eventTracking.action = function (name, url, duration, properties, measurements) {
  3075. if (!measurements) {
  3076. measurements = { duration: duration };
  3077. }
  3078. else {
  3079. if (isNaN(measurements["duration"])) {
  3080. measurements["duration"] = duration;
  3081. }
  3082. }
  3083. var event = new ApplicationInsights.Telemetry.Event(name, properties, measurements);
  3084. var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Event.dataType, event);
  3085. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Event.envelopeType);
  3086. _this.context.track(envelope);
  3087. };
  3088. this._pageTracking = new Timing("trackPageView");
  3089. this._pageTracking.action = function (name, url, duration, properties, measurements) {
  3090. _this.sendPageViewInternal(name, url, duration, properties, measurements);
  3091. };
  3092. this._pageVisitTimeManager = new ApplicationInsights.Telemetry.PageVisitTimeManager(function (pageName, pageUrl, pageVisitTime) { return _this.trackPageVisitTime(pageName, pageUrl, pageVisitTime); });
  3093. if (!this.config.disableAjaxTracking) {
  3094. new Microsoft.ApplicationInsights.AjaxMonitor(this);
  3095. }
  3096. }
  3097. AppInsights.prototype.sendPageViewInternal = function (name, url, duration, properties, measurements) {
  3098. var pageView = new ApplicationInsights.Telemetry.PageView(name, url, duration, properties, measurements);
  3099. var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.PageView.dataType, pageView);
  3100. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.PageView.envelopeType);
  3101. this.context.track(envelope);
  3102. this._trackAjaxAttempts = 0;
  3103. };
  3104. AppInsights.prototype.sendPageViewPerformanceInternal = function (pageViewPerformance) {
  3105. var pageViewPerformanceData = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.PageViewPerformance.dataType, pageViewPerformance);
  3106. var pageViewPerformanceEnvelope = new ApplicationInsights.Telemetry.Common.Envelope(pageViewPerformanceData, ApplicationInsights.Telemetry.PageViewPerformance.envelopeType);
  3107. this.context.track(pageViewPerformanceEnvelope);
  3108. };
  3109. AppInsights.prototype.startTrackPage = function (name) {
  3110. try {
  3111. if (typeof name !== "string") {
  3112. name = window.document && window.document.title || "";
  3113. }
  3114. this._pageTracking.start(name);
  3115. }
  3116. catch (e) {
  3117. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_StartTrackFailed, "startTrackPage failed, page view may not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3118. }
  3119. };
  3120. AppInsights.prototype.stopTrackPage = function (name, url, properties, measurements) {
  3121. try {
  3122. if (typeof name !== "string") {
  3123. name = window.document && window.document.title || "";
  3124. }
  3125. if (typeof url !== "string") {
  3126. url = window.location && window.location.href || "";
  3127. }
  3128. this._pageTracking.stop(name, url, properties, measurements);
  3129. if (this.config.autoTrackPageVisitTime) {
  3130. this._pageVisitTimeManager.trackPreviousPageVisit(name, url);
  3131. }
  3132. }
  3133. catch (e) {
  3134. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_StopTrackFailed, "stopTrackPage failed, page view will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3135. }
  3136. };
  3137. AppInsights.prototype.trackPageView = function (name, url, properties, measurements, duration) {
  3138. try {
  3139. this._pageViewManager.trackPageView(name, url, properties, measurements, duration);
  3140. if (this.config.autoTrackPageVisitTime) {
  3141. this._pageVisitTimeManager.trackPreviousPageVisit(name, url);
  3142. }
  3143. }
  3144. catch (e) {
  3145. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TrackPVFailed, "trackPageView failed, page view will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3146. }
  3147. };
  3148. AppInsights.prototype.startTrackEvent = function (name) {
  3149. try {
  3150. this._eventTracking.start(name);
  3151. }
  3152. catch (e) {
  3153. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_StartTrackEventFailed, "startTrackEvent failed, event will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3154. }
  3155. };
  3156. AppInsights.prototype.stopTrackEvent = function (name, properties, measurements) {
  3157. try {
  3158. this._eventTracking.stop(name, undefined, properties, measurements);
  3159. }
  3160. catch (e) {
  3161. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_StopTrackEventFailed, "stopTrackEvent failed, event will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3162. }
  3163. };
  3164. AppInsights.prototype.trackEvent = function (name, properties, measurements) {
  3165. try {
  3166. var eventTelemetry = new ApplicationInsights.Telemetry.Event(name, properties, measurements);
  3167. var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Event.dataType, eventTelemetry);
  3168. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Event.envelopeType);
  3169. this.context.track(envelope);
  3170. }
  3171. catch (e) {
  3172. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TrackEventFailed, "trackEvent failed, event will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3173. }
  3174. };
  3175. AppInsights.prototype.trackAjax = function (id, absoluteUrl, pathName, totalTime, success, resultCode) {
  3176. if (this.config.maxAjaxCallsPerView === -1 ||
  3177. this._trackAjaxAttempts < this.config.maxAjaxCallsPerView) {
  3178. var dependency = new ApplicationInsights.Telemetry.RemoteDependencyData(id, absoluteUrl, pathName, totalTime, success, resultCode);
  3179. var dependencyData = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.RemoteDependencyData.dataType, dependency);
  3180. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(dependencyData, ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType);
  3181. this.context.track(envelope);
  3182. }
  3183. else if (this._trackAjaxAttempts === this.config.maxAjaxCallsPerView) {
  3184. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_MaxAjaxPerPVExceeded, "Maximum ajax per page view limit reached, ajax monitoring is paused until the next trackPageView(). In order to increase the limit set the maxAjaxCallsPerView configuration parameter."));
  3185. }
  3186. ++this._trackAjaxAttempts;
  3187. };
  3188. AppInsights.prototype.trackException = function (exception, handledAt, properties, measurements) {
  3189. try {
  3190. if (!ApplicationInsights.Util.isError(exception)) {
  3191. try {
  3192. throw new Error(exception);
  3193. }
  3194. catch (error) {
  3195. exception = error;
  3196. }
  3197. }
  3198. var exceptionTelemetry = new ApplicationInsights.Telemetry.Exception(exception, handledAt, properties, measurements);
  3199. var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Exception.dataType, exceptionTelemetry);
  3200. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Exception.envelopeType);
  3201. this.context.track(envelope);
  3202. }
  3203. catch (e) {
  3204. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TrackExceptionFailed, "trackException failed, exception will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3205. }
  3206. };
  3207. AppInsights.prototype.trackMetric = function (name, average, sampleCount, min, max, properties) {
  3208. try {
  3209. var telemetry = new ApplicationInsights.Telemetry.Metric(name, average, sampleCount, min, max, properties);
  3210. var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Metric.dataType, telemetry);
  3211. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Metric.envelopeType);
  3212. this.context.track(envelope);
  3213. }
  3214. catch (e) {
  3215. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TrackMetricFailed, "trackMetric failed, metric will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3216. }
  3217. };
  3218. AppInsights.prototype.trackTrace = function (message, properties) {
  3219. try {
  3220. var telemetry = new ApplicationInsights.Telemetry.Trace(message, properties);
  3221. var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Trace.dataType, telemetry);
  3222. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Trace.envelopeType);
  3223. this.context.track(envelope);
  3224. }
  3225. catch (e) {
  3226. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_TrackTraceFailed, "trackTrace failed, trace will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3227. }
  3228. };
  3229. AppInsights.prototype.trackPageVisitTime = function (pageName, pageUrl, pageVisitTime) {
  3230. var properties = { PageName: pageName, PageUrl: pageUrl };
  3231. this.trackMetric("PageVisitTime", pageVisitTime, 1, pageVisitTime, pageVisitTime, properties);
  3232. };
  3233. AppInsights.prototype.flush = function () {
  3234. try {
  3235. this.context._sender.triggerSend();
  3236. }
  3237. catch (e) {
  3238. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FlushFailed, "flush failed, telemetry will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3239. }
  3240. };
  3241. AppInsights.prototype.setAuthenticatedUserContext = function (authenticatedUserId, accountId) {
  3242. try {
  3243. this.context.user.setAuthenticatedUserContext(authenticatedUserId, accountId);
  3244. }
  3245. catch (e) {
  3246. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_SetAuthContextFailed, "Setting auth user context failed. " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3247. }
  3248. };
  3249. AppInsights.prototype.clearAuthenticatedUserContext = function () {
  3250. try {
  3251. this.context.user.clearAuthenticatedUserContext();
  3252. }
  3253. catch (e) {
  3254. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_SetAuthContextFailed, "Clearing auth user context failed. " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) }));
  3255. }
  3256. };
  3257. AppInsights.prototype.SendCORSException = function (properties) {
  3258. var exceptionData = Microsoft.ApplicationInsights.Telemetry.Exception.CreateSimpleException("Script error.", "Error", "unknown", "unknown", "The browser’s same-origin policy prevents us from getting the details of this exception.The exception occurred in a script loaded from an origin different than the web page.For cross- domain error reporting you can use crossorigin attribute together with appropriate CORS HTTP headers.For more information please see http://www.w3.org/TR/cors/.", 0, null);
  3259. exceptionData.properties = properties;
  3260. var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Exception.dataType, exceptionData);
  3261. var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Exception.envelopeType);
  3262. this.context.track(envelope);
  3263. };
  3264. AppInsights.prototype._onerror = function (message, url, lineNumber, columnNumber, error) {
  3265. try {
  3266. var properties = { url: url ? url : document.URL };
  3267. if (ApplicationInsights.Util.isCrossOriginError(message, url, lineNumber, columnNumber, error)) {
  3268. this.SendCORSException(properties);
  3269. }
  3270. else {
  3271. if (!ApplicationInsights.Util.isError(error)) {
  3272. var stack = "window.onerror@" + properties.url + ":" + lineNumber + ":" + (columnNumber || 0);
  3273. error = new Error(message);
  3274. error["stack"] = stack;
  3275. }
  3276. this.trackException(error, null, properties);
  3277. }
  3278. }
  3279. catch (exception) {
  3280. var errorString = error ? (error.name + ", " + error.message) : "null";
  3281. var exceptionDump = ApplicationInsights.Util.dump(exception);
  3282. ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_ExceptionWhileLoggingError, "_onerror threw exception while logging error, error will not be collected: " + ApplicationInsights.Util.getExceptionName(exception), { exception: exceptionDump, errorString: errorString }));
  3283. }
  3284. };
  3285. return AppInsights;
  3286. })();
  3287. ApplicationInsights.AppInsights = AppInsights;
  3288. var Timing = (function () {
  3289. function Timing(name) {
  3290. this._name = name;
  3291. this._events = {};
  3292. }
  3293. Timing.prototype.start = function (name) {
  3294. if (typeof this._events[name] !== "undefined") {
  3295. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.", { name: this._name, key: name }));
  3296. }
  3297. this._events[name] = +new Date;
  3298. };
  3299. Timing.prototype.stop = function (name, url, properties, measurements) {
  3300. var start = this._events[name];
  3301. if (isNaN(start)) {
  3302. ApplicationInsights._InternalLogging.throwInternalUserActionable(ApplicationInsights.LoggingSeverity.WARNING, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.USRACT_StopCalledWithoutStart, "stop was called without a corresponding start.", { name: this._name, key: name }));
  3303. }
  3304. else {
  3305. var end = +new Date;
  3306. var duration = ApplicationInsights.Telemetry.PageViewPerformance.getDuration(start, end);
  3307. this.action(name, url, duration, properties, measurements);
  3308. }
  3309. delete this._events[name];
  3310. this._events[name] = undefined;
  3311. };
  3312. return Timing;
  3313. })();
  3314. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  3315. })(Microsoft || (Microsoft = {}));
  3316. /// <reference path="PageViewData.ts" />
  3317. var AI;
  3318. (function (AI) {
  3319. "use strict";
  3320. var AjaxCallData = (function (_super) {
  3321. __extends(AjaxCallData, _super);
  3322. function AjaxCallData() {
  3323. this.ver = 2;
  3324. this.properties = {};
  3325. this.measurements = {};
  3326. _super.call(this);
  3327. }
  3328. return AjaxCallData;
  3329. })(AI.PageViewData);
  3330. AI.AjaxCallData = AjaxCallData;
  3331. })(AI || (AI = {}));
  3332. /// <reference path="Domain.ts" />
  3333. var AI;
  3334. (function (AI) {
  3335. "use strict";
  3336. var RequestData = (function (_super) {
  3337. __extends(RequestData, _super);
  3338. function RequestData() {
  3339. this.ver = 2;
  3340. this.properties = {};
  3341. this.measurements = {};
  3342. _super.call(this);
  3343. }
  3344. return RequestData;
  3345. })(Microsoft.Telemetry.Domain);
  3346. AI.RequestData = RequestData;
  3347. })(AI || (AI = {}));
  3348. /// <reference path="Domain.ts" />
  3349. /// <reference path="SessionState.ts" />
  3350. var AI;
  3351. (function (AI) {
  3352. "use strict";
  3353. var SessionStateData = (function (_super) {
  3354. __extends(SessionStateData, _super);
  3355. function SessionStateData() {
  3356. this.ver = 2;
  3357. this.state = AI.SessionState.Start;
  3358. _super.call(this);
  3359. }
  3360. return SessionStateData;
  3361. })(Microsoft.Telemetry.Domain);
  3362. AI.SessionStateData = SessionStateData;
  3363. })(AI || (AI = {}));
  3364. /// <reference path="appinsights.ts" />
  3365. var Microsoft;
  3366. (function (Microsoft) {
  3367. var ApplicationInsights;
  3368. (function (ApplicationInsights) {
  3369. "use strict";
  3370. var Initialization = (function () {
  3371. function Initialization(snippet) {
  3372. snippet.queue = snippet.queue || [];
  3373. var config = snippet.config || {};
  3374. if (config && !config.instrumentationKey) {
  3375. config = snippet;
  3376. if (config["iKey"]) {
  3377. Microsoft.ApplicationInsights.Version = "0.10.0.0";
  3378. config.instrumentationKey = config["iKey"];
  3379. }
  3380. else if (config["applicationInsightsId"]) {
  3381. Microsoft.ApplicationInsights.Version = "0.7.2.0";
  3382. config.instrumentationKey = config["applicationInsightsId"];
  3383. }
  3384. else {
  3385. throw new Error("Cannot load Application Insights SDK, no instrumentationKey was provided.");
  3386. }
  3387. }
  3388. config = Initialization.getDefaultConfig(config);
  3389. this.snippet = snippet;
  3390. this.config = config;
  3391. }
  3392. Initialization.prototype.loadAppInsights = function () {
  3393. var appInsights = new Microsoft.ApplicationInsights.AppInsights(this.config);
  3394. if (this.config["iKey"]) {
  3395. var originalTrackPageView = appInsights.trackPageView;
  3396. appInsights.trackPageView = function (pagePath, properties, measurements) {
  3397. originalTrackPageView.apply(appInsights, [null, pagePath, properties, measurements]);
  3398. };
  3399. }
  3400. var legacyPageView = "logPageView";
  3401. if (typeof this.snippet[legacyPageView] === "function") {
  3402. appInsights[legacyPageView] = function (pagePath, properties, measurements) {
  3403. appInsights.trackPageView(null, pagePath, properties, measurements);
  3404. };
  3405. }
  3406. var legacyEvent = "logEvent";
  3407. if (typeof this.snippet[legacyEvent] === "function") {
  3408. appInsights[legacyEvent] = function (name, properties, measurements) {
  3409. appInsights.trackEvent(name, properties, measurements);
  3410. };
  3411. }
  3412. return appInsights;
  3413. };
  3414. Initialization.prototype.emptyQueue = function () {
  3415. try {
  3416. if (Microsoft.ApplicationInsights.Util.isArray(this.snippet.queue)) {
  3417. var length = this.snippet.queue.length;
  3418. for (var i = 0; i < length; i++) {
  3419. var call = this.snippet.queue[i];
  3420. call();
  3421. }
  3422. this.snippet.queue = undefined;
  3423. delete this.snippet.queue;
  3424. }
  3425. }
  3426. catch (exception) {
  3427. var properties = {};
  3428. if (exception && typeof exception.toString === "function") {
  3429. properties.exception = exception.toString();
  3430. }
  3431. var message = new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedToSendQueuedTelemetry, "Failed to send queued telemetry", properties);
  3432. Microsoft.ApplicationInsights._InternalLogging.throwInternalNonUserActionable(ApplicationInsights.LoggingSeverity.WARNING, message);
  3433. }
  3434. };
  3435. Initialization.prototype.pollInteralLogs = function (appInsightsInstance) {
  3436. return setInterval(function () {
  3437. var queue = Microsoft.ApplicationInsights._InternalLogging.queue;
  3438. var length = queue.length;
  3439. for (var i = 0; i < length; i++) {
  3440. appInsightsInstance.trackTrace(queue[i].message);
  3441. }
  3442. queue.length = 0;
  3443. }, this.config.diagnosticLogInterval);
  3444. };
  3445. Initialization.prototype.addHousekeepingBeforeUnload = function (appInsightsInstance) {
  3446. // Add callback to push events when the user navigates away
  3447. if (!appInsightsInstance.config.disableFlushOnBeforeUnload && ('onbeforeunload' in window)) {
  3448. var performHousekeeping = function () {
  3449. appInsightsInstance.context._sender.triggerSend();
  3450. appInsightsInstance.context._sessionManager.backup();
  3451. };
  3452. if (!Microsoft.ApplicationInsights.Util.addEventHandler('beforeunload', performHousekeeping)) {
  3453. Microsoft.ApplicationInsights._InternalLogging.throwInternalNonUserActionable(Microsoft.ApplicationInsights.LoggingSeverity.CRITICAL, new ApplicationInsights._InternalLogMessage(ApplicationInsights._InternalMessageId.NONUSRACT_FailedToAddHandlerForOnBeforeUnload, 'Could not add handler for beforeunload'));
  3454. }
  3455. }
  3456. };
  3457. Initialization.getDefaultConfig = function (config) {
  3458. if (!config) {
  3459. config = {};
  3460. }
  3461. config.endpointUrl = config.endpointUrl || "//dc.services.visualstudio.com/v2/track";
  3462. config.sessionRenewalMs = 30 * 60 * 1000;
  3463. config.sessionExpirationMs = 24 * 60 * 60 * 1000;
  3464. config.maxBatchSizeInBytes = config.maxBatchSizeInBytes > 0 ? config.maxBatchSizeInBytes : 1000000;
  3465. config.maxBatchInterval = !isNaN(config.maxBatchInterval) ? config.maxBatchInterval : 15000;
  3466. config.enableDebug = ApplicationInsights.Util.stringToBoolOrDefault(config.enableDebug);
  3467. config.disableExceptionTracking = (config.disableExceptionTracking !== undefined && config.disableExceptionTracking !== null) ?
  3468. ApplicationInsights.Util.stringToBoolOrDefault(config.disableExceptionTracking) :
  3469. false;
  3470. config.disableTelemetry = ApplicationInsights.Util.stringToBoolOrDefault(config.disableTelemetry);
  3471. config.verboseLogging = ApplicationInsights.Util.stringToBoolOrDefault(config.verboseLogging);
  3472. config.emitLineDelimitedJson = ApplicationInsights.Util.stringToBoolOrDefault(config.emitLineDelimitedJson);
  3473. config.diagnosticLogInterval = config.diagnosticLogInterval || 10000;
  3474. config.autoTrackPageVisitTime = ApplicationInsights.Util.stringToBoolOrDefault(config.autoTrackPageVisitTime);
  3475. if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
  3476. config.samplingPercentage = 100;
  3477. }
  3478. config.disableAjaxTracking = (config.disableAjaxTracking !== undefined && config.disableAjaxTracking !== null) ?
  3479. ApplicationInsights.Util.stringToBoolOrDefault(config.disableAjaxTracking) :
  3480. false;
  3481. config.maxAjaxCallsPerView = !isNaN(config.maxAjaxCallsPerView) ? config.maxAjaxCallsPerView : 500;
  3482. config.disableCorrelationHeaders = (config.disableCorrelationHeaders !== undefined && config.disableCorrelationHeaders !== null) ?
  3483. ApplicationInsights.Util.stringToBoolOrDefault(config.disableCorrelationHeaders) :
  3484. true;
  3485. config.disableFlushOnBeforeUnload = (config.disableFlushOnBeforeUnload !== undefined && config.disableFlushOnBeforeUnload !== null) ?
  3486. ApplicationInsights.Util.stringToBoolOrDefault(config.disableFlushOnBeforeUnload) :
  3487. false;
  3488. return config;
  3489. };
  3490. return Initialization;
  3491. })();
  3492. ApplicationInsights.Initialization = Initialization;
  3493. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  3494. })(Microsoft || (Microsoft = {}));
  3495. /// <reference path="initialization.ts" />
  3496. var Microsoft;
  3497. (function (Microsoft) {
  3498. var ApplicationInsights;
  3499. (function (ApplicationInsights) {
  3500. "use strict";
  3501. try {
  3502. if (typeof window !== "undefined" && typeof JSON !== "undefined") {
  3503. var aiName = "appInsights";
  3504. if (window[aiName] === undefined) {
  3505. Microsoft.ApplicationInsights.AppInsights.defaultConfig = Microsoft.ApplicationInsights.Initialization.getDefaultConfig();
  3506. }
  3507. else {
  3508. var snippet = window[aiName] || {};
  3509. var init = new Microsoft.ApplicationInsights.Initialization(snippet);
  3510. var appInsightsLocal = init.loadAppInsights();
  3511. for (var field in appInsightsLocal) {
  3512. snippet[field] = appInsightsLocal[field];
  3513. }
  3514. init.emptyQueue();
  3515. init.pollInteralLogs(appInsightsLocal);
  3516. init.addHousekeepingBeforeUnload(appInsightsLocal);
  3517. }
  3518. }
  3519. }
  3520. catch (e) {
  3521. Microsoft.ApplicationInsights._InternalLogging.warnToConsole('Failed to initialize AppInsights JS SDK: ' + e.message);
  3522. }
  3523. })(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
  3524. })(Microsoft || (Microsoft = {}));