Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release #913

Merged
merged 26 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
36f2b47
fix(staking): add sort numbers
hadzhehsen Jul 19, 2024
361012a
fix: resolve requested changes
hadzhehsen Jul 22, 2024
97a1948
chore(app): clean readme
hadzhehsen Jul 26, 2024
914f11c
fix(utils): add trim to sortValidatorsByName method
hadzhehsen Jul 26, 2024
c43857a
fix(staking): correct sort arrow direction
hadzhehsen Jul 26, 2024
90e0238
fix(staking): 'asc' & 'desc' by numbers
hadzhehsen Jul 26, 2024
4be86d1
fix(staking): sort by name & status
hadzhehsen Jul 26, 2024
a1f079f
fix(staking): get rid off IIFE
hadzhehsen Jul 29, 2024
8adac74
Revert "fix(staking): 'asc' & 'desc' by numbers"
hadzhehsen Jul 30, 2024
3a0e669
Revert "fix(staking): sort by name & status"
hadzhehsen Jul 30, 2024
3d3bfb3
Revert "fix(staking): get rid off IIFE"
hadzhehsen Jul 30, 2024
8e304a8
fix(staking): correct sort methods
hadzhehsen Jul 30, 2024
5d0a884
chore(deps): bump deps
olegshilov Jul 31, 2024
226b6f1
feat(shared): add `useLiquidTokens` hook
olegshilov Jul 31, 2024
52a5d55
feat(dao): add dao page with liquid balance and transfer ownership form
olegshilov Jul 31, 2024
f8957d6
chore(shell): add loader
olegshilov Jul 31, 2024
fb1d5f2
chore: fix husky git hooks scripts
olegshilov Jul 31, 2024
1b9ce16
fix(dao): add tx hashes to success toast and invalidate queries after…
olegshilov Jul 31, 2024
60befeb
chore: reinit husky hooks
olegshilov Jul 31, 2024
2bcc123
fix(shell): add priority attr to paralax image
olegshilov Aug 2, 2024
79ff515
feat(dao): implement fund and transfer for uc dao
olegshilov Aug 4, 2024
94016f6
chore: review fixes
olegshilov Aug 4, 2024
4edfa3e
chore(deps): upgrade nx
olegshilov Aug 23, 2024
7b9e7b7
chore(deps): upgrade deps
olegshilov Aug 23, 2024
71c3c6b
feat(vesting): add posthog, identify wallet users, track pageviews
olegshilov Aug 23, 2024
6529dfc
chore(shell): add log about identified wallet user, track pageleave w…
olegshilov Aug 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec commitlint --edit $1
3 changes: 0 additions & 3 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec lint-staged
3 changes: 0 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec nx affected:lint --base=dev
pnpm exec nx affected:test --base=dev
# pnpm exec nx affected:e2e
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

## Applications and websites

| Description | Domain | Source code |
| ------------------- | ---------------------------- | ---------------------------- |
| Shell app | https://shell.haqq.network | [Open](apps/shell) |
| Vesting app | https://vesting.haqq.network | [Open](apps/vesting) |
| HAQQ Website | https://haqq.hetwork | [Open](apps/haqq-website) |
| IslamicCoin Website | https://islamiccoin.net | [Open](apps/islamic-website) |
| Description | Domain | Source code |
| ----------- | ---------------------------- | -------------------- |
| Shell app | https://shell.haqq.network | [Open](apps/shell) |
| Vesting app | https://vesting.haqq.network | [Open](apps/vesting) |

## Development guide

Expand Down
46 changes: 46 additions & 0 deletions apps/shell/src/app/dao/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
dehydrate,
HydrationBoundary,
QueryClient,
} from '@tanstack/react-query';
import { headers } from 'next/headers';
import { haqqMainnet } from 'wagmi/chains';
import { createCosmosService, getChainParams } from '@haqq/data-access-cosmos';
import { DaoPage } from '@haqq/shell-dao';
import {
ethToHaqq,
indexerBalancesFetcher,
parseWagmiCookies,
} from '@haqq/shell-shared';

export default async function Authz() {
const cookies = headers().get('cookie');
const { chainId, walletAddress } = parseWagmiCookies(cookies);
const chainIdToUse = chainId ?? haqqMainnet.id;
const queryClient = new QueryClient();
const { cosmosRestEndpoint } = getChainParams(chainIdToUse);
const { getErc20TokenPairs } = createCosmosService(cosmosRestEndpoint);

if (walletAddress) {
const haqqAddress = ethToHaqq(walletAddress);

await queryClient.prefetchQuery({
queryKey: [chainIdToUse, 'indexer-balance', haqqAddress],
queryFn: async () => {
return await indexerBalancesFetcher(chainIdToUse, haqqAddress);
},
});

await queryClient.prefetchQuery({
queryKey: [chainIdToUse, 'token-pairs'],
queryFn: getErc20TokenPairs,
});
}
const dehydratedState = dehydrate(queryClient);

return (
<HydrationBoundary state={dehydratedState}>
<DaoPage />
</HydrationBoundary>
);
}
File renamed without changes.
1 change: 1 addition & 0 deletions apps/shell/src/components/paralax-background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function ParalaxBackground() {
setLoaded(true);
}}
className="scale-[1.5] md:scale-[1]"
priority
/>
</animated.div>
</animated.div>
Expand Down
1 change: 1 addition & 0 deletions apps/shell/src/components/posthog-identify-users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function PostHogIdentifyWalletUsers() {
useEffect(() => {
if (isHaqqWallet) {
const walletDistinctId = window.__HAQQWALLET__?.POSTHOG_DISTINCT_ID;
console.log('PostHogIdentifyWalletUsers', { walletDistinctId });
posthog.identify(walletDistinctId ?? posthog.get_distinct_id());
}
}, [isHaqqWallet]);
Expand Down
40 changes: 12 additions & 28 deletions apps/shell/src/components/posthog-page-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,21 @@ export function PostHogPageView() {
const posthog = usePostHog();

useEffect(() => {
const trackPageView = () => {
if (pathname && posthog) {
let url = window.origin + pathname;
if (searchParams.toString()) {
url += `?${searchParams.toString()}`;
}
posthog.capture('$pageview', {
$current_url: url,
$set: {
$browser_language: window.navigator.language,
},
});
}
};

const trackPageLeave = () => {
if (posthog) {
posthog.capture('$pageleave', {});
}
};

// Track pageviews
trackPageView();
if (pathname && posthog) {
let url = window.origin + pathname;

// Add event listener to track page leave
window.addEventListener('beforeunload', trackPageLeave);
if (searchParams.toString()) {
url = url + `?${searchParams.toString()}`;
}

// Cleanup the event listener when the component unmounts
return () => {
window.removeEventListener('beforeunload', trackPageLeave);
};
posthog.capture('$pageview', {
$current_url: url,
$set: {
$browser_language: window.navigator.language,
},
});
}
}, [pathname, searchParams, posthog]);

return null;
Expand Down
1 change: 1 addition & 0 deletions apps/shell/src/config/header-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const headerLinks: {
chains: number[];
}[] = [
// { href: '/', label: 'Home', chains: [haqqMainnet.id, haqqTestedge2.id] },
{ href: '/dao', label: 'DAO', chains: [haqqMainnet.id, haqqTestedge2.id] },
{
href: '/staking',
label: 'Staking',
Expand Down
2 changes: 1 addition & 1 deletion apps/shell/src/providers/posthog-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function PHProvider({ children }: PropsWithChildren) {
api_host: '/api/ingest',
ui_host: env.NEXT_PUBLIC_POSTHOG_HOST,
capture_pageview: false,
capture_pageleave: false,
capture_pageleave: true,
persistence: 'localStorage+cookie',
});

Expand Down
7 changes: 7 additions & 0 deletions apps/vesting/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { Navigate, Route, Routes } from 'react-router-dom';
import { Footer } from '../components/footer';
import { Header } from '../components/header';
import { Page } from '../components/Layout/Layout';
import {
usePosthogIdentifyWalletUsers,
usePosthogPageTracking,
} from '../hooks/posthog-track-hooks';
import { NotFoundPage } from '../pages/not-found-page';
import { PendingPage } from '../pages/pending-page';

Expand All @@ -20,6 +24,9 @@ const SwitchChainPage = lazy(() => {
});

export function App() {
usePosthogPageTracking();
usePosthogIdentifyWalletUsers();

return (
<Page header={<Header />} footer={<Footer />}>
<Suspense fallback={<PendingPage />}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export function LiquidVestingHooked({
<ToastLoading>Redeem liquid token in progress</ToastLoading>
),
success: (tx) => {
console.log('Convert to liquid successful', { tx });
console.log('Redeem successful', { tx });
const txHash = tx?.txhash;

return (
Expand Down
38 changes: 38 additions & 0 deletions apps/vesting/src/components/wallet-modals.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { lazy } from 'react';
import { useWallet } from '@haqq/shell-shared';

const SelectWalletModal = lazy(async () => {
const { SelectWalletModal } = await import(
'../components/select-wallet-modal'
);
return { default: SelectWalletModal };
});

export function WalletModals() {
const {
connectors,
connect,
availableConnectors,
closeSelectWallet,
connectError,
setConnectError,
isSelectWalletOpen,
} = useWallet();

return (
<SelectWalletModal
connectors={connectors}
onConnectClick={async (connectorId: number) => {
try {
await connect({ connector: availableConnectors[connectorId] });
closeSelectWallet();
} catch (error: unknown) {
setConnectError((error as Error).message);
}
}}
isOpen={isSelectWalletOpen}
onClose={closeSelectWallet}
error={connectError ?? ''}
/>
);
}
2 changes: 2 additions & 0 deletions apps/vesting/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const INDEXER_ENDPOINT = 'https://jsonrpc.indexer.haqq.network';
export const WALLETCONNECT_PROJECT_ID = process.env['WALLETCONNECT_PROJECT_ID'];
export const GIT_COMMIT_SHA = process.env['GIT_COMMIT_SHA'];
export const POSTHOG_KEY = process.env['POSTHOG_KEY'];
export const POSTHOG_HOST = process.env['POSTHOG_HOST'];
49 changes: 49 additions & 0 deletions apps/vesting/src/hooks/posthog-track-hooks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { useEffect } from 'react';
import { nanoid } from 'nanoid';
import { usePostHog } from 'posthog-js/react';
import { useLocation } from 'react-router-dom';
import { useWallet } from '@haqq/shell-shared';

declare const window: Window &
typeof globalThis & {
__HAQQWALLET__?: {
POSTHOG_DISTINCT_ID?: string;
};
};

export function usePosthogIdentifyWalletUsers() {
const { isHaqqWallet } = useWallet();
const posthog = usePostHog();

useEffect(() => {
if (isHaqqWallet) {
const walletDistinctId = window.__HAQQWALLET__?.POSTHOG_DISTINCT_ID;
console.log('usePosthogIdentifyWalletUsers', { walletDistinctId });

posthog.identify(
walletDistinctId ?? posthog.get_distinct_id() ?? nanoid(),
);
}
}, [isHaqqWallet, posthog]);
}

export function usePosthogPageTracking() {
const location = useLocation();
const posthog = usePostHog();

useEffect(() => {
posthog.capture('$pageview');
}, [location, posthog]);

useEffect(() => {
const handlePageLeave = () => {
posthog.capture('pageleave', { path: location.pathname });
};

window.addEventListener('beforeunload', handlePageLeave);

return () => {
window.removeEventListener('beforeunload', handlePageLeave);
};
}, [location, posthog]);
}
81 changes: 30 additions & 51 deletions apps/vesting/src/providers/app-providers.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { lazy, PropsWithChildren } from 'react';
import { PropsWithChildren } from 'react';
import { PostHogProvider } from 'posthog-js/react';
import { BrowserRouter } from 'react-router-dom';
import { createConfig, http, WagmiProvider } from 'wagmi';
import { haqqMainnet } from 'wagmi/chains';
Expand All @@ -7,10 +8,14 @@ import {
CosmosProvider,
ReactQueryProvider,
Toaster,
useWallet,
WalletProvider,
} from '@haqq/shell-shared';
import { WALLETCONNECT_PROJECT_ID } from '../constants';
import { WalletModals } from '../components/wallet-modals';
import {
WALLETCONNECT_PROJECT_ID,
POSTHOG_HOST,
POSTHOG_KEY,
} from '../constants';

export const wagmiConfig = createConfig({
chains: [haqqMainnet],
Expand All @@ -33,54 +38,28 @@ export const wagmiConfig = createConfig({

export function AppProviders({ children }: PropsWithChildren) {
return (
<BrowserRouter>
<WagmiProvider config={wagmiConfig}>
<ReactQueryProvider>
<CosmosProvider>
<WalletProvider>
{children}
<Toaster />
<WalletModals />
</WalletProvider>
</CosmosProvider>
</ReactQueryProvider>
</WagmiProvider>
</BrowserRouter>
);
}

const SelectWalletModal = lazy(async () => {
const { SelectWalletModal } = await import(
'../components/select-wallet-modal'
);
return { default: SelectWalletModal };
});

function WalletModals() {
const {
connectors,
connect,
availableConnectors,
closeSelectWallet,
connectError,
setConnectError,
isSelectWalletOpen,
} = useWallet();

return (
<SelectWalletModal
connectors={connectors}
onConnectClick={async (connectorId: number) => {
try {
await connect({ connector: availableConnectors[connectorId] });
closeSelectWallet();
} catch (error: unknown) {
setConnectError((error as Error).message);
}
<PostHogProvider
apiKey={POSTHOG_KEY}
options={{
api_host: POSTHOG_HOST,
capture_pageview: false,
capture_pageleave: true,
persistence: 'localStorage+cookie',
}}
isOpen={isSelectWalletOpen}
onClose={closeSelectWallet}
error={connectError ?? ''}
/>
>
<BrowserRouter>
<WagmiProvider config={wagmiConfig}>
<ReactQueryProvider>
<CosmosProvider>
<WalletProvider>
{children}
<Toaster />
<WalletModals />
</WalletProvider>
</CosmosProvider>
</ReactQueryProvider>
</WagmiProvider>
</BrowserRouter>
</PostHogProvider>
);
}
Loading
Loading