@microsoft/applicationinsights-react-js 3.3.0-beta.2203-09 → 3.3.0-beta.2203-12
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.
- package/browser/applicationinsights-react-js.js +106 -96
- package/browser/applicationinsights-react-js.js.map +1 -1
- package/browser/applicationinsights-react-js.min.js +2 -2
- package/browser/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.api.json +32 -7
- package/dist/applicationinsights-react-js.api.md +4 -7
- package/dist/applicationinsights-react-js.d.ts +5 -11
- package/dist/applicationinsights-react-js.js +106 -96
- package/dist/applicationinsights-react-js.js.map +1 -1
- package/dist/applicationinsights-react-js.min.js +2 -2
- package/dist/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.rollup.d.ts +5 -11
- package/dist-esm/AppInsightsContext.js +1 -1
- package/dist-esm/AppInsightsErrorBoundary.js +1 -1
- package/dist-esm/Interfaces/IReactExtensionConfig.js +1 -1
- package/dist-esm/ReactPlugin.js +96 -102
- package/dist-esm/ReactPlugin.js.map +1 -1
- package/dist-esm/applicationinsights-react-js.js +1 -1
- package/dist-esm/useTrackEvent.js +1 -1
- package/dist-esm/useTrackMetric.js +4 -3
- package/dist-esm/useTrackMetric.js.map +1 -1
- package/dist-esm/withAITracking.js +1 -1
- package/package.json +4 -4
- package/src/ReactPlugin.ts +118 -81
- package/src/useTrackMetric.ts +4 -3
- package/types/ReactPlugin.d.ts +3 -9
- package/types/tsdoc-metadata.json +1 -1
- package/types/useTrackMetric.d.ts +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript SDK - React Plugin, 3.3.0-beta.2203-12
|
|
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) {
|
|
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 __() {
|
|
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.
|
|
1283
|
+
var version = "2.8.0-beta.2203-12";
|
|
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 () {
|
|
1381
|
+
core: function () {
|
|
1382
|
+
return core;
|
|
1383
|
+
},
|
|
1367
1384
|
diagLog: function () {
|
|
1368
1385
|
return safeGetLogger(core, config);
|
|
1369
1386
|
},
|
|
@@ -2142,7 +2159,7 @@
|
|
|
2142
2159
|
eventName = (eventName || "") + theNamespace_1;
|
|
2143
2160
|
}
|
|
2144
2161
|
}
|
|
2145
|
-
var parsedEvent = (eventNamespace.exec(eventName) || []);
|
|
2162
|
+
var parsedEvent = (eventNamespace.exec(eventName || "") || []);
|
|
2146
2163
|
return {
|
|
2147
2164
|
type: parsedEvent[1],
|
|
2148
2165
|
ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
|
|
@@ -2402,98 +2419,91 @@
|
|
|
2402
2419
|
var ReactPlugin = /** @class */ (function (_super) {
|
|
2403
2420
|
__extendsFn(ReactPlugin, _super);
|
|
2404
2421
|
function ReactPlugin() {
|
|
2405
|
-
var _this = _super
|
|
2422
|
+
var _this = _super.call(this) || this;
|
|
2406
2423
|
_this.priority = 185;
|
|
2407
2424
|
_this.identifier = 'ReactPlugin';
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
var
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
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;
|
|
2421
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; });
|
|
2422
2504
|
});
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
var pageViewTelemetry = {
|
|
2426
|
-
uri: this._extensionConfig.history.location.pathname
|
|
2427
|
-
};
|
|
2428
|
-
this.trackPageView(pageViewTelemetry);
|
|
2429
|
-
}
|
|
2430
|
-
};
|
|
2431
|
-
ReactPlugin.prototype.getCookieMgr = function () {
|
|
2432
|
-
return safeGetCookieMgr(this.core);
|
|
2433
|
-
};
|
|
2434
|
-
ReactPlugin.prototype.getAppInsights = function () {
|
|
2435
|
-
return this._analyticsPlugin;
|
|
2436
|
-
};
|
|
2437
|
-
ReactPlugin.prototype.processTelemetry = function (event, itemCtx) {
|
|
2438
|
-
this.processNext(event, itemCtx);
|
|
2439
|
-
};
|
|
2440
|
-
ReactPlugin.prototype.trackMetric = function (metric, customProperties) {
|
|
2441
|
-
if (this._analyticsPlugin) {
|
|
2442
|
-
this._analyticsPlugin.trackMetric(metric, customProperties);
|
|
2443
|
-
}
|
|
2444
|
-
else {
|
|
2445
|
-
this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
|
|
2446
|
-
}
|
|
2447
|
-
};
|
|
2448
|
-
ReactPlugin.prototype.trackPageView = function (pageView) {
|
|
2449
|
-
if (this._analyticsPlugin) {
|
|
2450
|
-
this._analyticsPlugin.trackPageView(pageView);
|
|
2451
|
-
}
|
|
2452
|
-
else {
|
|
2453
|
-
this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
|
|
2454
|
-
}
|
|
2455
|
-
};
|
|
2456
|
-
ReactPlugin.prototype.trackEvent = function (event, customProperties) {
|
|
2457
|
-
if (this._analyticsPlugin) {
|
|
2458
|
-
this._analyticsPlugin.trackEvent(event, customProperties);
|
|
2459
|
-
}
|
|
2460
|
-
else {
|
|
2461
|
-
this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
|
|
2462
|
-
}
|
|
2463
|
-
};
|
|
2464
|
-
ReactPlugin.prototype.trackException = function (exception, customProperties) {
|
|
2465
|
-
if (this._analyticsPlugin) {
|
|
2466
|
-
this._analyticsPlugin.trackException(exception, customProperties);
|
|
2467
|
-
}
|
|
2468
|
-
else {
|
|
2469
|
-
this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
|
|
2470
|
-
}
|
|
2471
|
-
};
|
|
2472
|
-
ReactPlugin.prototype.trackTrace = function (trace, customProperties) {
|
|
2473
|
-
if (this._analyticsPlugin) {
|
|
2474
|
-
this._analyticsPlugin.trackTrace(trace, customProperties);
|
|
2475
|
-
}
|
|
2476
|
-
else {
|
|
2477
|
-
this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
|
|
2478
|
-
}
|
|
2479
|
-
};
|
|
2480
|
-
ReactPlugin.prototype.addHistoryListener = function (history) {
|
|
2481
|
-
var _this = this;
|
|
2482
|
-
var locationListener = function (arg) {
|
|
2483
|
-
var locn = null;
|
|
2484
|
-
if ("location" in arg) {
|
|
2485
|
-
locn = arg["location"];
|
|
2486
|
-
}
|
|
2487
|
-
else {
|
|
2488
|
-
locn = arg;
|
|
2489
|
-
}
|
|
2490
|
-
setTimeout(function () {
|
|
2491
|
-
var pageViewTelemetry = { uri: locn.pathname };
|
|
2492
|
-
_this.trackPageView(pageViewTelemetry);
|
|
2493
|
-
}, 500);
|
|
2494
|
-
};
|
|
2495
|
-
history.listen(locationListener);
|
|
2496
|
-
};
|
|
2505
|
+
return _this;
|
|
2506
|
+
}
|
|
2497
2507
|
return ReactPlugin;
|
|
2498
2508
|
}(BaseTelemetryPlugin));
|
|
2499
2509
|
var ReactPlugin$1 = ReactPlugin;
|
|
@@ -2640,7 +2650,7 @@
|
|
|
2640
2650
|
trackedData.idleCount * trackedData.idleTimeout) /
|
|
2641
2651
|
1000);
|
|
2642
2652
|
}
|
|
2643
|
-
var useComponentTracking = function (reactPlugin, componentName) {
|
|
2653
|
+
var useComponentTracking = function (reactPlugin, componentName, customProperties) {
|
|
2644
2654
|
var tracking = React.useRef({
|
|
2645
2655
|
hookTimestamp: dateNow(),
|
|
2646
2656
|
firstActiveTimestamp: 0,
|
|
@@ -2679,7 +2689,7 @@
|
|
|
2679
2689
|
name: "React Component Engaged Time (seconds)",
|
|
2680
2690
|
sampleCount: 1
|
|
2681
2691
|
};
|
|
2682
|
-
var additionalProperties = { "Component Name": componentName };
|
|
2692
|
+
var additionalProperties = __assignFn({ "Component Name": componentName }, customProperties);
|
|
2683
2693
|
reactPlugin.trackMetric(metricData, additionalProperties);
|
|
2684
2694
|
};
|
|
2685
2695
|
}, []);
|