@openreplay/tracker 16.1.0-beta.0 → 16.1.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,11 +5,11 @@ export declare class StringDictionary {
5
5
  /** backwards dictionary of
6
6
  * [repeated str:key]
7
7
  * */
8
- private backDict;
8
+ backDict: Record<string, number>;
9
9
  getKey: (str: string) => [number, boolean];
10
10
  }
11
11
  export default class AttributeSender {
12
- private dict;
12
+ dict: StringDictionary;
13
13
  private readonly app;
14
14
  private readonly isDictDisabled;
15
15
  constructor(options: {
package/dist/lib/entry.js CHANGED
@@ -721,7 +721,9 @@ class StringDictionary {
721
721
  this.backDict = {};
722
722
  this.getKey = (str) => {
723
723
  let isNew = false;
724
- if (!this.backDict[str]) {
724
+ // avoiding potential native object properties
725
+ const safeKey = `__${str}`;
726
+ if (!this.backDict[safeKey]) {
725
727
  isNew = true;
726
728
  // shaving the first 2 digits of the timestamp (since they are irrelevant for next millennia)
727
729
  const shavedTs = Date.now() % 10 ** (13 - 2);
@@ -733,10 +735,10 @@ class StringDictionary {
733
735
  else {
734
736
  this.lastSuffix = 1;
735
737
  }
736
- this.backDict[str] = id;
738
+ this.backDict[safeKey] = id;
737
739
  this.lastTs = shavedTs;
738
740
  }
739
- return [this.backDict[str], isNew];
741
+ return [this.backDict[safeKey], isNew];
740
742
  };
741
743
  }
742
744
  }
@@ -4706,7 +4708,7 @@ class App {
4706
4708
  this.stopCallbacks = [];
4707
4709
  this.commitCallbacks = [];
4708
4710
  this.activityState = ActivityState.NotActive;
4709
- this.version = '16.1.0-beta.0'; // TODO: version compatability check inside each plugin.
4711
+ this.version = '16.1.0-beta.10'; // TODO: version compatability check inside each plugin.
4710
4712
  this.socketMode = false;
4711
4713
  this.compressionThreshold = 24 * 1000;
4712
4714
  this.bc = null;
@@ -5341,15 +5343,19 @@ class App {
5341
5343
  requestIdleCb(() => {
5342
5344
  this.messages.unshift(TabData(this.session.getTabId()));
5343
5345
  this.messages.unshift(Timestamp(this.timestamp()));
5344
- if (this.messages.length > 3) {
5345
- console.log(this.messages);
5346
- }
5347
5346
  try {
5348
5347
  this.worker?.postMessage(this.messages);
5349
5348
  }
5350
5349
  catch (e) {
5351
- console.log(this.messages);
5352
5350
  console.error(e);
5351
+ this.messages.forEach(m => {
5352
+ try {
5353
+ this.worker?.postMessage([m]);
5354
+ }
5355
+ catch (e) {
5356
+ console.error(m, e);
5357
+ }
5358
+ });
5353
5359
  }
5354
5360
  this.commitCallbacks.forEach((cb) => cb(this.messages));
5355
5361
  this.messages.length = 0;
@@ -9178,7 +9184,7 @@ class API {
9178
9184
  this.signalStartIssue = (reason, missingApi) => {
9179
9185
  const doNotTrack = this.checkDoNotTrack();
9180
9186
  console.log("Tracker couldn't start due to:", JSON.stringify({
9181
- trackerVersion: '16.1.0-beta.0',
9187
+ trackerVersion: '16.1.0-beta.10',
9182
9188
  projectKey: this.options.projectKey,
9183
9189
  doNotTrack,
9184
9190
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,