@microsoft/applicationinsights-react-js 3.3.2 → 3.3.4-nightly.2205-04

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.
Files changed (30) hide show
  1. package/browser/applicationinsights-react-js.js +89 -454
  2. package/browser/applicationinsights-react-js.js.map +1 -1
  3. package/browser/applicationinsights-react-js.min.js +2 -2
  4. package/browser/applicationinsights-react-js.min.js.map +1 -1
  5. package/dist/applicationinsights-react-js.api.json +491 -2
  6. package/dist/applicationinsights-react-js.api.md +32 -1
  7. package/dist/applicationinsights-react-js.d.ts +25 -2
  8. package/dist/applicationinsights-react-js.js +89 -454
  9. package/dist/applicationinsights-react-js.js.map +1 -1
  10. package/dist/applicationinsights-react-js.min.js +2 -2
  11. package/dist/applicationinsights-react-js.min.js.map +1 -1
  12. package/dist/applicationinsights-react-js.rollup.d.ts +25 -2
  13. package/dist-esm/AppInsightsContext.js +1 -1
  14. package/dist-esm/AppInsightsErrorBoundary.js +1 -1
  15. package/dist-esm/Interfaces/IReactExtensionConfig.js +1 -1
  16. package/dist-esm/ReactPlugin.js +1 -1
  17. package/dist-esm/applicationinsights-react-js.js +3 -3
  18. package/dist-esm/applicationinsights-react-js.js.map +1 -1
  19. package/dist-esm/useTrackEvent.js +1 -1
  20. package/dist-esm/useTrackMetric.js +1 -1
  21. package/dist-esm/withAITracking.js +78 -64
  22. package/dist-esm/withAITracking.js.map +1 -1
  23. package/package.json +74 -71
  24. package/src/AppInsightsErrorBoundary.tsx +1 -0
  25. package/src/applicationinsights-react-js.ts +3 -2
  26. package/src/withAITracking.tsx +90 -70
  27. package/types/AppInsightsErrorBoundary.d.ts +2 -1
  28. package/types/applicationinsights-react-js.d.ts +2 -2
  29. package/types/tsdoc-metadata.json +1 -1
  30. package/types/withAITracking.d.ts +21 -0
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - React Plugin, 3.3.2
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.4-nightly.2205-04
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.5
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';
@@ -135,13 +135,15 @@
135
135
  var DynInstChkTag = '_dynInstChk';
136
136
  var DynAllowInstChkTag = DynInstChkTag;
137
137
  var DynProtoDefaultOptions = '_dfOpts';
138
- var DynProtoPolyProto = "_dynProto";
139
138
  var UnknownValue = '_unknown_';
140
139
  var str__Proto$1 = "__proto__";
140
+ var DynProtoBaseProto = "_dyn" + str__Proto$1;
141
+ var DynProtoCurrent = "_dynInstProto";
141
142
  var strUseBaseInst = 'useBaseInst';
142
143
  var strSetInstFuncs = 'setInstFuncs';
143
144
  var Obj = Object;
144
145
  var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
146
+ var _objGetOwnProps = Obj["getOwnPropertyNames"];
145
147
  var _dynamicNames = 0;
146
148
  function _hasOwnProperty(obj, prop) {
147
149
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -153,25 +155,25 @@
153
155
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
154
156
  }
155
157
  function _getObjProto$1(target) {
158
+ var newProto;
156
159
  if (target) {
157
160
  if (_objGetPrototypeOf$1) {
158
161
  return _objGetPrototypeOf$1(target);
159
162
  }
160
- var newProto = target[DynProtoPolyProto] || target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
161
- if (newProto) {
162
- if (!target[DynProtoPolyProto]) {
163
- target[DynProtoPolyProto] = newProto;
164
- }
165
- 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;
166
169
  }
167
170
  }
168
- return null;
171
+ return newProto;
169
172
  }
170
173
  function _forEachProp(target, func) {
171
174
  var props = [];
172
- var getOwnProps = Obj["getOwnPropertyNames"];
173
- if (getOwnProps) {
174
- props = getOwnProps(target);
175
+ if (_objGetOwnProps) {
176
+ props = _objGetOwnProps(target);
175
177
  }
176
178
  else {
177
179
  for (var name_1 in target) {
@@ -376,23 +378,16 @@
376
378
  var strDisabled = "disabled";
377
379
  var strDoTeardown = "_doTeardown";
378
380
 
379
- var strToISOString = "toISOString";
380
381
  var cStrEndsWith = "endsWith";
381
- var strIndexOf = "indexOf";
382
- var strMap = "map";
383
- var strReduce = "reduce";
384
382
  var cStrTrim = "trim";
385
383
  var strToString = "toString";
386
384
  var str__Proto = "__proto__";
387
385
  var strConstructor = "constructor";
388
386
  var _objDefineProperty$1 = ObjDefineProperty;
389
387
  var _objFreeze = ObjClass.freeze;
390
- var _objKeys = ObjClass.keys;
391
388
  var StringProto = String[strShimPrototype];
392
389
  var _strTrim = StringProto[cStrTrim];
393
390
  var _strEndsWith = StringProto[cStrEndsWith];
394
- var DateProto = Date[strShimPrototype];
395
- var _dataToISOString = DateProto[strToISOString];
396
391
  var _isArray = Array.isArray;
397
392
  var _objToString = ObjProto[strToString];
398
393
  var _fnToString = ObjHasOwnProperty[strToString];
@@ -413,9 +408,6 @@
413
408
  }
414
409
  return null;
415
410
  }
416
- function isTypeof(value, theType) {
417
- return typeof value === theType;
418
- }
419
411
  function isUndefined(value) {
420
412
  return value === undefined || typeof value === strShimUndefined;
421
413
  }
@@ -425,9 +417,6 @@
425
417
  function isNotNullOrUndefined(value) {
426
418
  return !isNullOrUndefined(value);
427
419
  }
428
- function hasOwnProperty(obj, prop) {
429
- return !!(obj && ObjHasOwnProperty.call(obj, prop));
430
- }
431
420
  function isObject(value) {
432
421
  return !!(value && typeof value === strShimObject);
433
422
  }
@@ -485,9 +474,6 @@
485
474
  }
486
475
  return false;
487
476
  }
488
- function isDate(obj) {
489
- return !!(obj && _objToString.call(obj) === "[object Date]");
490
- }
491
477
  var isArray = _isArray || _isArrayPoly;
492
478
  function _isArrayPoly(obj) {
493
479
  return !!(obj && _objToString.call(obj) === "[object Array]");
@@ -498,9 +484,6 @@
498
484
  function isString(value) {
499
485
  return typeof value === "string";
500
486
  }
501
- function isNumber(value) {
502
- return typeof value === "number";
503
- }
504
487
  function isBoolean(value) {
505
488
  return typeof value === "boolean";
506
489
  }
@@ -520,30 +503,6 @@
520
503
  }
521
504
  return result;
522
505
  }
523
- function toISOString(date) {
524
- if (date) {
525
- return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
526
- }
527
- }
528
- function _toISOStringPoly(date) {
529
- if (date && date.getUTCFullYear) {
530
- var pad = function (num) {
531
- var r = String(num);
532
- if (r.length === 1) {
533
- r = "0" + r;
534
- }
535
- return r;
536
- };
537
- return date.getUTCFullYear()
538
- + "-" + pad(date.getUTCMonth() + 1)
539
- + "-" + pad(date.getUTCDate())
540
- + "T" + pad(date.getUTCHours())
541
- + ":" + pad(date.getUTCMinutes())
542
- + ":" + pad(date.getUTCSeconds())
543
- + "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
544
- + "Z";
545
- }
546
- }
547
506
  function arrForEach(arr, callbackfn, thisArg) {
548
507
  var len = arr.length;
549
508
  try {
@@ -558,112 +517,12 @@
558
517
  catch (e) {
559
518
  }
560
519
  }
561
- function arrIndexOf(arr, searchElement, fromIndex) {
562
- if (arr) {
563
- if (arr[strIndexOf]) {
564
- return arr[strIndexOf](searchElement, fromIndex);
565
- }
566
- var len = arr.length;
567
- var from = fromIndex || 0;
568
- try {
569
- for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
570
- if (lp in arr && arr[lp] === searchElement) {
571
- return lp;
572
- }
573
- }
574
- }
575
- catch (e) {
576
- }
577
- }
578
- return -1;
579
- }
580
- function arrMap(arr, callbackfn, thisArg) {
581
- var results;
582
- if (arr) {
583
- if (arr[strMap]) {
584
- return arr[strMap](callbackfn, thisArg);
585
- }
586
- var len = arr.length;
587
- var _this = thisArg || arr;
588
- results = new Array(len);
589
- try {
590
- for (var lp = 0; lp < len; lp++) {
591
- if (lp in arr) {
592
- results[lp] = callbackfn.call(_this, arr[lp], arr);
593
- }
594
- }
595
- }
596
- catch (e) {
597
- }
598
- }
599
- return results;
600
- }
601
- function arrReduce(arr, callbackfn, initialValue) {
602
- var value;
603
- if (arr) {
604
- if (arr[strReduce]) {
605
- return arr[strReduce](callbackfn, initialValue);
606
- }
607
- var len = arr.length;
608
- var lp = 0;
609
- if (arguments.length >= 3) {
610
- value = arguments[2];
611
- }
612
- else {
613
- while (lp < len && !(lp in arr)) {
614
- lp++;
615
- }
616
- value = arr[lp++];
617
- }
618
- while (lp < len) {
619
- if (lp in arr) {
620
- value = callbackfn(value, arr[lp], lp, arr);
621
- }
622
- lp++;
623
- }
624
- }
625
- return value;
626
- }
627
520
  function strTrim(str) {
628
521
  if (str) {
629
522
  str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
630
523
  }
631
524
  return str;
632
525
  }
633
- var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
634
- var _objKeysDontEnums = [
635
- "toString",
636
- "toLocaleString",
637
- "valueOf",
638
- "hasOwnProperty",
639
- "isPrototypeOf",
640
- "propertyIsEnumerable",
641
- "constructor"
642
- ];
643
- function objKeys(obj) {
644
- var objType = typeof obj;
645
- if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
646
- throwTypeError("objKeys called on non-object");
647
- }
648
- if (!_objKeysHasDontEnumBug && _objKeys) {
649
- return _objKeys(obj);
650
- }
651
- var result = [];
652
- for (var prop in obj) {
653
- if (obj && ObjHasOwnProperty.call(obj, prop)) {
654
- result.push(prop);
655
- }
656
- }
657
- if (_objKeysHasDontEnumBug) {
658
- var dontEnumsLength = _objKeysDontEnums.length;
659
- for (var lp = 0; lp < dontEnumsLength; lp++) {
660
- if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
661
- result.push(_objKeysDontEnums[lp]);
662
- }
663
- }
664
- }
665
- return result;
666
- }
667
526
  function objDefineAccessors(target, prop, getProp, setProp) {
668
527
  if (_objDefineProperty$1) {
669
528
  try {
@@ -818,7 +677,6 @@
818
677
  var strNavigator = "navigator";
819
678
  var strLocation = "location";
820
679
  var strConsole = "console";
821
- var strPerformance = "performance";
822
680
  var strJSON = "JSON";
823
681
  var strCrypto = "crypto";
824
682
  var strMsCrypto = "msCrypto";
@@ -840,12 +698,6 @@
840
698
  function hasWindow() {
841
699
  return Boolean(typeof window === strShimObject && window);
842
700
  }
843
- function getWindow() {
844
- if (hasWindow()) {
845
- return window;
846
- }
847
- return getGlobalInst(strWindow);
848
- }
849
701
  function hasDocument() {
850
702
  return Boolean(typeof document === strShimObject && document);
851
703
  }
@@ -882,9 +734,6 @@
882
734
  }
883
735
  return getGlobalInst(strConsole);
884
736
  }
885
- function getPerformance() {
886
- return getGlobalInst(strPerformance);
887
- }
888
737
  function hasJSON() {
889
738
  return Boolean((typeof JSON === strShimObject && JSON) || getGlobalInst(strJSON) !== null);
890
739
  }
@@ -1226,12 +1075,6 @@
1226
1075
  catch (e) {
1227
1076
  }
1228
1077
  }
1229
- function randomValue(maxValue) {
1230
- if (maxValue > 0) {
1231
- return Math.floor((random32() / MaxUInt32) * (maxValue + 1)) >>> 0;
1232
- }
1233
- return 0;
1234
- }
1235
1078
  function random32(signed) {
1236
1079
  var value = 0;
1237
1080
  var c = getCrypto() || getMsCrypto();
@@ -1252,14 +1095,6 @@
1252
1095
  }
1253
1096
  return value;
1254
1097
  }
1255
- function mwcRandomSeed(value) {
1256
- if (!value) {
1257
- _autoSeedMwc();
1258
- }
1259
- else {
1260
- _mwcSeed(value);
1261
- }
1262
- }
1263
1098
  function mwcRandom32(signed) {
1264
1099
  _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1265
1100
  _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
@@ -1288,7 +1123,7 @@
1288
1123
  }
1289
1124
 
1290
1125
  var _objDefineProperty = ObjDefineProperty;
1291
- var version = "2.8.2";
1126
+ var version = "2.8.4-nightly.2205-04";
1292
1127
  var instanceName = "." + newId(6);
1293
1128
  var _dataUid = 0;
1294
1129
  function _createAccessor(target, prop, value) {
@@ -2130,216 +1965,6 @@
2130
1965
  return BaseTelemetryPlugin;
2131
1966
  }());
2132
1967
 
2133
- var strOnPrefix = "on";
2134
- var strAttachEvent = "attachEvent";
2135
- var strAddEventHelper = "addEventListener";
2136
- var strEvents = "events";
2137
- createUniqueNamespace("aiEvtPageHide");
2138
- createUniqueNamespace("aiEvtPageShow");
2139
- var rRemoveEmptyNs = /\.[\.]+/g;
2140
- var rRemoveTrailingEmptyNs = /[\.]+$/;
2141
- var _guid = 1;
2142
- var elmNodeData = createElmNodeData("events");
2143
- var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
2144
- function _normalizeNamespace(name) {
2145
- if (name && name.replace) {
2146
- return name.replace(/^\s*\.*|\.*\s*$/g, "");
2147
- }
2148
- return name;
2149
- }
2150
- function _getEvtNamespace(eventName, evtNamespace) {
2151
- if (evtNamespace) {
2152
- var theNamespace_1 = "";
2153
- if (isArray(evtNamespace)) {
2154
- theNamespace_1 = "";
2155
- arrForEach(evtNamespace, function (name) {
2156
- name = _normalizeNamespace(name);
2157
- if (name) {
2158
- if (name[0] !== ".") {
2159
- name = "." + name;
2160
- }
2161
- theNamespace_1 += name;
2162
- }
2163
- });
2164
- }
2165
- else {
2166
- theNamespace_1 = _normalizeNamespace(evtNamespace);
2167
- }
2168
- if (theNamespace_1) {
2169
- if (theNamespace_1[0] !== ".") {
2170
- theNamespace_1 = "." + theNamespace_1;
2171
- }
2172
- eventName = (eventName || "") + theNamespace_1;
2173
- }
2174
- }
2175
- var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2176
- return {
2177
- type: parsedEvent[1],
2178
- ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2179
- };
2180
- }
2181
- function _getRegisteredEvents(target, evtName, addDefault) {
2182
- if (addDefault === void 0) { addDefault = true; }
2183
- var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
2184
- var registeredEvents = aiEvts[evtName];
2185
- if (!registeredEvents) {
2186
- registeredEvents = aiEvts[evtName] = [];
2187
- }
2188
- return registeredEvents;
2189
- }
2190
- function _doAttach(obj, evtName, handlerRef, useCapture) {
2191
- var result = false;
2192
- if (obj && evtName && evtName.type && handlerRef) {
2193
- if (obj[strAddEventHelper]) {
2194
- obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
2195
- result = true;
2196
- }
2197
- else if (obj[strAttachEvent]) {
2198
- obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
2199
- result = true;
2200
- }
2201
- }
2202
- return result;
2203
- }
2204
- function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
2205
- if (useCapture === void 0) { useCapture = false; }
2206
- var result = false;
2207
- if (target) {
2208
- try {
2209
- var evtName = _getEvtNamespace(eventName, evtNamespace);
2210
- result = _doAttach(target, evtName, handlerRef, useCapture);
2211
- if (result && elmNodeData.accept(target)) {
2212
- var registeredEvent = {
2213
- guid: _guid++,
2214
- evtName: evtName,
2215
- handler: handlerRef,
2216
- capture: useCapture
2217
- };
2218
- _getRegisteredEvents(target, evtName.type).push(registeredEvent);
2219
- }
2220
- }
2221
- catch (e) {
2222
- }
2223
- }
2224
- return result;
2225
- }
2226
- function addEventHandler(eventName, callback, evtNamespace) {
2227
- var result = false;
2228
- var w = getWindow();
2229
- if (w) {
2230
- result = eventOn(w, eventName, callback, evtNamespace);
2231
- result = eventOn(w["body"], eventName, callback, evtNamespace) || result;
2232
- }
2233
- var doc = getDocument();
2234
- if (doc) {
2235
- result = eventOn(doc, eventName, callback, evtNamespace) || result;
2236
- }
2237
- return result;
2238
- }
2239
-
2240
- var _cookieMgrs = null;
2241
- var _canUseCookies;
2242
- function newGuid() {
2243
- function randomHexDigit() {
2244
- return randomValue(15);
2245
- }
2246
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(GuidRegex, function (c) {
2247
- var r = (randomHexDigit() | 0), v = (c === "x" ? r : r & 0x3 | 0x8);
2248
- return v.toString(16);
2249
- });
2250
- }
2251
- function perfNow() {
2252
- var perf = getPerformance();
2253
- if (perf && perf.now) {
2254
- return perf.now();
2255
- }
2256
- return dateNow();
2257
- }
2258
- function generateW3CId() {
2259
- var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2260
- var oct = strEmpty, tmp;
2261
- for (var a = 0; a < 4; a++) {
2262
- tmp = random32();
2263
- oct +=
2264
- hexValues[tmp & 0xF] +
2265
- hexValues[tmp >> 4 & 0xF] +
2266
- hexValues[tmp >> 8 & 0xF] +
2267
- hexValues[tmp >> 12 & 0xF] +
2268
- hexValues[tmp >> 16 & 0xF] +
2269
- hexValues[tmp >> 20 & 0xF] +
2270
- hexValues[tmp >> 24 & 0xF] +
2271
- hexValues[tmp >> 28 & 0xF];
2272
- }
2273
- var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2274
- return oct.substr(0, 8) + oct.substr(9, 4) + "4" + oct.substr(13, 3) + clockSequenceHi + oct.substr(16, 3) + oct.substr(19, 12);
2275
- }
2276
- var CoreUtils = {
2277
- _canUseCookies: undefined,
2278
- isTypeof: isTypeof,
2279
- isUndefined: isUndefined,
2280
- isNullOrUndefined: isNullOrUndefined,
2281
- hasOwnProperty: hasOwnProperty,
2282
- isFunction: isFunction,
2283
- isObject: isObject,
2284
- isDate: isDate,
2285
- isArray: isArray,
2286
- isError: isError,
2287
- isString: isString,
2288
- isNumber: isNumber,
2289
- isBoolean: isBoolean,
2290
- toISOString: toISOString,
2291
- arrForEach: arrForEach,
2292
- arrIndexOf: arrIndexOf,
2293
- arrMap: arrMap,
2294
- arrReduce: arrReduce,
2295
- strTrim: strTrim,
2296
- objCreate: objCreateFn,
2297
- objKeys: objKeys,
2298
- objDefineAccessors: objDefineAccessors,
2299
- addEventHandler: addEventHandler,
2300
- dateNow: dateNow,
2301
- isIE: isIE,
2302
- disableCookies: disableCookies,
2303
- newGuid: newGuid,
2304
- perfNow: perfNow,
2305
- newId: newId,
2306
- randomValue: randomValue,
2307
- random32: random32,
2308
- mwcRandomSeed: mwcRandomSeed,
2309
- mwcRandom32: mwcRandom32,
2310
- generateW3CId: generateW3CId
2311
- };
2312
- var GuidRegex = /[xy]/g;
2313
- function _legacyCookieMgr(config, logger) {
2314
- var cookieMgr = _gblCookieMgr(config, logger);
2315
- var legacyCanUseCookies = CoreUtils._canUseCookies;
2316
- if (_cookieMgrs === null) {
2317
- _cookieMgrs = [];
2318
- _canUseCookies = legacyCanUseCookies;
2319
- objDefineAccessors(CoreUtils, "_canUseCookies", function () {
2320
- return _canUseCookies;
2321
- }, function (value) {
2322
- _canUseCookies = value;
2323
- arrForEach(_cookieMgrs, function (mgr) {
2324
- mgr.setEnabled(value);
2325
- });
2326
- });
2327
- }
2328
- if (arrIndexOf(_cookieMgrs, cookieMgr) === -1) {
2329
- _cookieMgrs.push(cookieMgr);
2330
- }
2331
- if (isBoolean(legacyCanUseCookies)) {
2332
- cookieMgr.setEnabled(legacyCanUseCookies);
2333
- }
2334
- if (isBoolean(_canUseCookies)) {
2335
- cookieMgr.setEnabled(_canUseCookies);
2336
- }
2337
- return cookieMgr;
2338
- }
2339
- function disableCookies() {
2340
- _legacyCookieMgr().setEnabled(false);
2341
- }
2342
-
2343
1968
  var ReactPlugin = /** @class */ (function (_super) {
2344
1969
  __extendsFn(ReactPlugin, _super);
2345
1970
  function ReactPlugin() {
@@ -2432,6 +2057,74 @@
2432
2057
  }(BaseTelemetryPlugin));
2433
2058
  var ReactPlugin$1 = ReactPlugin;
2434
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));
2435
2128
  function withAITracking(reactPlugin, Component, componentName, className) {
2436
2129
  if (componentName === undefined || componentName === null || typeof componentName !== 'string') {
2437
2130
  componentName = Component.prototype &&
@@ -2444,74 +2137,15 @@
2444
2137
  }
2445
2138
  return /** @class */ (function (_super) {
2446
2139
  __extendsFn(class_1, _super);
2447
- function class_1() {
2448
- var _this = _super !== null && _super.apply(this, arguments) || this;
2449
- _this._mountTimestamp = 0;
2450
- _this._firstActiveTimestamp = 0;
2451
- _this._idleStartTimestamp = 0;
2452
- _this._lastActiveTimestamp = 0;
2453
- _this._totalIdleTime = 0;
2454
- _this._idleCount = 0;
2455
- _this._idleTimeout = 5000;
2456
- _this.trackActivity = function (e) {
2457
- if (_this._firstActiveTimestamp === 0) {
2458
- _this._firstActiveTimestamp = CoreUtils.dateNow();
2459
- _this._lastActiveTimestamp = _this._firstActiveTimestamp;
2460
- }
2461
- else {
2462
- _this._lastActiveTimestamp = CoreUtils.dateNow();
2463
- }
2464
- if (_this._idleStartTimestamp > 0) {
2465
- var lastIdleTime = _this._lastActiveTimestamp - _this._idleStartTimestamp;
2466
- _this._totalIdleTime += lastIdleTime;
2467
- _this._idleStartTimestamp = 0;
2468
- }
2469
- };
2470
- return _this;
2471
- }
2472
- class_1.prototype.componentDidMount = function () {
2473
- var _this = this;
2474
- this._mountTimestamp = CoreUtils.dateNow();
2475
- this._firstActiveTimestamp = 0;
2476
- this._totalIdleTime = 0;
2477
- this._lastActiveTimestamp = 0;
2478
- this._idleStartTimestamp = 0;
2479
- this._idleCount = 0;
2480
- this._intervalId = setInterval(function () {
2481
- if (_this._lastActiveTimestamp > 0 && _this._idleStartTimestamp === 0 && CoreUtils.dateNow() - _this._lastActiveTimestamp >= _this._idleTimeout) {
2482
- _this._idleStartTimestamp = CoreUtils.dateNow();
2483
- _this._idleCount++;
2484
- }
2485
- }, 100);
2486
- };
2487
- class_1.prototype.componentWillUnmount = function () {
2488
- if (this._mountTimestamp === 0) {
2489
- throw new Error('withAITracking:componentWillUnmount: mountTimestamp is not initialized.');
2490
- }
2491
- if (this._intervalId) {
2492
- clearInterval(this._intervalId);
2493
- }
2494
- if (this._firstActiveTimestamp === 0) {
2495
- return;
2496
- }
2497
- var engagementTime = this.getEngagementTimeSeconds();
2498
- var metricData = {
2499
- average: engagementTime,
2500
- name: 'React Component Engaged Time (seconds)',
2501
- sampleCount: 1
2502
- };
2503
- var additionalProperties = { 'Component Name': componentName };
2504
- reactPlugin.trackMetric(metricData, additionalProperties);
2505
- };
2140
+ function class_1(props) {
2141
+ return _super.call(this, props, reactPlugin, componentName) || this;
2142
+ }
2506
2143
  class_1.prototype.render = function () {
2507
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 },
2508
2145
  React__namespace.createElement(Component, __assignFn({}, this.props))));
2509
2146
  };
2510
- class_1.prototype.getEngagementTimeSeconds = function () {
2511
- return (CoreUtils.dateNow() - this._firstActiveTimestamp - this._totalIdleTime - this._idleCount * this._idleTimeout) / 1000;
2512
- };
2513
2147
  return class_1;
2514
- }(React__namespace.Component));
2148
+ }(AITrackedComponentBase));
2515
2149
  }
2516
2150
 
2517
2151
  var SeverityLevel = createEnumStyle({
@@ -2635,6 +2269,7 @@
2635
2269
  };
2636
2270
  var useComponentTracking$1 = useComponentTracking;
2637
2271
 
2272
+ exports.AITrackedComponentBase = AITrackedComponentBase;
2638
2273
  exports.AppInsightsContext = AppInsightsContext;
2639
2274
  exports.AppInsightsErrorBoundary = AppInsightsErrorBoundary$1;
2640
2275
  exports.ReactPlugin = ReactPlugin$1;