Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ public/page-data
tsconfig.tsbuildinfo

public/mdx-images/*

# yalc
.yalc
yalc.lock
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toolbar": "^1.0.4",
"@radix-ui/themes": "^2.0.3",
"@sentry-internal/global-search": "^1.0.0",
"@sentry-internal/global-search": "^1.1.0",
"@sentry/nextjs": "8.20.0",
"@types/mdx": "^2.0.9",
"algoliasearch": "^4.23.3",
Expand Down Expand Up @@ -136,4 +136,4 @@
"node": "20.11.0",
"yarn": "1.22.21"
}
}
}
26 changes: 25 additions & 1 deletion scripts/algolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import fs from 'fs';
import {join} from 'path';

import {extrapolate, htmlToAlgoliaRecord} from '@sentry-internal/global-search';
import {
extrapolate,
htmlToAlgoliaRecord,
sentryAlgoliaIndexSettings,
standardSDKSlug,
} from '@sentry-internal/global-search';
import algoliasearch, {SearchIndex} from 'algoliasearch';

import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
Expand Down Expand Up @@ -90,6 +95,12 @@ async function indexAndUpload() {
deleteResult.objectIDs.length,
DOCS_INDEX_NAME
);

if (!isDeveloperDocs) {
console.log('🔥 Applying custom index settings ...');
await index.setSettings(sentryAlgoliaIndexSettings);
console.log(`🔥 Applied custom settings to ${DOCS_INDEX_NAME}`);
}
}

async function fetchExistingRecordIds(algoliaIndex: SearchIndex) {
Expand Down Expand Up @@ -121,6 +132,17 @@ async function generateAlogliaRecords(pageFrontMatters: FrontMatter[]) {
async function getRecords(pageFm: FrontMatter) {
console.log('processing:', pageFm.slug);

let sdk: string | undefined;
let framework: string | undefined;
if (pageFm.slug.includes('platforms/')) {
sdk = standardSDKSlug(pageFm.slug.split('/')[1])?.slug as string;
framework = sdk;

if (pageFm.slug.includes('/guides/')) {
framework = standardSDKSlug(pageFm.slug.split('/')[3])?.slug as string;
}
}

try {
const htmlFile = join(staticHtmlFilesPath, pageFm.slug + '.html');
const html = fs.readFileSync(htmlFile).toString();
Expand All @@ -131,6 +153,8 @@ async function getRecords(pageFm: FrontMatter) {
url: '/' + pageFm.slug + '/',
pathSegments: extrapolate(pageFm.slug, '/').map(x => `/${x}/`),
keywords: pageFm.keywords,
sdk,
framework,
},
'#main'
);
Expand Down
4 changes: 1 addition & 3 deletions src/components/docPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export function DocPage({

const pathname = serverContext().path.join('/');

const searchPlatforms = [currentPlatform?.name, currentGuide?.platform].filter(
isTruthy
);
const searchPlatforms = [currentPlatform?.name, currentGuide?.name].filter(isTruthy);

const leafNode = nodeForPath(rootNode, path);

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2639,10 +2639,10 @@
"@sentry/types" "8.20.0"
"@sentry/utils" "8.20.0"

"@sentry-internal/global-search@^1.0.0":
version "1.0.0"
resolved "https://registry.npmjs.org/@sentry-internal/global-search/-/global-search-1.0.0.tgz"
integrity sha512-u4UUwxinDhUJ0kA4xGGQTr3QGJAWh7GRdFls9ys8coV7WjPNYt91MHfOWVdFzgeU6f4aO7RKE8uxSb/fkZiagQ==
"@sentry-internal/global-search@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/global-search/-/global-search-1.1.0.tgz#108f11149a2516ea96b8a544fb4f8a0c046288e2"
integrity sha512-PL2oGOxr0vdnfPwVczs7VuV8bKhypbi1yN13gAT42AxgaSk3joBWzlEzLo7SXK53zBTWVyM2SAyBDzHWXEerJg==
dependencies:
"@types/react" ">=16"
"@types/react-dom" ">=16"
Expand Down