Skip to content

Conversation

gewenyu99
Copy link
Contributor

@gewenyu99 gewenyu99 commented Sep 30, 2025

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:

  • Add a selector for available SDK versions
  • Path format will be <sdk-id>-<sdk-version> where posthog-python will be the latest version, posthog-python-6.0.0 will be a specific version
  • Type definitions will also use pathing like above.
  • SDKs are fetched in gatsby/sourceNodes.ts during build.
  • SDKs are expected to be files from specific, fixed paths in SDK repos. See related RFC

Separately in other PRs:

  • Python SDK repo will generate new reference files on publish which we can fetch
  • JS SDK repo will generate new reference files on publish for node, js, and react native sdks.
Screen.Recording.2025-09-30.at.4.52.44.PM.mov

Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
posthog Ready Ready Preview Oct 3, 2025 8:14pm

const SDK_REFERENCES_FOLDER_PATHS = [
{
id: 'posthog-python',
repo: 'gewenyu99/posthog-python',
Copy link
Contributor Author

@gewenyu99 gewenyu99 Sep 30, 2025

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

@gewenyu99 gewenyu99 requested a review from a team September 30, 2025 20:44
@gewenyu99 gewenyu99 marked this pull request as ready for review September 30, 2025 20:44
@gewenyu99 gewenyu99 requested a review from a team September 30, 2025 20:45
SDK Version: {fullReference.info.version}
SDK Version:
</p>
<Popover
Copy link
Contributor Author

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 :)

Copy link
Member

@edwinyjlim edwinyjlim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versions 🎉

description: node.info.description,
fullReference: node,
regex: `/docs/references/${node.referenceId}`,
types: sdkTypesByReference[node.referenceId][node.version],
Copy link
Member

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]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

Comment on lines 113 to 119
// 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 }
})
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

Copy link
Contributor Author

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)
Copy link
Member

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?

Comment on lines -165 to -172
{
resolve: `gatsby-source-filesystem`,
options: {
name: `sdkReferences`,
path: `${__dirname}/src/data/sdkReferences`,
ignore: [`**/*.{png,jpg,jpeg,gif,svg,webp,mp4,avi,mov}`],
},
},
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants