@microsoft/applicationinsights-react-js 3.3.0-beta.2203-08 → 3.3.0-beta.2203-11

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.0-beta.2203-08
2
+ * Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-11
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -98,7 +98,9 @@
98
98
  var __assignFn = ObjAssign || __objAssignFnImpl;
99
99
  var extendStaticsFn = function (d, b) {
100
100
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
101
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
101
+ ({ __proto__: [] } instanceof Array && function (d, b) {
102
+ d.__proto__ = b;
103
+ }) ||
102
104
  function (d, b) {
103
105
  for (var p in b) {
104
106
  if (b[strShimHasOwnProperty](p)) {
@@ -113,7 +115,9 @@
113
115
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
114
116
  }
115
117
  extendStaticsFn(d, b);
116
- function __() { this.constructor = d; }
118
+ function __() {
119
+ this.constructor = d;
120
+ }
117
121
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
118
122
  }
119
123
 
@@ -734,6 +738,17 @@
734
738
  }
735
739
  }
736
740
  }
741
+ function proxyFunctions(target, source, functionsToProxy, overwriteTarget) {
742
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
743
+ if (target && source && isObject(target) && isArray(functionsToProxy)) {
744
+ arrForEach(functionsToProxy, function (theFuncName) {
745
+ if (isString(theFuncName)) {
746
+ proxyFunctionAs(target, theFuncName, source, theFuncName, overwriteTarget);
747
+ }
748
+ });
749
+ }
750
+ return target;
751
+ }
737
752
  function createEnumStyle(values) {
738
753
  var enumClass = {};
739
754
  objForEachKey(values, function (field, value) {
@@ -1265,7 +1280,7 @@
1265
1280
  }
1266
1281
 
1267
1282
  var _objDefineProperty = ObjDefineProperty;
1268
- var version = "2.7.3";
1283
+ var version = "2.8.0-beta.2203-11";
1269
1284
  var instanceName = "." + newId(6);
1270
1285
  var _dataUid = 0;
1271
1286
  function _createAccessor(target, prop, value) {
@@ -1363,7 +1378,9 @@
1363
1378
  var context = {
1364
1379
  _next: _moveNext,
1365
1380
  ctx: {
1366
- core: function () { return core; },
1381
+ core: function () {
1382
+ return core;
1383
+ },
1367
1384
  diagLog: function () {
1368
1385
  return safeGetLogger(core, config);
1369
1386
  },
@@ -2106,6 +2123,8 @@
2106
2123
  var strEvents = "events";
2107
2124
  createUniqueNamespace("aiEvtPageHide");
2108
2125
  createUniqueNamespace("aiEvtPageShow");
2126
+ var rRemoveEmptyNs = /\.[\.]+/g;
2127
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
2109
2128
  var _guid = 1;
2110
2129
  var elmNodeData = createElmNodeData("events");
2111
2130
  var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
@@ -2140,10 +2159,10 @@
2140
2159
  eventName = (eventName || "") + theNamespace_1;
2141
2160
  }
2142
2161
  }
2143
- var parsedEvent = (eventNamespace.exec(eventName) || []);
2162
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
2144
2163
  return {
2145
2164
  type: parsedEvent[1],
2146
- ns: ((parsedEvent[2] || "").split(".").sort()).join(".")
2165
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
2147
2166
  };
2148
2167
  }
2149
2168
  function _getRegisteredEvents(target, evtName, addDefault) {
@@ -2400,98 +2419,91 @@
2400
2419
  var ReactPlugin = /** @class */ (function (_super) {
2401
2420
  __extendsFn(ReactPlugin, _super);
2402
2421
  function ReactPlugin() {
2403
- var _this = _super !== null && _super.apply(this, arguments) || this;
2422
+ var _this = _super.call(this) || this;
2404
2423
  _this.priority = 185;
2405
2424
  _this.identifier = 'ReactPlugin';
2406
- return _this;
2407
- }
2408
- ReactPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
2409
- var _this = this;
2410
- _super.prototype.initialize.call(this, config, core, extensions, pluginChain);
2411
- this._extensionConfig =
2412
- config.extensionConfig && config.extensionConfig[this.identifier]
2413
- ? config.extensionConfig[this.identifier]
2414
- : { history: null };
2415
- arrForEach(extensions, function (ext) {
2416
- var identifier = ext.identifier;
2417
- if (identifier === 'ApplicationInsightsAnalytics') {
2418
- _this._analyticsPlugin = ext;
2425
+ var _analyticsPlugin;
2426
+ var _extensionConfig;
2427
+ var _unlisten;
2428
+ var _pageViewTimer;
2429
+ dynamicProto(ReactPlugin, _this, function (_self, _base) {
2430
+ _initDefaults();
2431
+ _self.initialize = function (config, core, extensions, pluginChain) {
2432
+ _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
2433
+ _extensionConfig =
2434
+ config.extensionConfig && config.extensionConfig[_self.identifier]
2435
+ ? config.extensionConfig[_self.identifier]
2436
+ : { history: null };
2437
+ arrForEach(extensions, function (ext) {
2438
+ var identifier = ext.identifier;
2439
+ if (identifier === 'ApplicationInsightsAnalytics') {
2440
+ _analyticsPlugin = ext;
2441
+ }
2442
+ });
2443
+ if (_extensionConfig.history) {
2444
+ _addHistoryListener(_extensionConfig.history);
2445
+ var pageViewTelemetry = {
2446
+ uri: _extensionConfig.history.location.pathname
2447
+ };
2448
+ _self.trackPageView(pageViewTelemetry);
2449
+ }
2450
+ };
2451
+ _self.getCookieMgr = function () {
2452
+ return safeGetCookieMgr(_self.core);
2453
+ };
2454
+ _self.getAppInsights = _getAnalytics;
2455
+ _self.processTelemetry = function (event, itemCtx) {
2456
+ _self.processNext(event, itemCtx);
2457
+ };
2458
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
2459
+ if (isFunction(_unlisten)) {
2460
+ _unlisten();
2461
+ }
2462
+ if (_pageViewTimer) {
2463
+ clearTimeout(_pageViewTimer);
2464
+ }
2465
+ _initDefaults();
2466
+ };
2467
+ proxyFunctions(_self, _getAnalytics, [
2468
+ "trackMetric",
2469
+ "trackPageView",
2470
+ "trackEvent",
2471
+ "trackException",
2472
+ "trackTrace",
2473
+ ]);
2474
+ function _initDefaults() {
2475
+ _analyticsPlugin = null;
2476
+ _extensionConfig = null;
2477
+ _unlisten = null;
2478
+ _pageViewTimer = null;
2479
+ }
2480
+ function _getAnalytics() {
2481
+ if (!_analyticsPlugin) {
2482
+ _self.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2483
+ }
2484
+ return _analyticsPlugin;
2419
2485
  }
2486
+ function _addHistoryListener(history) {
2487
+ var locationListener = function (arg) {
2488
+ var locn = null;
2489
+ if ("location" in arg) {
2490
+ locn = arg["location"];
2491
+ }
2492
+ else {
2493
+ locn = arg;
2494
+ }
2495
+ _pageViewTimer = setTimeout(function () {
2496
+ _pageViewTimer = null;
2497
+ var pageViewTelemetry = { uri: locn.pathname };
2498
+ _self.trackPageView(pageViewTelemetry);
2499
+ }, 500);
2500
+ };
2501
+ _unlisten = history.listen(locationListener);
2502
+ }
2503
+ objDefineAccessors(_self, "_extensionConfig", function () { return _extensionConfig; });
2420
2504
  });
2421
- if (this._extensionConfig.history) {
2422
- this.addHistoryListener(this._extensionConfig.history);
2423
- var pageViewTelemetry = {
2424
- uri: this._extensionConfig.history.location.pathname
2425
- };
2426
- this.trackPageView(pageViewTelemetry);
2427
- }
2428
- };
2429
- ReactPlugin.prototype.getCookieMgr = function () {
2430
- return safeGetCookieMgr(this.core);
2431
- };
2432
- ReactPlugin.prototype.getAppInsights = function () {
2433
- return this._analyticsPlugin;
2434
- };
2435
- ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {
2436
- this.processNext(event, itemCtx);
2437
- };
2438
- ReactPlugin.prototype.trackMetric = function (metric, customProperties) {
2439
- if (this._analyticsPlugin) {
2440
- this._analyticsPlugin.trackMetric(metric, customProperties);
2441
- }
2442
- else {
2443
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2444
- }
2445
- };
2446
- ReactPlugin.prototype.trackPageView = function (pageView) {
2447
- if (this._analyticsPlugin) {
2448
- this._analyticsPlugin.trackPageView(pageView);
2449
- }
2450
- else {
2451
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2452
- }
2453
- };
2454
- ReactPlugin.prototype.trackEvent = function (event, customProperties) {
2455
- if (this._analyticsPlugin) {
2456
- this._analyticsPlugin.trackEvent(event, customProperties);
2457
- }
2458
- else {
2459
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2460
- }
2461
- };
2462
- ReactPlugin.prototype.trackException = function (exception, customProperties) {
2463
- if (this._analyticsPlugin) {
2464
- this._analyticsPlugin.trackException(exception, customProperties);
2465
- }
2466
- else {
2467
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2468
- }
2469
- };
2470
- ReactPlugin.prototype.trackTrace = function (trace, customProperties) {
2471
- if (this._analyticsPlugin) {
2472
- this._analyticsPlugin.trackTrace(trace, customProperties);
2473
- }
2474
- else {
2475
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
2476
- }
2477
- };
2478
- ReactPlugin.prototype.addHistoryListener = function (history) {
2479
- var _this = this;
2480
- var locationListener = function (arg) {
2481
- var locn = null;
2482
- if ("location" in arg) {
2483
- locn = arg["location"];
2484
- }
2485
- else {
2486
- locn = arg;
2487
- }
2488
- setTimeout(function () {
2489
- var pageViewTelemetry = { uri: locn.pathname };
2490
- _this.trackPageView(pageViewTelemetry);
2491
- }, 500);
2492
- };
2493
- history.listen(locationListener);
2494
- };
2505
+ return _this;
2506
+ }
2495
2507
  return ReactPlugin;
2496
2508
  }(BaseTelemetryPlugin));
2497
2509
  var ReactPlugin$1 = ReactPlugin;
@@ -2638,7 +2650,7 @@
2638
2650
  trackedData.idleCount * trackedData.idleTimeout) /
2639
2651
  1000);
2640
2652
  }
2641
- var useComponentTracking = function (reactPlugin, componentName) {
2653
+ var useComponentTracking = function (reactPlugin, componentName, customProperties) {
2642
2654
  var tracking = React.useRef({
2643
2655
  hookTimestamp: dateNow(),
2644
2656
  firstActiveTimestamp: 0,
@@ -2677,7 +2689,7 @@
2677
2689
  name: "React Component Engaged Time (seconds)",
2678
2690
  sampleCount: 1
2679
2691
  };
2680
- var additionalProperties = { "Component Name": componentName };
2692
+ var additionalProperties = __assignFn({ "Component Name": componentName }, customProperties);
2681
2693
  reactPlugin.trackMetric(metricData, additionalProperties);
2682
2694
  };
2683
2695
  }, []);