@openreplay/tracker 18.0.6 → 18.0.7-beta.0

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/dist/lib/index.js CHANGED
@@ -3343,6 +3343,13 @@ class Observer {
3343
3343
  this.throttledSetNodeData.clear();
3344
3344
  this.generation++;
3345
3345
  }
3346
+ /** Clear pending throttled-trailing setNodeData calls. Called from
3347
+ * top-level observe() before re-snapshotting so the second snapshot's
3348
+ * emissions fire as fresh first-calls instead of being deduped against
3349
+ * stale lastCalls entries from the previous snapshot. */
3350
+ resetThrottledSetNodeData() {
3351
+ this.throttledSetNodeData.clear();
3352
+ }
3346
3353
  }
3347
3354
 
3348
3355
  class IFrameObserver extends Observer {
@@ -3617,6 +3624,14 @@ class TopObserver extends Observer {
3617
3624
  observer.handleShadowRoot(shadow);
3618
3625
  return shadow;
3619
3626
  };
3627
+ // Reset the throttled setNodeData state before re-snapshotting. Without this,
3628
+ // a re-snapshot triggered by restart() (e.g. auth token age) within the throttle
3629
+ // window (30ms) of the previous snapshot would dedupe its setNodeData emissions
3630
+ // against the previous snapshot's lastCalls and queue trailing fires whose
3631
+ // args reflect the post-restart DOM state (often empty for antd v5 cssinjs
3632
+ // placeholders). Disconnecting first would also work but observe() isn't
3633
+ // always preceded by disconnect().
3634
+ this.resetThrottledSetNodeData();
3620
3635
  this.app.nodes.clear();
3621
3636
  // Can observe documentElement (<html>) here, because it is not supposed to be changing.
3622
3637
  // However, it is possible in some exotic cases and may cause an ignorance of the newly created <html>
@@ -4005,7 +4020,7 @@ class App {
4005
4020
  this.stopCallbacks = [];
4006
4021
  this.commitCallbacks = [];
4007
4022
  this.activityState = ActivityState.NotActive;
4008
- this.version = '18.0.6'; // TODO: version compatability check inside each plugin.
4023
+ this.version = '18.0.7-beta.0'; // TODO: version compatability check inside each plugin.
4009
4024
  this.socketMode = false;
4010
4025
  this.compressionThreshold = 24 * 1000;
4011
4026
  this.bc = null;
@@ -6069,9 +6084,11 @@ function Input (app, opts) {
6069
6084
  }
6070
6085
  const inputValues = new Map();
6071
6086
  const checkboxValues = new Map();
6087
+ const selectValues = new Map();
6072
6088
  app.attachStopCallback(() => {
6073
6089
  inputValues.clear();
6074
6090
  checkboxValues.clear();
6091
+ selectValues.clear();
6075
6092
  tagSelectorMap.clear();
6076
6093
  });
6077
6094
  function trackInputValue(id, node) {
@@ -6088,6 +6105,13 @@ function Input (app, opts) {
6088
6105
  checkboxValues.set(id, value);
6089
6106
  app.send(SetInputChecked(id, value));
6090
6107
  }
6108
+ function trackSelectValue(id, node) {
6109
+ if (selectValues.get(id) === node.value) {
6110
+ return;
6111
+ }
6112
+ selectValues.set(id, node.value);
6113
+ sendInputValue(id, node);
6114
+ }
6091
6115
  // The only way (to our knowledge) to track all kinds of input changes, including those made by JS
6092
6116
  app.ticker.attach(() => {
6093
6117
  inputValues.forEach((value, id) => {
@@ -6102,6 +6126,12 @@ function Input (app, opts) {
6102
6126
  return checkboxValues.delete(id);
6103
6127
  trackCheckboxValue(id, node.checked);
6104
6128
  });
6129
+ selectValues.forEach((_, id) => {
6130
+ const node = app.nodes.getNode(id);
6131
+ if (!node)
6132
+ return selectValues.delete(id);
6133
+ trackSelectValue(id, node);
6134
+ });
6105
6135
  }, 3);
6106
6136
  function sendInputChange(id, node, hesitationTime, inputTime) {
6107
6137
  const { value, mask } = getInputValue(id, node);
@@ -6118,8 +6148,8 @@ function Input (app, opts) {
6118
6148
  }
6119
6149
  // TODO: support multiple select (?): use selectedOptions;
6120
6150
  if (hasTag(node, 'select')) {
6121
- sendInputValue(id, node);
6122
- app.nodes.attachNodeListener(node, 'change', () => sendInputValue(id, node));
6151
+ trackSelectValue(id, node);
6152
+ app.nodes.attachNodeListener(node, 'change', () => trackSelectValue(id, node));
6123
6153
  }
6124
6154
  if (isTextFieldElement(node)) {
6125
6155
  trackInputValue(id, node);
@@ -7395,7 +7425,7 @@ class NetworkMessage {
7395
7425
  return null;
7396
7426
  const gqlHeader = "application/graphql-response";
7397
7427
  const isGraphql = messageInfo.url.includes("/graphql")
7398
- || Object.values(messageInfo.request.headers).some(v => v && v.includes(gqlHeader));
7428
+ || Object.values(messageInfo.request.headers).some(v => v.includes(gqlHeader));
7399
7429
  if (isGraphql && messageInfo.response.body && typeof messageInfo.response.body === 'string') {
7400
7430
  const isError = messageInfo.response.body.includes("errors");
7401
7431
  messageInfo.status = isError ? 400 : 200;
@@ -7499,7 +7529,6 @@ const genStringBody = (body) => {
7499
7529
  }
7500
7530
  else if (body instanceof Blob ||
7501
7531
  body instanceof ReadableStream ||
7502
- ArrayBuffer.isView(body) ||
7503
7532
  body instanceof ArrayBuffer) {
7504
7533
  result = 'byte data';
7505
7534
  }
@@ -8988,7 +9017,7 @@ class ConstantProperties {
8988
9017
  user_id: this.user_id,
8989
9018
  distinct_id: this.deviceId,
8990
9019
  sdk_edition: 'web',
8991
- sdk_version: '18.0.6',
9020
+ sdk_version: '18.0.7-beta.0',
8992
9021
  timezone: getUTCOffsetString(),
8993
9022
  search_engine: this.searchEngine,
8994
9023
  };
@@ -9690,7 +9719,7 @@ class API {
9690
9719
  this.signalStartIssue = (reason, missingApi) => {
9691
9720
  const doNotTrack = this.checkDoNotTrack();
9692
9721
  console.log("Tracker couldn't start due to:", JSON.stringify({
9693
- trackerVersion: '18.0.6',
9722
+ trackerVersion: '18.0.7-beta.0',
9694
9723
  projectKey: this.options.projectKey,
9695
9724
  doNotTrack,
9696
9725
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,