@microsoft/applicationinsights-analytics-js 2.8.4-nightly.2205-07 → 2.8.4-nightly.2205-10

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 (26) hide show
  1. package/browser/applicationinsights-analytics-js.integrity.json +9 -9
  2. package/browser/applicationinsights-analytics-js.js +769 -704
  3. package/browser/applicationinsights-analytics-js.js.map +1 -1
  4. package/browser/applicationinsights-analytics-js.min.js +2 -2
  5. package/browser/applicationinsights-analytics-js.min.js.map +1 -1
  6. package/dist/applicationinsights-analytics-js.api.json +1 -1
  7. package/dist/applicationinsights-analytics-js.d.ts +1 -1
  8. package/dist/applicationinsights-analytics-js.js +769 -704
  9. package/dist/applicationinsights-analytics-js.js.map +1 -1
  10. package/dist/applicationinsights-analytics-js.min.js +2 -2
  11. package/dist/applicationinsights-analytics-js.min.js.map +1 -1
  12. package/dist/applicationinsights-analytics-js.rollup.d.ts +1 -1
  13. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js +40 -26
  14. package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js.map +1 -1
  15. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js +3 -3
  16. package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js +4 -4
  18. package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js +1 -1
  20. package/dist-esm/JavaScriptSDK/Timing.js +3 -3
  21. package/dist-esm/JavaScriptSDK/Timing.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryConfig.js +1 -1
  23. package/dist-esm/applicationinsights-analytics-js.js +1 -1
  24. package/package.json +6 -6
  25. package/src/JavaScriptSDK/AnalyticsPlugin.ts +32 -16
  26. package/types/tsdoc-metadata.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PageViewPerformanceManager.js.map","sources":["PageViewPerformanceManager.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dateTimeUtilsDuration, msToTimeSpan } from \"@microsoft/applicationinsights-common\";\r\nimport { getNavigator, getPerformance, _throwInternal } from \"@microsoft/applicationinsights-core-js\";\r\n/**\r\n * Class encapsulates sending page view performance telemetry.\r\n */\r\nvar PageViewPerformanceManager = /** @class */ (function () {\r\n function PageViewPerformanceManager(core) {\r\n this.MAX_DURATION_ALLOWED = 3600000; // 1h\r\n if (core) {\r\n this._logger = core.logger;\r\n }\r\n }\r\n PageViewPerformanceManager.prototype.populatePageViewPerformanceEvent = function (pageViewPerformance) {\r\n pageViewPerformance.isValid = false;\r\n /*\r\n * http://www.w3.org/TR/navigation-timing/#processing-model\r\n * |-navigationStart\r\n * | |-connectEnd\r\n * | ||-requestStart\r\n * | || |-responseStart\r\n * | || | |-responseEnd\r\n * | || | |\r\n * | || | | |-loadEventEnd\r\n * |---network---||---request---|---response---|---dom---|\r\n * |--------------------------total----------------------|\r\n *\r\n * total = The difference between the load event of the current document is completed and the first recorded timestamp of the performance entry : https://developer.mozilla.org/en-US/docs/Web/Performance/Navigation_and_resource_timings#duration\r\n * network = Redirect time + App Cache + DNS lookup time + TCP connection time\r\n * request = Request time : https://developer.mozilla.org/en-US/docs/Web/Performance/Navigation_and_resource_timings#request_time\r\n * response = Response time\r\n * dom = Document load time : https://html.spec.whatwg.org/multipage/dom.html#document-load-timing-info\r\n * = Document processing time : https://developers.google.com/web/fundamentals/performance/navigation-and-resource-timing/#document_processing\r\n * + Loading time : https://developers.google.com/web/fundamentals/performance/navigation-and-resource-timing/#loading\r\n */\r\n var navigationTiming = this.getPerformanceNavigationTiming();\r\n var timing = this.getPerformanceTiming();\r\n var total = 0;\r\n var network = 0;\r\n var request = 0;\r\n var response = 0;\r\n var dom = 0;\r\n if (navigationTiming || timing) {\r\n if (navigationTiming) {\r\n total = navigationTiming.duration;\r\n /**\r\n * support both cases:\r\n * - startTime is always zero: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming\r\n * - for older browsers where the startTime is not zero\r\n */\r\n network = navigationTiming.startTime === 0 ? navigationTiming.connectEnd : dateTimeUtilsDuration(navigationTiming.startTime, navigationTiming.connectEnd);\r\n request = dateTimeUtilsDuration(navigationTiming.requestStart, navigationTiming.responseStart);\r\n response = dateTimeUtilsDuration(navigationTiming.responseStart, navigationTiming.responseEnd);\r\n dom = dateTimeUtilsDuration(navigationTiming.responseEnd, navigationTiming.loadEventEnd);\r\n }\r\n else {\r\n total = dateTimeUtilsDuration(timing.navigationStart, timing.loadEventEnd);\r\n network = dateTimeUtilsDuration(timing.navigationStart, timing.connectEnd);\r\n request = dateTimeUtilsDuration(timing.requestStart, timing.responseStart);\r\n response = dateTimeUtilsDuration(timing.responseStart, timing.responseEnd);\r\n dom = dateTimeUtilsDuration(timing.responseEnd, timing.loadEventEnd);\r\n }\r\n var logger = this._logger;\r\n if (total === 0) {\r\n _throwInternal(logger, 2 /* WARNING */, 10 /* ErrorPVCalc */, \"error calculating page view performance.\", { total: total, network: network, request: request, response: response, dom: dom });\r\n }\r\n else if (!this.shouldCollectDuration(total, network, request, response, dom)) {\r\n _throwInternal(logger, 2 /* WARNING */, 45 /* InvalidDurationValue */, \"Invalid page load duration value. Browser perf data won't be sent.\", { total: total, network: network, request: request, response: response, dom: dom });\r\n }\r\n else if (total < Math.floor(network) + Math.floor(request) + Math.floor(response) + Math.floor(dom)) {\r\n // some browsers may report individual components incorrectly so that the sum of the parts will be bigger than total PLT\r\n // in this case, don't report client performance from this page\r\n _throwInternal(logger, 2 /* WARNING */, 8 /* ClientPerformanceMathError */, \"client performance math error.\", { total: total, network: network, request: request, response: response, dom: dom });\r\n }\r\n else {\r\n pageViewPerformance.durationMs = total;\r\n // // convert to timespans\r\n pageViewPerformance.perfTotal = pageViewPerformance.duration = msToTimeSpan(total);\r\n pageViewPerformance.networkConnect = msToTimeSpan(network);\r\n pageViewPerformance.sentRequest = msToTimeSpan(request);\r\n pageViewPerformance.receivedResponse = msToTimeSpan(response);\r\n pageViewPerformance.domProcessing = msToTimeSpan(dom);\r\n pageViewPerformance.isValid = true;\r\n }\r\n }\r\n };\r\n PageViewPerformanceManager.prototype.getPerformanceTiming = function () {\r\n if (this.isPerformanceTimingSupported()) {\r\n return getPerformance().timing;\r\n }\r\n return null;\r\n };\r\n PageViewPerformanceManager.prototype.getPerformanceNavigationTiming = function () {\r\n if (this.isPerformanceNavigationTimingSupported()) {\r\n return getPerformance().getEntriesByType(\"navigation\")[0];\r\n }\r\n return null;\r\n };\r\n /**\r\n * Returns true is window PerformanceNavigationTiming API is supported, false otherwise.\r\n */\r\n PageViewPerformanceManager.prototype.isPerformanceNavigationTimingSupported = function () {\r\n var perf = getPerformance();\r\n return perf && perf.getEntriesByType && perf.getEntriesByType(\"navigation\").length > 0;\r\n };\r\n /**\r\n * Returns true is window performance timing API is supported, false otherwise.\r\n */\r\n PageViewPerformanceManager.prototype.isPerformanceTimingSupported = function () {\r\n var perf = getPerformance();\r\n return perf && perf.timing;\r\n };\r\n /**\r\n * As page loads different parts of performance timing numbers get set. When all of them are set we can report it.\r\n * Returns true if ready, false otherwise.\r\n */\r\n PageViewPerformanceManager.prototype.isPerformanceTimingDataReady = function () {\r\n var perf = getPerformance();\r\n var timing = perf ? perf.timing : 0;\r\n return timing\r\n && timing.domainLookupStart > 0\r\n && timing.navigationStart > 0\r\n && timing.responseStart > 0\r\n && timing.requestStart > 0\r\n && timing.loadEventEnd > 0\r\n && timing.responseEnd > 0\r\n && timing.connectEnd > 0\r\n && timing.domLoading > 0;\r\n };\r\n /**\r\n * This method tells if given durations should be excluded from collection.\r\n */\r\n PageViewPerformanceManager.prototype.shouldCollectDuration = function () {\r\n var durations = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n durations[_i] = arguments[_i];\r\n }\r\n var _navigator = getNavigator() || {};\r\n // a full list of Google crawlers user agent strings - https://support.google.com/webmasters/answer/1061943?hl=en\r\n var botAgentNames = [\"googlebot\", \"adsbot-google\", \"apis-google\", \"mediapartners-google\"];\r\n var userAgent = _navigator.userAgent;\r\n var isGoogleBot = false;\r\n if (userAgent) {\r\n for (var i = 0; i < botAgentNames.length; i++) {\r\n isGoogleBot = isGoogleBot || userAgent.toLowerCase().indexOf(botAgentNames[i]) !== -1;\r\n }\r\n }\r\n if (isGoogleBot) {\r\n // Don't report durations for GoogleBot, it is returning invalid values in performance.timing API.\r\n return false;\r\n }\r\n else {\r\n // for other page views, don't report if it's outside of a reasonable range\r\n for (var i = 0; i < durations.length; i++) {\r\n if (durations[i] < 0 || durations[i] >= this.MAX_DURATION_ALLOWED) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n };\r\n return PageViewPerformanceManager;\r\n}());\r\nexport { PageViewPerformanceManager };\r\n//# sourceMappingURL=PageViewPerformanceManager.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"PageViewPerformanceManager.js.map","sources":["PageViewPerformanceManager.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dateTimeUtilsDuration, msToTimeSpan } from \"@microsoft/applicationinsights-common\";\r\nimport { getNavigator, getPerformance, _throwInternal } from \"@microsoft/applicationinsights-core-js\";\r\n/**\r\n * Class encapsulates sending page view performance telemetry.\r\n */\r\nvar PageViewPerformanceManager = /** @class */ (function () {\r\n function PageViewPerformanceManager(core) {\r\n this.MAX_DURATION_ALLOWED = 3600000; // 1h\r\n if (core) {\r\n this._logger = core.logger;\r\n }\r\n }\r\n PageViewPerformanceManager.prototype.populatePageViewPerformanceEvent = function (pageViewPerformance) {\r\n pageViewPerformance.isValid = false;\r\n /*\r\n * http://www.w3.org/TR/navigation-timing/#processing-model\r\n * |-navigationStart\r\n * | |-connectEnd\r\n * | ||-requestStart\r\n * | || |-responseStart\r\n * | || | |-responseEnd\r\n * | || | |\r\n * | || | | |-loadEventEnd\r\n * |---network---||---request---|---response---|---dom---|\r\n * |--------------------------total----------------------|\r\n *\r\n * total = The difference between the load event of the current document is completed and the first recorded timestamp of the performance entry : https://developer.mozilla.org/en-US/docs/Web/Performance/Navigation_and_resource_timings#duration\r\n * network = Redirect time + App Cache + DNS lookup time + TCP connection time\r\n * request = Request time : https://developer.mozilla.org/en-US/docs/Web/Performance/Navigation_and_resource_timings#request_time\r\n * response = Response time\r\n * dom = Document load time : https://html.spec.whatwg.org/multipage/dom.html#document-load-timing-info\r\n * = Document processing time : https://developers.google.com/web/fundamentals/performance/navigation-and-resource-timing/#document_processing\r\n * + Loading time : https://developers.google.com/web/fundamentals/performance/navigation-and-resource-timing/#loading\r\n */\r\n var navigationTiming = this.getPerformanceNavigationTiming();\r\n var timing = this.getPerformanceTiming();\r\n var total = 0;\r\n var network = 0;\r\n var request = 0;\r\n var response = 0;\r\n var dom = 0;\r\n if (navigationTiming || timing) {\r\n if (navigationTiming) {\r\n total = navigationTiming.duration;\r\n /**\r\n * support both cases:\r\n * - startTime is always zero: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming\r\n * - for older browsers where the startTime is not zero\r\n */\r\n network = navigationTiming.startTime === 0 ? navigationTiming.connectEnd : dateTimeUtilsDuration(navigationTiming.startTime, navigationTiming.connectEnd);\r\n request = dateTimeUtilsDuration(navigationTiming.requestStart, navigationTiming.responseStart);\r\n response = dateTimeUtilsDuration(navigationTiming.responseStart, navigationTiming.responseEnd);\r\n dom = dateTimeUtilsDuration(navigationTiming.responseEnd, navigationTiming.loadEventEnd);\r\n }\r\n else {\r\n total = dateTimeUtilsDuration(timing.navigationStart, timing.loadEventEnd);\r\n network = dateTimeUtilsDuration(timing.navigationStart, timing.connectEnd);\r\n request = dateTimeUtilsDuration(timing.requestStart, timing.responseStart);\r\n response = dateTimeUtilsDuration(timing.responseStart, timing.responseEnd);\r\n dom = dateTimeUtilsDuration(timing.responseEnd, timing.loadEventEnd);\r\n }\r\n var logger = this._logger;\r\n if (total === 0) {\r\n _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 10 /* _eInternalMessageId.ErrorPVCalc */, \"error calculating page view performance.\", { total: total, network: network, request: request, response: response, dom: dom });\r\n }\r\n else if (!this.shouldCollectDuration(total, network, request, response, dom)) {\r\n _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 45 /* _eInternalMessageId.InvalidDurationValue */, \"Invalid page load duration value. Browser perf data won't be sent.\", { total: total, network: network, request: request, response: response, dom: dom });\r\n }\r\n else if (total < Math.floor(network) + Math.floor(request) + Math.floor(response) + Math.floor(dom)) {\r\n // some browsers may report individual components incorrectly so that the sum of the parts will be bigger than total PLT\r\n // in this case, don't report client performance from this page\r\n _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 8 /* _eInternalMessageId.ClientPerformanceMathError */, \"client performance math error.\", { total: total, network: network, request: request, response: response, dom: dom });\r\n }\r\n else {\r\n pageViewPerformance.durationMs = total;\r\n // // convert to timespans\r\n pageViewPerformance.perfTotal = pageViewPerformance.duration = msToTimeSpan(total);\r\n pageViewPerformance.networkConnect = msToTimeSpan(network);\r\n pageViewPerformance.sentRequest = msToTimeSpan(request);\r\n pageViewPerformance.receivedResponse = msToTimeSpan(response);\r\n pageViewPerformance.domProcessing = msToTimeSpan(dom);\r\n pageViewPerformance.isValid = true;\r\n }\r\n }\r\n };\r\n PageViewPerformanceManager.prototype.getPerformanceTiming = function () {\r\n if (this.isPerformanceTimingSupported()) {\r\n return getPerformance().timing;\r\n }\r\n return null;\r\n };\r\n PageViewPerformanceManager.prototype.getPerformanceNavigationTiming = function () {\r\n if (this.isPerformanceNavigationTimingSupported()) {\r\n return getPerformance().getEntriesByType(\"navigation\")[0];\r\n }\r\n return null;\r\n };\r\n /**\r\n * Returns true is window PerformanceNavigationTiming API is supported, false otherwise.\r\n */\r\n PageViewPerformanceManager.prototype.isPerformanceNavigationTimingSupported = function () {\r\n var perf = getPerformance();\r\n return perf && perf.getEntriesByType && perf.getEntriesByType(\"navigation\").length > 0;\r\n };\r\n /**\r\n * Returns true is window performance timing API is supported, false otherwise.\r\n */\r\n PageViewPerformanceManager.prototype.isPerformanceTimingSupported = function () {\r\n var perf = getPerformance();\r\n return perf && perf.timing;\r\n };\r\n /**\r\n * As page loads different parts of performance timing numbers get set. When all of them are set we can report it.\r\n * Returns true if ready, false otherwise.\r\n */\r\n PageViewPerformanceManager.prototype.isPerformanceTimingDataReady = function () {\r\n var perf = getPerformance();\r\n var timing = perf ? perf.timing : 0;\r\n return timing\r\n && timing.domainLookupStart > 0\r\n && timing.navigationStart > 0\r\n && timing.responseStart > 0\r\n && timing.requestStart > 0\r\n && timing.loadEventEnd > 0\r\n && timing.responseEnd > 0\r\n && timing.connectEnd > 0\r\n && timing.domLoading > 0;\r\n };\r\n /**\r\n * This method tells if given durations should be excluded from collection.\r\n */\r\n PageViewPerformanceManager.prototype.shouldCollectDuration = function () {\r\n var durations = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n durations[_i] = arguments[_i];\r\n }\r\n var _navigator = getNavigator() || {};\r\n // a full list of Google crawlers user agent strings - https://support.google.com/webmasters/answer/1061943?hl=en\r\n var botAgentNames = [\"googlebot\", \"adsbot-google\", \"apis-google\", \"mediapartners-google\"];\r\n var userAgent = _navigator.userAgent;\r\n var isGoogleBot = false;\r\n if (userAgent) {\r\n for (var i = 0; i < botAgentNames.length; i++) {\r\n isGoogleBot = isGoogleBot || userAgent.toLowerCase().indexOf(botAgentNames[i]) !== -1;\r\n }\r\n }\r\n if (isGoogleBot) {\r\n // Don't report durations for GoogleBot, it is returning invalid values in performance.timing API.\r\n return false;\r\n }\r\n else {\r\n // for other page views, don't report if it's outside of a reasonable range\r\n for (var i = 0; i < durations.length; i++) {\r\n if (durations[i] < 0 || durations[i] >= this.MAX_DURATION_ALLOWED) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n };\r\n return PageViewPerformanceManager;\r\n}());\r\nexport { PageViewPerformanceManager };\r\n//# sourceMappingURL=PageViewPerformanceManager.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-07
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-10
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-07
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-10
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -15,14 +15,14 @@ var Timing = /** @class */ (function () {
15
15
  var _events = {};
16
16
  _self.start = function (name) {
17
17
  if (typeof _events[name] !== "undefined") {
18
- _throwInternal(logger, 2 /* WARNING */, 62 /* StartCalledMoreThanOnce */, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
18
+ _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 62 /* _eInternalMessageId.StartCalledMoreThanOnce */, "start was called more than once for this event without calling stop.", { name: name, key: name }, true);
19
19
  }
20
20
  _events[name] = +new Date;
21
21
  };
22
22
  _self.stop = function (name, url, properties, measurements) {
23
23
  var start = _events[name];
24
24
  if (isNaN(start)) {
25
- _throwInternal(logger, 2 /* WARNING */, 63 /* StopCalledWithoutStart */, "stop was called without a corresponding start.", { name: name, key: name }, true);
25
+ _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 63 /* _eInternalMessageId.StopCalledWithoutStart */, "stop was called without a corresponding start.", { name: name, key: name }, true);
26
26
  }
27
27
  else {
28
28
  var end = +new Date;
@@ -1 +1 @@
1
- {"version":3,"file":"Timing.js.map","sources":["Timing.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dateTimeUtilsDuration } from \"@microsoft/applicationinsights-common\";\r\nimport { _throwInternal } from \"@microsoft/applicationinsights-core-js\";\r\n/**\r\n * Used to record timed events and page views.\r\n */\r\nvar Timing = /** @class */ (function () {\r\n function Timing(logger, name) {\r\n var _self = this;\r\n var _events = {};\r\n _self.start = function (name) {\r\n if (typeof _events[name] !== \"undefined\") {\r\n _throwInternal(logger, 2 /* WARNING */, 62 /* StartCalledMoreThanOnce */, \"start was called more than once for this event without calling stop.\", { name: name, key: name }, true);\r\n }\r\n _events[name] = +new Date;\r\n };\r\n _self.stop = function (name, url, properties, measurements) {\r\n var start = _events[name];\r\n if (isNaN(start)) {\r\n _throwInternal(logger, 2 /* WARNING */, 63 /* StopCalledWithoutStart */, \"stop was called without a corresponding start.\", { name: name, key: name }, true);\r\n }\r\n else {\r\n var end = +new Date;\r\n var duration = dateTimeUtilsDuration(start, end);\r\n _self.action(name, url, duration, properties, measurements);\r\n }\r\n delete _events[name];\r\n _events[name] = undefined;\r\n };\r\n }\r\n return Timing;\r\n}());\r\nexport { Timing };\r\n//# sourceMappingURL=Timing.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"Timing.js.map","sources":["Timing.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { dateTimeUtilsDuration } from \"@microsoft/applicationinsights-common\";\r\nimport { _throwInternal } from \"@microsoft/applicationinsights-core-js\";\r\n/**\r\n * Used to record timed events and page views.\r\n */\r\nvar Timing = /** @class */ (function () {\r\n function Timing(logger, name) {\r\n var _self = this;\r\n var _events = {};\r\n _self.start = function (name) {\r\n if (typeof _events[name] !== \"undefined\") {\r\n _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 62 /* _eInternalMessageId.StartCalledMoreThanOnce */, \"start was called more than once for this event without calling stop.\", { name: name, key: name }, true);\r\n }\r\n _events[name] = +new Date;\r\n };\r\n _self.stop = function (name, url, properties, measurements) {\r\n var start = _events[name];\r\n if (isNaN(start)) {\r\n _throwInternal(logger, 2 /* eLoggingSeverity.WARNING */, 63 /* _eInternalMessageId.StopCalledWithoutStart */, \"stop was called without a corresponding start.\", { name: name, key: name }, true);\r\n }\r\n else {\r\n var end = +new Date;\r\n var duration = dateTimeUtilsDuration(start, end);\r\n _self.action(name, url, duration, properties, measurements);\r\n }\r\n delete _events[name];\r\n _events[name] = undefined;\r\n };\r\n }\r\n return Timing;\r\n}());\r\nexport { Timing };\r\n//# sourceMappingURL=Timing.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-07
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-10
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-07
2
+ * Application Insights JavaScript SDK - Web Analytics, 2.8.4-nightly.2205-10
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-analytics-js",
3
- "version": "2.8.4-nightly.2205-07",
3
+ "version": "2.8.4-nightly.2205-10",
4
4
  "description": "Microsoft Application Insights JavaScript SDK - Web Analytics",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -26,8 +26,8 @@
26
26
  "@microsoft/ai-test-framework": "0.0.1",
27
27
  "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
28
28
  "@microsoft/applicationinsights-rollup-es3": "1.1.3",
29
- "@microsoft/applicationinsights-properties-js": "2.8.4-nightly.2205-07",
30
- "@microsoft/applicationinsights-channel-js": "2.8.4-nightly.2205-07",
29
+ "@microsoft/applicationinsights-properties-js": "2.8.4-nightly.2205-10",
30
+ "@microsoft/applicationinsights-channel-js": "2.8.4-nightly.2205-10",
31
31
  "@microsoft/api-extractor": "^7.18.1",
32
32
  "typescript": "^4.3.4",
33
33
  "tslib": "^2.0.0",
@@ -39,7 +39,7 @@
39
39
  "@rollup/plugin-replace": "^2.3.3",
40
40
  "rollup-plugin-cleanup": "^3.2.1",
41
41
  "rollup": "^2.32.0",
42
- "grunt": "^1.4.1",
42
+ "grunt": "^1.5.3",
43
43
  "grunt-cli": "^1.4.3",
44
44
  "grunt-contrib-qunit": "^5.0.1",
45
45
  "@nevware21/grunt-ts-plugin": "^0.4.3",
@@ -53,8 +53,8 @@
53
53
  "dependencies": {
54
54
  "@microsoft/dynamicproto-js": "^1.1.6",
55
55
  "@microsoft/applicationinsights-shims": "2.0.1",
56
- "@microsoft/applicationinsights-core-js": "2.8.4-nightly.2205-07",
57
- "@microsoft/applicationinsights-common": "2.8.4-nightly.2205-07"
56
+ "@microsoft/applicationinsights-core-js": "2.8.4-nightly.2205-10",
57
+ "@microsoft/applicationinsights-common": "2.8.4-nightly.2205-10"
58
58
  },
59
59
  "license": "MIT",
60
60
  "publishConfig": {
@@ -9,7 +9,7 @@ import {
9
9
  IExceptionTelemetry, ITraceTelemetry, IMetricTelemetry, IAutoExceptionTelemetry,
10
10
  IPageViewTelemetryInternal, IPageViewTelemetry, IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal,
11
11
  IExceptionInternal, PropertiesPluginIdentifier, AnalyticsPluginIdentifier, stringToBoolOrDefault, createDomEvent,
12
- strNotSpecified, isCrossOriginError, utlDisableStorage, utlEnableStorage, dataSanitizeString
12
+ strNotSpecified, isCrossOriginError, utlDisableStorage, utlEnableStorage, dataSanitizeString, createDistributedTraceContextFromTrace
13
13
  } from "@microsoft/applicationinsights-common";
14
14
 
15
15
  import {
@@ -20,7 +20,7 @@ import {
20
20
  isString, isFunction, isNullOrUndefined, arrForEach, generateW3CId, dumpObj, getExceptionName, ICookieMgr, safeGetCookieMgr,
21
21
  TelemetryInitializerFunction, hasHistory, strUndefined, objDefineAccessors, InstrumentEvent, IInstrumentCallDetails, eventOn, eventOff,
22
22
  mergeEvtNamespace, createUniqueNamespace, ITelemetryInitializerHandler, throwError, isUndefined, hasWindow, createProcessTelemetryContext,
23
- ITelemetryUnloadState, IProcessTelemetryUnloadContext
23
+ ITelemetryUnloadState, IProcessTelemetryUnloadContext, IDistributedTraceContext
24
24
  } from "@microsoft/applicationinsights-core-js";
25
25
  import { PageViewManager, IAppInsightsInternal } from "./Telemetry/PageViewManager";
26
26
  import { PageVisitTimeManager } from "./Telemetry/PageVisitTimeManager";
@@ -109,7 +109,7 @@ function _updateStorageUsage(extConfig: IConfig) {
109
109
  }
110
110
 
111
111
  export class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights, IAppInsightsInternal {
112
- public static Version = "2.8.4-nightly.2205-07"; // Not currently used anywhere
112
+ public static Version = "2.8.4-nightly.2205-10"; // Not currently used anywhere
113
113
 
114
114
  public static getDefaultConfig = _getDefaultConfig;
115
115
 
@@ -736,6 +736,26 @@ export class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights
736
736
  }
737
737
  }
738
738
 
739
+ function _getDistributedTraceCtx(): IDistributedTraceContext {
740
+ let distributedTraceCtx: IDistributedTraceContext = null;
741
+ if (_self.core && _self.core.getTraceCtx) {
742
+ distributedTraceCtx = _self.core.getTraceCtx(false);
743
+ }
744
+
745
+ if (!distributedTraceCtx) {
746
+ // Fallback when using an older Core and PropertiesPlugin
747
+ let properties = _self.core.getPlugin<PropertiesPlugin>(PropertiesPluginIdentifier);
748
+ if (properties) {
749
+ let context = properties.plugin.context;
750
+ if (context) {
751
+ distributedTraceCtx = createDistributedTraceContextFromTrace(context.telemetryTrace);
752
+ }
753
+ }
754
+ }
755
+
756
+ return distributedTraceCtx;
757
+ }
758
+
739
759
  /**
740
760
  * Create a custom "locationchange" event which is triggered each time the history object is changed
741
761
  */
@@ -757,20 +777,16 @@ export class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights
757
777
  }
758
778
 
759
779
  if (_enableAutoRouteTracking) {
760
- let properties = _self.core.getPlugin<PropertiesPlugin>(PropertiesPluginIdentifier);
761
-
762
- if (properties) {
763
- let context = properties.plugin.context;
764
- if (context && context.telemetryTrace) {
765
- context.telemetryTrace.traceID = generateW3CId();
766
- let traceLocationName = "_unknown_";
767
- if (locn && locn.pathname) {
768
- traceLocationName = locn.pathname + (locn.hash || "");
769
- }
770
-
771
- // This populates the ai.operation.name which has a maximum size of 1024 so we need to sanitize it
772
- context.telemetryTrace.name = dataSanitizeString(_self.diagLog(), traceLocationName);
780
+ let distributedTraceCtx = _getDistributedTraceCtx();
781
+ if (distributedTraceCtx) {
782
+ distributedTraceCtx.setTraceId(generateW3CId());
783
+ let traceLocationName = "_unknown_";
784
+ if (locn && locn.pathname) {
785
+ traceLocationName = locn.pathname + (locn.hash || "");
773
786
  }
787
+
788
+ // This populates the ai.operation.name which has a maximum size of 1024 so we need to sanitize it
789
+ distributedTraceCtx.setName(dataSanitizeString(_self.diagLog(), traceLocationName));
774
790
  }
775
791
 
776
792
  setTimeout(((uri: string) => {
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.23.2"
8
+ "packageVersion": "7.24.2"
9
9
  }
10
10
  ]
11
11
  }