@microsoft/applicationinsights-react-js 3.3.2-nightly.2204-22 → 3.3.3-nightly.2205-03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - React Plugin, 3.3.2-nightly.2204-22
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.3-nightly.2205-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -122,7 +122,7 @@
122
122
  }
123
123
 
124
124
  /*!
125
- * Microsoft Dynamic Proto Utility, 1.1.4
125
+ * Microsoft Dynamic Proto Utility, 1.1.6
126
126
  * Copyright (c) Microsoft and contributors. All rights reserved.
127
127
  */
128
128
  var Constructor = 'constructor';
@@ -137,10 +137,13 @@
137
137
  var DynProtoDefaultOptions = '_dfOpts';
138
138
  var UnknownValue = '_unknown_';
139
139
  var str__Proto$1 = "__proto__";
140
+ var DynProtoBaseProto = "_dyn" + str__Proto$1;
141
+ var DynProtoCurrent = "_dynInstProto";
140
142
  var strUseBaseInst = 'useBaseInst';
141
143
  var strSetInstFuncs = 'setInstFuncs';
142
144
  var Obj = Object;
143
145
  var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
146
+ var _objGetOwnProps = Obj["getOwnPropertyNames"];
144
147
  var _dynamicNames = 0;
145
148
  function _hasOwnProperty(obj, prop) {
146
149
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -152,22 +155,25 @@
152
155
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
153
156
  }
154
157
  function _getObjProto$1(target) {
158
+ var newProto;
155
159
  if (target) {
156
160
  if (_objGetPrototypeOf$1) {
157
161
  return _objGetPrototypeOf$1(target);
158
162
  }
159
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
160
- if (newProto) {
161
- return newProto;
163
+ var curProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
164
+ newProto = target[DynProtoBaseProto] || curProto;
165
+ if (!_hasOwnProperty(target, DynProtoBaseProto)) {
166
+ delete target[DynProtoCurrent];
167
+ newProto = target[DynProtoBaseProto] = target[DynProtoCurrent] || target[DynProtoBaseProto];
168
+ target[DynProtoCurrent] = curProto;
162
169
  }
163
170
  }
164
- return null;
171
+ return newProto;
165
172
  }
166
173
  function _forEachProp(target, func) {
167
174
  var props = [];
168
- var getOwnProps = Obj["getOwnPropertyNames"];
169
- if (getOwnProps) {
170
- props = getOwnProps(target);
175
+ if (_objGetOwnProps) {
176
+ props = _objGetOwnProps(target);
171
177
  }
172
178
  else {
173
179
  for (var name_1 in target) {
@@ -316,8 +322,9 @@
316
322
  visited.push(thisProto);
317
323
  thisProto = _getObjProto$1(thisProto);
318
324
  }
325
+ return false;
319
326
  }
320
- return false;
327
+ return true;
321
328
  }
322
329
  function _getObjName(target, unknownValue) {
323
330
  if (_hasOwnProperty(target, Prototype)) {
@@ -371,23 +378,16 @@
371
378
  var strDisabled = "disabled";
372
379
  var strDoTeardown = "_doTeardown";
373
380
 
374
- var strToISOString = "toISOString";
375
381
  var cStrEndsWith = "endsWith";
376
- var strIndexOf = "indexOf";
377
- var strMap = "map";
378
- var strReduce = "reduce";
379
382
  var cStrTrim = "trim";
380
383
  var strToString = "toString";
381
384
  var str__Proto = "__proto__";
382
385
  var strConstructor = "constructor";
383
386
  var _objDefineProperty$1 = ObjDefineProperty;
384
387
  var _objFreeze = ObjClass.freeze;
385
- var _objKeys = ObjClass.keys;
386
388
  var StringProto = String[strShimPrototype];
387
389
  var _strTrim = StringProto[cStrTrim];
388
390
  var _strEndsWith = StringProto[cStrEndsWith];
389
- var DateProto = Date[strShimPrototype];
390
- var _dataToISOString = DateProto[strToISOString];
391
391
  var _isArray = Array.isArray;
392
392
  var _objToString = ObjProto[strToString];
393
393
  var _fnToString = ObjHasOwnProperty[strToString];
@@ -408,9 +408,6 @@
408
408
  }
409
409
  return null;
410
410
  }
411
- function isTypeof(value, theType) {
412
- return typeof value === theType;
413
- }
414
411
  function isUndefined(value) {
415
412
  return value === undefined || typeof value === strShimUndefined;
416
413
  }
@@ -420,9 +417,6 @@
420
417
  function isNotNullOrUndefined(value) {
421
418
  return !isNullOrUndefined(value);
422
419
  }
423
- function hasOwnProperty(obj, prop) {
424
- return !!(obj && ObjHasOwnProperty.call(obj, prop));
425
- }
426
420
  function isObject(value) {
427
421
  return !!(value && typeof value === strShimObject);
428
422
  }
@@ -480,9 +474,6 @@
480
474
  }
481
475
  return false;
482
476
  }
483
- function isDate(obj) {
484
- return !!(obj && _objToString.call(obj) === "[object Date]");
485
- }
486
477
  var isArray = _isArray || _isArrayPoly;
487
478
  function _isArrayPoly(obj) {
488
479
  return !!(obj && _objToString.call(obj) === "[object Array]");
@@ -493,9 +484,6 @@
493
484
  function isString(value) {
494
485
  return typeof value === "string";
495
486
  }
496
- function isNumber(value) {
497
- return typeof value === "number";
498
- }
499
487
  function isBoolean(value) {
500
488
  return typeof value === "boolean";
501
489
  }
@@ -515,30 +503,6 @@
515
503
  }
516
504
  return result;
517
505
  }
518
- function toISOString(date) {
519
- if (date) {
520
- return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
521
- }
522
- }
523
- function _toISOStringPoly(date) {
524
- if (date && date.getUTCFullYear) {
525
- var pad = function (num) {
526
- var r = String(num);
527
- if (r.length === 1) {
528
- r = "0" + r;
529
- }
530
- return r;
531
- };
532
- return date.getUTCFullYear()
533
- + "-" + pad(date.getUTCMonth() + 1)
534
- + "-" + pad(date.getUTCDate())
535
- + "T" + pad(date.getUTCHours())
536
- + ":" + pad(date.getUTCMinutes())
537
- + ":" + pad(date.getUTCSeconds())
538
- + "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
539
- + "Z";
540
- }
541
- }
542
506
  function arrForEach(arr, callbackfn, thisArg) {
543
507
  var len = arr.length;
544
508
  try {
@@ -553,112 +517,12 @@
553
517
  catch (e) {
554
518
  }
555
519
  }
556
- function arrIndexOf(arr, searchElement, fromIndex) {
557
- if (arr) {
558
- if (arr[strIndexOf]) {
559
- return arr[strIndexOf](searchElement, fromIndex);
560
- }
561
- var len = arr.length;
562
- var from = fromIndex || 0;
563
- try {
564
- for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
565
- if (lp in arr && arr[lp] === searchElement) {
566
- return lp;
567
- }
568
- }
569
- }
570
- catch (e) {
571
- }
572
- }
573
- return -1;
574
- }
575
- function arrMap(arr, callbackfn, thisArg) {
576
- var results;
577
- if (arr) {
578
- if (arr[strMap]) {
579
- return arr[strMap](callbackfn, thisArg);
580
- }
581
- var len = arr.length;
582
- var _this = thisArg || arr;
583
- results = new Array(len);
584
- try {
585
- for (var lp = 0; lp < len; lp++) {
586
- if (lp in arr) {
587
- results[lp] = callbackfn.call(_this, arr[lp], arr);
588
- }
589
- }
590
- }
591
- catch (e) {
592
- }
593
- }
594
- return results;
595
- }
596
- function arrReduce(arr, callbackfn, initialValue) {
597
- var value;
598
- if (arr) {
599
- if (arr[strReduce]) {
600
- return arr[strReduce](callbackfn, initialValue);
601
- }
602
- var len = arr.length;
603
- var lp = 0;
604
- if (arguments.length >= 3) {
605
- value = arguments[2];
606
- }
607
- else {
608
- while (lp < len && !(lp in arr)) {
609
- lp++;
610
- }
611
- value = arr[lp++];
612
- }
613
- while (lp < len) {
614
- if (lp in arr) {
615
- value = callbackfn(value, arr[lp], lp, arr);
616
- }
617
- lp++;
618
- }
619
- }
620
- return value;
621
- }
622
520
  function strTrim(str) {
623
521
  if (str) {
624
522
  str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
625
523
  }
626
524
  return str;
627
525
  }
628
- var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
629
- var _objKeysDontEnums = [
630
- "toString",
631
- "toLocaleString",
632
- "valueOf",
633
- "hasOwnProperty",
634
- "isPrototypeOf",
635
- "propertyIsEnumerable",
636
- "constructor"
637
- ];
638
- function objKeys(obj) {
639
- var objType = typeof obj;
640
- if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
641
- throwTypeError("objKeys called on non-object");
642
- }
643
- if (!_objKeysHasDontEnumBug && _objKeys) {
644
- return _objKeys(obj);
645
- }
646
- var result = [];
647
- for (var prop in obj) {
648
- if (obj && ObjHasOwnProperty.call(obj, prop)) {
649
- result.push(prop);
650
- }
651
- }
652
- if (_objKeysHasDontEnumBug) {
653
- var dontEnumsLength = _objKeysDontEnums.length;
654
- for (var lp = 0; lp < dontEnumsLength; lp++) {
655
- if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
656
- result.push(_objKeysDontEnums[lp]);
657
- }
658
- }
659
- }
660
- return result;
661
- }
662
526
  function objDefineAccessors(target, prop, getProp, setProp) {
663
527
  if (_objDefineProperty$1) {
664
528
  try {
@@ -813,7 +677,6 @@
813
677
  var strNavigator = "navigator";
814
678
  var strLocation = "location";
815
679
  var strConsole = "console";
816
- var strPerformance = "performance";
817
680
  var strJSON = "JSON";
818
681
  var strCrypto = "crypto";
819
682
  var strMsCrypto = "msCrypto";
@@ -835,12 +698,6 @@
835
698
  function hasWindow() {
836
699
  return Boolean(typeof window === strShimObject && window);
837
700
  }
838
- function getWindow() {
839
- if (hasWindow()) {
840
- return window;
841
- }
842
- return getGlobalInst(strWindow);
843
- }
844
701
  function hasDocument() {
845
702
  return Boolean(typeof document === strShimObject && document);
846
703
  }
@@ -877,9 +734,6 @@
877
734
  }
878
735
  return getGlobalInst(strConsole);
879
736
  }
880
- function getPerformance() {
881
- return getGlobalInst(strPerformance);
882
- }
883
737
  function hasJSON() {
884
738
  return Boolean((typeof JSON === strShimObject && JSON) || getGlobalInst(strJSON) !== null);
885
739
  }
@@ -995,7 +849,7 @@
995
849
  if (isUserAct === void 0) { isUserAct = false; }
996
850
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
997
851
  if (_self.enableDebugExceptions()) {
998
- throw message;
852
+ throw dumpObj(message);
999
853
  }
1000
854
  else {
1001
855
  var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
@@ -1221,12 +1075,6 @@
1221
1075
  catch (e) {
1222
1076
  }
1223
1077
  }
1224
- function randomValue(maxValue) {
1225
- if (maxValue > 0) {
1226
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1227
- }
1228
- return 0;
1229
- }
1230
1078
  function random32(signed) {
1231
1079
  var value = 0;
1232
1080
  var c = getCrypto() || getMsCrypto();
@@ -1247,14 +1095,6 @@
1247
1095
  }
1248
1096
  return value;
1249
1097
  }
1250
- function mwcRandomSeed(value) {
1251
- if (!value) {
1252
- _autoSeedMwc();
1253
- }
1254
- else {
1255
- _mwcSeed(value);
1256
- }
1257
- }
1258
1098
  function mwcRandom32(signed) {
1259
1099
  _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1260
1100
  _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
@@ -1283,7 +1123,7 @@
1283
1123
  }
1284
1124
 
1285
1125
  var _objDefineProperty = ObjDefineProperty;
1286
- var version = "2.8.2-nightly.2204-22";
1126
+ var version = "2.8.3-nightly.2205-03";
1287
1127
  var instanceName = "." + newId(6);
1288
1128
  var _dataUid = 0;
1289
1129
  function _createAccessor(target, prop, value) {
@@ -2125,216 +1965,6 @@
2125
1965
  return BaseTelemetryPlugin;
2126
1966
  }());
2127
1967
 
2128
- var strOnPrefix = "on";
2129
- var strAttachEvent = "attachEvent";
2130
- var strAddEventHelper = "addEventListener";
2131
- var strEvents = "events";
2132
- createUniqueNamespace("aiEvtPageHide");
2133
- createUniqueNamespace("aiEvtPageShow");
2134
- var rRemoveEmptyNs = /\.[\.]+/g;
2135
- var rRemoveTrailingEmptyNs = /[\.]+$/;
2136
- var _guid = 1;
2137
- var elmNodeData = createElmNodeData("events");
2138
- var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2139
- function _normalizeNamespace(name) {
2140
- if (name && name.replace) {
2141
- return name.replace(/^\s*\.*|\.*\s*$/g, "");
2142
- }
2143
- return name;
2144
- }
2145
- function _getEvtNamespace(eventName, evtNamespace) {
2146
- if (evtNamespace) {
2147
- var theNamespace_1 = "";
2148
- if (isArray(evtNamespace)) {
2149
- theNamespace_1 = "";
2150
- arrForEach(evtNamespace, function (name) {
2151
- name = _normalizeNamespace(name);
2152
- if (name) {
2153
- if (name[0] !== ".") {
2154
- name = "." + name;
2155
- }
2156
- theNamespace_1 += name;
2157
- }
2158
- });
2159
- }
2160
- else {
2161
- theNamespace_1 = _normalizeNamespace(evtNamespace);
2162
- }
2163
- if (theNamespace_1) {
2164
- if (theNamespace_1[0] !== ".") {
2165
- theNamespace_1 = "." + theNamespace_1;
2166
- }
2167
- eventName = (eventName || "") + theNamespace_1;
2168
- }
2169
- }
2170
- var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2171
- return {
2172
- type: parsedEvent[1],
2173
- ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2174
- };
2175
- }
2176
- function _getRegisteredEvents(target, evtName, addDefault) {
2177
- if (addDefault === void 0) { addDefault = true; }
2178
- var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2179
- var registeredEvents = aiEvts[evtName];
2180
- if (!registeredEvents) {
2181
- registeredEvents = aiEvts[evtName] = [];
2182
- }
2183
- return registeredEvents;
2184
- }
2185
- function _doAttach(obj, evtName, handlerRef, useCapture) {
2186
- var result = false;
2187
- if (obj && evtName && evtName.type && handlerRef) {
2188
- if (obj[strAddEventHelper]) {
2189
- obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2190
- result = true;
2191
- }
2192
- else if (obj[strAttachEvent]) {
2193
- obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2194
- result = true;
2195
- }
2196
- }
2197
- return result;
2198
- }
2199
- function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2200
- if (useCapture === void 0) { useCapture = false; }
2201
- var result = false;
2202
- if (target) {
2203
- try {
2204
- var evtName = _getEvtNamespace(eventName, evtNamespace);
2205
- result = _doAttach(target, evtName, handlerRef, useCapture);
2206
- if (result && elmNodeData.accept(target)) {
2207
- var registeredEvent = {
2208
- guid: _guid++,
2209
- evtName: evtName,
2210
- handler: handlerRef,
2211
- capture: useCapture
2212
- };
2213
- _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2214
- }
2215
- }
2216
- catch (e) {
2217
- }
2218
- }
2219
- return result;
2220
- }
2221
- function addEventHandler(eventName, callback, evtNamespace) {
2222
- var result = false;
2223
- var w = getWindow();
2224
- if (w) {
2225
- result = eventOn(w, eventName, callback, evtNamespace);
2226
- result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
2227
- }
2228
- var doc = getDocument();
2229
- if (doc) {
2230
- result = eventOn(doc, eventName, callback, evtNamespace) || result;
2231
- }
2232
- return result;
2233
- }
2234
-
2235
- var _cookieMgrs = null;
2236
- var _canUseCookies;
2237
- function newGuid() {
2238
- function randomHexDigit() {
2239
- return randomValue(15);
2240
- }
2241
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(GuidRegex, function (c) {
2242
- var r = (randomHexDigit() | 0), v = (c === "x" ? r : r & 0x3 | 0x8);
2243
- return v.toString(16);
2244
- });
2245
- }
2246
- function perfNow() {
2247
- var perf = getPerformance();
2248
- if (perf && perf.now) {
2249
- return perf.now();
2250
- }
2251
- return dateNow();
2252
- }
2253
- function generateW3CId() {
2254
- var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2255
- var oct = strEmpty, tmp;
2256
- for (var a = 0; a < 4; a++) {
2257
- tmp = random32();
2258
- oct +=
2259
- hexValues[tmp & 0xF] +
2260
- hexValues[tmp >> 4 & 0xF] +
2261
- hexValues[tmp >> 8 & 0xF] +
2262
- hexValues[tmp >> 12 & 0xF] +
2263
- hexValues[tmp >> 16 & 0xF] +
2264
- hexValues[tmp >> 20 & 0xF] +
2265
- hexValues[tmp >> 24 & 0xF] +
2266
- hexValues[tmp >> 28 & 0xF];
2267
- }
2268
- var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2269
- return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
2270
- }
2271
- var CoreUtils = {
2272
- _canUseCookies: undefined,
2273
- isTypeof: isTypeof,
2274
- isUndefined: isUndefined,
2275
- isNullOrUndefined: isNullOrUndefined,
2276
- hasOwnProperty: hasOwnProperty,
2277
- isFunction: isFunction,
2278
- isObject: isObject,
2279
- isDate: isDate,
2280
- isArray: isArray,
2281
- isError: isError,
2282
- isString: isString,
2283
- isNumber: isNumber,
2284
- isBoolean: isBoolean,
2285
- toISOString: toISOString,
2286
- arrForEach: arrForEach,
2287
- arrIndexOf: arrIndexOf,
2288
- arrMap: arrMap,
2289
- arrReduce: arrReduce,
2290
- strTrim: strTrim,
2291
- objCreate: objCreateFn,
2292
- objKeys: objKeys,
2293
- objDefineAccessors: objDefineAccessors,
2294
- addEventHandler: addEventHandler,
2295
- dateNow: dateNow,
2296
- isIE: isIE,
2297
- disableCookies: disableCookies,
2298
- newGuid: newGuid,
2299
- perfNow: perfNow,
2300
- newId: newId,
2301
- randomValue: randomValue,
2302
- random32: random32,
2303
- mwcRandomSeed: mwcRandomSeed,
2304
- mwcRandom32: mwcRandom32,
2305
- generateW3CId: generateW3CId
2306
- };
2307
- var GuidRegex = /[xy]/g;
2308
- function _legacyCookieMgr(config, logger) {
2309
- var cookieMgr = _gblCookieMgr(config, logger);
2310
- var legacyCanUseCookies = CoreUtils._canUseCookies;
2311
- if (_cookieMgrs === null) {
2312
- _cookieMgrs = [];
2313
- _canUseCookies = legacyCanUseCookies;
2314
- objDefineAccessors(CoreUtils, "_canUseCookies", function () {
2315
- return _canUseCookies;
2316
- }, function (value) {
2317
- _canUseCookies = value;
2318
- arrForEach(_cookieMgrs, function (mgr) {
2319
- mgr.setEnabled(value);
2320
- });
2321
- });
2322
- }
2323
- if (arrIndexOf(_cookieMgrs, cookieMgr) === -1) {
2324
- _cookieMgrs.push(cookieMgr);
2325
- }
2326
- if (isBoolean(legacyCanUseCookies)) {
2327
- cookieMgr.setEnabled(legacyCanUseCookies);
2328
- }
2329
- if (isBoolean(_canUseCookies)) {
2330
- cookieMgr.setEnabled(_canUseCookies);
2331
- }
2332
- return cookieMgr;
2333
- }
2334
- function disableCookies() {
2335
- _legacyCookieMgr().setEnabled(false);
2336
- }
2337
-
2338
1968
  var ReactPlugin = /** @class */ (function (_super) {
2339
1969
  __extendsFn(ReactPlugin, _super);
2340
1970
  function ReactPlugin() {
@@ -2427,6 +2057,74 @@
2427
2057
  }(BaseTelemetryPlugin));
2428
2058
  var ReactPlugin$1 = ReactPlugin;
2429
2059
 
2060
+ var AITrackedComponentBase = /** @class */ (function (_super) {
2061
+ __extendsFn(AITrackedComponentBase, _super);
2062
+ function AITrackedComponentBase(props, reactPlugin, componentName) {
2063
+ var _this = _super.call(this, props) || this;
2064
+ _this._mountTimestamp = 0;
2065
+ _this._firstActiveTimestamp = 0;
2066
+ _this._idleStartTimestamp = 0;
2067
+ _this._lastActiveTimestamp = 0;
2068
+ _this._totalIdleTime = 0;
2069
+ _this._idleCount = 0;
2070
+ _this._idleTimeout = 5000;
2071
+ _this.trackActivity = function (e) {
2072
+ if (_this._firstActiveTimestamp === 0) {
2073
+ _this._firstActiveTimestamp = dateNow();
2074
+ _this._lastActiveTimestamp = _this._firstActiveTimestamp;
2075
+ }
2076
+ else {
2077
+ _this._lastActiveTimestamp = dateNow();
2078
+ }
2079
+ if (_this._idleStartTimestamp > 0) {
2080
+ var lastIdleTime = _this._lastActiveTimestamp - _this._idleStartTimestamp;
2081
+ _this._totalIdleTime += lastIdleTime;
2082
+ _this._idleStartTimestamp = 0;
2083
+ }
2084
+ };
2085
+ _this._reactPlugin = reactPlugin;
2086
+ _this._componentName = componentName;
2087
+ return _this;
2088
+ }
2089
+ AITrackedComponentBase.prototype.componentDidMount = function () {
2090
+ var _this = this;
2091
+ this._mountTimestamp = dateNow();
2092
+ this._firstActiveTimestamp = 0;
2093
+ this._totalIdleTime = 0;
2094
+ this._lastActiveTimestamp = 0;
2095
+ this._idleStartTimestamp = 0;
2096
+ this._idleCount = 0;
2097
+ this._intervalId = setInterval(function () {
2098
+ if (_this._lastActiveTimestamp > 0 && _this._idleStartTimestamp === 0 && dateNow() - _this._lastActiveTimestamp >= _this._idleTimeout) {
2099
+ _this._idleStartTimestamp = dateNow();
2100
+ _this._idleCount++;
2101
+ }
2102
+ }, 100);
2103
+ };
2104
+ AITrackedComponentBase.prototype.componentWillUnmount = function () {
2105
+ if (this._mountTimestamp === 0) {
2106
+ throw new Error('withAITracking:componentWillUnmount: mountTimestamp is not initialized.');
2107
+ }
2108
+ if (this._intervalId) {
2109
+ clearInterval(this._intervalId);
2110
+ }
2111
+ if (this._firstActiveTimestamp === 0) {
2112
+ return;
2113
+ }
2114
+ var engagementTime = this.getEngagementTimeSeconds();
2115
+ var metricData = {
2116
+ average: engagementTime,
2117
+ name: 'React Component Engaged Time (seconds)',
2118
+ sampleCount: 1
2119
+ };
2120
+ var additionalProperties = { 'Component Name': this._componentName };
2121
+ this._reactPlugin.trackMetric(metricData, additionalProperties);
2122
+ };
2123
+ AITrackedComponentBase.prototype.getEngagementTimeSeconds = function () {
2124
+ return (dateNow() - this._firstActiveTimestamp - this._totalIdleTime - this._idleCount * this._idleTimeout) / 1000;
2125
+ };
2126
+ return AITrackedComponentBase;
2127
+ }(React__namespace.Component));
2430
2128
  function withAITracking(reactPlugin, Component, componentName, className) {
2431
2129
  if (componentName === undefined || componentName === null || typeof componentName !== 'string') {
2432
2130
  componentName = Component.prototype &&
@@ -2439,74 +2137,15 @@
2439
2137
  }
2440
2138
  return /** @class */ (function (_super) {
2441
2139
  __extendsFn(class_1, _super);
2442
- function class_1() {
2443
- var _this = _super !== null && _super.apply(this, arguments) || this;
2444
- _this._mountTimestamp = 0;
2445
- _this._firstActiveTimestamp = 0;
2446
- _this._idleStartTimestamp = 0;
2447
- _this._lastActiveTimestamp = 0;
2448
- _this._totalIdleTime = 0;
2449
- _this._idleCount = 0;
2450
- _this._idleTimeout = 5000;
2451
- _this.trackActivity = function (e) {
2452
- if (_this._firstActiveTimestamp === 0) {
2453
- _this._firstActiveTimestamp = CoreUtils.dateNow();
2454
- _this._lastActiveTimestamp = _this._firstActiveTimestamp;
2455
- }
2456
- else {
2457
- _this._lastActiveTimestamp = CoreUtils.dateNow();
2458
- }
2459
- if (_this._idleStartTimestamp > 0) {
2460
- var lastIdleTime = _this._lastActiveTimestamp - _this._idleStartTimestamp;
2461
- _this._totalIdleTime += lastIdleTime;
2462
- _this._idleStartTimestamp = 0;
2463
- }
2464
- };
2465
- return _this;
2466
- }
2467
- class_1.prototype.componentDidMount = function () {
2468
- var _this = this;
2469
- this._mountTimestamp = CoreUtils.dateNow();
2470
- this._firstActiveTimestamp = 0;
2471
- this._totalIdleTime = 0;
2472
- this._lastActiveTimestamp = 0;
2473
- this._idleStartTimestamp = 0;
2474
- this._idleCount = 0;
2475
- this._intervalId = setInterval(function () {
2476
- if (_this._lastActiveTimestamp > 0 && _this._idleStartTimestamp === 0 && CoreUtils.dateNow() - _this._lastActiveTimestamp >= _this._idleTimeout) {
2477
- _this._idleStartTimestamp = CoreUtils.dateNow();
2478
- _this._idleCount++;
2479
- }
2480
- }, 100);
2481
- };
2482
- class_1.prototype.componentWillUnmount = function () {
2483
- if (this._mountTimestamp === 0) {
2484
- throw new Error('withAITracking:componentWillUnmount: mountTimestamp is not initialized.');
2485
- }
2486
- if (this._intervalId) {
2487
- clearInterval(this._intervalId);
2488
- }
2489
- if (this._firstActiveTimestamp === 0) {
2490
- return;
2491
- }
2492
- var engagementTime = this.getEngagementTimeSeconds();
2493
- var metricData = {
2494
- average: engagementTime,
2495
- name: 'React Component Engaged Time (seconds)',
2496
- sampleCount: 1
2497
- };
2498
- var additionalProperties = { 'Component Name': componentName };
2499
- reactPlugin.trackMetric(metricData, additionalProperties);
2500
- };
2140
+ function class_1(props) {
2141
+ return _super.call(this, props, reactPlugin, componentName) || this;
2142
+ }
2501
2143
  class_1.prototype.render = function () {
2502
2144
  return (React__namespace.createElement("div", { onKeyDown: this.trackActivity, onMouseMove: this.trackActivity, onScroll: this.trackActivity, onMouseDown: this.trackActivity, onTouchStart: this.trackActivity, onTouchMove: this.trackActivity, className: className },
2503
2145
  React__namespace.createElement(Component, __assignFn({}, this.props))));
2504
2146
  };
2505
- class_1.prototype.getEngagementTimeSeconds = function () {
2506
- return (CoreUtils.dateNow() - this._firstActiveTimestamp - this._totalIdleTime - this._idleCount * this._idleTimeout) / 1000;
2507
- };
2508
2147
  return class_1;
2509
- }(React__namespace.Component));
2148
+ }(AITrackedComponentBase));
2510
2149
  }
2511
2150
 
2512
2151
  var SeverityLevel = createEnumStyle({
@@ -2630,6 +2269,7 @@
2630
2269
  };
2631
2270
  var useComponentTracking$1 = useComponentTracking;
2632
2271
 
2272
+ exports.AITrackedComponentBase = AITrackedComponentBase;
2633
2273
  exports.AppInsightsContext = AppInsightsContext;
2634
2274
  exports.AppInsightsErrorBoundary = AppInsightsErrorBoundary$1;
2635
2275
  exports.ReactPlugin = ReactPlugin$1;