feat: add UTM-tagged docs links to SDK warnings and enterprise-only errors (#4797)

Add a central documentation link registry (`lancedb::docs::DocLink`) in
the Rust core that builds `docs.lancedb.com` URLs with UTM parameters
(`utm_source=lancedb_sdk`, `utm_medium=warning|error`,
`utm_campaign=<id>`, `utm_content=<sdk>-<version>`) placed before any
`#anchor` fragment and without user-identifying data.

- Initialize `utm_content` per language binding (`python`, `nodejs`,
`cli`, defaulting to `rust`) and expose the link builder to Python so
`DBConnection` and `Job` stubs reuse the core definitions.
- Append published documentation links to Enterprise-only `NotSupported`
/ `NotImplementedError` errors across database, job, catalog, and table
operations.
- Emit rate-limited maintenance warnings (once per table per process
when `warn` logging is enabled) when opening a native table with at
least 100 small fragments (`< 100k` physical rows each) or at least
1,000,000 unindexed rows on an optimizable user index, reading only
manifest metadata without opening data or `_indices/` files, and
document the thresholds in the compaction and reindexing guides.
- Verify published/in-repo `docs/web/` targets and `#anchor` fragments
in unit tests and include extracted SDK links in the scheduled
`docs-link-check` workflow.

Linear: OSS-2772
This commit is contained in:
Xuanwo
2026-11-03 14:12:15 +08:00
committed by GitHub
parent f9e25960e3
commit 2d70bec53a
20 changed files with 1319 additions and 59 deletions
+19
View File
@@ -58,8 +58,25 @@ fn shutdown_runtime(py: Python<'_>) {
py.detach(|| runtime::shutdown(std::time::Duration::from_secs(5)));
}
#[pyfunction]
fn _doc_url(campaign: &str) -> PyResult<String> {
let link = lancedb::docs::DocLink::from_campaign(campaign).ok_or_else(|| {
pyo3::exceptions::PyValueError::new_err(format!("unknown doc link campaign: {campaign}"))
})?;
Ok(link.url())
}
#[pyfunction]
fn _append_doc_url(message: &str, campaign: &str) -> PyResult<String> {
let link = lancedb::docs::DocLink::from_campaign(campaign).ok_or_else(|| {
pyo3::exceptions::PyValueError::new_err(format!("unknown doc link campaign: {campaign}"))
})?;
Ok(link.append_to(message))
}
#[pymodule]
pub fn _lancedb(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
lancedb::docs::set_sdk_ident("python", env!("CARGO_PKG_VERSION"));
let env = Env::new()
.filter_or("LANCEDB_LOG", "warn")
.write_style("LANCEDB_LOG_STYLE");
@@ -133,6 +150,8 @@ pub fn _lancedb(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(expr_col, m)?)?;
m.add_function(wrap_pyfunction!(expr_lit, m)?)?;
m.add_function(wrap_pyfunction!(expr_func, m)?)?;
m.add_function(wrap_pyfunction!(_doc_url, m)?)?;
m.add_function(wrap_pyfunction!(_append_doc_url, m)?)?;
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
m.add(
"_experimental_functions_enabled",