Compare commits

...

2 Commits

Author SHA1 Message Date
Nicolas Dorseuil c49b3a8e90 fix typing 2025-06-18 12:27:58 +02:00
conico974 0004d0228d Refactor insights event props 2025-06-18 10:09:22 +02:00
25 changed files with 241 additions and 75 deletions
+3 -3
View File
@@ -12,7 +12,7 @@ import * as React from 'react';
import { t, useLanguage } from '@/intl/client';
import { type ClassValue, tcls } from '@/lib/tailwind';
import { useTrackEvent } from '../Insights';
import { toSlimTrackEvent, useTrackEvent } from '../Insights';
import { useHasBeenInViewport } from '../hooks/useHasBeenInViewport';
import { Link } from '../primitives';
import { renderAd } from './renderAd';
@@ -137,10 +137,10 @@ function AdSponsoredLink(props: { spaceId: string }) {
target="_blank"
href={viaUrl.toString()}
className={tcls('hover:underline')}
insights={{
insights={toSlimTrackEvent({
type: 'trademark_click',
placement: SiteInsightsTrademarkPlacement.Ad,
}}
})}
>
{t(language, 'sponsored_via_gitbook')}
</Link>
@@ -4,6 +4,7 @@ import { getResizedImageURL } from '@v2/lib/images';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { Link } from '../primitives';
import type { AdItem } from './types';
@@ -33,10 +34,10 @@ export async function AdClassicRendering({
target="_blank"
insights={
insightsAd
? {
? toSlimTrackEvent({
type: 'ad_click',
ad: insightsAd,
}
})
: undefined
}
className={tcls(
@@ -5,6 +5,7 @@ import { getResizedImageURL } from '@v2/lib/images';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { Link } from '../primitives';
import type { AdCover } from './types';
@@ -31,10 +32,10 @@ export async function AdCoverRendering({
target="_blank"
insights={
insightsAd
? {
? toSlimTrackEvent({
type: 'ad_click',
ad: insightsAd,
}
})
: undefined
}
className={tcls(
@@ -6,6 +6,7 @@ import type { ResolvedContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { type CustomizationAnnouncement, SiteInsightsLinkPosition } from '@gitbook/api';
import { Icon, type IconName } from '@gitbook/icons';
import { toSlimTrackEvent } from '../Insights';
import { CONTAINER_STYLE } from '../layout';
import { Link, linkStyles } from '../primitives';
import { ANNOUNCEMENT_CSS_CLASS, ANNOUNCEMENT_STORAGE_KEY } from './constants';
@@ -41,13 +42,13 @@ export function AnnouncementBanner(props: {
)}
insights={
announcement.link
? {
? toSlimTrackEvent({
type: 'link_click',
link: {
target: announcement.link.to,
position: SiteInsightsLinkPosition.Announcement,
},
}
})
: undefined
}
>
@@ -2,6 +2,7 @@ import { type DocumentBlockContentRef, SiteInsightsLinkPosition } from '@gitbook
import { Card } from '@/components/primitives';
import { type ResolvedContentRef, resolveContentRef } from '@/lib/references';
import { toSlimTrackEvent } from '../Insights';
import type { BlockProps } from './Block';
@@ -34,13 +35,13 @@ export async function BlockContentRef(props: BlockProps<DocumentBlockContentRef>
href={resolved.href}
title={resolved.text}
style={style}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: block.data.ref,
position: SiteInsightsLinkPosition.Content,
},
}}
})}
/>
);
}
@@ -4,6 +4,7 @@ import { getSimplifiedContentType } from '@/lib/files';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { Link } from '../primitives';
import type { BlockProps } from './Block';
import { Caption } from './Caption';
@@ -28,13 +29,13 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
<Link
href={file.downloadURL}
download={file.name}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: block.data.ref,
position: SiteInsightsLinkPosition.Content,
},
}}
})}
className={tcls('group/file', 'flex', 'flex-row', 'items-center', 'px-5', 'py-3')}
>
<div
@@ -1,5 +1,6 @@
import { resolveContentRef } from '@/lib/references';
import * as api from '@gitbook/api';
import { toSlimTrackEvent } from '../Insights';
import { Button } from '../primitives';
import type { InlineProps } from './Inline';
@@ -25,13 +26,13 @@ export async function InlineButton(props: InlineProps<api.DocumentInlineButton>)
// TODO: use a variant specifically for user-defined buttons.
variant={inline.data.kind}
className="leading-normal"
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: inline.data.ref,
position: api.SiteInsightsLinkPosition.Content,
},
}}
})}
/>
</span>
);
@@ -2,6 +2,7 @@ import { type DocumentInlineLink, SiteInsightsLinkPosition } from '@gitbook/api'
import { resolveContentRef } from '@/lib/references';
import { Icon } from '@gitbook/icons';
import { toSlimTrackEvent } from '../Insights';
import { StyledLink } from '../primitives';
import type { InlineProps } from './Inline';
import { InlineLinkTooltip } from './InlineLinkTooltip';
@@ -35,13 +36,13 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
<InlineLinkTooltip inline={inline} context={context.contentContext} resolved={resolved}>
<StyledLink
href={resolved.href}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: inline.data.ref,
position: SiteInsightsLinkPosition.Content,
},
}}
})}
>
<Inlines
context={context}
@@ -2,6 +2,7 @@ import { type DocumentInlineMention, SiteInsightsLinkPosition } from '@gitbook/a
import { StyledLink } from '@/components/primitives';
import { resolveContentRef } from '@/lib/references';
import { toSlimTrackEvent } from '../Insights';
import type { InlineProps } from './Inline';
@@ -21,13 +22,13 @@ export async function Mention(props: InlineProps<DocumentInlineMention>) {
return (
<StyledLink
href={resolved.href}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: inline.data.ref,
position: SiteInsightsLinkPosition.Content,
},
}}
})}
>
{resolved.text}
</StyledLink>
@@ -8,6 +8,7 @@ import { LinkBox, LinkOverlay } from '@/components/primitives';
import { Image } from '@/components/utils';
import { resolveContentRef } from '@/lib/references';
import { type ClassValue, tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../../Insights';
import { RecordColumnValue } from './RecordColumnValue';
import type { TableRecordKV, TableViewProps } from './Table';
@@ -174,13 +175,13 @@ export async function RecordCard(
<LinkBox href={target.href} className={tcls(style, 'hover:before:ring-tint-12/5')}>
<LinkOverlay
href={target.href}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: targetRef,
position: SiteInsightsLinkPosition.Content,
},
}}
})}
/>
{body}
</LinkBox>
@@ -15,6 +15,7 @@ import { getSimplifiedContentType } from '@/lib/files';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { filterOutNullable } from '@/lib/typescript';
import { toSlimTrackEvent } from '../../Insights';
import type { BlockProps } from '../Block';
import { Blocks } from '../Blocks';
@@ -172,7 +173,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
className="flex flex-row items-center gap-2"
insights={
ref.file
? {
? toSlimTrackEvent({
type: 'link_click',
link: {
target: {
@@ -181,7 +182,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
},
position: SiteInsightsLinkPosition.Content,
},
}
})
: undefined
}
>
@@ -235,13 +236,13 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
href={resolved.href}
insights={
contentRef
? {
? toSlimTrackEvent({
type: 'link_click',
link: {
target: contentRef,
position: SiteInsightsLinkPosition.Content,
},
}
})
: undefined
}
>
@@ -275,13 +276,13 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
<StyledLink
key={index}
href={resolved.href}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: contentRef,
position: SiteInsightsLinkPosition.Content,
},
}}
})}
>
{resolved.text}
</StyledLink>
@@ -7,6 +7,7 @@ import type { GitBookAnyContext } from '@v2/lib/context';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { Link } from '../primitives';
@@ -58,13 +59,13 @@ async function FooterLink(props: { link: CustomizationContentLink; context: GitB
'links-accent:decoration-primary-subtle',
'links-accent:decoration-[3px]'
)}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: link.to,
position: SiteInsightsLinkPosition.Footer,
},
}}
})}
>
{link.title}
</Link>
@@ -11,6 +11,7 @@ import assertNever from 'assert-never';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { Button, Link } from '../primitives';
import {
type DropdownButtonProps,
@@ -125,13 +126,13 @@ function HeaderItemButton(
),
}[linkStyle]
)}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: linkTarget,
position: SiteInsightsLinkPosition.Header,
},
}}
})}
label={title}
{...rest}
/>
@@ -169,13 +170,13 @@ function HeaderItemLink(props: Omit<HeaderLinkNavItemProps, 'linkStyle'>) {
<Link
href={href}
className={getHeaderLinkClassName({ headerPreset })}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: linkTarget,
position: SiteInsightsLinkPosition.Header,
},
}}
})}
{...rest}
>
{title}
@@ -217,13 +218,13 @@ async function SubHeaderLink(props: {
return (
<DropdownMenuItem
href={target.href}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: link.to,
position: SiteInsightsLinkPosition.Header,
},
}}
})}
>
{link.title}
</DropdownMenuItem>
@@ -10,6 +10,7 @@ import type React from 'react';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { DropdownChevron, DropdownMenu, DropdownMenuItem, DropdownSubMenu } from './DropdownMenu';
import styles from './headerLinks.module.css';
@@ -80,13 +81,13 @@ async function MoreMenuLink(props: {
href={target?.href ?? null}
insights={
link.to
? {
? toSlimTrackEvent({
type: 'link_click',
link: {
target: link.to,
position: SiteInsightsLinkPosition.Header,
},
}
})
: undefined
}
>
@@ -3,3 +3,4 @@ export * from './visitorId';
export * from './cookies';
export * from './TrackPageViewEvent';
export * from './useVisitedPages';
export * from './slimTrackEvent';
@@ -0,0 +1,160 @@
import type * as api from '@gitbook/api';
import type { InsightsEventName, TrackEventInput } from './InsightsProvider';
type SlimTrackEventName =
| 'pv' // page_view
| 'so' // search_open
| 'stq' // search_type_query
| 'sor' // search_open_result
| 'ppf' // page_post_feedback
| 'ppfc' // page_post_feedback_comment
| 'aq' // ask_question
| 'lc' // link_click
| 'aco' // api_client_open
| 'acr' // api_client_request
| 'tc' // trademark_click
| 'ac' // ad_click
| 'ad'; // ad_display
type BaseSlimTrackEvent<T extends SlimTrackEventName> = {
t: T; // type
};
export type SlimTrackEventInput<T extends SlimTrackEventName = SlimTrackEventName> = T extends 'pv'
? BaseSlimTrackEvent<'pv'>
: T extends 'so'
? BaseSlimTrackEvent<'so'>
: T extends 'stq'
? BaseSlimTrackEvent<'stq'> & { q: string }
: T extends 'sor'
? BaseSlimTrackEvent<'sor'> & { q: string; r: { s: string; p: string } }
: T extends 'ppf'
? BaseSlimTrackEvent<'ppf'> & { f: { r: api.PageFeedbackRating } }
: T extends 'ppfc'
? BaseSlimTrackEvent<'ppfc'> & { f: { r: api.PageFeedbackRating; c: string } }
: T extends 'aq'
? BaseSlimTrackEvent<'aq'> & { q: string }
: T extends 'lc'
? BaseSlimTrackEvent<'lc'> & {
l: { t: api.ContentRef; p: api.SiteInsightsLinkPosition };
}
: T extends 'aco'
? BaseSlimTrackEvent<'aco'> & { o: api.OpenAPIOperationPointer }
: T extends 'acr'
? BaseSlimTrackEvent<'acr'> & { o: api.OpenAPIOperationPointer }
: T extends 'tc'
? BaseSlimTrackEvent<'tc'> & { p: api.SiteInsightsTrademarkPlacement }
: T extends 'ac'
? BaseSlimTrackEvent<'ac'> & { a: api.SiteInsightsAd }
: T extends 'ad'
? BaseSlimTrackEvent<'ad'> & { a: api.SiteInsightsAd }
: never;
export function expandSlimTrackEvent<EventName extends SlimTrackEventName = SlimTrackEventName>(
input: SlimTrackEventInput<EventName>
) {
switch (input.t) {
case 'pv':
return { type: 'page_view' as const };
case 'so':
return { type: 'search_open' as const };
case 'stq':
return { type: 'search_type_query' as const, query: input.q };
case 'sor':
return {
type: 'search_open_result' as const,
query: input.q,
result: { spaceId: input.r.s, pageId: input.r.p },
};
case 'ppf':
return { type: 'page_post_feedback' as const, feedback: { rating: input.f.r } };
case 'ppfc':
return {
type: 'page_post_feedback_comment' as const,
feedback: { rating: input.f.r, comment: input.f.c },
};
case 'aq':
return { type: 'ask_question' as const, query: input.q };
case 'lc':
return {
type: 'link_click' as const,
link: { target: input.l.t, position: input.l.p },
};
case 'aco':
return { type: 'api_client_open' as const, operation: input.o };
case 'acr':
return { type: 'api_client_request' as const, operation: input.o };
case 'tc':
return { type: 'trademark_click' as const, placement: input.p };
case 'ac':
return { type: 'ad_click' as const, ad: input.a };
case 'ad':
return { type: 'ad_display' as const, ad: input.a };
default:
throw new Error('Unknown slim event');
}
}
export function toSlimTrackEvent<EventName extends InsightsEventName>(
event: TrackEventInput<EventName>
) {
switch (event.type) {
case 'page_view':
return { t: 'pv' as const };
case 'search_open':
return { t: 'so' as const };
case 'search_type_query': {
const _event = event as unknown as TrackEventInput<'search_type_query'>;
return { t: 'stq' as const, q: _event.query };
}
case 'search_open_result': {
const _event = event as unknown as TrackEventInput<'search_open_result'>;
return {
t: 'sor' as const,
q: _event.query,
r: { s: _event.result.spaceId, p: _event.result.pageId },
};
}
case 'page_post_feedback': {
const _event = event as unknown as TrackEventInput<'page_post_feedback'>;
return { t: 'ppf' as const, f: { r: _event.feedback.rating } };
}
case 'page_post_feedback_comment': {
const _event = event as unknown as TrackEventInput<'page_post_feedback_comment'>;
return {
t: 'ppfc' as const,
f: { r: _event.feedback.rating, c: _event.feedback.comment },
};
}
case 'ask_question': {
const _event = event as unknown as TrackEventInput<'ask_question'>;
return { t: 'aq' as const, q: _event.query };
}
case 'link_click': {
const _event = event as unknown as TrackEventInput<'link_click'>;
return { t: 'lc' as const, l: { t: _event.link.target, p: _event.link.position } };
}
case 'api_client_open': {
const _event = event as unknown as TrackEventInput<'api_client_open'>;
return { t: 'aco' as const, o: _event.operation };
}
case 'api_client_request': {
const _event = event as unknown as TrackEventInput<'api_client_request'>;
return { t: 'acr' as const, o: _event.operation };
}
case 'trademark_click': {
const _event = event as unknown as TrackEventInput<'trademark_click'>;
return { t: 'tc' as const, p: _event.placement };
}
case 'ad_click': {
const _event = event as unknown as TrackEventInput<'ad_click'>;
return { t: 'ac' as const, a: _event.ad };
}
case 'ad_display': {
const _event = event as unknown as TrackEventInput<'ad_display'>;
return { t: 'ad' as const, a: _event.ad };
}
default:
throw new Error('Unknown event type');
}
}
@@ -8,6 +8,7 @@ import type { GitBookAnyContext } from '@v2/lib/context';
import { Card } from '@/components/primitives';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { PageIcon } from '../PageIcon';
@@ -48,13 +49,13 @@ export async function PageBodyBlankslate(props: {
leadingIcon={icon}
title={child.title}
href={resolved.href}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: child.target,
position: SiteInsightsLinkPosition.Content,
},
}}
})}
/>
);
}
@@ -7,6 +7,7 @@ import { resolvePrevNextPages } from '@/lib/pages';
import { tcls } from '@/lib/tailwind';
import type { GitBookSiteContext } from '@v2/lib/context';
import { toSlimTrackEvent } from '../Insights';
import { Link, type LinkInsightsProps } from '../primitives';
/**
@@ -43,7 +44,7 @@ export async function PageFooterNavigation(props: {
label={t(language, 'previous_page')}
title={previous.title}
href={previousHref}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: {
@@ -52,7 +53,7 @@ export async function PageFooterNavigation(props: {
},
position: SiteInsightsLinkPosition.Content,
},
}}
})}
reversed
/>
) : null}
@@ -62,7 +63,7 @@ export async function PageFooterNavigation(props: {
label={t(language, 'next_page')}
title={next.title}
href={nextHref}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: {
@@ -71,7 +72,7 @@ export async function PageFooterNavigation(props: {
},
position: SiteInsightsLinkPosition.Content,
},
}}
})}
/>
) : null}
</div>
@@ -32,9 +32,7 @@ export function PageFeedbackForm(props: {
trackEvent({
type: 'page_post_feedback',
feedback: {
rating,
},
feedback: { rating },
});
};
@@ -43,10 +41,7 @@ export function PageFeedbackForm(props: {
trackEvent({
type: 'page_post_feedback_comment',
feedback: {
rating,
comment,
},
feedback: { rating, comment },
});
};
@@ -2,6 +2,7 @@ import { tcls } from '@/lib/tailwind';
import { Icon, type IconName } from '@gitbook/icons';
import React from 'react';
import { toSlimTrackEvent } from '../Insights';
import { Link } from '../primitives';
import { HighlightQuery } from './HighlightQuery';
import type { ComputedPageResult } from './server-actions';
@@ -45,14 +46,11 @@ export const SearchPageResultItem = React.forwardRef(function SearchPageResultIt
? ['is-active', 'bg-primary', 'text-contrast-primary', 'hover:bg-primary-hover']
: null
)}
insights={{
insights={toSlimTrackEvent({
type: 'search_open_result',
query,
result: {
pageId: item.pageId,
spaceId: item.spaceId,
},
}}
result: { pageId: item.pageId, spaceId: item.spaceId },
})}
>
<div className="size-4">
<Icon
@@ -3,6 +3,7 @@ import React from 'react';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { Link } from '../primitives';
import { HighlightQuery } from './HighlightQuery';
import type { ComputedSectionResult } from './server-actions';
@@ -40,14 +41,11 @@ export const SearchSectionResultItem = React.forwardRef(function SearchSectionRe
'hover:bg-primary-hover',
]
)}
insights={{
insights={toSlimTrackEvent({
type: 'search_open_result',
query,
result: {
pageId: item.pageId,
spaceId: item.spaceId,
},
}}
result: { pageId: item.pageId, spaceId: item.spaceId },
})}
>
<div
className={tcls(
@@ -7,6 +7,7 @@ import {
} from '@gitbook/api';
import type { GitBookSiteContext } from '@v2/lib/context';
import { toSlimTrackEvent } from '../Insights';
import { PagesList } from './PagesList';
import { TOCPageIcon } from './TOCPageIcon';
import { ToggleableLinkItem } from './ToggleableLinkItem';
@@ -28,7 +29,7 @@ export async function PageDocumentItem(props: {
<ToggleableLinkItem
href={href}
pathname={getPagePath(rootPages, page)}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: {
@@ -37,7 +38,7 @@ export async function PageDocumentItem(props: {
},
position: SiteInsightsLinkPosition.Sidebar,
},
}}
})}
descendants={
hasPageVisibleDescendant(page) ? (
<PagesList
@@ -6,6 +6,7 @@ import { Link } from '@/components/primitives';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { TOCPageIcon } from './TOCPageIcon';
export async function PageLinkItem(props: { page: RevisionPageLink; context: GitBookSiteContext }) {
@@ -36,13 +37,13 @@ export async function PageLinkItem(props: { page: RevisionPageLink; context: Git
'hover:bg-tint',
'hover:text-tint-strong'
)}
insights={{
insights={toSlimTrackEvent({
type: 'link_click',
link: {
target: page.target,
position: SiteInsightsLinkPosition.Sidebar,
},
}}
})}
>
<TOCPageIcon page={page} />
{page.title}
@@ -8,6 +8,7 @@ import { Icon } from '@gitbook/icons';
import { getSpaceLanguage, t } from '@/intl/server';
import { tcls } from '@/lib/tailwind';
import { toSlimTrackEvent } from '../Insights';
import { Link } from '../primitives';
/**
@@ -115,10 +116,10 @@ export function TrademarkLink(props: {
'transition-colors',
'pointer-events-auto'
)}
insights={{
insights={toSlimTrackEvent({
type: 'trademark_click',
placement,
}}
})}
>
<Icon
icon="gitbook"
@@ -4,7 +4,7 @@ import NextLink, { type LinkProps as NextLinkProps } from 'next/link';
import React from 'react';
import { tcls } from '@/lib/tailwind';
import { type TrackEventInput, useTrackEvent } from '../Insights';
import { type SlimTrackEventInput, expandSlimTrackEvent, useTrackEvent } from '../Insights';
// Props from Next, which includes NextLinkProps and all the things anchor elements support.
type BaseLinkProps = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NextLinkProps> &
@@ -14,11 +14,7 @@ type BaseLinkProps = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof N
export type LinkInsightsProps = {
/** Event to track when the link is clicked. */
insights?:
| TrackEventInput<'ad_click'>
| TrackEventInput<'link_click'>
| TrackEventInput<'trademark_click'>
| TrackEventInput<'search_open_result'>;
insights?: SlimTrackEventInput;
};
export type LinkProps = Omit<BaseLinkProps, 'href'> &
@@ -44,7 +40,7 @@ export const Link = React.forwardRef(function Link(
const onClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
if (insights) {
trackEvent(insights, undefined, {
trackEvent(expandSlimTrackEvent(insights), undefined, {
immediate: isExternal,
});
}