@gemx-dev/clarity-js 0.8.63 → 0.8.64

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.
@@ -147,7 +147,7 @@ function process$8() {
147
147
  }
148
148
  }
149
149
 
150
- var config$2 = {
150
+ var config$3 = {
151
151
  projectId: null,
152
152
  delay: 1 * 1000 /* Time.Second */,
153
153
  lean: false,
@@ -332,7 +332,7 @@ function url$1(input, electron, truncate) {
332
332
  result = "".concat("https://" /* Data.Constant.HTTPS */).concat("Electron" /* Data.Constant.Electron */);
333
333
  }
334
334
  else {
335
- var drop_1 = config$2.drop;
335
+ var drop_1 = config$3.drop;
336
336
  if (drop_1 && drop_1.length > 0 && input && input.indexOf("?") > 0) {
337
337
  var _a = input.split("?"), path = _a[0], query = _a[1];
338
338
  var swap_1 = "*na*" /* Data.Constant.Dropped */;
@@ -1254,7 +1254,7 @@ function getCookie(key, limit) {
1254
1254
  function setCookie(key, value, time) {
1255
1255
  // only write cookies if we are currently in a cookie writing mode (and they are supported)
1256
1256
  // OR if we are trying to write an empty cookie (i.e. clear the cookie value out)
1257
- if ((config$2.track || value == "" /* Constant.Empty */) && ((navigator && navigator.cookieEnabled) || supported(document, "cookie" /* Constant.Cookie */))) {
1257
+ if ((config$3.track || value == "" /* Constant.Empty */) && ((navigator && navigator.cookieEnabled) || supported(document, "cookie" /* Constant.Cookie */))) {
1258
1258
  // Some browsers automatically url encode cookie values if they are not url encoded.
1259
1259
  // We therefore encode and decode cookie values ourselves.
1260
1260
  var encodedValue = encodeCookieValue(value);
@@ -1372,7 +1372,7 @@ function start$F() {
1372
1372
  }
1373
1373
  function check$5(id, target, input) {
1374
1374
  // Compute hash for fraud detection, if enabled. Hash is computed only if input meets the minimum length criteria
1375
- if (config$2.fraud && id !== null && input && input.length >= 5 /* Setting.WordLength */) {
1375
+ if (config$3.fraud && id !== null && input && input.length >= 5 /* Setting.WordLength */) {
1376
1376
  data$f = { id: id, target: target, checksum: hash(input, 28 /* Setting.ChecksumPrecision */) };
1377
1377
  // Only encode this event if we haven't already reported this hash
1378
1378
  if (history$5.indexOf(data$f.checksum) < 0) {
@@ -1393,7 +1393,7 @@ function recompute$8(evt) {
1393
1393
  var element = target(evt);
1394
1394
  if (element) {
1395
1395
  var value = element.value;
1396
- var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$2.fraud && "password,secret,pass,social,ssn,code,hidden" /* Mask.Exclude */.indexOf(element.type) === -1 ? hash(value, 28 /* Setting.ChecksumPrecision */) : "" /* Constant.Empty */;
1396
+ var checksum = value && value.length >= 5 /* Setting.WordLength */ && config$3.fraud && "password,secret,pass,social,ssn,code,hidden" /* Mask.Exclude */.indexOf(element.type) === -1 ? hash(value, 28 /* Setting.ChecksumPrecision */) : "" /* Constant.Empty */;
1397
1397
  state$a.push({ time: time(evt), event: 42 /* Event.Change */, data: { target: target(evt), type: element.type, value: value, checksum: checksum } });
1398
1398
  schedule(encode$4.bind(this, 42 /* Event.Change */));
1399
1399
  }
@@ -2194,7 +2194,7 @@ var styleTimeMap = {};
2194
2194
  var documentNodes = [];
2195
2195
  var createdSheetIds = [];
2196
2196
  function proxyStyleRules$1(win) {
2197
- if ((config$2.lean && config$2.lite) || win === null || win === undefined) {
2197
+ if ((config$3.lean && config$3.lite) || win === null || win === undefined) {
2198
2198
  return;
2199
2199
  }
2200
2200
  win.clarityOverrides = win.clarityOverrides || {};
@@ -2233,7 +2233,7 @@ function start$q() {
2233
2233
  proxyStyleRules$1(window);
2234
2234
  }
2235
2235
  function checkDocumentStyles(documentNode, timestamp) {
2236
- if (config$2.lean && config$2.lite) {
2236
+ if (config$3.lean && config$3.lite) {
2237
2237
  return;
2238
2238
  }
2239
2239
  if (documentNodes.indexOf(documentNode) === -1) {
@@ -2620,7 +2620,7 @@ function encode$5 (type, timer, ts) {
2620
2620
  if (type === 6 /* Event.Mutation */) {
2621
2621
  activity(eventTime);
2622
2622
  }
2623
- queue(tokenize(tokens), !config$2.lean);
2623
+ queue(tokenize(tokens), !config$3.lean);
2624
2624
  _o.label = 11;
2625
2625
  case 11: return [3 /*break*/, 13];
2626
2626
  case 12:
@@ -2830,7 +2830,7 @@ function processMutation(timer, mutation, instance, timestamp) {
2830
2830
  return [2 /*return*/];
2831
2831
  }
2832
2832
  target = mutation.target;
2833
- type = config$2.throttleDom ? track$5(mutation, timer, instance, timestamp) : mutation.type;
2833
+ type = config$3.throttleDom ? track$5(mutation, timer, instance, timestamp) : mutation.type;
2834
2834
  if (type && target && target.ownerDocument) {
2835
2835
  parse(target.ownerDocument);
2836
2836
  }
@@ -3539,8 +3539,9 @@ var selectorMap = {};
3539
3539
  function reset$8() {
3540
3540
  selectorMap = {};
3541
3541
  }
3542
- function configure(classNames) {
3542
+ function config$2(classNames) {
3543
3543
  extraExcludeClassNames = classNames || [];
3544
+ console.log("[Selector] config called \u2014 extraExcludeClassNames set to: [".concat(extraExcludeClassNames.join(', '), "]"));
3544
3545
  }
3545
3546
  function get$1(input, type) {
3546
3547
  var a = input.attributes;
@@ -3564,7 +3565,13 @@ function get$1(input, type) {
3564
3565
  input.tag = input.tag.indexOf("svg:" /* Constant.SvgPrefix */) === 0 ? input.tag.substr("svg:" /* Constant.SvgPrefix */.length) : input.tag;
3565
3566
  var selector = "".concat(prefix).concat(input.tag).concat(suffix);
3566
3567
  var id = "id" /* Constant.Id */ in a && a["id" /* Constant.Id */].length > 0 ? a["id" /* Constant.Id */] : null;
3567
- var classes = input.tag !== "BODY" /* Constant.BodyTag */ && "class" /* Constant.Class */ in a && a["class" /* Constant.Class */].length > 0 ? a["class" /* Constant.Class */].trim().split(/\s+/).filter(function (c) { return filter(c); }).join("." /* Constant.Period */) : null;
3568
+ var rawClasses = "class" /* Constant.Class */ in a ? a["class" /* Constant.Class */].trim().split(/\s+/) : [];
3569
+ var filteredClasses = rawClasses.filter(function (c) { return filter(c); });
3570
+ var removedClasses = rawClasses.filter(function (c) { return !filter(c); });
3571
+ if (removedClasses.length > 0) {
3572
+ console.log("[Selector] tag=\"".concat(input.tag, "\" id=\"").concat(input.id, "\" \u2014 removed classes: [").concat(removedClasses.join(', '), "] | kept: [").concat(filteredClasses.join(', '), "] | extraExclude: [").concat(extraExcludeClassNames.join(', '), "]"));
3573
+ }
3574
+ var classes = input.tag !== "BODY" /* Constant.BodyTag */ && filteredClasses.length > 0 ? filteredClasses.join("." /* Constant.Period */) : null;
3568
3575
  if (classes && classes.length > 0) {
3569
3576
  if (type === 0 /* Selector.Alpha */) {
3570
3577
  // In Alpha mode, update selector to use class names, with relative positioning within the parent id container.
@@ -3577,16 +3584,19 @@ function get$1(input, type) {
3577
3584
  selectorMap[key].push(input.id);
3578
3585
  }
3579
3586
  selector = "".concat(key).concat("~" /* Constant.Tilde */).concat(selectorMap[key].indexOf(input.id));
3587
+ console.log("\uD83D\uDE80 \uD83D\uDC25 ~ get ~ selector:", selector);
3580
3588
  }
3581
3589
  else {
3582
3590
  // In Beta mode, we continue to look at query selectors in context of the full page
3583
3591
  selector = "".concat(prefix).concat(input.tag, ".").concat(classes).concat(suffix);
3592
+ console.log("\uD83D\uDE80 \uD83D\uDC25 ~ get ~ selector:", selector);
3584
3593
  }
3585
3594
  }
3586
3595
  // Update selector to use "id" field when available. There are two exceptions:
3587
3596
  // (1) if "id" appears to be an auto generated string token, e.g. guid or a random id containing digits
3588
3597
  // (2) if "id" appears inside a shadow DOM, in which case we continue to prefix up to shadow DOM to prevent conflicts
3589
3598
  selector = id && filter(id) ? "".concat(getDomPrefix(prefix)).concat("#" /* Constant.Hash */).concat(id) : selector;
3599
+ console.log("\uD83D\uDE80 \uD83D\uDC25 ~ get ~ selector:", selector);
3590
3600
  return selector;
3591
3601
  }
3592
3602
  }
@@ -3613,7 +3623,9 @@ function filter(value) {
3613
3623
  if (!value) {
3614
3624
  return false;
3615
3625
  } // Do not process empty strings
3616
- if (getExcludeClassNames().some(function (x) { return value.toLowerCase().indexOf(x) >= 0; })) {
3626
+ var excludeClassNames = getExcludeClassNames();
3627
+ console.log("\uD83D\uDE80 \uD83D\uDC25 ~ filter ~ excludeClassNames:", excludeClassNames);
3628
+ if (excludeClassNames.some(function (x) { return value.toLowerCase().indexOf(x) >= 0; })) {
3617
3629
  return false;
3618
3630
  }
3619
3631
  for (var i = 0; i < value.length; i++) {
@@ -3625,12 +3637,14 @@ function filter(value) {
3625
3637
  return true;
3626
3638
  }
3627
3639
  function getExcludeClassNames() {
3640
+ console.log("\uD83D\uDE80 \uD83D\uDC25 ~ getExcludeClassNames ~ extraExcludeClassNames:", extraExcludeClassNames);
3641
+ console.log("\uD83D\uDE80 \uD83D\uDC25 ~ getExcludeClassNames ~ excludeClassNames:", excludeClassNames);
3628
3642
  return __spreadArray(__spreadArray([], excludeClassNames, true), extraExcludeClassNames, true);
3629
3643
  }
3630
3644
 
3631
3645
  var selector = /*#__PURE__*/Object.freeze({
3632
3646
  __proto__: null,
3633
- configure: configure,
3647
+ config: config$2,
3634
3648
  get: get$1,
3635
3649
  reset: reset$8
3636
3650
  });
@@ -3687,14 +3701,14 @@ function parse(root, init) {
3687
3701
  try {
3688
3702
  // Parse unmask configuration into separate query selectors and override tokens as part of initialization
3689
3703
  if (init) {
3690
- config$2.unmask.forEach(function (x) { return x.indexOf("!" /* Constant.Bang */) < 0 ? unmask.push(x) : override.push(x.substr(1)); });
3704
+ config$3.unmask.forEach(function (x) { return x.indexOf("!" /* Constant.Bang */) < 0 ? unmask.push(x) : override.push(x.substr(1)); });
3691
3705
  }
3692
3706
  // Since mutations may happen on leaf nodes too, e.g. text nodes, which may not support all selector APIs.
3693
3707
  // We ensure that the root note supports querySelectorAll API before executing the code below to identify new regions.
3694
3708
  if ("querySelectorAll" in root) {
3695
- config$2.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
3696
- config$2.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* Privacy.TextImage */); }); }); // Masked Elements
3697
- config$2.checksum.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Checksum Check
3709
+ config$3.regions.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return observe$1(e, "".concat(x[0])); }); }); // Regions
3710
+ config$3.mask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 3 /* Privacy.TextImage */); }); }); // Masked Elements
3711
+ config$3.checksum.forEach(function (x) { return root.querySelectorAll(x[1]).forEach(function (e) { return fraudMap.set(e, x[0]); }); }); // Fraud Checksum Check
3698
3712
  unmask.forEach(function (x) { return root.querySelectorAll(x).forEach(function (e) { return privacyMap.set(e, 0 /* Privacy.None */); }); }); // Unmasked Elements
3699
3713
  }
3700
3714
  }
@@ -3725,7 +3739,7 @@ function add$1(node, parent, data, source) {
3725
3739
  var parentValue = null;
3726
3740
  var regionId = exists(node) ? id : null;
3727
3741
  var fraudId = fraudMap.has(node) ? fraudMap.get(node) : null;
3728
- var privacyId = config$2.content ? 1 /* Privacy.Sensitive */ : 3 /* Privacy.TextImage */;
3742
+ var privacyId = config$3.content ? 1 /* Privacy.Sensitive */ : 3 /* Privacy.TextImage */;
3729
3743
  if (parentId >= 0 && values$1[parentId]) {
3730
3744
  parentValue = values$1[parentId];
3731
3745
  parentValue.children.push(id);
@@ -4029,7 +4043,7 @@ function getPreviousId(node) {
4029
4043
  function track$4(id, source, changed, parentChanged) {
4030
4044
  if (changed === void 0) { changed = true; }
4031
4045
  if (parentChanged === void 0) { parentChanged = false; }
4032
- if (config$2.lean && config$2.lite) {
4046
+ if (config$3.lean && config$3.lite) {
4033
4047
  return;
4034
4048
  }
4035
4049
  // Keep track of the order in which mutations happened, they may not be sequential
@@ -4618,8 +4632,8 @@ var modules$1 = null;
4618
4632
  function start$i() {
4619
4633
  active$2 = true;
4620
4634
  modules$1 = new Set();
4621
- if (config$2.modules && config$2.modules.length > 0) {
4622
- config$2.modules.forEach(function (m) { event(m); });
4635
+ if (config$3.modules && config$3.modules.length > 0) {
4636
+ config$3.modules.forEach(function (m) { event(m); });
4623
4637
  }
4624
4638
  }
4625
4639
  function stop$g() {
@@ -4707,7 +4721,7 @@ function queue(tokens, transmit) {
4707
4721
  var now = time();
4708
4722
  var type = tokens.length > 1 ? tokens[1] : null;
4709
4723
  var event = JSON.stringify(tokens);
4710
- if (!config$2.lean) {
4724
+ if (!config$3.lean) {
4711
4725
  leanLimit = false;
4712
4726
  }
4713
4727
  else if (!leanLimit && playbackBytes + event.length > 10485760 /* Setting.PlaybackBytesLimit */) {
@@ -4783,7 +4797,7 @@ function upload(final) {
4783
4797
  return [2 /*return*/];
4784
4798
  }
4785
4799
  timeout = null;
4786
- sendPlaybackBytes = config$2.lean === false && playbackBytes > 0 && (playbackBytes < 1048576 /* Setting.MaxFirstPayloadBytes */ || data$1.sequence > 0);
4800
+ sendPlaybackBytes = config$3.lean === false && playbackBytes > 0 && (playbackBytes < 1048576 /* Setting.MaxFirstPayloadBytes */ || data$1.sequence > 0);
4787
4801
  if (sendPlaybackBytes) {
4788
4802
  max(1 /* Metric.Playback */, 1 /* BooleanFlag.True */);
4789
4803
  }
@@ -4836,8 +4850,8 @@ function stringify(encoded) {
4836
4850
  function send(payload, zipped, sequence, beacon) {
4837
4851
  if (beacon === void 0) { beacon = false; }
4838
4852
  // Upload data if a valid URL is defined in the config
4839
- if (typeof config$2.upload === "string" /* Constant.String */) {
4840
- var url_1 = config$2.upload;
4853
+ if (typeof config$3.upload === "string" /* Constant.String */) {
4854
+ var url_1 = config$3.upload;
4841
4855
  var dispatched = false;
4842
4856
  // If it's the last payload, attempt to upload using sendBeacon first.
4843
4857
  // The advantage to using sendBeacon is that browser can decide to upload asynchronously, improving chances of success
@@ -4888,8 +4902,8 @@ function send(payload, zipped, sequence, beacon) {
4888
4902
  }
4889
4903
  }
4890
4904
  }
4891
- else if (config$2.upload) {
4892
- var callback = config$2.upload;
4905
+ else if (config$3.upload) {
4906
+ var callback = config$3.upload;
4893
4907
  callback(payload);
4894
4908
  done(sequence);
4895
4909
  }
@@ -4911,7 +4925,7 @@ function check$3(xhr, sequence) {
4911
4925
  // 2: Safari will terminate pending XHR requests with status code 0 if the user navigates away from the page
4912
4926
  // In any case, we switch the upload URL to fallback configuration (if available) before re-trying one more time
4913
4927
  if (xhr.status === 0) {
4914
- config$2.upload = config$2.fallback ? config$2.fallback : config$2.upload;
4928
+ config$3.upload = config$3.fallback ? config$3.fallback : config$3.upload;
4915
4929
  }
4916
4930
  // Capture the status code and number of attempts so we can report it back to the server
4917
4931
  track$1 = { sequence: sequence, attempts: transitData.attempts, status: xhr.status };
@@ -4958,8 +4972,8 @@ function done(sequence) {
4958
4972
  function delay() {
4959
4973
  // Progressively increase delay as we continue to send more payloads from the client to the server
4960
4974
  // If we are not uploading data to a server, and instead invoking UploadCallback, in that case keep returning configured value
4961
- var gap = config$2.lean === false && discoverBytes > 0 ? 100 /* Setting.MinUploadDelay */ : data$1.sequence * config$2.delay;
4962
- return typeof config$2.upload === "string" /* Constant.String */ ? Math.max(Math.min(gap, 30000 /* Setting.MaxUploadDelay */), 100 /* Setting.MinUploadDelay */) : config$2.delay;
4975
+ var gap = config$3.lean === false && discoverBytes > 0 ? 100 /* Setting.MinUploadDelay */ : data$1.sequence * config$3.delay;
4976
+ return typeof config$3.upload === "string" /* Constant.String */ ? Math.max(Math.min(gap, 30000 /* Setting.MaxUploadDelay */), 100 /* Setting.MinUploadDelay */) : config$3.delay;
4963
4977
  }
4964
4978
  function response(payload) {
4965
4979
  var lines = payload && payload.length > 0 ? payload.split("\n") : [];
@@ -4977,8 +4991,8 @@ function response(payload) {
4977
4991
  break;
4978
4992
  case "ACTION" /* Constant.Action */:
4979
4993
  // Invoke action callback, if configured and has a valid value
4980
- if (config$2.action && parts.length > 1) {
4981
- config$2.action(parts[1]);
4994
+ if (config$3.action && parts.length > 1) {
4995
+ config$3.action(parts[1]);
4982
4996
  }
4983
4997
  break;
4984
4998
  case "EXTRACT" /* Constant.Extract */:
@@ -4997,7 +5011,7 @@ function response(payload) {
4997
5011
  }
4998
5012
  break;
4999
5013
  case "SNAPSHOT" /* Constant.Snapshot */:
5000
- config$2.lean = false; // Disable lean mode to ensure we can send playback information to server.
5014
+ config$3.lean = false; // Disable lean mode to ensure we can send playback information to server.
5001
5015
  snapshot();
5002
5016
  break;
5003
5017
  }
@@ -5331,8 +5345,8 @@ function discover() {
5331
5345
 
5332
5346
  var data$6 = null;
5333
5347
  function start$c() {
5334
- if (!config$2.lean && config$2.upgrade) {
5335
- config$2.upgrade("Config" /* Constant.Config */);
5348
+ if (!config$3.lean && config$3.upgrade) {
5349
+ config$3.upgrade("Config" /* Constant.Config */);
5336
5350
  }
5337
5351
  data$6 = null;
5338
5352
  }
@@ -5342,18 +5356,18 @@ function start$c() {
5342
5356
  // and send all backed up layout events to the server.
5343
5357
  function upgrade(key) {
5344
5358
  // Upgrade only if Clarity was successfully activated on the page
5345
- if (active() && config$2.lean) {
5346
- config$2.lean = false;
5359
+ if (active() && config$3.lean) {
5360
+ config$3.lean = false;
5347
5361
  data$6 = { key: key };
5348
5362
  // Update metadata to track we have upgraded this session
5349
5363
  callback();
5350
5364
  save();
5351
5365
  // Callback upgrade handler, if configured
5352
- if (config$2.upgrade) {
5353
- config$2.upgrade(key);
5366
+ if (config$3.upgrade) {
5367
+ config$3.upgrade(key);
5354
5368
  }
5355
5369
  encode$1(3 /* Event.Upgrade */);
5356
- if (config$2.lite) {
5370
+ if (config$3.lite) {
5357
5371
  start$d();
5358
5372
  start$q();
5359
5373
  }
@@ -5641,7 +5655,7 @@ function compute$2() {
5641
5655
  if (updateConsent) {
5642
5656
  encode$1(47 /* Event.Consent */);
5643
5657
  updateConsent = false;
5644
- if (!config$2.track) {
5658
+ if (!config$3.track) {
5645
5659
  var ics = (_a = window.google_tag_data) === null || _a === void 0 ? void 0 : _a.ics;
5646
5660
  if (ics === null || ics === void 0 ? void 0 : ics.usedUpdate) {
5647
5661
  processConsent();
@@ -5666,13 +5680,13 @@ function start$8() {
5666
5680
  // Populate ids for this page
5667
5681
  var s = session();
5668
5682
  var u = user();
5669
- var projectId = config$2.projectId || hash(location.host);
5670
- var userId = config$2.externalSession && config$2.userId ? config$2.userId : u.id;
5671
- var sessionId = config$2.externalSession && config$2.sessionId ? config$2.sessionId : s.session;
5683
+ var projectId = config$3.projectId || hash(location.host);
5684
+ var userId = config$3.externalSession && config$3.userId ? config$3.userId : u.id;
5685
+ var sessionId = config$3.externalSession && config$3.sessionId ? config$3.sessionId : s.session;
5672
5686
  data$2 = { projectId: projectId, userId: userId, sessionId: sessionId, pageNum: s.count };
5673
5687
  // Override configuration based on what's in the session storage, unless it is blank (e.g. using upload callback, like in devtools)
5674
- config$2.lean = config$2.track && s.upgrade !== null ? s.upgrade === 0 /* BooleanFlag.False */ : config$2.lean;
5675
- config$2.upload = config$2.track && typeof config$2.upload === "string" /* Constant.String */ && s.upload && s.upload.length > "https://" /* Constant.HTTPS */.length ? s.upload : config$2.upload;
5688
+ config$3.lean = config$3.track && s.upgrade !== null ? s.upgrade === 0 /* BooleanFlag.False */ : config$3.lean;
5689
+ config$3.upload = config$3.track && typeof config$3.upload === "string" /* Constant.String */ && s.upload && s.upload.length > "https://" /* Constant.HTTPS */.length ? s.upload : config$3.upload;
5676
5690
  // Log page metadata as dimensions
5677
5691
  log(0 /* Dimension.UserAgent */, ua);
5678
5692
  log(3 /* Dimension.PageTitle */, title);
@@ -5710,7 +5724,7 @@ function start$8() {
5710
5724
  max(16 /* Metric.ColorDepth */, Math.round(screen.colorDepth));
5711
5725
  }
5712
5726
  // Read cookies specified in configuration
5713
- for (var _i = 0, _d = config$2.cookies; _i < _d.length; _i++) {
5727
+ for (var _i = 0, _d = config$3.cookies; _i < _d.length; _i++) {
5714
5728
  var key = _d[_i];
5715
5729
  var value = getCookie(key);
5716
5730
  if (value) {
@@ -5722,14 +5736,14 @@ function start$8() {
5722
5736
  if (consentStatus === null) {
5723
5737
  consentStatus = {
5724
5738
  source: u.consent ? 6 /* ConsentSource.Cookie */ : 0 /* ConsentSource.Implicit */,
5725
- ad_Storage: config$2.track ? "granted" /* Constant.Granted */ : "denied" /* Constant.Denied */,
5726
- analytics_Storage: config$2.track ? "granted" /* Constant.Granted */ : "denied" /* Constant.Denied */,
5739
+ ad_Storage: config$3.track ? "granted" /* Constant.Granted */ : "denied" /* Constant.Denied */,
5740
+ analytics_Storage: config$3.track ? "granted" /* Constant.Granted */ : "denied" /* Constant.Denied */,
5727
5741
  };
5728
5742
  }
5729
5743
  var consent = getConsentData(consentStatus);
5730
5744
  config$1(consent);
5731
5745
  // Track ids using a cookie if configuration allows it, skip if using external session
5732
- if (!config$2.externalSession) {
5746
+ if (!config$3.externalSession) {
5733
5747
  track(u);
5734
5748
  }
5735
5749
  }
@@ -5757,14 +5771,14 @@ function metadata(cb, wait, recall, consentInfo) {
5757
5771
  if (wait === void 0) { wait = true; }
5758
5772
  if (recall === void 0) { recall = false; }
5759
5773
  if (consentInfo === void 0) { consentInfo = false; }
5760
- var upgraded = config$2.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
5774
+ var upgraded = config$3.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
5761
5775
  var called = false;
5762
5776
  // if caller hasn't specified that they want to skip waiting for upgrade but we've already upgraded, we need to
5763
5777
  // directly execute the callback in addition to adding to our list as we only process callbacks at the moment
5764
5778
  // we go through the upgrading flow.
5765
5779
  if (data$2 && (upgraded || wait === false)) {
5766
5780
  // Immediately invoke the callback if the caller explicitly doesn't want to wait for the upgrade confirmation
5767
- cb(data$2, !config$2.lean, consentInfo ? consentStatus : undefined);
5781
+ cb(data$2, !config$3.lean, consentInfo ? consentStatus : undefined);
5768
5782
  called = true;
5769
5783
  }
5770
5784
  if (recall || !called) {
@@ -5804,15 +5818,15 @@ function consentv2(consentState, source) {
5804
5818
  consentStatus = updatedStatus;
5805
5819
  callback(true);
5806
5820
  var consentData = getConsentData(consentStatus);
5807
- if (!consentData.analytics_Storage && config$2.track) {
5808
- config$2.track = false;
5821
+ if (!consentData.analytics_Storage && config$3.track) {
5822
+ config$3.track = false;
5809
5823
  clear(true);
5810
5824
  stop();
5811
5825
  window.setTimeout(start, 250 /* Setting.RestartDelay */);
5812
5826
  return;
5813
5827
  }
5814
5828
  if (active() && consentData.analytics_Storage) {
5815
- config$2.track = true;
5829
+ config$3.track = true;
5816
5830
  track(user(), 1 /* BooleanFlag.True */);
5817
5831
  save();
5818
5832
  }
@@ -5843,7 +5857,7 @@ function clear(all) {
5843
5857
  }
5844
5858
  function tab() {
5845
5859
  var id = shortid();
5846
- if (config$2.track && supported(window, "sessionStorage" /* Constant.SessionStorage */)) {
5860
+ if (config$3.track && supported(window, "sessionStorage" /* Constant.SessionStorage */)) {
5847
5861
  var value = sessionStorage.getItem("_cltk" /* Constant.TabKey */);
5848
5862
  id = value ? value : id;
5849
5863
  sessionStorage.setItem("_cltk" /* Constant.TabKey */, id);
@@ -5852,15 +5866,15 @@ function tab() {
5852
5866
  }
5853
5867
  function callback(consentUpdate) {
5854
5868
  if (consentUpdate === void 0) { consentUpdate = false; }
5855
- var upgrade = config$2.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
5869
+ var upgrade = config$3.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
5856
5870
  processCallback(upgrade, consentUpdate);
5857
5871
  }
5858
5872
  function save() {
5859
- if (!data$2 || !config$2.track || config$2.externalSession)
5873
+ if (!data$2 || !config$3.track || config$3.externalSession)
5860
5874
  return;
5861
5875
  var ts = Math.round(Date.now());
5862
- var upload = config$2.upload && typeof config$2.upload === "string" /* Constant.String */ ? config$2.upload.replace("https://" /* Constant.HTTPS */, "" /* Constant.Empty */) : "" /* Constant.Empty */;
5863
- var upgrade = config$2.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
5876
+ var upload = config$3.upload && typeof config$3.upload === "string" /* Constant.String */ ? config$3.upload.replace("https://" /* Constant.HTTPS */, "" /* Constant.Empty */) : "" /* Constant.Empty */;
5877
+ var upgrade = config$3.lean ? 0 /* BooleanFlag.False */ : 1 /* BooleanFlag.True */;
5864
5878
  setCookie("_clsk" /* Constant.SessionKey */, [data$2.sessionId, ts, data$2.pageNum, upgrade, upload].join(COOKIE_SEP), 1 /* Setting.SessionExpire */);
5865
5879
  }
5866
5880
  function processCallback(upgrade, consentUpdate) {
@@ -5871,7 +5885,7 @@ function processCallback(upgrade, consentUpdate) {
5871
5885
  if (cb.callback &&
5872
5886
  ((!cb.called && !consentUpdate) || (cb.consentInfo && consentUpdate)) && //If consentUpdate is true, we only call the callback if it has consentInfo
5873
5887
  (!cb.wait || upgrade)) {
5874
- cb.callback(data$2, !config$2.lean, cb.consentInfo ? consentStatus : undefined);
5888
+ cb.callback(data$2, !config$3.lean, cb.consentInfo ? consentStatus : undefined);
5875
5889
  cb.called = true;
5876
5890
  if (!cb.recall) {
5877
5891
  callbacks.splice(i, 1);
@@ -5889,7 +5903,7 @@ function track(u, consent) {
5889
5903
  // E.g. Math.ceil(1628735962643 / (24*60*60*1000)) => 18852 (days) => ejo in base36 (13 bytes => 3 bytes)
5890
5904
  var end = Math.ceil((Date.now() + (365 /* Setting.Expire */ * 86400000 /* Time.Day */)) / 86400000 /* Time.Day */);
5891
5905
  // If DOB is not set in the user object, use the date set in the config as a DOB
5892
- var dob = u.dob === 0 ? (config$2.dob === null ? 0 : config$2.dob) : u.dob;
5906
+ var dob = u.dob === 0 ? (config$3.dob === null ? 0 : config$3.dob) : u.dob;
5893
5907
  // To avoid cookie churn, write user id cookie only once every day
5894
5908
  if (u.expiry === null || Math.abs(end - u.expiry) >= 1 /* Setting.CookieInterval */ || u.consent !== consent || u.dob !== dob) {
5895
5909
  var cookieParts = [data$2.userId, 2 /* Setting.CookieVersion */, end.toString(36), consent, dob];
@@ -5905,7 +5919,7 @@ function shortid() {
5905
5919
  }
5906
5920
  function session() {
5907
5921
  var output = { session: shortid(), ts: Math.round(Date.now()), count: 1, upgrade: null, upload: "" /* Constant.Empty */ };
5908
- var value = getCookie("_clsk" /* Constant.SessionKey */, !config$2.includeSubdomains);
5922
+ var value = getCookie("_clsk" /* Constant.SessionKey */, !config$3.includeSubdomains);
5909
5923
  if (value) {
5910
5924
  // Maintaining support for pipe separator for backward compatibility, this can be removed in future releases
5911
5925
  var parts = value.includes("^" /* Constant.Caret */) ? value.split("^" /* Constant.Caret */) : value.split("|" /* Constant.Pipe */);
@@ -5926,7 +5940,7 @@ function num(string, base) {
5926
5940
  }
5927
5941
  function user() {
5928
5942
  var output = { id: shortid(), version: 0, expiry: null, consent: 0 /* BooleanFlag.False */, dob: 0 };
5929
- var cookie = getCookie("_clck" /* Constant.CookieKey */, !config$2.includeSubdomains);
5943
+ var cookie = getCookie("_clck" /* Constant.CookieKey */, !config$3.includeSubdomains);
5930
5944
  if (cookie && cookie.length > 0) {
5931
5945
  // Splitting and looking up first part for forward compatibility, in case we wish to store additional information in a cookie
5932
5946
  // Maintaining support for pipe separator for backward compatibility, this can be removed in future releases
@@ -5946,9 +5960,9 @@ function user() {
5946
5960
  output.dob = num(parts[4]);
5947
5961
  }
5948
5962
  // Set track configuration to true for this user if we have explicit consent, regardless of project setting
5949
- config$2.track = config$2.track || output.consent === 1 /* BooleanFlag.True */;
5963
+ config$3.track = config$3.track || output.consent === 1 /* BooleanFlag.True */;
5950
5964
  // Get user id from cookie only if we tracking is enabled, otherwise fallback to a random id
5951
- output.id = config$2.track ? parts[0] : output.id;
5965
+ output.id = config$3.track ? parts[0] : output.id;
5952
5966
  }
5953
5967
  return output;
5954
5968
  }
@@ -6005,7 +6019,7 @@ function reset$2() {
6005
6019
  function report(e) {
6006
6020
  // Do not report the same message twice for the same page
6007
6021
  if (history$1 && history$1.indexOf(e.message) === -1) {
6008
- var url = config$2.report;
6022
+ var url = config$3.report;
6009
6023
  if (url && url.length > 0 && data$1) {
6010
6024
  var payload = { v: data$1.version, p: data$1.projectId, u: data$1.userId, s: data$1.sessionId, n: data$1.pageNum };
6011
6025
  if (e.message) {
@@ -6190,8 +6204,8 @@ function config(override) {
6190
6204
  return false;
6191
6205
  }
6192
6206
  for (var key in override) {
6193
- if (key in config$2) {
6194
- config$2[key] = override[key];
6207
+ if (key in config$3) {
6208
+ config$3[key] = override[key];
6195
6209
  }
6196
6210
  }
6197
6211
  return true;
@@ -6235,11 +6249,12 @@ var diagnostic = /*#__PURE__*/Object.freeze({
6235
6249
  function start$3() {
6236
6250
  // The order below is important
6237
6251
  // and is determined by interdependencies of modules
6238
- configure(config$2.excludeClassNames || []);
6252
+ config$2(config$3.excludeClassNames || []);
6253
+ console.log("\uD83D\uDE80 \uD83D\uDC25 ~ start ~ config:", config$3);
6239
6254
  start$n();
6240
6255
  start$k();
6241
6256
  start$l();
6242
- if (config$2.delayDom) {
6257
+ if (config$3.delayDom) {
6243
6258
  // Lazy load layout module as part of page load time performance improvements experiment
6244
6259
  bind(window, 'load', function () {
6245
6260
  start$m();
@@ -6488,7 +6503,7 @@ function process(entries) {
6488
6503
  case "resource" /* Constant.Resource */:
6489
6504
  var name_1 = entry.name;
6490
6505
  log(4 /* Dimension.NetworkHosts */, host(name_1));
6491
- if (name_1 === config$2.upload || name_1 === config$2.fallback) {
6506
+ if (name_1 === config$3.upload || name_1 === config$3.fallback) {
6492
6507
  max(28 /* Metric.UploadTime */, entry.duration);
6493
6508
  }
6494
6509
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemx-dev/clarity-js",
3
- "version": "0.8.63",
3
+ "version": "0.8.64",
4
4
  "description": "Clarity js",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -1,2 +1,2 @@
1
- let version = "0.8.63";
1
+ let version = "0.8.64";
2
2
  export default version;
@@ -15,7 +15,8 @@ export { hashText } from "@src/layout/dom";
15
15
  export function start(): void {
16
16
  // The order below is important
17
17
  // and is determined by interdependencies of modules
18
- selector.configure(config.excludeClassNames || []);
18
+ selector.config(config.excludeClassNames || []);
19
+ console.log(`🚀 🐥 ~ start ~ config:`, config);
19
20
  doc.start();
20
21
  region.start();
21
22
  dom.start();
@@ -2,6 +2,7 @@ import { Character } from "../../types/data";
2
2
  import { Constant, Selector, SelectorInput } from "../../types/layout";
3
3
 
4
4
  const excludeClassNames = Constant.ExcludeClassNames.split(Constant.Comma);
5
+
5
6
  let extraExcludeClassNames: string[] = [];
6
7
  let selectorMap: { [selector: string]: number[] } = {};
7
8
 
@@ -9,8 +10,9 @@ export function reset(): void {
9
10
  selectorMap = {};
10
11
  }
11
12
 
12
- export function configure(classNames: string[]): void {
13
+ export function config(classNames: string[]): void {
13
14
  extraExcludeClassNames = classNames || [];
15
+ console.log(`[Selector] config called — extraExcludeClassNames set to: [${extraExcludeClassNames.join(', ')}]`);
14
16
  }
15
17
 
16
18
  export function get(input: SelectorInput, type: Selector): string {
@@ -33,7 +35,13 @@ export function get(input: SelectorInput, type: Selector): string {
33
35
  input.tag = input.tag.indexOf(Constant.SvgPrefix) === 0 ? input.tag.substr(Constant.SvgPrefix.length) : input.tag;
34
36
  let selector = `${prefix}${input.tag}${suffix}`;
35
37
  let id = Constant.Id in a && a[Constant.Id].length > 0 ? a[Constant.Id] : null;
36
- let classes = input.tag !== Constant.BodyTag && Constant.Class in a && a[Constant.Class].length > 0 ? a[Constant.Class].trim().split(/\s+/).filter(c => filter(c)).join(Constant.Period) : null;
38
+ const rawClasses = Constant.Class in a ? a[Constant.Class].trim().split(/\s+/) : [];
39
+ const filteredClasses = rawClasses.filter(c => filter(c));
40
+ const removedClasses = rawClasses.filter(c => !filter(c));
41
+ if (removedClasses.length > 0) {
42
+ console.log(`[Selector] tag="${input.tag}" id="${input.id}" — removed classes: [${removedClasses.join(', ')}] | kept: [${filteredClasses.join(', ')}] | extraExclude: [${extraExcludeClassNames.join(', ')}]`);
43
+ }
44
+ let classes = input.tag !== Constant.BodyTag && filteredClasses.length > 0 ? filteredClasses.join(Constant.Period) : null;
37
45
  if (classes && classes.length > 0) {
38
46
  if (type === Selector.Alpha) {
39
47
  // In Alpha mode, update selector to use class names, with relative positioning within the parent id container.
@@ -42,15 +50,18 @@ export function get(input: SelectorInput, type: Selector): string {
42
50
  if (!(key in selectorMap)) { selectorMap[key] = []; }
43
51
  if (selectorMap[key].indexOf(input.id) < 0) { selectorMap[key].push(input.id); }
44
52
  selector = `${key}${Constant.Tilde}${selectorMap[key].indexOf(input.id)}`;
53
+ console.log(`🚀 🐥 ~ get ~ selector:`, selector);
45
54
  } else {
46
55
  // In Beta mode, we continue to look at query selectors in context of the full page
47
56
  selector = `${prefix}${input.tag}.${classes}${suffix}`
57
+ console.log(`🚀 🐥 ~ get ~ selector:`, selector);
48
58
  }
49
59
  }
50
60
  // Update selector to use "id" field when available. There are two exceptions:
51
61
  // (1) if "id" appears to be an auto generated string token, e.g. guid or a random id containing digits
52
62
  // (2) if "id" appears inside a shadow DOM, in which case we continue to prefix up to shadow DOM to prevent conflicts
53
63
  selector = id && filter(id) ? `${getDomPrefix(prefix)}${Constant.Hash}${id}` : selector;
64
+ console.log(`🚀 🐥 ~ get ~ selector:`, selector);
54
65
  return selector;
55
66
  }
56
67
  }
@@ -78,7 +89,10 @@ function getDomPath(input: string): string {
78
89
  // Check if the given input string has digits or excluded class names
79
90
  function filter(value: string): boolean {
80
91
  if (!value) { return false; } // Do not process empty strings
81
- if (getExcludeClassNames().some(x => value.toLowerCase().indexOf(x) >= 0)) { return false; }
92
+
93
+ const excludeClassNames = getExcludeClassNames();
94
+ console.log(`🚀 🐥 ~ filter ~ excludeClassNames:`, excludeClassNames);
95
+ if (excludeClassNames.some(x => value.toLowerCase().indexOf(x) >= 0)) { return false; }
82
96
  for (let i = 0; i < value.length; i++) {
83
97
  let c = value.charCodeAt(i);
84
98
  if (c >= Character.Zero && c <= Character.Nine) { return false };
@@ -88,5 +102,7 @@ function filter(value: string): boolean {
88
102
 
89
103
 
90
104
  function getExcludeClassNames(): string[] {
105
+ console.log(`🚀 🐥 ~ getExcludeClassNames ~ extraExcludeClassNames:`, extraExcludeClassNames);
106
+ console.log(`🚀 🐥 ~ getExcludeClassNames ~ excludeClassNames:`, excludeClassNames);
91
107
  return [...excludeClassNames, ...extraExcludeClassNames];
92
108
  }