@garagem-ai/site-sdk 0.13.5 → 0.14.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/react.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { k as SearchUi, a as Listing, ai as LocationNameTables, S as SearchPathFilters, A as AppliedSearchQuery, bq as MapSearchSubscription, an as MapBounds, as as MapPolygon, au as MapSearchResult, ar as MapPinCluster, O as PhotoSearchItem, U as ListingWithMatchedPhoto, F as FetchLike } from './types-photo-search-CVPyF9zC.mjs';
1
+ import { k as SearchUi, a as Listing, ai as LocationNameTables, S as SearchPathFilters, A as AppliedSearchQuery, bq as MapSearchSubscription, an as MapBounds, as as MapPolygon, au as MapSearchResult, ar as MapPinCluster, O as PhotoSearchItem, U as ListingWithMatchedPhoto, F as FetchLike } from './types-photo-search-CokmqLjn.mjs';
2
2
 
3
3
  type SiteIdInput = string | Promise<string> | (() => string | Promise<string>);
4
4
  type PublicSearchSnapshot = {
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { k as SearchUi, a as Listing, ai as LocationNameTables, S as SearchPathFilters, A as AppliedSearchQuery, bq as MapSearchSubscription, an as MapBounds, as as MapPolygon, au as MapSearchResult, ar as MapPinCluster, O as PhotoSearchItem, U as ListingWithMatchedPhoto, F as FetchLike } from './types-photo-search-CVPyF9zC.js';
1
+ import { k as SearchUi, a as Listing, ai as LocationNameTables, S as SearchPathFilters, A as AppliedSearchQuery, bq as MapSearchSubscription, an as MapBounds, as as MapPolygon, au as MapSearchResult, ar as MapPinCluster, O as PhotoSearchItem, U as ListingWithMatchedPhoto, F as FetchLike } from './types-photo-search-CokmqLjn.js';
2
2
 
3
3
  type SiteIdInput = string | Promise<string> | (() => string | Promise<string>);
4
4
  type PublicSearchSnapshot = {
package/dist/react.js CHANGED
@@ -32,6 +32,43 @@ module.exports = __toCommonJS(react_exports);
32
32
  var import_react = require("react");
33
33
  var import_navigation = require("next/navigation");
34
34
 
35
+ // src/analytics-document.ts
36
+ var FILTER_SEGMENT_SOURCE = "(?:^|-)(?:quartos|banheiros|suites|suite|vagas)$|(?:^|-)(?:reais|m2)$|^mapa$";
37
+ var CLICK_ID_SOURCE = "^(?:fbclid|gclid|gbraid|wbraid|msclkid|ttclid|igshid|yclid|twclid|mc_eid|mc_cid|gad_source|_gl)$";
38
+ var DOCUMENT_QUERY_KEYS = ["q", "ordenar", "page", "pagina"];
39
+ var FILTER_SEGMENT = new RegExp(FILTER_SEGMENT_SOURCE, "i");
40
+ var CLICK_ID = new RegExp(CLICK_ID_SOURCE);
41
+ function isAnalyticsDocumentUrl(href) {
42
+ let url;
43
+ try {
44
+ url = new URL(href, "https://site.invalid");
45
+ } catch {
46
+ return true;
47
+ }
48
+ const pageRaw = param(url, "page") ?? param(url, "pagina");
49
+ if (pageRaw != null && pageRaw !== "") {
50
+ const page = Number(pageRaw);
51
+ if (!Number.isInteger(page) || page !== 1) return false;
52
+ }
53
+ const path = url.pathname.replace(/\/+$/, "").toLowerCase() || "/";
54
+ if (path !== "/imoveis" && !path.startsWith("/imoveis/")) return true;
55
+ for (const key of url.searchParams.keys()) {
56
+ if (ignoredQuery(key.toLowerCase())) continue;
57
+ return false;
58
+ }
59
+ const segments = path.split("/").filter(Boolean).slice(1);
60
+ return segments.every((segment) => !FILTER_SEGMENT.test(segment));
61
+ }
62
+ function param(url, name) {
63
+ for (const [key, value] of url.searchParams) {
64
+ if (key.toLowerCase() === name) return value;
65
+ }
66
+ return null;
67
+ }
68
+ function ignoredQuery(key) {
69
+ return DOCUMENT_QUERY_KEYS.includes(key) || key.startsWith("utm_") || CLICK_ID.test(key);
70
+ }
71
+
35
72
  // ../search-url/types.ts
36
73
  var SEARCH_BASE_ROUTE = "imoveis";
37
74
  var MAX_PAGE = 1e4;
@@ -711,8 +748,17 @@ function clearStagedPathFilters(current, keepFilterIds = []) {
711
748
 
712
749
  // src/analytics.ts
713
750
  var SITE_ANALYTICS_EVENT = "garagem:site-event";
751
+ function browserPageHref() {
752
+ if (typeof window === "undefined") return null;
753
+ const location = window.location;
754
+ return typeof location?.href === "string" ? location.href : null;
755
+ }
714
756
  function emitSiteEvent(event, properties) {
715
757
  if (typeof window === "undefined") return;
758
+ const href = browserPageHref();
759
+ if (href && event !== "lead_generated" && !isAnalyticsDocumentUrl(href)) {
760
+ return;
761
+ }
716
762
  window.dispatchEvent(
717
763
  new CustomEvent(SITE_ANALYTICS_EVENT, { detail: { event, properties } })
718
764
  );
@@ -1426,9 +1472,21 @@ var import_react2 = require("react");
1426
1472
  function listingLocationLabel(location) {
1427
1473
  return [location.neighborhood, location.city, location.state].map((part) => part ? String(part).trim() : "").filter(Boolean).join(", ");
1428
1474
  }
1475
+ function cardPriceLabel(isPrivate, collapsed, price, formattedPrice) {
1476
+ if (isPrivate) return "Sob consulta";
1477
+ if (collapsed && price != null) return `A partir de ${formattedPrice}`;
1478
+ return formattedPrice;
1479
+ }
1429
1480
  function toListingCardModel(listing) {
1430
1481
  const isPrivate = listing.priceVisibility === "private";
1431
1482
  const area = listing.property?.usableArea ?? listing.property?.totalArea;
1483
+ const unitCount = listing.development?.unitCount;
1484
+ const collapsed = typeof unitCount === "number" && unitCount > 1;
1485
+ const formattedPrice = formatListingPrice(
1486
+ listing.price,
1487
+ "pt-BR",
1488
+ listing.currency ?? "BRL"
1489
+ );
1432
1490
  return {
1433
1491
  href: listingPublicPath(listing),
1434
1492
  title: listing.title,
@@ -1436,7 +1494,12 @@ function toListingCardModel(listing) {
1436
1494
  businessLabel: listingBusinessLabel(listing.businessType),
1437
1495
  priceVisibility: listing.priceVisibility,
1438
1496
  price: listing.price,
1439
- priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price, "pt-BR", listing.currency ?? "BRL"),
1497
+ priceLabel: cardPriceLabel(
1498
+ isPrivate,
1499
+ collapsed,
1500
+ listing.price,
1501
+ formattedPrice
1502
+ ),
1440
1503
  pricePeriod: listing.businessType === "rental" && !isPrivate && listing.price != null ? "/m\xEAs" : null,
1441
1504
  locationLabel: listingLocationLabel(listing.location || {}),
1442
1505
  propertyType: listing.property?.type ?? null,
@@ -1445,7 +1508,8 @@ function toListingCardModel(listing) {
1445
1508
  bedrooms: listing.property?.bedrooms ?? null,
1446
1509
  bathrooms: listing.property?.bathrooms ?? null,
1447
1510
  parkingSpaces: listing.property?.parkingSpaces ?? null,
1448
- areaM2: area ?? null
1511
+ areaM2: area ?? null,
1512
+ unitCount: collapsed && typeof unitCount === "number" ? unitCount : null
1449
1513
  };
1450
1514
  }
1451
1515