Skip to content

feat: add header to installing extension with the build mode so we know where the installation is coming from #6478

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export async function handleAutoInstallExtensions({
netlifyToken: token,
slug: ext.slug,
hostSiteUrl: ext.hostSiteUrl,
extensionInstallationSource: mode,
})
}),
)
Expand Down
9 changes: 9 additions & 0 deletions packages/config/src/utils/extensions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { createRequire } from 'module'
import { EXTENSION_API_BASE_URL } from '../../integrations.js'
import { ModeOption } from '../../types/options.js'

const require = createRequire(import.meta.url)
const { version: configVersion } = require('@netlify/config/package.json')

export type InstallExtensionResult =
| {
Expand All @@ -18,12 +23,15 @@ export const installExtension = async ({
accountId,
slug,
hostSiteUrl,
extensionInstallationSource,
}: {
netlifyToken: string
accountId: string
slug: string
hostSiteUrl: string
extensionInstallationSource: ModeOption
}): Promise<InstallExtensionResult> => {
const userAgent = `Netlify Config (mode:${extensionInstallationSource}) / ${configVersion}`
const extensionOnInstallUrl = new URL('/.netlify/functions/handler/on-install', hostSiteUrl)
const installedResponse = await fetch(extensionOnInstallUrl, {
method: 'POST',
Expand All @@ -32,6 +40,7 @@ export const installExtension = async ({
}),
headers: {
'netlify-token': netlifyToken,
'User-Agent': userAgent,
},
})

Expand Down
Loading