@trafficwar/node 2.2.4 → 2.2.5

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/README.md CHANGED
@@ -89,13 +89,13 @@ const trafficwar = new TrafficWar({
89
89
  });
90
90
  ```
91
91
 
92
- Set `verbose: true` to print, once at startup, every `event` and `label` the
93
- SDK can see statically in `capture()` calls under the working directory (or
94
- `catalogRoot`). String literals are printed as written. A present value that
95
- is not a static string is printed as `<dynamic>`, and a missing one as
96
- `<missing>`. The scan skips `node_modules` and does not print payloads, API
97
- keys, or other properties. A scan failure is logged and does not stop the
98
- client.
92
+ Set `verbose: true` to print, once at startup, `capture()` calls whose
93
+ `event` and `label` are both fixed string literals. The scan looks under the
94
+ working directory, or `catalogRoot` when that is set. A call is omitted when
95
+ either value is missing or computed (a variable, concatenation, or template
96
+ with an expression). The scan skips `node_modules` and does not print
97
+ payloads, API keys, or other properties. A scan failure is logged and does
98
+ not stop the client.
99
99
 
100
100
  ```ts
101
101
  const trafficwar = new TrafficWar({
@@ -338,7 +338,8 @@ delivery still fails.
338
338
  - `debug`: print safe batch lifecycle diagnostics with `console.debug`.
339
339
  Defaults to `false`.
340
340
  - `verbose`: at startup, statically scan source for `capture()` calls and
341
- print each `event` and `label`. Defaults to `false`.
341
+ print pairs whose `event` and `label` are both fixed string literals.
342
+ Dynamic or missing values are omitted. Defaults to `false`.
342
343
  - `catalogRoot`: directory scanned when `verbose` is true. Defaults to the
343
344
  process working directory.
344
345
  - `timeoutMs`: timeout for each attempt. Defaults to 30,000 ms, safely above
package/dist/index.cjs CHANGED
@@ -576,7 +576,7 @@ function isSourceFile(name) {
576
576
  return SOURCE_EXTENSIONS.has(path__default.default.extname(name));
577
577
  }
578
578
  function clip(value) {
579
- if (value === "<dynamic>" || value === "<missing>" || value.length <= MAX_LITERAL_CHARS) {
579
+ if (value.length <= MAX_LITERAL_CHARS) {
580
580
  return value;
581
581
  }
582
582
  return `${value.slice(0, MAX_LITERAL_CHARS - 3)}...`;
@@ -667,7 +667,6 @@ function parseObject(source, open, limit) {
667
667
  const line = lineAt(source, open);
668
668
  let event;
669
669
  let label;
670
- let saw = false;
671
670
  let index = open + 1;
672
671
  while (index < limit) {
673
672
  index = skipTrivia(source, index, limit);
@@ -676,7 +675,7 @@ function parseObject(source, open, limit) {
676
675
  }
677
676
  if (source[index] === "}") {
678
677
  return {
679
- row: saw ? finishRow(event, label, line) : void 0,
678
+ row: fixedCapture(event, label, line),
680
679
  next: index + 1
681
680
  };
682
681
  }
@@ -695,39 +694,32 @@ function parseObject(source, open, limit) {
695
694
  }
696
695
  index = skipTrivia(source, key.next, limit);
697
696
  if (source[index] !== ":") {
698
- if (key.name === "event" || key.name === "label") {
699
- saw = true;
700
- if (key.name === "event") {
701
- event = "<dynamic>";
702
- } else {
703
- label = "<dynamic>";
704
- }
697
+ if (key.name === "event") {
698
+ event = void 0;
699
+ } else if (key.name === "label") {
700
+ label = void 0;
705
701
  }
702
+ index = key.next;
706
703
  continue;
707
704
  }
708
705
  const value = readValue(source, index + 1, limit);
709
- if (key.name === "event" || key.name === "label") {
710
- saw = true;
711
- const text = value.literal ?? "<dynamic>";
712
- if (key.name === "event") {
713
- event = text;
714
- } else {
715
- label = text;
716
- }
706
+ if (key.name === "event") {
707
+ event = value.literal ?? void 0;
708
+ } else if (key.name === "label") {
709
+ label = value.literal ?? void 0;
717
710
  }
718
711
  index = value.next;
719
712
  }
720
713
  return {
721
- row: saw ? finishRow(event, label, line) : void 0,
714
+ row: fixedCapture(event, label, line),
722
715
  next: index
723
716
  };
724
717
  }
725
- function finishRow(event, label, line) {
726
- return {
727
- event: event ?? "<missing>",
728
- label: label ?? "<missing>",
729
- line
730
- };
718
+ function fixedCapture(event, label, line) {
719
+ if (event === void 0 || label === void 0) {
720
+ return void 0;
721
+ }
722
+ return { event, label, line };
731
723
  }
732
724
  function readKey(source, start, limit) {
733
725
  const index = skipTrivia(source, start, limit);
@@ -1124,7 +1116,7 @@ function uuidv7() {
1124
1116
 
1125
1117
  // package.json
1126
1118
  var package_default = {
1127
- version: "2.2.4"};
1119
+ version: "2.2.5"};
1128
1120
 
1129
1121
  // src/client.ts
1130
1122
  var TRAFFICWAR_DEFAULT_BASE_URL = "https://ingest.trafficwar.tech";