Skip to content

Commit 2f68f6a

Browse files
docs-botCopilotsarahsheiskr
authored
Add docsTeamMetrics frontmatter and plumb through to analytics events (#60662)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Sarah Schneider <sarahs@github.com> Co-authored-by: Sarah Schneider <sarahs@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
1 parent 4bf1472 commit 2f68f6a

File tree

6 files changed

+13
-0
lines changed

6 files changed

+13
-0
lines changed

src/events/components/events.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export function sendEvent<T extends EventType>({
120120
page_document_type: getMetaContent('page-document-type'),
121121
page_type: getMetaContent('page-type'),
122122
content_type: getMetaContent('page-content-type'),
123+
docs_team_metrics: getMetaContent('docs-team-metrics') || undefined,
123124
status: Number(getMetaContent('status') || 0),
124125
is_logged_in: isLoggedIn(),
125126
octo_client_id: getOctoClientId(),

src/events/lib/schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ const context = {
106106
description: 'Optional content type from the content frontmatter (EDI content models).',
107107
enum: contentTypesEnum,
108108
},
109+
docs_team_metrics: {
110+
type: 'string',
111+
description:
112+
'Optional comma-separated list of docsTeamMetrics frontmatter values for internal analytics filtering.',
113+
},
109114
status: {
110115
type: 'number',
111116
description: 'The HTTP response status code of the main page HTML.',

src/events/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type EventProps = {
3737
page_document_type: string
3838
page_type: string
3939
content_type: string
40+
docs_team_metrics?: string
4041
status: number
4142
is_logged_in: boolean
4243
dotcom_user: string

src/frame/components/DefaultLayout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ export const DefaultLayout = (props: Props) => {
162162
)}
163163
{page.contentType && <meta name="page-content-type" content={page.contentType} />}
164164
{page.documentType && <meta name="page-document-type" content={page.documentType} />}
165+
{page.docsTeamMetrics && page.docsTeamMetrics.length > 0 && (
166+
<meta name="docs-team-metrics" content={page.docsTeamMetrics.join(',')} />
167+
)}
165168
{status && <meta name="status" content={status.toString()} />}
166169

167170
{/* OpenGraph data */}

src/frame/components/context/MainContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export type MainContextT = {
125125
hidden: boolean
126126
noEarlyAccessBanner: boolean
127127
applicableVersions: string[]
128+
docsTeamMetrics?: string[]
128129
} | null
129130
relativePath?: string
130131
sidebarTree?: ProductTreeNode | null
@@ -227,6 +228,7 @@ export const getMainContext = async (req: any, res: any): Promise<MainContextT>
227228
applicableVersions: req.context.page?.permalinks.map((obj: any) => obj.pageVersion) || [],
228229
hidden: req.context.page.hidden || false,
229230
noEarlyAccessBanner: req.context.page.noEarlyAccessBanner || false,
231+
docsTeamMetrics: req.context.page.docsTeamMetrics || undefined,
230232
}) ||
231233
null
232234

src/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export type Page = {
345345
industry?: string[]
346346
sidebarLink?: SidebarLink
347347
contentType?: string
348+
docsTeamMetrics?: string[]
348349
children?: string[]
349350
}
350351

0 commit comments

Comments
 (0)