diff --git a/.github/workflows/sync-search-indices.yml b/.github/workflows/sync-search-indices.yml index 721ec557f7..add8682215 100644 --- a/.github/workflows/sync-search-indices.yml +++ b/.github/workflows/sync-search-indices.yml @@ -51,7 +51,6 @@ jobs: - name: Update search indexes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # TODO remove version and language after first successful run to test run: npm run sync-search - name: Update private docs repository search indexes @@ -65,8 +64,6 @@ jobs: git config user.name "GitHub Actions" echo 'git config user.email action@github.com' git config user.email action@github.com - echo 'git config pull.ff only' - git config pull.ff only echo 'git commit -am "update search indexes"' git commit -am "update search indexes" echo 'git lfs push --all origin' @@ -85,12 +82,6 @@ jobs: git remote add public-docs-repo https://github.com/github/docs.git echo 'git lfs push --all public-docs-repo' git lfs push --all public-docs-repo - # echo 'git fetch public-docs-repo' - # git fetch public-docs-repo - # echo 'git push public-docs-repo main --force --no-verify' - # git push public-docs-repo main --force --no-verify - # echo "Removing public-docs-repo remote" - # git remote rm public-docs-repo - name: Send slack notification if workflow run fails uses: someimportantcompany/github-actions-slack-message@0b470c14b39da4260ed9e3f9a4f1298a74ccdefd diff --git a/.github/workflows/sync-single-english-index.yml b/.github/workflows/sync-single-english-index.yml index 2e92a08552..1718353a05 100644 --- a/.github/workflows/sync-single-english-index.yml +++ b/.github/workflows/sync-single-english-index.yml @@ -25,13 +25,16 @@ jobs: steps: - name: checkout uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f + - name: Setup Node uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f with: node-version: 16.x cache: npm + - name: Install dependencies run: npm ci + - name: Get version from search label if present; only continue if the label is found. id: getVersion run: $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-search-label.js @@ -44,11 +47,19 @@ jobs: run: | npm run build npm run sync-search + echo 'git config user.name "GitHub Actions"' + git config user.name "GitHub Actions" + echo 'git config user.email action@github.com' + git config user.email action@github.com + echo 'git lfs push --all origin' + git lfs push --all origin + - name: Check in search index uses: EndBug/add-and-commit@2bdc0a61a03738a1d1bda24d566ad0dbe3083d87 with: # The arguments for the `git add` command add: 'lib/search/indexes' - # The message for the commit message: 'Updated search index for ${{ steps.getVersion.outputs.versionToSync }}' + author_name: 'GitHub Actions' + author_email: 'action@github.com' diff --git a/components/lib/display-platform-specific-content.ts b/components/lib/display-platform-specific-content.ts index c59affdc73..18918e5eff 100644 --- a/components/lib/display-platform-specific-content.ts +++ b/components/lib/display-platform-specific-content.ts @@ -1,4 +1,7 @@ +import Cookies from 'js-cookie' import parseUserAgent from './user-agent' +import { sendEvent, EventType } from './events' + const supportedPlatforms = ['mac', 'windows', 'linux'] const detectedPlatforms = new Set() @@ -35,6 +38,18 @@ export default function displayPlatformSpecificContent() { const target = event.target as HTMLElement setActiveSwitcherLinks(target.dataset.platform || '') showPlatformSpecificContent(target.dataset.platform || '') + + Cookies.set('osPreferred', target.dataset.platform || '', { + sameSite: 'strict', + secure: true, + }) + + // Send event data + sendEvent({ + type: EventType.preference, + preference_name: 'os', + preference_value: target.dataset.platform, + }) }) }) } @@ -108,6 +123,8 @@ function detectPlatforms(el: HTMLElement) { } function getDefaultPlatform() { + if (Cookies.get('osPreferred')) return Cookies.get('osPreferred') + const el = document.querySelector('[data-default-platform]') as HTMLElement if (el) return el.dataset.defaultPlatform } diff --git a/components/lib/events.ts b/components/lib/events.ts index 620e6125bb..ccdc0045c4 100644 --- a/components/lib/events.ts +++ b/components/lib/events.ts @@ -100,6 +100,7 @@ export function sendEvent({ type, version = '1.0.0', ...props }: SendEventProps) // Preference information application_preference: Cookies.get('toolPreferred'), color_mode_preference: getColorModePreference(), + os_preference: Cookies.get('osPreferred'), }, ...props, diff --git a/lib/schema-event.js b/lib/schema-event.js index 8abd02bd09..498b1c8c71 100644 --- a/lib/schema-event.js +++ b/lib/schema-event.js @@ -107,10 +107,11 @@ const context = { }, // Preference information - /* os_preference: { + os_preference: { type: 'string', - description: 'The os for examples selected by the user.' - }, */ + enum: ['linux', 'mac', 'windows'], + description: 'The os for examples selected by the user.', + }, application_preference: { type: 'string', enum: ['webui', 'cli', 'desktop', 'curl'], @@ -360,13 +361,26 @@ const preferenceSchema = { }, preference_name: { type: 'string', - enum: ['application', 'color_mode'], // os + enum: ['application', 'color_mode', 'os'], description: 'The preference name, such as os, application, or color_mode', }, preference_value: { type: 'string', - enum: ['webui', 'cli', 'desktop', 'curl', 'dark', 'light', 'auto', 'auto:dark', 'auto:light'], - description: 'The application or color_mode selected by the user.', + enum: [ + 'webui', + 'cli', + 'desktop', + 'curl', + 'dark', + 'light', + 'auto', + 'auto:dark', + 'auto:light', + 'linux', + 'mac', + 'windows', + ], + description: 'The application, color_mode, or os selected by the user.', }, }, }