Skip to content

Commit

Permalink
Merge pull request #302 from near/update_analytics
Browse files Browse the repository at this point in the history
chore: replace wombi with a link to search analytics dapps in BOS
  • Loading branch information
charleslavon authored Aug 2, 2023
2 parents 0dfd8e4 + e560da7 commit c0456a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 85 deletions.
93 changes: 10 additions & 83 deletions frontend/pages/project-analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,109 +1,36 @@
import type { Api } from '@pc/common/types/api';
import { iframeResizer } from 'iframe-resizer';
import Link from 'next/link';
import { useEffect, useRef } from 'react';

import { ButtonLink } from '@/components/lib/Button';
import { Container } from '@/components/lib/Container';
import { FeatherIcon } from '@/components/lib/FeatherIcon';
import { Flex } from '@/components/lib/Flex';
import { H1 } from '@/components/lib/Heading';
import { Section } from '@/components/lib/Section';
import { Spinner } from '@/components/lib/Spinner';
import { Text } from '@/components/lib/Text';
import { TextLink } from '@/components/lib/TextLink';
import { useContracts } from '@/hooks/contracts';
import { usePublicOrPrivateContracts } from '@/hooks/contracts';
import { useCurrentEnvironment } from '@/hooks/environments';
import { useDashboardLayout } from '@/hooks/layouts';
import { useSelectedProject } from '@/hooks/selected-project';
import { useTheme } from '@/hooks/theme';
import config from '@/utils/config';
import { StableId } from '@/utils/stable-ids';
import type { NextPageWithLayout } from '@/utils/types';

const ProjectAnalytics: NextPageWithLayout = () => {
const { project } = useSelectedProject();
const { environment } = useCurrentEnvironment();
const { contracts: privateContracts } = useContracts(project?.slug, environment?.subId);
const { contracts } = usePublicOrPrivateContracts(privateContracts);

if (!environment || !contracts) {
return <Spinner center />;
}

if (contracts.length === 0) {
return <NoContractsNotice />;
}

return (
<Section>
<AnalyticsIframe environment={environment} contracts={contracts} />
</Section>
);
};

type Environment = Api.Query.Output<'/projects/getEnvironments'>[number];
type Project = Api.Query.Output<'/projects/getContracts'>;

function AnalyticsIframe({ environment, contracts }: { environment: Environment; contracts: Project }) {
const { activeTheme } = useTheme();
const iframeId = 'analytics-iframe';
const initialized = useRef(false);

useEffect(() => {
if (!initialized.current) {
iframeResizer({}, `#${iframeId}`);
initialized.current = true;
}
}, []);

const themeParam = activeTheme === 'dark' ? '#theme=night' : '';
let contractParams = '';
contracts.forEach((contract) => {
contractParams += `&contract=${contract.address}`;
});
const iframeUrl = `${config.analyticsIframeUrl[environment.net]}?${contractParams}${themeParam}`;

return (
<iframe
id={iframeId}
src={iframeUrl}
frameBorder="0"
style={{
width: '1px',
minWidth: '100%',
}}
></iframe>
);
}

function NoContractsNotice() {
return (
<Section css={{ margin: 'auto', textAlign: 'center' }}>
<Container size="s">
<Flex stack gap="l" align="center">
<H1>Analytics</H1>

<Text>
Your selected project and environment doesn&apos;t have any saved contracts yet. Visit the{' '}
<Link href="/contracts" passHref>
<TextLink stableId={StableId.PROJECT_ANALYTICS_NO_CONTRACTS_LINK}>Contracts</TextLink>
</Link>{' '}
page to add a contract.
</Text>

<Link href="/contracts" passHref>
<ButtonLink stableId={StableId.PROJECT_ANALYTICS_NO_CONTRACTS_BUTTON_LINK}>
<FeatherIcon icon="zap" />
Contracts
Pagoda Console Analytics has been deprecated in favor of the ecosystem of apps in Near&lsquo;s Blockchain
Operating System <br />
<ButtonLink
stableId={StableId.PROJECT_ANALYTICS_NO_CONTRACTS_BUTTON_LINK}
href="https://near.org/near/widget/Search.IndexPage?term=analytics"
external
>
Search Analytics d.Apps
</ButtonLink>
</Link>
</Text>
</Flex>
</Container>
</Section>
);
}
};

ProjectAnalytics.getLayout = useDashboardLayout;

Expand Down
2 changes: 0 additions & 2 deletions frontend/tutorials/nfts/md/2-minting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ Input the contract's account name (the `$NFT_CONTRACT_ID`) and click the Add but
</li>
</ol>

You can also view these metrics in [the Developer Console Analytics screen](/project-analytics). Now we'll see how to verify these details through the CLI.

### Viewing the contract's metadata

Now that the contract has been initialized, you can call some of the functions you wrote earlier. More specifically, let's test out the function that returns the contract's metadata:
Expand Down

0 comments on commit c0456a0

Please sign in to comment.