@diegotsi/flint-react 0.3.3 → 0.3.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/dist/index.js CHANGED
@@ -7869,6 +7869,11 @@ function ScreenAnnotator({ zIndex: zIndex2, onCapture, onCancel }) {
7869
7869
  return;
7870
7870
  }
7871
7871
  setPhase("capturing");
7872
+ const sx = window.scrollX ?? window.pageXOffset ?? 0;
7873
+ const sy = window.scrollY ?? window.pageYOffset ?? 0;
7874
+ const dpr = window.devicePixelRatio ?? 1;
7875
+ const vw = window.innerWidth;
7876
+ const vh = window.innerHeight;
7872
7877
  await new Promise(
7873
7878
  (resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
7874
7879
  );
@@ -7878,18 +7883,24 @@ function ScreenAnnotator({ zIndex: zIndex2, onCapture, onCancel }) {
7878
7883
  useCORS: true,
7879
7884
  logging: false,
7880
7885
  allowTaint: true,
7886
+ scale: dpr,
7887
+ x: sx,
7888
+ y: sy,
7889
+ width: vw,
7890
+ height: vh,
7891
+ windowWidth: vw,
7892
+ windowHeight: vh,
7893
+ scrollX: -sx,
7894
+ scrollY: -sy,
7881
7895
  ignoreElements: (el) => el === overlayRef.current
7882
7896
  });
7883
7897
  unpatch();
7884
- const dpr = window.devicePixelRatio ?? 1;
7885
- const sx = window.scrollX ?? window.pageXOffset ?? 0;
7886
- const sy = window.scrollY ?? window.pageYOffset ?? 0;
7887
7898
  const ctx = canvas.getContext("2d");
7888
7899
  ctx.fillStyle = "rgba(255,200,0,0.25)";
7889
- ctx.fillRect((finalRect.x + sx) * dpr, (finalRect.y + sy) * dpr, finalRect.w * dpr, finalRect.h * dpr);
7900
+ ctx.fillRect(finalRect.x * dpr, finalRect.y * dpr, finalRect.w * dpr, finalRect.h * dpr);
7890
7901
  ctx.strokeStyle = "#f97316";
7891
7902
  ctx.lineWidth = 3 * dpr;
7892
- ctx.strokeRect((finalRect.x + sx) * dpr, (finalRect.y + sy) * dpr, finalRect.w * dpr, finalRect.h * dpr);
7903
+ ctx.strokeRect(finalRect.x * dpr, finalRect.y * dpr, finalRect.w * dpr, finalRect.h * dpr);
7893
7904
  canvas.toBlob((blob) => {
7894
7905
  if (blob) {
7895
7906
  onCapture(new File([blob], "annotation.png", { type: "image/png" }));
@@ -8914,10 +8925,11 @@ var BLOCKED_HOSTS = /* @__PURE__ */ new Set([
8914
8925
  "logs.browser-intake-datadoghq.com",
8915
8926
  "session-replay.browser-intake-datadoghq.com"
8916
8927
  ]);
8917
- function isBlockedUrl(url) {
8928
+ function isBlockedUrl(url, extra) {
8918
8929
  try {
8919
8930
  const host = new URL(url, location.href).hostname;
8920
- return BLOCKED_HOSTS.has(host) || [...BLOCKED_HOSTS].some((b) => host.endsWith("." + b));
8931
+ const all = [...BLOCKED_HOSTS, ...extra];
8932
+ return all.some((b) => host === b || host.endsWith("." + b));
8921
8933
  } catch {
8922
8934
  return false;
8923
8935
  }
@@ -8931,8 +8943,9 @@ function truncateUrl(url) {
8931
8943
  return url.length > 200 ? url.slice(0, 200) + "\u2026" : url;
8932
8944
  }
8933
8945
  }
8934
- function createNetworkCollector() {
8946
+ function createNetworkCollector(extraBlockedHosts = []) {
8935
8947
  const entries = [];
8948
+ const blocked = new Set(extraBlockedHosts);
8936
8949
  let origFetch = null;
8937
8950
  let origXHROpen = null;
8938
8951
  let active = false;
@@ -8950,7 +8963,7 @@ function createNetworkCollector() {
8950
8963
  const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
8951
8964
  const startTime = Date.now();
8952
8965
  const res = await origFetch.call(window, input, init);
8953
- if (!isBlockedUrl(url)) {
8966
+ if (!isBlockedUrl(url, blocked)) {
8954
8967
  push({
8955
8968
  method,
8956
8969
  url: truncateUrl(url),
@@ -8966,7 +8979,7 @@ function createNetworkCollector() {
8966
8979
  const startTime = Date.now();
8967
8980
  const urlStr = typeof url === "string" ? url : url.href;
8968
8981
  this.addEventListener("load", () => {
8969
- if (!isBlockedUrl(urlStr)) {
8982
+ if (!isBlockedUrl(urlStr, blocked)) {
8970
8983
  push({
8971
8984
  method: method.toUpperCase(),
8972
8985
  url: truncateUrl(urlStr),
@@ -9066,7 +9079,14 @@ function WidgetContent({
9066
9079
  consoleCollector.current.start();
9067
9080
  }
9068
9081
  if (!networkCollector.current) {
9069
- networkCollector.current = createNetworkCollector();
9082
+ const flintHost = (() => {
9083
+ try {
9084
+ return new URL(serverUrl).hostname;
9085
+ } catch {
9086
+ return "";
9087
+ }
9088
+ })();
9089
+ networkCollector.current = createNetworkCollector(flintHost ? [flintHost] : []);
9070
9090
  networkCollector.current.start();
9071
9091
  }
9072
9092
  useEffect3(() => {