@microsoft/applicationinsights-properties-js 3.0.0-beta.2301-12 → 3.0.0-beta.2301-14

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 (36) hide show
  1. package/browser/applicationinsights-properties-js.integrity.json +9 -9
  2. package/browser/applicationinsights-properties-js.js +36 -30
  3. package/browser/applicationinsights-properties-js.js.map +1 -1
  4. package/browser/applicationinsights-properties-js.min.js +2 -2
  5. package/browser/applicationinsights-properties-js.min.js.map +1 -1
  6. package/dist/applicationinsights-properties-js.api.json +69 -26
  7. package/dist/applicationinsights-properties-js.d.ts +1 -1
  8. package/dist/applicationinsights-properties-js.js +36 -30
  9. package/dist/applicationinsights-properties-js.js.map +1 -1
  10. package/dist/applicationinsights-properties-js.min.js +2 -2
  11. package/dist/applicationinsights-properties-js.min.js.map +1 -1
  12. package/dist/applicationinsights-properties-js.rollup.d.ts +1 -1
  13. package/dist-esm/Context/Application.js +1 -1
  14. package/dist-esm/Context/Device.js +1 -1
  15. package/dist-esm/Context/Internal.js +7 -3
  16. package/dist-esm/Context/Internal.js.map +1 -1
  17. package/dist-esm/Context/Location.js +1 -1
  18. package/dist-esm/Context/Session.js +22 -18
  19. package/dist-esm/Context/Session.js.map +1 -1
  20. package/dist-esm/Context/TelemetryTrace.js +1 -1
  21. package/dist-esm/Context/User.js +1 -1
  22. package/dist-esm/Interfaces/IPropTelemetryContext.js +1 -1
  23. package/dist-esm/Interfaces/IPropertiesConfig.js +1 -1
  24. package/dist-esm/PropertiesPlugin.js +9 -9
  25. package/dist-esm/PropertiesPlugin.js.map +1 -1
  26. package/dist-esm/TelemetryContext.js +1 -1
  27. package/dist-esm/__DynamicConstants.js +3 -3
  28. package/dist-esm/__DynamicConstants.js.map +1 -1
  29. package/dist-esm/applicationinsights-properties-js.js +1 -1
  30. package/package.json +3 -3
  31. package/src/Context/Internal.ts +6 -2
  32. package/src/Context/Session.ts +24 -20
  33. package/src/PropertiesPlugin.ts +8 -9
  34. package/src/__DynamicConstants.ts +2 -2
  35. package/types/__DynamicConstants.d.ts +2 -2
  36. package/types/tsdoc-metadata.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights properties plugin, 3.0.0-beta.2301-12
2
+ * Microsoft Application Insights properties plugin, 3.0.0-beta.2301-14
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,17 +1,21 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
+ import { onConfigChange } from "@microsoft/applicationinsights-core-js";
7
8
  var Version = "2.8.5";
8
9
  var Internal = /** @class */ (function () {
9
10
  /**
10
11
  * Constructs a new instance of the internal telemetry data class.
11
12
  */
12
13
  function Internal(config) {
13
- var prefix = config.sdkExtension;
14
- this.sdkVersion = (prefix ? prefix + "_" : "") + "javascript:" + Version;
14
+ var _this = this;
15
+ onConfigChange((config), function () {
16
+ var prefix = config.sdkExtension;
17
+ _this.sdkVersion = (prefix ? prefix + "_" : "") + "javascript:" + Version;
18
+ });
15
19
  }
16
20
  return Internal;
17
21
  }());
@@ -1 +1 @@
1
- {"version":3,"file":"Internal.js.map","sources":["Internal.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nvar Version = \"2.8.5\";\r\nvar Internal = /** @class */ (function () {\r\n /**\r\n * Constructs a new instance of the internal telemetry data class.\r\n */\r\n function Internal(config) {\r\n var prefix = config.sdkExtension;\r\n this.sdkVersion = (prefix ? prefix + \"_\" : \"\") + \"javascript:\" + Version;\r\n }\r\n return Internal;\r\n}());\r\nexport { Internal };\r\n//# sourceMappingURL=Internal.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"Internal.js.map","sources":["Internal.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { onConfigChange } from \"@microsoft/applicationinsights-core-js\";\r\nvar Version = \"2.8.5\";\r\nvar Internal = /** @class */ (function () {\r\n /**\r\n * Constructs a new instance of the internal telemetry data class.\r\n */\r\n function Internal(config) {\r\n var _this = this;\r\n onConfigChange((config), function () {\r\n var prefix = config.sdkExtension;\r\n _this.sdkVersion = (prefix ? prefix + \"_\" : \"\") + \"javascript:\" + Version;\r\n });\r\n }\r\n return Internal;\r\n}());\r\nexport { Internal };\r\n//# sourceMappingURL=Internal.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -21,21 +21,13 @@ export { Session };
21
21
  var _SessionManager = /** @class */ (function () {
22
22
  function _SessionManager(config, core) {
23
23
  var self = this;
24
- var _storageNamePrefix;
25
24
  var _cookieUpdatedTimestamp;
26
25
  var _logger = safeGetLogger(core);
27
26
  var _cookieManager = safeGetCookieMgr(core);
28
- var _sessionExpirationMs;
29
- var _sessionRenewalMs;
30
27
  dynamicProto(_SessionManager, self, function (_self) {
31
28
  if (!config) {
32
29
  config = {};
33
30
  }
34
- _sessionExpirationMs = config.sessionExpirationMs || ACQUISITION_SPAN;
35
- _sessionRenewalMs = config.sessionRenewalMs || RENEWAL_SPAN;
36
- // sessionCookiePostfix takes the preference if it is configured, otherwise takes namePrefix if configured.
37
- var sessionCookiePostfix = config.sessionCookiePostfix || config[_DYN_NAME_PREFIX /* @min:%2enamePrefix */] || "";
38
- _storageNamePrefix = SESSION_COOKIE_NAME + sessionCookiePostfix;
39
31
  _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */] = new Session();
40
32
  _self[_DYN_UPDATE /* @min:%2eupdate */] = function () {
41
33
  // Always using Date getTime() as there is a bug in older IE instances that causes the performance timings to have the hi-bit set eg 0x800000000 causing
@@ -46,12 +38,12 @@ var _SessionManager = /** @class */ (function () {
46
38
  if (!session.id) {
47
39
  isExpired = !_initializeAutomaticSession(session, nowMs);
48
40
  }
49
- if (!isExpired && _sessionExpirationMs > 0) {
41
+ if (!isExpired && _sessionExpirationMs() > 0) {
50
42
  var timeSinceAcqMs = nowMs - session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */];
51
43
  var timeSinceRenewalMs = nowMs - session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */];
52
44
  isExpired = timeSinceAcqMs < 0 || timeSinceRenewalMs < 0; // expired if the acquisition or last renewal are in the future
53
- isExpired = isExpired || timeSinceAcqMs > _sessionExpirationMs; // expired if the time since acquisition is more than session Expiration
54
- isExpired = isExpired || timeSinceRenewalMs > _sessionRenewalMs; // expired if the time since last renewal is more than renewal period
45
+ isExpired = isExpired || timeSinceAcqMs > _sessionExpirationMs(); // expired if the time since acquisition is more than session Expiration
46
+ isExpired = isExpired || timeSinceRenewalMs > _sessionRenewalMs(); // expired if the time since last renewal is more than renewal period
55
47
  }
56
48
  // renew if acquisitionSpan or renewalSpan has elapsed
57
49
  if (isExpired) {
@@ -74,6 +66,18 @@ var _SessionManager = /** @class */ (function () {
74
66
  var session = _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */];
75
67
  _setStorage(session.id, session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */], session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */]);
76
68
  };
69
+ //TODO: move _storageNamePrefix, _sessionExpirationMs _sessionRenewalMs back to local variables after dynamic config fix
70
+ function _storageNamePrefix() {
71
+ // sessionCookiePostfix takes the preference if it is configured, otherwise takes namePrefix if configured.
72
+ var sessionCookiePostfix = config.sessionCookiePostfix || config[_DYN_NAME_PREFIX /* @min:%2enamePrefix */] || "";
73
+ return SESSION_COOKIE_NAME + sessionCookiePostfix;
74
+ }
75
+ function _sessionExpirationMs() {
76
+ return config.sessionExpirationMs || ACQUISITION_SPAN;
77
+ }
78
+ function _sessionRenewalMs() {
79
+ return config.sessionRenewalMs || RENEWAL_SPAN;
80
+ }
77
81
  /**
78
82
  * Use config.namePrefix + ai_session cookie data or local storage data (when the cookie is unavailable) to
79
83
  * initialize the automatic session.
@@ -81,7 +85,7 @@ var _SessionManager = /** @class */ (function () {
81
85
  */
82
86
  function _initializeAutomaticSession(session, now) {
83
87
  var isValid = false;
84
- var cookieValue = _cookieManager.get(_storageNamePrefix);
88
+ var cookieValue = _cookieManager.get(_storageNamePrefix());
85
89
  if (cookieValue && isFunction(cookieValue.split)) {
86
90
  isValid = _initializeAutomaticSessionWithData(session, cookieValue);
87
91
  }
@@ -90,7 +94,7 @@ var _SessionManager = /** @class */ (function () {
90
94
  // This can happen if the session expired or the user actively deleted the cookie
91
95
  // We only want to recover data if the cookie is missing from expiry. We should respect the user's wishes if the cookie was deleted actively.
92
96
  // The User class handles this for us and deletes our local storage object if the persistent user cookie was removed.
93
- var storageValue = utlGetLocalStorage(_logger, _storageNamePrefix);
97
+ var storageValue = utlGetLocalStorage(_logger, _storageNamePrefix());
94
98
  if (storageValue) {
95
99
  isValid = _initializeAutomaticSessionWithData(session, storageValue);
96
100
  }
@@ -145,10 +149,10 @@ var _SessionManager = /** @class */ (function () {
145
149
  function _setCookie(session, nowMs) {
146
150
  var acq = session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */];
147
151
  session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */] = nowMs;
148
- var renewalPeriodMs = _sessionRenewalMs;
152
+ var renewalPeriodMs = _sessionRenewalMs();
149
153
  // Set cookie to expire after the session expiry time passes or the session renewal deadline, whichever is sooner
150
154
  // Expiring the cookie will cause the session to expire even if the user isn't on the page
151
- var acqTimeLeftMs = (acq + _sessionExpirationMs) - nowMs;
155
+ var acqTimeLeftMs = (acq + _sessionExpirationMs()) - nowMs;
152
156
  var cookie = [session.id, acq, nowMs];
153
157
  var maxAgeSec = 0;
154
158
  if (acqTimeLeftMs < renewalPeriodMs) {
@@ -161,14 +165,14 @@ var _SessionManager = /** @class */ (function () {
161
165
  // if sessionExpirationMs is set to 0, it means the expiry is set to 0 for this session cookie
162
166
  // A cookie with 0 expiry in the session cookie will never expire for that browser session. If the browser is closed the cookie expires.
163
167
  // Depending on the browser, another instance does not inherit this cookie, however, another tab will
164
- _cookieManager.set(_storageNamePrefix, cookie[_DYN_JOIN /* @min:%2ejoin */]("|"), _sessionExpirationMs > 0 ? maxAgeSec : null, cookieDomain);
168
+ _cookieManager.set(_storageNamePrefix(), cookie[_DYN_JOIN /* @min:%2ejoin */]("|"), _sessionExpirationMs() > 0 ? maxAgeSec : null, cookieDomain);
165
169
  _cookieUpdatedTimestamp = nowMs;
166
170
  }
167
171
  function _setStorage(guid, acq, renewal) {
168
172
  // Keep data in local storage to retain the last session id, allowing us to cleanly end the session when it expires
169
173
  // Browsers that don't support local storage won't be able to end sessions cleanly from the client
170
174
  // The server will notice this and end the sessions itself, with loss of accurate session duration
171
- utlSetLocalStorage(_logger, _storageNamePrefix, [guid, acq, renewal][_DYN_JOIN /* @min:%2ejoin */]("|"));
175
+ utlSetLocalStorage(_logger, _storageNamePrefix(), [guid, acq, renewal][_DYN_JOIN /* @min:%2ejoin */]("|"));
172
176
  }
173
177
  });
174
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Session.js.map","sources":["Session.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from \"@microsoft/applicationinsights-common\";\r\nimport { _throwInternal, dateNow, dumpObj, getExceptionName, isFunction, newId, safeGetCookieMgr, safeGetLogger } from \"@microsoft/applicationinsights-core-js\";\r\nimport { _DYN_ACQUISITION_DATE, _DYN_AUTOMATIC_SESSION, _DYN_GET_NEW_ID, _DYN_ID_LENGTH, _DYN_JOIN, _DYN_LENGTH, _DYN_NAME_PREFIX, _DYN_RENEWAL_DATE, _DYN_UPDATE } from \"../__DynamicConstants\";\r\nvar SESSION_COOKIE_NAME = \"ai_session\";\r\nvar ACQUISITION_SPAN = 86400000; // 24 hours in ms\r\nvar RENEWAL_SPAN = 1800000; // 30 minutes in ms\r\nvar COOKIE_UPDATE_INTERVAL = 60000; // 1 minute in ms\r\nvar Session = /** @class */ (function () {\r\n function Session() {\r\n }\r\n return Session;\r\n}());\r\nexport { Session };\r\nvar _SessionManager = /** @class */ (function () {\r\n function _SessionManager(config, core) {\r\n var self = this;\r\n var _storageNamePrefix;\r\n var _cookieUpdatedTimestamp;\r\n var _logger = safeGetLogger(core);\r\n var _cookieManager = safeGetCookieMgr(core);\r\n var _sessionExpirationMs;\r\n var _sessionRenewalMs;\r\n dynamicProto(_SessionManager, self, function (_self) {\r\n if (!config) {\r\n config = {};\r\n }\r\n _sessionExpirationMs = config.sessionExpirationMs || ACQUISITION_SPAN;\r\n _sessionRenewalMs = config.sessionRenewalMs || RENEWAL_SPAN;\r\n // sessionCookiePostfix takes the preference if it is configured, otherwise takes namePrefix if configured.\r\n var sessionCookiePostfix = config.sessionCookiePostfix || config[_DYN_NAME_PREFIX /* @min:%2enamePrefix */] || \"\";\r\n _storageNamePrefix = SESSION_COOKIE_NAME + sessionCookiePostfix;\r\n _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */] = new Session();\r\n _self[_DYN_UPDATE /* @min:%2eupdate */] = function () {\r\n // Always using Date getTime() as there is a bug in older IE instances that causes the performance timings to have the hi-bit set eg 0x800000000 causing\r\n // the number to be incorrect.\r\n var nowMs = dateNow();\r\n var isExpired = false;\r\n var session = _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */];\r\n if (!session.id) {\r\n isExpired = !_initializeAutomaticSession(session, nowMs);\r\n }\r\n if (!isExpired && _sessionExpirationMs > 0) {\r\n var timeSinceAcqMs = nowMs - session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */];\r\n var timeSinceRenewalMs = nowMs - session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */];\r\n isExpired = timeSinceAcqMs < 0 || timeSinceRenewalMs < 0; // expired if the acquisition or last renewal are in the future\r\n isExpired = isExpired || timeSinceAcqMs > _sessionExpirationMs; // expired if the time since acquisition is more than session Expiration\r\n isExpired = isExpired || timeSinceRenewalMs > _sessionRenewalMs; // expired if the time since last renewal is more than renewal period\r\n }\r\n // renew if acquisitionSpan or renewalSpan has elapsed\r\n if (isExpired) {\r\n // update automaticSession so session state has correct id\r\n _renew(nowMs);\r\n }\r\n else {\r\n // do not update the cookie more often than cookieUpdateInterval\r\n if (!_cookieUpdatedTimestamp || nowMs - _cookieUpdatedTimestamp > COOKIE_UPDATE_INTERVAL) {\r\n _setCookie(session, nowMs);\r\n }\r\n }\r\n };\r\n /**\r\n * Record the current state of the automatic session and store it in our cookie string format\r\n * into the browser's local storage. This is used to restore the session data when the cookie\r\n * expires.\r\n */\r\n _self.backup = function () {\r\n var session = _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */];\r\n _setStorage(session.id, session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */], session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */]);\r\n };\r\n /**\r\n * Use config.namePrefix + ai_session cookie data or local storage data (when the cookie is unavailable) to\r\n * initialize the automatic session.\r\n * @returns true if values set otherwise false\r\n */\r\n function _initializeAutomaticSession(session, now) {\r\n var isValid = false;\r\n var cookieValue = _cookieManager.get(_storageNamePrefix);\r\n if (cookieValue && isFunction(cookieValue.split)) {\r\n isValid = _initializeAutomaticSessionWithData(session, cookieValue);\r\n }\r\n else {\r\n // There's no cookie, but we might have session data in local storage\r\n // This can happen if the session expired or the user actively deleted the cookie\r\n // We only want to recover data if the cookie is missing from expiry. We should respect the user's wishes if the cookie was deleted actively.\r\n // The User class handles this for us and deletes our local storage object if the persistent user cookie was removed.\r\n var storageValue = utlGetLocalStorage(_logger, _storageNamePrefix);\r\n if (storageValue) {\r\n isValid = _initializeAutomaticSessionWithData(session, storageValue);\r\n }\r\n }\r\n return isValid || !!session.id;\r\n }\r\n /**\r\n * Extract id, acquisitionDate, and renewalDate from an ai_session payload string and\r\n * use this data to initialize automaticSession.\r\n *\r\n * @param sessionData - The string stored in an ai_session cookie or local storage backup\r\n * @returns true if values set otherwise false\r\n */\r\n function _initializeAutomaticSessionWithData(session, sessionData) {\r\n var isValid = false;\r\n var sessionReset = \", session will be reset\";\r\n var tokens = sessionData.split(\"|\");\r\n if (tokens[_DYN_LENGTH /* @min:%2elength */] >= 2) {\r\n try {\r\n var acqMs = +tokens[1] || 0;\r\n var renewalMs = +tokens[2] || 0;\r\n if (isNaN(acqMs) || acqMs <= 0) {\r\n _throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 27 /* _eInternalMessageId.SessionRenewalDateIsZero */, \"AI session acquisition date is 0\" + sessionReset);\r\n }\r\n else if (isNaN(renewalMs) || renewalMs <= 0) {\r\n _throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 27 /* _eInternalMessageId.SessionRenewalDateIsZero */, \"AI session renewal date is 0\" + sessionReset);\r\n }\r\n else if (tokens[0]) {\r\n // Everything looks valid so set the values\r\n session.id = tokens[0];\r\n session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */] = acqMs;\r\n session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */] = renewalMs;\r\n isValid = true;\r\n }\r\n }\r\n catch (e) {\r\n _throwInternal(_logger, 1 /* eLoggingSeverity.CRITICAL */, 9 /* _eInternalMessageId.ErrorParsingAISessionCookie */, \"Error parsing ai_session value [\" + (sessionData || \"\") + \"]\" + sessionReset + \" - \" + getExceptionName(e), { exception: dumpObj(e) });\r\n }\r\n }\r\n return isValid;\r\n }\r\n function _renew(nowMs) {\r\n var getNewId = config[_DYN_GET_NEW_ID /* @min:%2egetNewId */] || newId;\r\n _self.automaticSession.id = getNewId(config[_DYN_ID_LENGTH /* @min:%2eidLength */] || 22);\r\n _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */][_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */] = nowMs;\r\n _setCookie(_self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */], nowMs);\r\n // If this browser does not support local storage, fire an internal log to keep track of it at this point\r\n if (!utlCanUseLocalStorage()) {\r\n _throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 0 /* _eInternalMessageId.BrowserDoesNotSupportLocalStorage */, \"Browser does not support local storage. Session durations will be inaccurate.\");\r\n }\r\n }\r\n function _setCookie(session, nowMs) {\r\n var acq = session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */];\r\n session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */] = nowMs;\r\n var renewalPeriodMs = _sessionRenewalMs;\r\n // Set cookie to expire after the session expiry time passes or the session renewal deadline, whichever is sooner\r\n // Expiring the cookie will cause the session to expire even if the user isn't on the page\r\n var acqTimeLeftMs = (acq + _sessionExpirationMs) - nowMs;\r\n var cookie = [session.id, acq, nowMs];\r\n var maxAgeSec = 0;\r\n if (acqTimeLeftMs < renewalPeriodMs) {\r\n maxAgeSec = acqTimeLeftMs / 1000;\r\n }\r\n else {\r\n maxAgeSec = renewalPeriodMs / 1000;\r\n }\r\n var cookieDomain = config.cookieDomain || null;\r\n // if sessionExpirationMs is set to 0, it means the expiry is set to 0 for this session cookie\r\n // A cookie with 0 expiry in the session cookie will never expire for that browser session. If the browser is closed the cookie expires.\r\n // Depending on the browser, another instance does not inherit this cookie, however, another tab will\r\n _cookieManager.set(_storageNamePrefix, cookie[_DYN_JOIN /* @min:%2ejoin */](\"|\"), _sessionExpirationMs > 0 ? maxAgeSec : null, cookieDomain);\r\n _cookieUpdatedTimestamp = nowMs;\r\n }\r\n function _setStorage(guid, acq, renewal) {\r\n // Keep data in local storage to retain the last session id, allowing us to cleanly end the session when it expires\r\n // Browsers that don't support local storage won't be able to end sessions cleanly from the client\r\n // The server will notice this and end the sessions itself, with loss of accurate session duration\r\n utlSetLocalStorage(_logger, _storageNamePrefix, [guid, acq, renewal][_DYN_JOIN /* @min:%2ejoin */](\"|\"));\r\n }\r\n });\r\n }\r\n _SessionManager.prototype.update = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Record the current state of the automatic session and store it in our cookie string format\r\n * into the browser's local storage. This is used to restore the session data when the cookie\r\n * expires.\r\n */\r\n _SessionManager.prototype.backup = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return _SessionManager;\r\n}());\r\nexport { _SessionManager };\r\n//# sourceMappingURL=Session.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;AACA;AACA;AACA;AACA;AACA;qDAUM,CAAC;;;;;2BACoB;AAC3B;AACA;AACA"}
1
+ {"version":3,"file":"Session.js.map","sources":["Session.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from \"@microsoft/applicationinsights-common\";\r\nimport { _throwInternal, dateNow, dumpObj, getExceptionName, isFunction, newId, safeGetCookieMgr, safeGetLogger } from \"@microsoft/applicationinsights-core-js\";\r\nimport { _DYN_ACQUISITION_DATE, _DYN_AUTOMATIC_SESSION, _DYN_GET_NEW_ID, _DYN_ID_LENGTH, _DYN_JOIN, _DYN_LENGTH, _DYN_NAME_PREFIX, _DYN_RENEWAL_DATE, _DYN_UPDATE } from \"../__DynamicConstants\";\r\nvar SESSION_COOKIE_NAME = \"ai_session\";\r\nvar ACQUISITION_SPAN = 86400000; // 24 hours in ms\r\nvar RENEWAL_SPAN = 1800000; // 30 minutes in ms\r\nvar COOKIE_UPDATE_INTERVAL = 60000; // 1 minute in ms\r\nvar Session = /** @class */ (function () {\r\n function Session() {\r\n }\r\n return Session;\r\n}());\r\nexport { Session };\r\nvar _SessionManager = /** @class */ (function () {\r\n function _SessionManager(config, core) {\r\n var self = this;\r\n var _cookieUpdatedTimestamp;\r\n var _logger = safeGetLogger(core);\r\n var _cookieManager = safeGetCookieMgr(core);\r\n dynamicProto(_SessionManager, self, function (_self) {\r\n if (!config) {\r\n config = {};\r\n }\r\n _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */] = new Session();\r\n _self[_DYN_UPDATE /* @min:%2eupdate */] = function () {\r\n // Always using Date getTime() as there is a bug in older IE instances that causes the performance timings to have the hi-bit set eg 0x800000000 causing\r\n // the number to be incorrect.\r\n var nowMs = dateNow();\r\n var isExpired = false;\r\n var session = _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */];\r\n if (!session.id) {\r\n isExpired = !_initializeAutomaticSession(session, nowMs);\r\n }\r\n if (!isExpired && _sessionExpirationMs() > 0) {\r\n var timeSinceAcqMs = nowMs - session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */];\r\n var timeSinceRenewalMs = nowMs - session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */];\r\n isExpired = timeSinceAcqMs < 0 || timeSinceRenewalMs < 0; // expired if the acquisition or last renewal are in the future\r\n isExpired = isExpired || timeSinceAcqMs > _sessionExpirationMs(); // expired if the time since acquisition is more than session Expiration\r\n isExpired = isExpired || timeSinceRenewalMs > _sessionRenewalMs(); // expired if the time since last renewal is more than renewal period\r\n }\r\n // renew if acquisitionSpan or renewalSpan has elapsed\r\n if (isExpired) {\r\n // update automaticSession so session state has correct id\r\n _renew(nowMs);\r\n }\r\n else {\r\n // do not update the cookie more often than cookieUpdateInterval\r\n if (!_cookieUpdatedTimestamp || nowMs - _cookieUpdatedTimestamp > COOKIE_UPDATE_INTERVAL) {\r\n _setCookie(session, nowMs);\r\n }\r\n }\r\n };\r\n /**\r\n * Record the current state of the automatic session and store it in our cookie string format\r\n * into the browser's local storage. This is used to restore the session data when the cookie\r\n * expires.\r\n */\r\n _self.backup = function () {\r\n var session = _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */];\r\n _setStorage(session.id, session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */], session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */]);\r\n };\r\n //TODO: move _storageNamePrefix, _sessionExpirationMs _sessionRenewalMs back to local variables after dynamic config fix\r\n function _storageNamePrefix() {\r\n // sessionCookiePostfix takes the preference if it is configured, otherwise takes namePrefix if configured.\r\n var sessionCookiePostfix = config.sessionCookiePostfix || config[_DYN_NAME_PREFIX /* @min:%2enamePrefix */] || \"\";\r\n return SESSION_COOKIE_NAME + sessionCookiePostfix;\r\n }\r\n function _sessionExpirationMs() {\r\n return config.sessionExpirationMs || ACQUISITION_SPAN;\r\n }\r\n function _sessionRenewalMs() {\r\n return config.sessionRenewalMs || RENEWAL_SPAN;\r\n }\r\n /**\r\n * Use config.namePrefix + ai_session cookie data or local storage data (when the cookie is unavailable) to\r\n * initialize the automatic session.\r\n * @returns true if values set otherwise false\r\n */\r\n function _initializeAutomaticSession(session, now) {\r\n var isValid = false;\r\n var cookieValue = _cookieManager.get(_storageNamePrefix());\r\n if (cookieValue && isFunction(cookieValue.split)) {\r\n isValid = _initializeAutomaticSessionWithData(session, cookieValue);\r\n }\r\n else {\r\n // There's no cookie, but we might have session data in local storage\r\n // This can happen if the session expired or the user actively deleted the cookie\r\n // We only want to recover data if the cookie is missing from expiry. We should respect the user's wishes if the cookie was deleted actively.\r\n // The User class handles this for us and deletes our local storage object if the persistent user cookie was removed.\r\n var storageValue = utlGetLocalStorage(_logger, _storageNamePrefix());\r\n if (storageValue) {\r\n isValid = _initializeAutomaticSessionWithData(session, storageValue);\r\n }\r\n }\r\n return isValid || !!session.id;\r\n }\r\n /**\r\n * Extract id, acquisitionDate, and renewalDate from an ai_session payload string and\r\n * use this data to initialize automaticSession.\r\n *\r\n * @param sessionData - The string stored in an ai_session cookie or local storage backup\r\n * @returns true if values set otherwise false\r\n */\r\n function _initializeAutomaticSessionWithData(session, sessionData) {\r\n var isValid = false;\r\n var sessionReset = \", session will be reset\";\r\n var tokens = sessionData.split(\"|\");\r\n if (tokens[_DYN_LENGTH /* @min:%2elength */] >= 2) {\r\n try {\r\n var acqMs = +tokens[1] || 0;\r\n var renewalMs = +tokens[2] || 0;\r\n if (isNaN(acqMs) || acqMs <= 0) {\r\n _throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 27 /* _eInternalMessageId.SessionRenewalDateIsZero */, \"AI session acquisition date is 0\" + sessionReset);\r\n }\r\n else if (isNaN(renewalMs) || renewalMs <= 0) {\r\n _throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 27 /* _eInternalMessageId.SessionRenewalDateIsZero */, \"AI session renewal date is 0\" + sessionReset);\r\n }\r\n else if (tokens[0]) {\r\n // Everything looks valid so set the values\r\n session.id = tokens[0];\r\n session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */] = acqMs;\r\n session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */] = renewalMs;\r\n isValid = true;\r\n }\r\n }\r\n catch (e) {\r\n _throwInternal(_logger, 1 /* eLoggingSeverity.CRITICAL */, 9 /* _eInternalMessageId.ErrorParsingAISessionCookie */, \"Error parsing ai_session value [\" + (sessionData || \"\") + \"]\" + sessionReset + \" - \" + getExceptionName(e), { exception: dumpObj(e) });\r\n }\r\n }\r\n return isValid;\r\n }\r\n function _renew(nowMs) {\r\n var getNewId = config[_DYN_GET_NEW_ID /* @min:%2egetNewId */] || newId;\r\n _self.automaticSession.id = getNewId(config[_DYN_ID_LENGTH /* @min:%2eidLength */] || 22);\r\n _self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */][_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */] = nowMs;\r\n _setCookie(_self[_DYN_AUTOMATIC_SESSION /* @min:%2eautomaticSession */], nowMs);\r\n // If this browser does not support local storage, fire an internal log to keep track of it at this point\r\n if (!utlCanUseLocalStorage()) {\r\n _throwInternal(_logger, 2 /* eLoggingSeverity.WARNING */, 0 /* _eInternalMessageId.BrowserDoesNotSupportLocalStorage */, \"Browser does not support local storage. Session durations will be inaccurate.\");\r\n }\r\n }\r\n function _setCookie(session, nowMs) {\r\n var acq = session[_DYN_ACQUISITION_DATE /* @min:%2eacquisitionDate */];\r\n session[_DYN_RENEWAL_DATE /* @min:%2erenewalDate */] = nowMs;\r\n var renewalPeriodMs = _sessionRenewalMs();\r\n // Set cookie to expire after the session expiry time passes or the session renewal deadline, whichever is sooner\r\n // Expiring the cookie will cause the session to expire even if the user isn't on the page\r\n var acqTimeLeftMs = (acq + _sessionExpirationMs()) - nowMs;\r\n var cookie = [session.id, acq, nowMs];\r\n var maxAgeSec = 0;\r\n if (acqTimeLeftMs < renewalPeriodMs) {\r\n maxAgeSec = acqTimeLeftMs / 1000;\r\n }\r\n else {\r\n maxAgeSec = renewalPeriodMs / 1000;\r\n }\r\n var cookieDomain = config.cookieDomain || null;\r\n // if sessionExpirationMs is set to 0, it means the expiry is set to 0 for this session cookie\r\n // A cookie with 0 expiry in the session cookie will never expire for that browser session. If the browser is closed the cookie expires.\r\n // Depending on the browser, another instance does not inherit this cookie, however, another tab will\r\n _cookieManager.set(_storageNamePrefix(), cookie[_DYN_JOIN /* @min:%2ejoin */](\"|\"), _sessionExpirationMs() > 0 ? maxAgeSec : null, cookieDomain);\r\n _cookieUpdatedTimestamp = nowMs;\r\n }\r\n function _setStorage(guid, acq, renewal) {\r\n // Keep data in local storage to retain the last session id, allowing us to cleanly end the session when it expires\r\n // Browsers that don't support local storage won't be able to end sessions cleanly from the client\r\n // The server will notice this and end the sessions itself, with loss of accurate session duration\r\n utlSetLocalStorage(_logger, _storageNamePrefix(), [guid, acq, renewal][_DYN_JOIN /* @min:%2ejoin */](\"|\"));\r\n }\r\n });\r\n }\r\n _SessionManager.prototype.update = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Record the current state of the automatic session and store it in our cookie string format\r\n * into the browser's local storage. This is used to restore the session data when the cookie\r\n * expires.\r\n */\r\n _SessionManager.prototype.backup = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return _SessionManager;\r\n}());\r\nexport { _SessionManager };\r\n//# sourceMappingURL=Session.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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;qDAUM,CAAC;;;;;2BACoB;AAC3B;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  /**
@@ -56,6 +56,14 @@ var PropertiesPlugin = /** @class */ (function (_super) {
56
56
  _self.initialize = function (config, core, extensions, pluginChain) {
57
57
  _base.initialize(config, core, extensions, pluginChain);
58
58
  _populateDefaults(config);
59
+ _previousTraceCtx = core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */](false);
60
+ _context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
61
+ _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context[_DYN_TELEMETRY_TRACE /* @min:%2etelemetryTrace */], _previousTraceCtx);
62
+ core.setTraceCtx(_distributedTraceCtx);
63
+ _self.context.appId = function () {
64
+ var breezeChannel = core.getPlugin(BreezeChannelIdentifier);
65
+ return breezeChannel ? breezeChannel.plugin["_appId"] : null;
66
+ };
59
67
  };
60
68
  /**
61
69
  * Add Part A fields to the event
@@ -111,14 +119,6 @@ var PropertiesPlugin = /** @class */ (function (_super) {
111
119
  _self._addHook(onConfigChange(config, function () {
112
120
  var ctx = createProcessTelemetryContext(null, config, core);
113
121
  _extensionConfig = ctx.getExtCfg(identifier, _defaultConfig);
114
- _previousTraceCtx = core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */](false);
115
- _context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
116
- _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context[_DYN_TELEMETRY_TRACE /* @min:%2etelemetryTrace */], _previousTraceCtx);
117
- core.setTraceCtx(_distributedTraceCtx);
118
- _self.context.appId = function () {
119
- var breezeChannel = core.getPlugin(BreezeChannelIdentifier);
120
- return breezeChannel ? breezeChannel.plugin["_appId"] : null;
121
- };
122
122
  // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class
123
123
  _self["_extConfig"] = _extensionConfig;
124
124
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"PropertiesPlugin.js.map","sources":["PropertiesPlugin.js"],"sourcesContent":["/**\r\n* PropertiesPlugin.ts\r\n* @copyright Microsoft 2018\r\n*/\r\nvar _a;\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BreezeChannelIdentifier, PageView, PropertiesPluginIdentifier, createDistributedTraceContextFromTrace } from \"@microsoft/applicationinsights-common\";\r\nimport { BaseTelemetryPlugin, _InternalLogMessage, _logInternalMessage, createProcessTelemetryContext, getNavigator, getSetValue, isNullOrUndefined, onConfigChange } from \"@microsoft/applicationinsights-core-js\";\r\nimport { objDeepFreeze, objDefineProp } from \"@nevware21/ts-utils\";\r\nimport { TelemetryContext } from \"./TelemetryContext\";\r\nimport { _DYN_ACCOUNT_ID, _DYN_APPLY_APPLICATION_CO1, _DYN_APPLY_DEVICE_CONTEXT, _DYN_APPLY_INTERNAL_CONTE5, _DYN_APPLY_LOCATION_CONTE4, _DYN_APPLY_OPERATING_SYST3, _DYN_APPLY_OPERATION_CONT2, _DYN_APPLY_SESSION_CONTEX0, _DYN_APPLY_USER_CONTEXT, _DYN_GET_NEW_ID, _DYN_GET_SESSION_ID, _DYN_GET_TRACE_CTX, _DYN_ID_LENGTH, _DYN_IS_NEW_USER, _DYN_IS_USER_COOKIE_SET, _DYN_NAME_PREFIX, _DYN_SESSION_COOKIE_POSTF6, _DYN_SESSION_MANAGER, _DYN_TELEMETRY_TRACE, _DYN_UPDATE, _DYN_USER_COOKIE_POSTFIX } from \"./__DynamicConstants\";\r\nvar undefString;\r\nvar nullValue = null;\r\nvar _defaultConfig = objDeepFreeze((_a = {\r\n instrumentationKey: undefString\r\n },\r\n _a[_DYN_ACCOUNT_ID /* @min:accountId */] = nullValue,\r\n _a.sessionRenewalMs = 30 * 60 * 1000,\r\n _a.samplingPercentage = 100,\r\n _a.sessionExpirationMs = 24 * 60 * 60 * 1000,\r\n _a.cookieDomain = nullValue,\r\n _a.sdkExtension = nullValue,\r\n _a.isBrowserLinkTrackingEnabled = false,\r\n _a.appId = nullValue,\r\n _a[_DYN_GET_SESSION_ID /* @min:getSessionId */] = nullValue,\r\n _a[_DYN_NAME_PREFIX /* @min:namePrefix */] = undefString,\r\n _a[_DYN_SESSION_COOKIE_POSTF6 /* @min:sessionCookiePostfix */] = undefString,\r\n _a[_DYN_USER_COOKIE_POSTFIX /* @min:userCookiePostfix */] = undefString,\r\n _a[_DYN_ID_LENGTH /* @min:idLength */] = 22,\r\n _a[_DYN_GET_NEW_ID /* @min:getNewId */] = nullValue,\r\n _a));\r\nvar PropertiesPlugin = /** @class */ (function (_super) {\r\n __extends(PropertiesPlugin, _super);\r\n function PropertiesPlugin() {\r\n var _this = _super.call(this) || this;\r\n _this.priority = 110;\r\n _this.identifier = PropertiesPluginIdentifier;\r\n var _extensionConfig;\r\n var _distributedTraceCtx;\r\n var _previousTraceCtx;\r\n var _context;\r\n dynamicProto(PropertiesPlugin, _this, function (_self, _base) {\r\n _initDefaults();\r\n objDefineProp(_self, \"context\", {\r\n enumerable: true,\r\n configurable: true,\r\n get: function () {\r\n return _context;\r\n }\r\n });\r\n _self.initialize = function (config, core, extensions, pluginChain) {\r\n _base.initialize(config, core, extensions, pluginChain);\r\n _populateDefaults(config);\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event - The event that needs to be processed\r\n */\r\n _self.processTelemetry = function (event, itemCtx) {\r\n if (!isNullOrUndefined(event)) {\r\n itemCtx = _self._getTelCtx(itemCtx);\r\n // If the envelope is PageView, reset the internal message count so that we can send internal telemetry for the new page.\r\n if (event.name === PageView.envelopeType) {\r\n itemCtx.diagLog().resetInternalMessageCount();\r\n }\r\n var theContext = (_context || {});\r\n if (theContext.session) {\r\n // If customer did not provide custom session id update the session manager\r\n if (typeof _context.session.id !== \"string\" && theContext[_DYN_SESSION_MANAGER /* @min:%2esessionManager */]) {\r\n theContext[_DYN_SESSION_MANAGER /* @min:%2esessionManager */][_DYN_UPDATE /* @min:%2eupdate */]();\r\n }\r\n }\r\n var userCtx = theContext.user;\r\n if (userCtx && !userCtx[_DYN_IS_USER_COOKIE_SET /* @min:%2eisUserCookieSet */]) {\r\n userCtx[_DYN_UPDATE /* @min:%2eupdate */](theContext.user.id);\r\n }\r\n _processTelemetryInternal(event, itemCtx);\r\n if (userCtx && userCtx[_DYN_IS_NEW_USER /* @min:%2eisNewUser */]) {\r\n userCtx[_DYN_IS_NEW_USER /* @min:%2eisNewUser */] = false;\r\n var message = new _InternalLogMessage(72 /* _eInternalMessageId.SendBrowserInfoOnUserInit */, ((getNavigator() || {}).userAgent || \"\"));\r\n _logInternalMessage(itemCtx.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, message);\r\n }\r\n _self.processNext(event, itemCtx);\r\n }\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState) {\r\n var core = (unloadCtx || {}).core();\r\n if (core && core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */]) {\r\n var traceCtx = core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */](false);\r\n if (traceCtx === _distributedTraceCtx) {\r\n core.setTraceCtx(_previousTraceCtx);\r\n }\r\n }\r\n _initDefaults();\r\n };\r\n function _initDefaults() {\r\n _extensionConfig = null;\r\n _distributedTraceCtx = null;\r\n _previousTraceCtx = null;\r\n _context = null;\r\n }\r\n function _populateDefaults(config) {\r\n var identifier = _self.identifier;\r\n var core = _self.core;\r\n // This function will be re-called whenever any referenced configuration is changed\r\n _self._addHook(onConfigChange(config, function () {\r\n var ctx = createProcessTelemetryContext(null, config, core);\r\n _extensionConfig = ctx.getExtCfg(identifier, _defaultConfig);\r\n _previousTraceCtx = core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */](false);\r\n _context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);\r\n _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context[_DYN_TELEMETRY_TRACE /* @min:%2etelemetryTrace */], _previousTraceCtx);\r\n core.setTraceCtx(_distributedTraceCtx);\r\n _self.context.appId = function () {\r\n var breezeChannel = core.getPlugin(BreezeChannelIdentifier);\r\n return breezeChannel ? breezeChannel.plugin[\"_appId\"] : null;\r\n };\r\n // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class\r\n _self[\"_extConfig\"] = _extensionConfig;\r\n }));\r\n }\r\n function _processTelemetryInternal(evt, itemCtx) {\r\n // Set Part A fields\r\n getSetValue(evt, \"tags\", []);\r\n getSetValue(evt, \"ext\", {});\r\n var ctx = _self.context;\r\n ctx[_DYN_APPLY_SESSION_CONTEX0 /* @min:%2eapplySessionContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_APPLICATION_CO1 /* @min:%2eapplyApplicationContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_DEVICE_CONTEXT /* @min:%2eapplyDeviceContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_OPERATION_CONT2 /* @min:%2eapplyOperationContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_USER_CONTEXT /* @min:%2eapplyUserContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_OPERATING_SYST3 /* @min:%2eapplyOperatingSystemContxt */](evt, itemCtx);\r\n ctx.applyWebContext(evt, itemCtx);\r\n ctx[_DYN_APPLY_LOCATION_CONTE4 /* @min:%2eapplyLocationContext */](evt, itemCtx); // legacy tags\r\n ctx[_DYN_APPLY_INTERNAL_CONTE5 /* @min:%2eapplyInternalContext */](evt, itemCtx); // legacy tags\r\n ctx.cleanUp(evt, itemCtx);\r\n }\r\n });\r\n return _this;\r\n }\r\n PropertiesPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event - The event that needs to be processed\r\n */\r\n PropertiesPlugin.prototype.processTelemetry = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return PropertiesPlugin;\r\n}(BaseTelemetryPlugin));\r\nexport default PropertiesPlugin;\r\n//# sourceMappingURL=PropertiesPlugin.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA,gFAAkC;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;gEASM,CAAC;;;;;4BACqB;AAC5B;AACA;AACA"}
1
+ {"version":3,"file":"PropertiesPlugin.js.map","sources":["PropertiesPlugin.js"],"sourcesContent":["/**\r\n* PropertiesPlugin.ts\r\n* @copyright Microsoft 2018\r\n*/\r\nvar _a;\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BreezeChannelIdentifier, PageView, PropertiesPluginIdentifier, createDistributedTraceContextFromTrace } from \"@microsoft/applicationinsights-common\";\r\nimport { BaseTelemetryPlugin, _InternalLogMessage, _logInternalMessage, createProcessTelemetryContext, getNavigator, getSetValue, isNullOrUndefined, onConfigChange } from \"@microsoft/applicationinsights-core-js\";\r\nimport { objDeepFreeze, objDefineProp } from \"@nevware21/ts-utils\";\r\nimport { TelemetryContext } from \"./TelemetryContext\";\r\nimport { _DYN_ACCOUNT_ID, _DYN_APPLY_APPLICATION_CO1, _DYN_APPLY_DEVICE_CONTEXT, _DYN_APPLY_INTERNAL_CONTE5, _DYN_APPLY_LOCATION_CONTE4, _DYN_APPLY_OPERATING_SYST3, _DYN_APPLY_OPERATION_CONT2, _DYN_APPLY_SESSION_CONTEX0, _DYN_APPLY_USER_CONTEXT, _DYN_GET_NEW_ID, _DYN_GET_SESSION_ID, _DYN_GET_TRACE_CTX, _DYN_ID_LENGTH, _DYN_IS_NEW_USER, _DYN_IS_USER_COOKIE_SET, _DYN_NAME_PREFIX, _DYN_SESSION_COOKIE_POSTF6, _DYN_SESSION_MANAGER, _DYN_TELEMETRY_TRACE, _DYN_UPDATE, _DYN_USER_COOKIE_POSTFIX } from \"./__DynamicConstants\";\r\nvar undefString;\r\nvar nullValue = null;\r\nvar _defaultConfig = objDeepFreeze((_a = {\r\n instrumentationKey: undefString\r\n },\r\n _a[_DYN_ACCOUNT_ID /* @min:accountId */] = nullValue,\r\n _a.sessionRenewalMs = 30 * 60 * 1000,\r\n _a.samplingPercentage = 100,\r\n _a.sessionExpirationMs = 24 * 60 * 60 * 1000,\r\n _a.cookieDomain = nullValue,\r\n _a.sdkExtension = nullValue,\r\n _a.isBrowserLinkTrackingEnabled = false,\r\n _a.appId = nullValue,\r\n _a[_DYN_GET_SESSION_ID /* @min:getSessionId */] = nullValue,\r\n _a[_DYN_NAME_PREFIX /* @min:namePrefix */] = undefString,\r\n _a[_DYN_SESSION_COOKIE_POSTF6 /* @min:sessionCookiePostfix */] = undefString,\r\n _a[_DYN_USER_COOKIE_POSTFIX /* @min:userCookiePostfix */] = undefString,\r\n _a[_DYN_ID_LENGTH /* @min:idLength */] = 22,\r\n _a[_DYN_GET_NEW_ID /* @min:getNewId */] = nullValue,\r\n _a));\r\nvar PropertiesPlugin = /** @class */ (function (_super) {\r\n __extends(PropertiesPlugin, _super);\r\n function PropertiesPlugin() {\r\n var _this = _super.call(this) || this;\r\n _this.priority = 110;\r\n _this.identifier = PropertiesPluginIdentifier;\r\n var _extensionConfig;\r\n var _distributedTraceCtx;\r\n var _previousTraceCtx;\r\n var _context;\r\n dynamicProto(PropertiesPlugin, _this, function (_self, _base) {\r\n _initDefaults();\r\n objDefineProp(_self, \"context\", {\r\n enumerable: true,\r\n configurable: true,\r\n get: function () {\r\n return _context;\r\n }\r\n });\r\n _self.initialize = function (config, core, extensions, pluginChain) {\r\n _base.initialize(config, core, extensions, pluginChain);\r\n _populateDefaults(config);\r\n _previousTraceCtx = core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */](false);\r\n _context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);\r\n _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context[_DYN_TELEMETRY_TRACE /* @min:%2etelemetryTrace */], _previousTraceCtx);\r\n core.setTraceCtx(_distributedTraceCtx);\r\n _self.context.appId = function () {\r\n var breezeChannel = core.getPlugin(BreezeChannelIdentifier);\r\n return breezeChannel ? breezeChannel.plugin[\"_appId\"] : null;\r\n };\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event - The event that needs to be processed\r\n */\r\n _self.processTelemetry = function (event, itemCtx) {\r\n if (!isNullOrUndefined(event)) {\r\n itemCtx = _self._getTelCtx(itemCtx);\r\n // If the envelope is PageView, reset the internal message count so that we can send internal telemetry for the new page.\r\n if (event.name === PageView.envelopeType) {\r\n itemCtx.diagLog().resetInternalMessageCount();\r\n }\r\n var theContext = (_context || {});\r\n if (theContext.session) {\r\n // If customer did not provide custom session id update the session manager\r\n if (typeof _context.session.id !== \"string\" && theContext[_DYN_SESSION_MANAGER /* @min:%2esessionManager */]) {\r\n theContext[_DYN_SESSION_MANAGER /* @min:%2esessionManager */][_DYN_UPDATE /* @min:%2eupdate */]();\r\n }\r\n }\r\n var userCtx = theContext.user;\r\n if (userCtx && !userCtx[_DYN_IS_USER_COOKIE_SET /* @min:%2eisUserCookieSet */]) {\r\n userCtx[_DYN_UPDATE /* @min:%2eupdate */](theContext.user.id);\r\n }\r\n _processTelemetryInternal(event, itemCtx);\r\n if (userCtx && userCtx[_DYN_IS_NEW_USER /* @min:%2eisNewUser */]) {\r\n userCtx[_DYN_IS_NEW_USER /* @min:%2eisNewUser */] = false;\r\n var message = new _InternalLogMessage(72 /* _eInternalMessageId.SendBrowserInfoOnUserInit */, ((getNavigator() || {}).userAgent || \"\"));\r\n _logInternalMessage(itemCtx.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, message);\r\n }\r\n _self.processNext(event, itemCtx);\r\n }\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState) {\r\n var core = (unloadCtx || {}).core();\r\n if (core && core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */]) {\r\n var traceCtx = core[_DYN_GET_TRACE_CTX /* @min:%2egetTraceCtx */](false);\r\n if (traceCtx === _distributedTraceCtx) {\r\n core.setTraceCtx(_previousTraceCtx);\r\n }\r\n }\r\n _initDefaults();\r\n };\r\n function _initDefaults() {\r\n _extensionConfig = null;\r\n _distributedTraceCtx = null;\r\n _previousTraceCtx = null;\r\n _context = null;\r\n }\r\n function _populateDefaults(config) {\r\n var identifier = _self.identifier;\r\n var core = _self.core;\r\n // This function will be re-called whenever any referenced configuration is changed\r\n _self._addHook(onConfigChange(config, function () {\r\n var ctx = createProcessTelemetryContext(null, config, core);\r\n _extensionConfig = ctx.getExtCfg(identifier, _defaultConfig);\r\n // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class\r\n _self[\"_extConfig\"] = _extensionConfig;\r\n }));\r\n }\r\n function _processTelemetryInternal(evt, itemCtx) {\r\n // Set Part A fields\r\n getSetValue(evt, \"tags\", []);\r\n getSetValue(evt, \"ext\", {});\r\n var ctx = _self.context;\r\n ctx[_DYN_APPLY_SESSION_CONTEX0 /* @min:%2eapplySessionContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_APPLICATION_CO1 /* @min:%2eapplyApplicationContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_DEVICE_CONTEXT /* @min:%2eapplyDeviceContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_OPERATION_CONT2 /* @min:%2eapplyOperationContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_USER_CONTEXT /* @min:%2eapplyUserContext */](evt, itemCtx);\r\n ctx[_DYN_APPLY_OPERATING_SYST3 /* @min:%2eapplyOperatingSystemContxt */](evt, itemCtx);\r\n ctx.applyWebContext(evt, itemCtx);\r\n ctx[_DYN_APPLY_LOCATION_CONTE4 /* @min:%2eapplyLocationContext */](evt, itemCtx); // legacy tags\r\n ctx[_DYN_APPLY_INTERNAL_CONTE5 /* @min:%2eapplyInternalContext */](evt, itemCtx); // legacy tags\r\n ctx.cleanUp(evt, itemCtx);\r\n }\r\n });\r\n return _this;\r\n }\r\n PropertiesPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add Part A fields to the event\r\n * @param event - The event that needs to be processed\r\n */\r\n PropertiesPlugin.prototype.processTelemetry = function (event, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return PropertiesPlugin;\r\n}(BaseTelemetryPlugin));\r\nexport default PropertiesPlugin;\r\n//# sourceMappingURL=PropertiesPlugin.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA,gFAAkC;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;gEASM,CAAC;;;;;4BACqB;AAC5B;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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 - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -11,12 +11,12 @@
11
11
  // ###########################################################################################################################################
12
12
  // Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change
13
13
  // ###########################################################################################################################################
14
+ export var _DYN_GET_TRACE_CTX = "getTraceCtx"; // Count: 3
15
+ export var _DYN_TELEMETRY_TRACE = "telemetryTrace"; // Count: 3
14
16
  export var _DYN_SESSION_MANAGER = "sessionManager"; // Count: 3
15
17
  export var _DYN_UPDATE = "update"; // Count: 4
16
18
  export var _DYN_IS_USER_COOKIE_SET = "isUserCookieSet"; // Count: 4
17
19
  export var _DYN_IS_NEW_USER = "isNewUser"; // Count: 4
18
- export var _DYN_GET_TRACE_CTX = "getTraceCtx"; // Count: 3
19
- export var _DYN_TELEMETRY_TRACE = "telemetryTrace"; // Count: 3
20
20
  export var _DYN_APPLY_SESSION_CONTEX0 = "applySessionContext"; // Count: 2
21
21
  export var _DYN_APPLY_APPLICATION_CO1 = "applyApplicationContext"; // Count: 2
22
22
  export var _DYN_APPLY_DEVICE_CONTEXT = "applyDeviceContext"; // Count: 2
@@ -1 +1 @@
1
- {"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// ###########################################################################################################################################\r\n// Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change\r\n// ###########################################################################################################################################\r\nexport var _DYN_SESSION_MANAGER = \"sessionManager\"; // Count: 3\r\nexport var _DYN_UPDATE = \"update\"; // Count: 4\r\nexport var _DYN_IS_USER_COOKIE_SET = \"isUserCookieSet\"; // Count: 4\r\nexport var _DYN_IS_NEW_USER = \"isNewUser\"; // Count: 4\r\nexport var _DYN_GET_TRACE_CTX = \"getTraceCtx\"; // Count: 3\r\nexport var _DYN_TELEMETRY_TRACE = \"telemetryTrace\"; // Count: 3\r\nexport var _DYN_APPLY_SESSION_CONTEX0 = \"applySessionContext\"; // Count: 2\r\nexport var _DYN_APPLY_APPLICATION_CO1 = \"applyApplicationContext\"; // Count: 2\r\nexport var _DYN_APPLY_DEVICE_CONTEXT = \"applyDeviceContext\"; // Count: 2\r\nexport var _DYN_APPLY_OPERATION_CONT2 = \"applyOperationContext\"; // Count: 2\r\nexport var _DYN_APPLY_USER_CONTEXT = \"applyUserContext\"; // Count: 2\r\nexport var _DYN_APPLY_OPERATING_SYST3 = \"applyOperatingSystemContxt\"; // Count: 2\r\nexport var _DYN_APPLY_LOCATION_CONTE4 = \"applyLocationContext\"; // Count: 2\r\nexport var _DYN_APPLY_INTERNAL_CONTE5 = \"applyInternalContext\"; // Count: 2\r\nexport var _DYN_ACCOUNT_ID = \"accountId\"; // Count: 7\r\nexport var _DYN_GET_SESSION_ID = \"getSessionId\"; // Count: 4\r\nexport var _DYN_NAME_PREFIX = \"namePrefix\"; // Count: 3\r\nexport var _DYN_SESSION_COOKIE_POSTF6 = \"sessionCookiePostfix\"; // Count: 2\r\nexport var _DYN_USER_COOKIE_POSTFIX = \"userCookiePostfix\"; // Count: 2\r\nexport var _DYN_ID_LENGTH = \"idLength\"; // Count: 4\r\nexport var _DYN_GET_NEW_ID = \"getNewId\"; // Count: 3\r\nexport var _DYN_LENGTH = \"length\"; // Count: 4\r\nexport var _DYN_AUTOMATIC_SESSION = \"automaticSession\"; // Count: 5\r\nexport var _DYN_AUTHENTICATED_ID = \"authenticatedId\"; // Count: 6\r\nexport var _DYN_ACQUISITION_DATE = \"acquisitionDate\"; // Count: 5\r\nexport var _DYN_RENEWAL_DATE = \"renewalDate\"; // Count: 4\r\nexport var _DYN_JOIN = \"join\"; // Count: 5\r\nexport var _DYN_COOKIE_SEPARATOR = \"cookieSeparator\"; // Count: 5\r\nexport var _DYN_AUTH_USER_COOKIE_NAM7 = \"authUserCookieName\"; // Count: 3\r\n//# sourceMappingURL=__DynamicConstants.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"}
1
+ {"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// ###########################################################################################################################################\r\n// Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change\r\n// ###########################################################################################################################################\r\nexport var _DYN_GET_TRACE_CTX = \"getTraceCtx\"; // Count: 3\r\nexport var _DYN_TELEMETRY_TRACE = \"telemetryTrace\"; // Count: 3\r\nexport var _DYN_SESSION_MANAGER = \"sessionManager\"; // Count: 3\r\nexport var _DYN_UPDATE = \"update\"; // Count: 4\r\nexport var _DYN_IS_USER_COOKIE_SET = \"isUserCookieSet\"; // Count: 4\r\nexport var _DYN_IS_NEW_USER = \"isNewUser\"; // Count: 4\r\nexport var _DYN_APPLY_SESSION_CONTEX0 = \"applySessionContext\"; // Count: 2\r\nexport var _DYN_APPLY_APPLICATION_CO1 = \"applyApplicationContext\"; // Count: 2\r\nexport var _DYN_APPLY_DEVICE_CONTEXT = \"applyDeviceContext\"; // Count: 2\r\nexport var _DYN_APPLY_OPERATION_CONT2 = \"applyOperationContext\"; // Count: 2\r\nexport var _DYN_APPLY_USER_CONTEXT = \"applyUserContext\"; // Count: 2\r\nexport var _DYN_APPLY_OPERATING_SYST3 = \"applyOperatingSystemContxt\"; // Count: 2\r\nexport var _DYN_APPLY_LOCATION_CONTE4 = \"applyLocationContext\"; // Count: 2\r\nexport var _DYN_APPLY_INTERNAL_CONTE5 = \"applyInternalContext\"; // Count: 2\r\nexport var _DYN_ACCOUNT_ID = \"accountId\"; // Count: 7\r\nexport var _DYN_GET_SESSION_ID = \"getSessionId\"; // Count: 4\r\nexport var _DYN_NAME_PREFIX = \"namePrefix\"; // Count: 3\r\nexport var _DYN_SESSION_COOKIE_POSTF6 = \"sessionCookiePostfix\"; // Count: 2\r\nexport var _DYN_USER_COOKIE_POSTFIX = \"userCookiePostfix\"; // Count: 2\r\nexport var _DYN_ID_LENGTH = \"idLength\"; // Count: 4\r\nexport var _DYN_GET_NEW_ID = \"getNewId\"; // Count: 3\r\nexport var _DYN_LENGTH = \"length\"; // Count: 4\r\nexport var _DYN_AUTOMATIC_SESSION = \"automaticSession\"; // Count: 5\r\nexport var _DYN_AUTHENTICATED_ID = \"authenticatedId\"; // Count: 6\r\nexport var _DYN_ACQUISITION_DATE = \"acquisitionDate\"; // Count: 5\r\nexport var _DYN_RENEWAL_DATE = \"renewalDate\"; // Count: 4\r\nexport var _DYN_JOIN = \"join\"; // Count: 5\r\nexport var _DYN_COOKIE_SEPARATOR = \"cookieSeparator\"; // Count: 5\r\nexport var _DYN_AUTH_USER_COOKIE_NAM7 = \"authUserCookieName\"; // Count: 3\r\n//# sourceMappingURL=__DynamicConstants.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"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-12
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2301-14
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-properties-js",
3
- "version": "3.0.0-beta.2301-12",
3
+ "version": "3.0.0-beta.2301-14",
4
4
  "description": "Microsoft Application Insights properties (Part A) plugin",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -54,8 +54,8 @@
54
54
  "dependencies": {
55
55
  "@microsoft/dynamicproto-js": "^1.1.7",
56
56
  "@microsoft/applicationinsights-shims": "2.0.2",
57
- "@microsoft/applicationinsights-core-js": "3.0.0-beta.2301-12",
58
- "@microsoft/applicationinsights-common": "3.0.0-beta.2301-12",
57
+ "@microsoft/applicationinsights-core-js": "3.0.0-beta.2301-14",
58
+ "@microsoft/applicationinsights-common": "3.0.0-beta.2301-14",
59
59
  "@nevware21/ts-utils": "^0.6.0"
60
60
  },
61
61
  "license": "MIT",
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  import { IInternal } from "@microsoft/applicationinsights-common";
5
+ import { onConfigChange } from "@microsoft/applicationinsights-core-js";
5
6
  import { IPropertiesConfig } from "../Interfaces/IPropertiesConfig";
6
7
 
7
8
  const Version = "2.8.5";
@@ -37,7 +38,10 @@ export class Internal implements IInternal {
37
38
  * Constructs a new instance of the internal telemetry data class.
38
39
  */
39
40
  constructor(config: IPropertiesConfig) {
40
- let prefix = config.sdkExtension;
41
- this.sdkVersion = (prefix ? prefix + "_" : "") + "javascript:" + Version;
41
+
42
+ onConfigChange((config), () => {
43
+ let prefix = config.sdkExtension;
44
+ this.sdkVersion = (prefix ? prefix + "_" : "") + "javascript:" + Version;
45
+ });
42
46
  }
43
47
  }
@@ -53,12 +53,9 @@ export class _SessionManager {
53
53
 
54
54
  constructor(config: ISessionConfig, core?: IAppInsightsCore) {
55
55
  let self = this;
56
- let _storageNamePrefix: string;
57
56
  let _cookieUpdatedTimestamp: number;
58
57
  let _logger: IDiagnosticLogger = safeGetLogger(core);
59
58
  let _cookieManager: ICookieMgr = safeGetCookieMgr(core);
60
- let _sessionExpirationMs: number;
61
- let _sessionRenewalMs: number;
62
59
 
63
60
  dynamicProto(_SessionManager, self, (_self) => {
64
61
 
@@ -66,14 +63,6 @@ export class _SessionManager {
66
63
  config = ({} as any);
67
64
  }
68
65
 
69
- _sessionExpirationMs = config.sessionExpirationMs || ACQUISITION_SPAN;
70
- _sessionRenewalMs = config.sessionRenewalMs || RENEWAL_SPAN;
71
-
72
- // sessionCookiePostfix takes the preference if it is configured, otherwise takes namePrefix if configured.
73
- const sessionCookiePostfix = config.sessionCookiePostfix || config.namePrefix || "";
74
-
75
- _storageNamePrefix = SESSION_COOKIE_NAME + sessionCookiePostfix;
76
-
77
66
  _self.automaticSession = new Session();
78
67
 
79
68
  _self.update = () => {
@@ -87,12 +76,12 @@ export class _SessionManager {
87
76
  isExpired = !_initializeAutomaticSession(session, nowMs);
88
77
  }
89
78
 
90
- if (!isExpired && _sessionExpirationMs > 0) {
79
+ if (!isExpired && _sessionExpirationMs() > 0) {
91
80
  const timeSinceAcqMs = nowMs - session.acquisitionDate;
92
81
  const timeSinceRenewalMs = nowMs - session.renewalDate;
93
82
  isExpired = timeSinceAcqMs < 0 || timeSinceRenewalMs < 0; // expired if the acquisition or last renewal are in the future
94
- isExpired = isExpired || timeSinceAcqMs > _sessionExpirationMs; // expired if the time since acquisition is more than session Expiration
95
- isExpired = isExpired || timeSinceRenewalMs > _sessionRenewalMs; // expired if the time since last renewal is more than renewal period
83
+ isExpired = isExpired || timeSinceAcqMs > _sessionExpirationMs(); // expired if the time since acquisition is more than session Expiration
84
+ isExpired = isExpired || timeSinceRenewalMs > _sessionRenewalMs(); // expired if the time since last renewal is more than renewal period
96
85
  }
97
86
 
98
87
  // renew if acquisitionSpan or renewalSpan has elapsed
@@ -116,6 +105,21 @@ export class _SessionManager {
116
105
  const session = _self.automaticSession;
117
106
  _setStorage(session.id, session.acquisitionDate, session.renewalDate);
118
107
  };
108
+
109
+ //TODO: move _storageNamePrefix, _sessionExpirationMs _sessionRenewalMs back to local variables after dynamic config fix
110
+ function _storageNamePrefix(): string {
111
+ // sessionCookiePostfix takes the preference if it is configured, otherwise takes namePrefix if configured.
112
+ let sessionCookiePostfix = config.sessionCookiePostfix || config.namePrefix || "";
113
+ return SESSION_COOKIE_NAME + sessionCookiePostfix;
114
+ }
115
+
116
+ function _sessionExpirationMs(): number {
117
+ return config.sessionExpirationMs || ACQUISITION_SPAN;
118
+ }
119
+
120
+ function _sessionRenewalMs(): number {
121
+ return config.sessionRenewalMs || RENEWAL_SPAN;
122
+ }
119
123
 
120
124
  /**
121
125
  * Use config.namePrefix + ai_session cookie data or local storage data (when the cookie is unavailable) to
@@ -124,7 +128,7 @@ export class _SessionManager {
124
128
  */
125
129
  function _initializeAutomaticSession(session: ISession, now: number): boolean {
126
130
  let isValid = false;
127
- const cookieValue = _cookieManager.get(_storageNamePrefix);
131
+ const cookieValue = _cookieManager.get(_storageNamePrefix());
128
132
  if (cookieValue && isFunction(cookieValue.split)) {
129
133
  isValid = _initializeAutomaticSessionWithData(session, cookieValue);
130
134
  } else {
@@ -132,7 +136,7 @@ export class _SessionManager {
132
136
  // This can happen if the session expired or the user actively deleted the cookie
133
137
  // We only want to recover data if the cookie is missing from expiry. We should respect the user's wishes if the cookie was deleted actively.
134
138
  // The User class handles this for us and deletes our local storage object if the persistent user cookie was removed.
135
- const storageValue = utlGetLocalStorage(_logger, _storageNamePrefix);
139
+ const storageValue = utlGetLocalStorage(_logger, _storageNamePrefix());
136
140
  if (storageValue) {
137
141
  isValid = _initializeAutomaticSessionWithData(session, storageValue);
138
142
  }
@@ -206,11 +210,11 @@ export class _SessionManager {
206
210
  let acq = session.acquisitionDate;
207
211
  session.renewalDate = nowMs;
208
212
 
209
- let renewalPeriodMs = _sessionRenewalMs;
213
+ let renewalPeriodMs = _sessionRenewalMs();
210
214
 
211
215
  // Set cookie to expire after the session expiry time passes or the session renewal deadline, whichever is sooner
212
216
  // Expiring the cookie will cause the session to expire even if the user isn't on the page
213
- const acqTimeLeftMs = (acq +_sessionExpirationMs) - nowMs;
217
+ const acqTimeLeftMs = (acq +_sessionExpirationMs()) - nowMs;
214
218
  const cookie = [session.id, acq, nowMs];
215
219
  let maxAgeSec = 0;
216
220
 
@@ -225,7 +229,7 @@ export class _SessionManager {
225
229
  // if sessionExpirationMs is set to 0, it means the expiry is set to 0 for this session cookie
226
230
  // A cookie with 0 expiry in the session cookie will never expire for that browser session. If the browser is closed the cookie expires.
227
231
  // Depending on the browser, another instance does not inherit this cookie, however, another tab will
228
- _cookieManager.set(_storageNamePrefix, cookie.join("|"), _sessionExpirationMs > 0 ? maxAgeSec : null, cookieDomain);
232
+ _cookieManager.set(_storageNamePrefix(), cookie.join("|"), _sessionExpirationMs() > 0 ? maxAgeSec : null, cookieDomain);
229
233
  _cookieUpdatedTimestamp = nowMs;
230
234
  }
231
235
 
@@ -233,7 +237,7 @@ export class _SessionManager {
233
237
  // Keep data in local storage to retain the last session id, allowing us to cleanly end the session when it expires
234
238
  // Browsers that don't support local storage won't be able to end sessions cleanly from the client
235
239
  // The server will notice this and end the sessions itself, with loss of accurate session duration
236
- utlSetLocalStorage(_logger, _storageNamePrefix, [guid, acq, renewal].join("|"));
240
+ utlSetLocalStorage(_logger, _storageNamePrefix(), [guid, acq, renewal].join("|"));
237
241
  }
238
242
  });
239
243
  }
@@ -68,6 +68,14 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
68
68
  _self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => {
69
69
  _base.initialize(config, core, extensions, pluginChain);
70
70
  _populateDefaults(config);
71
+ _previousTraceCtx = core.getTraceCtx(false);
72
+ _context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
73
+ _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context.telemetryTrace, _previousTraceCtx);
74
+ core.setTraceCtx(_distributedTraceCtx);
75
+ _self.context.appId = () => {
76
+ let breezeChannel = core.getPlugin<IPlugin>(BreezeChannelIdentifier);
77
+ return breezeChannel ? breezeChannel.plugin["_appId"] : null;
78
+ };
71
79
  };
72
80
 
73
81
  /**
@@ -135,15 +143,6 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
135
143
  _self._addHook(onConfigChange(config, () => {
136
144
  let ctx = createProcessTelemetryContext(null, config, core);
137
145
  _extensionConfig = ctx.getExtCfg(identifier, _defaultConfig);
138
-
139
- _previousTraceCtx = core.getTraceCtx(false);
140
- _context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
141
- _distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context.telemetryTrace, _previousTraceCtx);
142
- core.setTraceCtx(_distributedTraceCtx);
143
- _self.context.appId = () => {
144
- let breezeChannel = core.getPlugin<IPlugin>(BreezeChannelIdentifier);
145
- return breezeChannel ? breezeChannel.plugin["_appId"] : null;
146
- };
147
146
 
148
147
  // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class
149
148
  _self["_extConfig"] = _extensionConfig;