mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
FSL-1.0-Apache-2.0 grants us the code, not the name. "Sentry" is Functional Software's trademark, so every place the running app says it to a user -- page titles, onboarding, empty states, toasts, settings copy, the self-hosted footer -- now says Sentinel. Attribution is the other half of the deal and stays untouched: upstream copyright headers, LICENSE, NOTICE. So does anything where the mark is a fact rather than a brand -- @sentry/* packages, sentry-cli, the wizard and bundler plugins, docs.sentry.io, the whole gettingStartedDocs tree. Renaming those would leave instructions that no longer work. Nothing structural moved. No import, identifier, route path, feature flag, API field or test id changed; the diff is 312 lines in and 312 out. Colocated specs were updated in lockstep with the copy they assert. Marketing and community links point at hanzo.ai, only where a real page exists to point at. Co-authored-by: Hanzo Dev <[email protected]>
91 lines
2.0 KiB
TypeScript
91 lines
2.0 KiB
TypeScript
import {createContext, useContext, useEffect, useMemo} from 'react';
|
|
|
|
type Props = {
|
|
children?: React.ReactNode;
|
|
/**
|
|
* Should the ` - Sentinel` suffix be excluded?
|
|
*/
|
|
noSuffix?: boolean;
|
|
/**
|
|
* The organization slug to show in the title
|
|
*/
|
|
orgSlug?: string;
|
|
/**
|
|
* The project slug to show in the title.
|
|
*/
|
|
projectSlug?: string;
|
|
|
|
/**
|
|
* This string will be shown at the very front of the title
|
|
*/
|
|
title?: string;
|
|
};
|
|
|
|
const DEFAULT_PAGE_TITLE = 'Sentinel';
|
|
|
|
const DocumentTitleContext = createContext(DEFAULT_PAGE_TITLE);
|
|
|
|
/**
|
|
* Assigns the document title. The deepest nested version of this title will be
|
|
* the one which is assigned.
|
|
*/
|
|
function SentryDocumentTitle({
|
|
title = '',
|
|
orgSlug,
|
|
projectSlug,
|
|
noSuffix,
|
|
children,
|
|
}: Props) {
|
|
const parentTitle = useContext(DocumentTitleContext);
|
|
|
|
const pageTitle = useMemo(() => {
|
|
if (orgSlug && projectSlug) {
|
|
return `${title} — ${orgSlug} — ${projectSlug}`;
|
|
}
|
|
|
|
if (orgSlug) {
|
|
return `${title} — ${orgSlug}`;
|
|
}
|
|
|
|
if (projectSlug) {
|
|
return `${title} — ${projectSlug}`;
|
|
}
|
|
|
|
return title;
|
|
}, [orgSlug, projectSlug, title]);
|
|
|
|
const documentTitle = useMemo(() => {
|
|
if (noSuffix) {
|
|
return pageTitle;
|
|
}
|
|
|
|
if (pageTitle !== '') {
|
|
return `${pageTitle} — Sentinel`;
|
|
}
|
|
|
|
return DEFAULT_PAGE_TITLE;
|
|
}, [noSuffix, pageTitle]);
|
|
|
|
// NOTE: We do this OUTSIDE of a use effect so that the update order is
|
|
// correct, otherwsie the inner most SentryDocumentTitle will have it's
|
|
// useEffect called first followed by the parents, which will cause the wrong
|
|
// title be set.
|
|
if (document.title !== documentTitle) {
|
|
document.title = documentTitle;
|
|
}
|
|
|
|
useEffect(() => {
|
|
return () => {
|
|
document.title = parentTitle;
|
|
};
|
|
}, [parentTitle]);
|
|
|
|
return (
|
|
<DocumentTitleContext.Provider value={documentTitle}>
|
|
{children}
|
|
</DocumentTitleContext.Provider>
|
|
);
|
|
}
|
|
|
|
export default SentryDocumentTitle;
|