:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { useActions, useValues } from 'kea'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { IconOpenInNew } from 'lib/lemon-ui/icons'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { addProductIntentForCrossSell } from 'lib/utils/product-intents'
import { WebQuery } from 'scenes/web-analytics/tiles/WebAnalyticsTile'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
import { ProductTab } from './common'
import { webAnalyticsDateMapping } from './constants'
import { getNewInsightUrlForQuery } from './insightsUtils'
import { WebAnalyticsExport } from './WebAnalyticsExport'
import { webAnalyticsLogic } from './webAnalyticsLogic'
import { webAnalyticsModalLogic } from './webAnalyticsModalLogic'
import { WebPropertyFilters } from './WebPropertyFilters'
export const WebAnalyticsModal = (): JSX.Element | null => {
const {
dateFilter: { dateFrom, dateTo },
productTab,
} = useValues(webAnalyticsLogic)
const { modal } = useValues(webAnalyticsModalLogic)
const { setDates } = useActions(webAnalyticsLogic)
const { closeModal } = useActions(webAnalyticsModalLogic)
if (!modal) {
return null
}
return (
<LemonModal
isOpen={!!modal}
onClose={closeModal}
simple={false}
title={modal?.title || ''}
width={1600}
fullScreen={false}
closable={true}
>
<div className="WebAnalyticsModal deprecated-space-y-4">
<div className="flex flex-row flex-wrap gap-2">
{productTab !== ProductTab.MARKETING && <WebPropertyFilters />}
<DateFilter
dateFrom={dateFrom}
dateTo={dateTo}
onChange={setDates}
dateOptions={webAnalyticsDateMapping}
/>
<div className="ml-auto">
<WebAnalyticsExport query={modal.query} insightProps={modal.insightProps} />
</div>
</div>
<LemonModal.Content embedded>
<WebQuery
attachTo={webAnalyticsLogic}
uniqueKey="WebAnalyticsModal.Query"
query={modal.query}
insightProps={modal.insightProps}
showIntervalSelect={modal.showIntervalSelect}
control={modal.control}
tileId={modal.tileId}
enablePagination
/>
</LemonModal.Content>
<div className="flex flex-row justify-end">
{modal.canOpenInsight ? (
<LemonButton
to={getNewInsightUrlForQuery(modal.query)}
icon={<IconOpenInNew />}
size="small"
type="secondary"
onClick={() => {
void addProductIntentForCrossSell({
from: ProductKey.WEB_ANALYTICS,
to: ProductKey.PRODUCT_ANALYTICS,
intent_context: ProductIntentContext.WEB_ANALYTICS_INSIGHT,
})
}}
>
Open as new insight
</LemonButton>
) : null}
</div>
</div>
</LemonModal>
)
}