@microsoft/applicationinsights-web-basic 3.0.0-beta.2211-04 → 3.0.0-beta.2212-03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser/aib.2.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2211-04
2
+ * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -582,114 +582,39 @@
582
582
  return registry.k[key];
583
583
  }
584
584
 
585
- function objSetPrototypeOf(obj, proto) {
586
- var fn = ObjClass["setPrototypeOf"] ||
587
- ({ __proto__: [] } instanceof Array && function (d, b) {
588
- d.__proto__ = b;
589
- }) ||
590
- function (d, b) {
591
- objForEachKey(b, function (key, value) {
592
- d[key] = value;
593
- });
594
- };
595
- return fn(obj, proto);
596
- }
597
-
598
- function _createCustomError(name, d, b) {
599
- objSetPrototypeOf(d, b);
600
- function __() {
601
- this.constructor = d;
602
- }
603
- __[PROTOTYPE] = b[PROTOTYPE];
604
- __[PROTOTYPE].name = name;
605
- d[PROTOTYPE] = new __();
606
- return d;
607
- }
608
- function createCustomError(name, constructCb) {
609
- var baseClass = Error;
610
- var customError = _createCustomError(name, function () {
611
- var _this = this;
612
- _this = baseClass.apply(_this, arguments) || _this;
613
- constructCb && constructCb(_this, arguments);
614
- return _this;
615
- }, baseClass);
616
- return customError;
617
- }
618
- var _unsupportedError;
619
- function throwUnsupported(message) {
620
- if (!_unsupportedError) {
621
- _unsupportedError = createCustomError("UnsupportedError");
622
- }
623
- throw new _unsupportedError(message);
624
- }
625
-
626
- function dumpObj(object, format) {
627
- var objectTypeDump = objToString(object);
628
- var propertyValueDump = "";
629
- if (objectTypeDump === "[object Error]") {
630
- propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
631
- }
632
- else {
633
- try {
634
- if (format) {
635
- if (isNumber(format)) {
636
- propertyValueDump = JSON.stringify(object, null, format);
637
- }
638
- else {
639
- propertyValueDump = JSON.stringify(object, null, 4);
640
- }
641
- }
642
- else {
643
- propertyValueDump = JSON.stringify(object);
644
- }
645
- }
646
- catch (e) {
647
- propertyValueDump = objToString(object) + " - " + dumpObj(e, format);
648
- }
649
- }
650
- return objectTypeDump + ": " + propertyValueDump;
651
- }
652
-
653
- var _objDefineProperty$1 = ObjClass["defineProperty"];
654
- function objDefineProp(target, key, descriptor) {
655
- if (_objDefineProperty$1) {
656
- _objDefineProperty$1(target, key, descriptor);
657
- return target;
658
- }
659
- throwUnsupported("Unable to define property [" + objToString(key) + "] on " + dumpObj(target));
585
+ var propMap = {
586
+ e: "enumerable",
587
+ c: "configurable",
588
+ v: VALUE,
589
+ w: "writable",
590
+ g: "get",
591
+ s: "set"
592
+ };
593
+ function _createProp(value) {
594
+ var prop = {};
595
+ prop[propMap["c"]] = true;
596
+ prop[propMap["e"]] = true;
597
+ objForEachKey(value, function (key, value) {
598
+ prop[propMap[key]] = isUndefined(value) ? prop[propMap[key]] : value;
599
+ });
600
+ return prop;
660
601
  }
661
- function objDefineGet(target, key, value, configurable) {
602
+ var objDefineProp = ObjClass.defineProperty;
603
+ function objDefineAccessors(target, prop, getProp, setProp, configurable, enumerable) {
662
604
  var desc = {
663
- enumerable: true,
664
- configurable: isUndefined(configurable) ? true : configurable
605
+ e: enumerable,
606
+ c: configurable
665
607
  };
666
- if (isFunction(value)) {
667
- desc.get = value;
608
+ if (getProp) {
609
+ desc.g = getProp;
668
610
  }
669
- else {
670
- desc[VALUE] = value;
611
+ if (setProp) {
612
+ desc.s = setProp;
671
613
  }
672
- return objDefineProp(target, key, desc);
614
+ return objDefineProp(target, prop, _createProp(desc));
673
615
  }
674
- function objDefineAccessors(target, prop, getProp, setProp, configurable) {
675
- if (_objDefineProperty$1) {
676
- try {
677
- var descriptor = {
678
- enumerable: true,
679
- configurable: isUndefined(configurable) ? true : configurable
680
- };
681
- if (getProp) {
682
- descriptor.get = getProp;
683
- }
684
- if (setProp) {
685
- descriptor.set = setProp;
686
- }
687
- return objDefineProp(target, prop, descriptor);
688
- }
689
- catch (e) {
690
- throwUnsupported("Unable to define accessors for [" + objToString(prop) + "] on " + dumpObj(target));
691
- }
692
- }
616
+ function objDefine(target, key, propDesc) {
617
+ return objDefineProp(target, key, _createProp(propDesc));
693
618
  }
694
619
 
695
620
  var _globalLazyTestHooks;
@@ -701,24 +626,21 @@
701
626
  var lazyValue = {};
702
627
  _fetchLazyTestHooks && _fetchLazyTestHooks();
703
628
  lazyValue.b = _globalLazyTestHooks.lzy;
704
- objDefineGet(lazyValue, "v", function () {
705
- var result = cb();
706
- if (!_globalLazyTestHooks.lzy) {
707
- objDefineProp(lazyValue, "v", {
708
- enumerable: true,
709
- configurable: true,
710
- writable: false,
711
- value: result
712
- });
713
- if (lazyValue.b) {
714
- delete lazyValue.b;
629
+ objDefine(lazyValue, "v", {
630
+ g: function () {
631
+ var result = cb();
632
+ if (!_globalLazyTestHooks.lzy) {
633
+ objDefine(lazyValue, "v", { v: result });
634
+ if (lazyValue.b) {
635
+ delete lazyValue.b;
636
+ }
715
637
  }
638
+ if (_globalLazyTestHooks.lzy && lazyValue.b !== _globalLazyTestHooks.lzy) {
639
+ lazyValue.b = _globalLazyTestHooks.lzy;
640
+ }
641
+ return result;
716
642
  }
717
- if (_globalLazyTestHooks.lzy && lazyValue.b !== _globalLazyTestHooks.lzy) {
718
- lazyValue.b = _globalLazyTestHooks.lzy;
719
- }
720
- return result;
721
- }, true);
643
+ });
722
644
  return lazyValue;
723
645
  }
724
646
 
@@ -824,6 +746,33 @@
824
746
  }
825
747
  }
826
748
 
749
+ function dumpObj(object, format) {
750
+ var objectTypeDump = objToString(object);
751
+ var propertyValueDump = "";
752
+ if (objectTypeDump === "[object Error]") {
753
+ propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
754
+ }
755
+ else {
756
+ try {
757
+ if (format) {
758
+ if (isNumber(format)) {
759
+ propertyValueDump = JSON.stringify(object, null, format);
760
+ }
761
+ else {
762
+ propertyValueDump = JSON.stringify(object, null, 4);
763
+ }
764
+ }
765
+ else {
766
+ propertyValueDump = JSON.stringify(object);
767
+ }
768
+ }
769
+ catch (e) {
770
+ propertyValueDump = objToString(object) + " - " + dumpObj(e, format);
771
+ }
772
+ }
773
+ return objectTypeDump + ": " + propertyValueDump;
774
+ }
775
+
827
776
  function _unwrapFunction(funcName) {
828
777
  return function (thisArg) {
829
778
  var args = [];
@@ -841,6 +790,42 @@
841
790
 
842
791
  var arrMap = _unwrapFunction("map");
843
792
 
793
+ var arrReduce = _unwrapFunction("reduce");
794
+
795
+ function objSetPrototypeOf(obj, proto) {
796
+ var fn = ObjClass["setPrototypeOf"] ||
797
+ ({ __proto__: [] } instanceof Array && function (d, b) {
798
+ d.__proto__ = b;
799
+ }) ||
800
+ function (d, b) {
801
+ objForEachKey(b, function (key, value) {
802
+ d[key] = value;
803
+ });
804
+ };
805
+ return fn(obj, proto);
806
+ }
807
+
808
+ function _createCustomError(name, d, b) {
809
+ objSetPrototypeOf(d, b);
810
+ function __() {
811
+ this.constructor = d;
812
+ }
813
+ __[PROTOTYPE] = b[PROTOTYPE];
814
+ __[PROTOTYPE].name = name;
815
+ d[PROTOTYPE] = new __();
816
+ return d;
817
+ }
818
+ function createCustomError(name, constructCb) {
819
+ var baseClass = Error;
820
+ var customError = _createCustomError(name, function () {
821
+ var _this = this;
822
+ _this = baseClass.apply(_this, arguments) || _this;
823
+ constructCb && constructCb(_this, arguments);
824
+ return _this;
825
+ }, baseClass);
826
+ return customError;
827
+ }
828
+
844
829
  function utcNow() {
845
830
  return (Date.now || polyUtcNow)();
846
831
  }
@@ -930,11 +915,14 @@
930
915
  };
931
916
  if (!details.isPrim) {
932
917
  return _getSetVisited(visitMap, value, newPath, function (newEntry) {
933
- objDefineAccessors(details, "result", function () {
934
- return newEntry.v;
935
- }, function (newValue) {
936
- newEntry.v = newValue;
937
- }, true);
918
+ objDefine(details, "result", {
919
+ g: function () {
920
+ return newEntry.v;
921
+ },
922
+ s: function (newValue) {
923
+ newEntry.v = newValue;
924
+ }
925
+ });
938
926
  var idx = 0;
939
927
  var handler = userHandler;
940
928
  while (!(handler || (idx < defaultDeepCopyHandlers.length ? defaultDeepCopyHandlers[idx++] : _defaultDeepCopyHandler)).call(ctx, details)) {
@@ -1563,7 +1551,7 @@
1563
1551
  }
1564
1552
 
1565
1553
  var _objDefineProperty = ObjDefineProperty;
1566
- var version = "3.0.0-beta.2211-04";
1554
+ var version = "3.0.0-beta.2212-03";
1567
1555
  var instanceName = "." + newId(6);
1568
1556
  var _dataUid = 0;
1569
1557
  function _createAccessor(target, prop, value) {
@@ -2769,14 +2757,11 @@
2769
2757
  if (lastPlugin && lastPlugin[_DYN_SET_NEXT_PLUGIN ] && thePlugin[STR_PROCESS_TELEMETRY ]) {
2770
2758
  lastPlugin[_DYN_SET_NEXT_PLUGIN ](thePlugin);
2771
2759
  }
2772
- var isInitialized = false;
2773
- if (isFunction(thePlugin[_DYN_IS_INITIALIZED ])) {
2760
+ pluginState = _getPluginState(thePlugin);
2761
+ var isInitialized = !!pluginState[_DYN_IS_INITIALIZED ];
2762
+ if (thePlugin[_DYN_IS_INITIALIZED ]) {
2774
2763
  isInitialized = thePlugin[_DYN_IS_INITIALIZED ]();
2775
2764
  }
2776
- else {
2777
- pluginState = _getPluginState(thePlugin);
2778
- isInitialized = pluginState[_DYN_IS_INITIALIZED ];
2779
- }
2780
2765
  if (!isInitialized) {
2781
2766
  initPlugins[_DYN_PUSH$1 ](thePlugin);
2782
2767
  }
@@ -3995,8 +3980,7 @@
3995
3980
  _pluginVersionStringArr = null;
3996
3981
  _channels = (_channelConfig || [])[0] || [];
3997
3982
  _channels = sortPlugins(arrAppend(_channels, theExtensions[STR_CHANNELS ]));
3998
- var allExtensions = sortPlugins(theExtensions[STR_CORE ]);
3999
- arrAppend(allExtensions, _channels);
3983
+ var allExtensions = arrAppend(sortPlugins(theExtensions[STR_CORE ]), _channels);
4000
3984
  _extensions = objFreeze(allExtensions);
4001
3985
  var rootCtx = _createTelCtx();
4002
3986
  if (_channels && _channels[_DYN_LENGTH$2 ] > 0) {
@@ -4415,6 +4399,7 @@
4415
4399
  var _DYN_SPLIT = "split";
4416
4400
  var _DYN_LENGTH$1 = "length";
4417
4401
  var _DYN_TO_LOWER_CASE = "toLowerCase";
4402
+ var _DYN_INGESTIONENDPOINT = "ingestionendpoint";
4418
4403
  var _DYN_TO_STRING$1 = "toString";
4419
4404
  var _DYN_EXCEPTIONS = "exceptions";
4420
4405
  var _DYN_PARSED_STACK = "parsedStack";
@@ -4714,6 +4699,32 @@
4714
4699
  return false;
4715
4700
  }
4716
4701
 
4702
+ var _FIELDS_SEPARATOR = ";";
4703
+ var _FIELD_KEY_VALUE_SEPARATOR = "=";
4704
+ function parseConnectionString(connectionString) {
4705
+ if (!connectionString) {
4706
+ return {};
4707
+ }
4708
+ var kvPairs = connectionString[_DYN_SPLIT ](_FIELDS_SEPARATOR);
4709
+ var result = arrReduce(kvPairs, function (fields, kv) {
4710
+ var kvParts = kv[_DYN_SPLIT ](_FIELD_KEY_VALUE_SEPARATOR);
4711
+ if (kvParts[_DYN_LENGTH$1 ] === 2) {
4712
+ var key = kvParts[0][_DYN_TO_LOWER_CASE ]();
4713
+ var value = kvParts[1];
4714
+ fields[key] = value;
4715
+ }
4716
+ return fields;
4717
+ }, {});
4718
+ if (objKeys(result)[_DYN_LENGTH$1 ] > 0) {
4719
+ if (result.endpointsuffix) {
4720
+ var locationPrefix = result.location ? result.location + "." : "";
4721
+ result[_DYN_INGESTIONENDPOINT ] = result[_DYN_INGESTIONENDPOINT ] || ("https://" + locationPrefix + "dc." + result.endpointsuffix);
4722
+ }
4723
+ result[_DYN_INGESTIONENDPOINT ] = result[_DYN_INGESTIONENDPOINT ] || DEFAULT_BREEZE_ENDPOINT;
4724
+ }
4725
+ return result;
4726
+ }
4727
+
4717
4728
  var Envelope = /** @class */ (function () {
4718
4729
  function Envelope(logger, data, name) {
4719
4730
  var _this = this;
@@ -5553,7 +5564,7 @@
5553
5564
  var _DYN__BUFFER = "_buffer";
5554
5565
  var _DYN_ENABLE_SESSION_STORA4 = "enableSessionStorageBuffer";
5555
5566
  var _DYN_SAMPLING_PERCENTAGE = "samplingPercentage";
5556
- var _DYN_INSTRUMENTATION_KEY = "instrumentationKey";
5567
+ var _DYN_INSTRUMENTATION_KEY$1 = "instrumentationKey";
5557
5568
  var _DYN_CUSTOM_HEADERS = "customHeaders";
5558
5569
  var _DYN_DISABLE_XHR = "disableXhr";
5559
5570
  var _DYN_ONUNLOAD_DISABLE_FET5 = "onunloadDisableFetch";
@@ -5681,7 +5692,7 @@
5681
5692
  }
5682
5693
  }
5683
5694
  var EnvelopeCreator = {
5684
- Version: "3.0.0-beta.2211-04"
5695
+ Version: "3.0.0-beta.2212-03"
5685
5696
  };
5686
5697
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
5687
5698
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -6326,7 +6337,7 @@
6326
6337
  _a[_DYN_DISABLE_XHR ] = false,
6327
6338
  _a[_DYN_ONUNLOAD_DISABLE_FET5 ] = false,
6328
6339
  _a[_DYN_ONUNLOAD_DISABLE_BEA2 ] = false,
6329
- _a[_DYN_INSTRUMENTATION_KEY ] = UNDEFINED_VALUE,
6340
+ _a[_DYN_INSTRUMENTATION_KEY$1 ] = UNDEFINED_VALUE,
6330
6341
  _a[_DYN_NAME_PREFIX ] = UNDEFINED_VALUE,
6331
6342
  _a[_DYN_SAMPLING_PERCENTAGE ] = 100,
6332
6343
  _a[_DYN_CUSTOM_HEADERS ] = UNDEFINED_VALUE,
@@ -6450,7 +6461,7 @@
6450
6461
  ? new SessionStorageSendBuffer(diagLog, senderConfig) : new ArraySendBuffer(diagLog, senderConfig);
6451
6462
  }
6452
6463
  _self._sample = new Sample(senderConfig[_DYN_SAMPLING_PERCENTAGE ], diagLog);
6453
- _instrumentationKey = senderConfig[_DYN_INSTRUMENTATION_KEY ];
6464
+ _instrumentationKey = senderConfig[_DYN_INSTRUMENTATION_KEY$1 ];
6454
6465
  if (!_validateInstrumentationKey(_instrumentationKey, config)) {
6455
6466
  _throwInternal(diagLog, 1 , 100 , "Invalid Instrumentation key " + _instrumentationKey);
6456
6467
  }
@@ -7069,28 +7080,27 @@
7069
7080
  return Sender;
7070
7081
  }(BaseTelemetryPlugin));
7071
7082
 
7072
- var _DYN_DIAGNOSTIC_LOG_INTER0 = "diagnosticLogInterval";
7083
+ var _DYN_CONNECTION_STRING = "connectionString";
7084
+ var _DYN_INSTRUMENTATION_KEY = "instrumentationKey";
7073
7085
 
7086
+ var defaultConfigValues = {
7087
+ diagnosticLogInterval: { isVal: _chkDiagLevel, v: 10000 }
7088
+ };
7089
+ function _chkDiagLevel(value) {
7090
+ return value && value > 0;
7091
+ }
7074
7092
  var ApplicationInsights = /** @class */ (function () {
7075
7093
  function ApplicationInsights(config) {
7076
7094
  var core = new AppInsightsCore();
7077
- if (isNullOrUndefined(config) ||
7078
- isNullOrUndefined(config.instrumentationKey)) {
7079
- throwError("Invalid input configuration");
7080
- }
7095
+ var _config;
7081
7096
  dynamicProto(ApplicationInsights, this, function (_self) {
7082
7097
  objDefineProp(_self, "config", {
7083
7098
  configurable: true,
7084
7099
  enumerable: true,
7085
- get: function () { return config; }
7100
+ get: function () { return _config; }
7086
7101
  });
7087
7102
  _initialize();
7088
7103
  _self.initialize = _initialize;
7089
- _self.getSKUDefaults = function () {
7090
- _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 ] =
7091
- _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 ] && _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 ] > 0 ? _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 ] : 10000;
7092
- };
7093
- _self.getSKUDefaults();
7094
7104
  proxyFunctions(_self, core, [
7095
7105
  "track",
7096
7106
  "flush",
@@ -7100,10 +7110,21 @@
7100
7110
  "getPlugin",
7101
7111
  "addPlugin",
7102
7112
  "evtNamespace",
7103
- "addUnloadCb"
7113
+ "addUnloadCb",
7114
+ "onCfgChange"
7104
7115
  ]);
7105
7116
  function _initialize() {
7106
- core.initialize(_self.config, [new Sender()]);
7117
+ var cfgHandler = createDynamicConfig(config || {}, defaultConfigValues);
7118
+ _config = cfgHandler.cfg;
7119
+ core.addUnloadHook(onConfigChange(cfgHandler, function () {
7120
+ if (_config[_DYN_CONNECTION_STRING ]) {
7121
+ var cs = parseConnectionString(_config[_DYN_CONNECTION_STRING ]);
7122
+ var ingest = cs.ingestionendpoint;
7123
+ _config.endpointUrl = ingest ? (ingest + DEFAULT_BREEZE_PATH) : _config.endpointUrl;
7124
+ _config[_DYN_INSTRUMENTATION_KEY ] = cs.instrumentationkey || _config[_DYN_INSTRUMENTATION_KEY ];
7125
+ }
7126
+ }));
7127
+ core.initialize(_config, [new Sender()]);
7107
7128
  }
7108
7129
  });
7109
7130
  }