@rulemetric/proxy 0.7.38 → 0.7.40

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.
Files changed (2) hide show
  1. package/addon/reporter.py +22 -4
  2. package/package.json +1 -1
package/addon/reporter.py CHANGED
@@ -171,11 +171,19 @@ def _get_api_url() -> str:
171
171
  # env > env-file > prod (NOT a dead localhost). Mirrors api-client.ts:70 and
172
172
  # _config.sh:78 so the proxy agrees with the CLI + hooks. Dev still opts into
173
173
  # localhost by exporting RULEMETRIC_API_URL.
174
- return (
175
- os.environ.get("RULEMETRIC_API_URL")
176
- or _env_file_values().get("RULEMETRIC_API_URL")
177
- or "https://rulemetric.com"
174
+ configured = os.environ.get("RULEMETRIC_API_URL") or _env_file_values().get(
175
+ "RULEMETRIC_API_URL"
178
176
  )
177
+ if configured:
178
+ return configured
179
+ # L1.2: strict-local refuses the cloud default — the reporter goes dark
180
+ # rather than shipping captured context to rulemetric.com.
181
+ strict = os.environ.get("RULEMETRIC_STRICT_LOCAL") or _env_file_values().get(
182
+ "RULEMETRIC_STRICT_LOCAL"
183
+ )
184
+ if strict == "1":
185
+ return ""
186
+ return "https://rulemetric.com"
179
187
 
180
188
 
181
189
  def _get_auth_headers(prefer_file: bool = False) -> dict[str, str]:
@@ -475,6 +483,10 @@ def _replay_envelope(envelope: dict) -> tuple[bool, bool]:
475
483
  return False, True
476
484
 
477
485
  api_url = _get_api_url()
486
+ if not api_url:
487
+ # Strict-local: reporting disabled — drop the line as permanent so the
488
+ # drainer doesn't spin on a spool it is forbidden to deliver.
489
+ return False, True
478
490
  if kind == "event":
479
491
  url = f"{api_url}/api/sessions/{session_id}/events"
480
492
  elif kind == "snapshot":
@@ -663,6 +675,8 @@ def start_drainer() -> None:
663
675
  def _post_event(session_id: str, event: dict) -> None:
664
676
  """Synchronous POST for session events — called from a background thread."""
665
677
  api_url = _get_api_url()
678
+ if not api_url:
679
+ return # strict-local: reporting disabled
666
680
  url = f"{api_url}/api/sessions/{session_id}/events"
667
681
  headers = _get_auth_headers()
668
682
  data = json.dumps(event).encode("utf-8")
@@ -683,6 +697,8 @@ def _post_event(session_id: str, event: dict) -> None:
683
697
  def _post_snapshot(session_id: str, snapshot: dict) -> None:
684
698
  """Synchronous POST — called from a background thread."""
685
699
  api_url = _get_api_url()
700
+ if not api_url:
701
+ return # strict-local: reporting disabled
686
702
  url = f"{api_url}/api/sessions/{session_id}/context-snapshots"
687
703
  headers = _get_auth_headers()
688
704
  data = json.dumps(snapshot).encode("utf-8")
@@ -716,6 +732,8 @@ def _trigger_link_instructions(session_id: str) -> None:
716
732
  (whole-account scans are gated behind an explicit backfill flag).
717
733
  """
718
734
  api_url = _get_api_url()
735
+ if not api_url:
736
+ return # strict-local: reporting disabled
719
737
  url = f"{api_url}/api/sessions/link-instructions"
720
738
  headers = _get_auth_headers()
721
739
  data = json.dumps({"sessionId": session_id}).encode("utf-8")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulemetric/proxy",
3
- "version": "0.7.38",
3
+ "version": "0.7.40",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"