-
Notifications
You must be signed in to change notification settings - Fork 632
Fetch versioned references from repos #12987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
const SDK_REFERENCES_FOLDER_PATHS = [ | ||
{ | ||
id: 'posthog-python', | ||
repo: 'gewenyu99/posthog-python', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update these to point to real SDK repo folders once I merge changes in the SDK repos
SDK Version: {fullReference.info.version} | ||
SDK Version: | ||
</p> | ||
<Popover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always appreciate help from design and website with UI :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versions 🎉
gatsby/createPages.ts
Outdated
description: node.info.description, | ||
fullReference: node, | ||
regex: `/docs/references/${node.referenceId}`, | ||
types: sdkTypesByReference[node.referenceId][node.version], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null check on sdkTypesByReference[node.referenceId]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
gatsby/sourceNodes.ts
Outdated
// Fetch all folder contents in parallel | ||
const folderPromises = SDK_REFERENCES_FOLDER_PATHS.map(async (folderPath) => { | ||
const url = `https://api.github.com/repos/${folderPath.repo}/contents/${folderPath.folder_path}?ref=${folderPath.repo_branch}` | ||
const response = await fetch(url) | ||
const data = await response.json() | ||
return { folderPath, data } | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error handling if the api.github.com fetch fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Maybe we should block the build though, when the requests fail, we'll end up with silent 404 on some pages 🤔 These will be hard to catch quickly.
Maybe we do save a version of these locally that we fall back to if GitHub has an outage or something. Like: attempt to fetch files -> attempt to save as filename+commit hash.json -> read from local files.
@smallbrownbike thoughts on what makes sense?
.filter((item) => item.type === 'file') | ||
.map(async (item) => { | ||
const fileUrl = `https://api.github.com/repos/${folderPath.repo}/contents/${folderPath.folder_path}/${item.name}?ref=${folderPath.repo_branch}` | ||
const fileResponse = await fetch(fileUrl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add error handling if the api.github.com fetch fails?
{ | ||
resolve: `gatsby-source-filesystem`, | ||
options: { | ||
name: `sdkReferences`, | ||
path: `${__dirname}/src/data/sdkReferences`, | ||
ignore: [`**/*.{png,jpg,jpeg,gif,svg,webp,mp4,avi,mov}`], | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is replaced by sourceNodes yea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Changes
We want automatically updated, versioned, and persisted references for all SDKs.⚠️ We won't merge this until we land the PRs on the SDK repos
See related RFC
This PR does the following:
<sdk-id>-<sdk-version>
whereposthog-python
will be the latest version,posthog-python-6.0.0
will be a specific versiongatsby/sourceNodes.ts
during build.Separately in other PRs:
Screen.Recording.2025-09-30.at.4.52.44.PM.mov