@garagem-ai/site-sdk 0.13.4 → 0.13.6
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.d.mts +16 -11
- package/dist/index.d.ts +16 -11
- package/dist/index.js +105 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +63 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +63 -3
- package/dist/react.mjs.map +1 -1
- package/dist/{types-photo-search-BROgleJq.d.mts → types-photo-search-CVPyF9zC.d.mts} +1 -0
- package/dist/{types-photo-search-BROgleJq.d.ts → types-photo-search-CVPyF9zC.d.ts} +1 -0
- package/package.json +1 -1
- package/src/analytics-document.ts +90 -0
- package/src/analytics.ts +13 -0
- package/src/index.ts +4 -0
- package/src/search-engine.ts +5 -3
- package/src/studio-contract.ts +3 -0
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-
|
|
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';
|
|
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-
|
|
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';
|
|
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;
|
|
@@ -99,6 +136,19 @@ var LISTING_TYPE_ALIASES = {
|
|
|
99
136
|
rental: ["alugar"]
|
|
100
137
|
};
|
|
101
138
|
|
|
139
|
+
// ../search-url/listing-identity.ts
|
|
140
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
141
|
+
var LISTING_CODE_RE = /^(?:[A-Za-z0-9]+|[A-Z0-9]+(?:-[A-Z0-9]+)+)$/;
|
|
142
|
+
var LETTER_CODE_RE = /^[A-Z]{5}$/;
|
|
143
|
+
function isShortListingIdentity(segment) {
|
|
144
|
+
if (UUID_RE.test(segment) || LETTER_CODE_RE.test(segment)) return true;
|
|
145
|
+
return /\d/.test(segment) && LISTING_CODE_RE.test(segment);
|
|
146
|
+
}
|
|
147
|
+
function isShortListingPath(pathname) {
|
|
148
|
+
const parts = (pathname.split(/[?#]/)[0] ?? "").split("/").filter(Boolean);
|
|
149
|
+
return parts.length === 2 && parts[0] === SEARCH_BASE_ROUTE && isShortListingIdentity(parts[1] ?? "");
|
|
150
|
+
}
|
|
151
|
+
|
|
102
152
|
// ../search-url/path.ts
|
|
103
153
|
function toArray(value) {
|
|
104
154
|
if (value === void 0) return [];
|
|
@@ -195,6 +245,7 @@ function parseSearchPublicPath(pathname, dictionary = emptySearchUrlDictionary()
|
|
|
195
245
|
if (segments.some((segment) => segment.toLowerCase().startsWith("id-"))) {
|
|
196
246
|
return null;
|
|
197
247
|
}
|
|
248
|
+
if (isShortListingPath(raw)) return null;
|
|
198
249
|
const filters = {};
|
|
199
250
|
const locationParts = [];
|
|
200
251
|
const propertyTypes = [];
|
|
@@ -527,9 +578,9 @@ function pathnameOnly(pathname) {
|
|
|
527
578
|
return String(pathname || "").split(/[?#]/)[0] || "/";
|
|
528
579
|
}
|
|
529
580
|
function isListingDetailPath(pathname) {
|
|
530
|
-
const
|
|
531
|
-
const last =
|
|
532
|
-
return last.toLowerCase().startsWith("id-");
|
|
581
|
+
const path = pathnameOnly(pathname);
|
|
582
|
+
const last = path.split("/").filter(Boolean).pop() || "";
|
|
583
|
+
return last.toLowerCase().startsWith("id-") || isShortListingPath(path);
|
|
533
584
|
}
|
|
534
585
|
function readPublicSearch(pathname, search, dictionary) {
|
|
535
586
|
const pathFilters = parseSearchPublicPath2(pathnameOnly(pathname), dictionary) || {};
|
|
@@ -697,8 +748,17 @@ function clearStagedPathFilters(current, keepFilterIds = []) {
|
|
|
697
748
|
|
|
698
749
|
// src/analytics.ts
|
|
699
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
|
+
}
|
|
700
756
|
function emitSiteEvent(event, properties) {
|
|
701
757
|
if (typeof window === "undefined") return;
|
|
758
|
+
const href = browserPageHref();
|
|
759
|
+
if (href && event !== "lead_generated" && !isAnalyticsDocumentUrl(href)) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
702
762
|
window.dispatchEvent(
|
|
703
763
|
new CustomEvent(SITE_ANALYTICS_EVENT, { detail: { event, properties } })
|
|
704
764
|
);
|