mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
fix(analytics-docs): Fix addind platforms properly to events
This commit is contained in:
@@ -5,7 +5,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
|
||||
import type { EventDef } from '@suite-common/analytics';
|
||||
|
||||
import { EventDoc, platforms } from '../src/types';
|
||||
import type { EventDoc } from '../src/types';
|
||||
import {
|
||||
AttributeTypesByEventName,
|
||||
extractAttributeTypesByEventName,
|
||||
@@ -24,6 +24,12 @@ const PACKAGES = [
|
||||
'@suite-native/analytics',
|
||||
] as const;
|
||||
|
||||
const PACKAGE_TO_PLATFORM: Record<(typeof PACKAGES)[number], string> = {
|
||||
'@suite-common/analytics': 'shared',
|
||||
'@suite/analytics': 'desktop',
|
||||
'@suite-native/analytics': 'mobile',
|
||||
};
|
||||
|
||||
const loadEventsFromPackage = async (
|
||||
packageName: string,
|
||||
): Promise<Array<EventDef<unknown, string>>> => {
|
||||
@@ -37,12 +43,16 @@ const loadEventsFromPackage = async (
|
||||
const loadAllEvents = async (): Promise<
|
||||
Array<EventDef<unknown, string> & { platform: string }>
|
||||
> => {
|
||||
const [shared, desktop, mobile] = await Promise.all(
|
||||
PACKAGES.map(name => loadEventsFromPackage(name)),
|
||||
);
|
||||
const lists = [shared, desktop, mobile];
|
||||
const results = await Promise.all(
|
||||
PACKAGES.map(async packageName => {
|
||||
const events = await loadEventsFromPackage(packageName);
|
||||
const platform = PACKAGE_TO_PLATFORM[packageName];
|
||||
|
||||
return lists.flatMap((list, i) => list.map(event => ({ ...event, platform: platforms[i] })));
|
||||
return events.map(event => ({ ...event, platform }));
|
||||
}),
|
||||
);
|
||||
|
||||
return results.flat();
|
||||
};
|
||||
|
||||
const getTsConfigPath = (): string => {
|
||||
|
||||
@@ -5,15 +5,16 @@ import styled from 'styled-components';
|
||||
|
||||
import type { SuiteThemeColors } from '@trezor/components';
|
||||
import {
|
||||
Banner,
|
||||
Box,
|
||||
Button,
|
||||
Column,
|
||||
H2,
|
||||
H3,
|
||||
IconButton,
|
||||
Paragraph,
|
||||
Row,
|
||||
Spinner,
|
||||
Text,
|
||||
Tooltip,
|
||||
useMediaQuery,
|
||||
variables,
|
||||
@@ -134,10 +135,27 @@ const AnalyticsContent = ({
|
||||
if (isAnalyticsDataLoading) return <Spinner size={20} />;
|
||||
if (!isAnalyticsDataGenerated) {
|
||||
return (
|
||||
<Paragraph typographyStyle="callout" intent="warning">
|
||||
analytics.json has not been generated. Run <code>yarn build-data</code> (or{' '}
|
||||
<code>yarn dev</code>) to generate it.
|
||||
</Paragraph>
|
||||
<Banner
|
||||
intent="warning"
|
||||
icon
|
||||
description={
|
||||
<>
|
||||
File{' '}
|
||||
<Text isMonospaced typographyStyle="inherit">
|
||||
analytics.json
|
||||
</Text>{' '}
|
||||
has not been generated. Run{' '}
|
||||
<Text isMonospaced typographyStyle="inherit">
|
||||
yarn build-data
|
||||
</Text>{' '}
|
||||
(or{' '}
|
||||
<Text isMonospaced typographyStyle="inherit">
|
||||
yarn dev
|
||||
</Text>
|
||||
) to generate it.
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,13 +78,13 @@ const Header = ({ event }: { event: EventDoc }) => {
|
||||
const dropdownItems = [
|
||||
{
|
||||
key: 'open-definition',
|
||||
label: 'Open definition in Github',
|
||||
label: 'Open definition on Github',
|
||||
icon: 'note' as const,
|
||||
onClick: () => window.open(getEventDefinitionUrl(event.name), '_blank'),
|
||||
},
|
||||
{
|
||||
key: 'find-usages',
|
||||
label: 'Find usages in Github',
|
||||
label: 'Find usages on Github',
|
||||
icon: 'magnifyingGlass' as const,
|
||||
onClick: () => window.open(getEventUsagesUrl(event.name), '_blank'),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user