Skip to content

Commit

Permalink
Merge pull request #688 from haqq-network/dev
Browse files Browse the repository at this point in the history
release
  • Loading branch information
kioqq authored Feb 13, 2024
2 parents 30dafe9 + 4d92ebc commit 3f97a21
Show file tree
Hide file tree
Showing 18 changed files with 4,795 additions and 4,509 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ NX_VESTING_SENTRY_DSN=example_sentry_dsn

NX_WALLETCONNECT_PROJECT_ID=example_wallet_connect_project_id

HAQQ_STORYBLOK_ACCESS_TOKEN=example_storyblock_token
ISLAMIC_STORYBLOK_ACCESS_TOKEN=example_storyblock_token

GOOGLE_TAG_ID=example_ga_measurement_id

FALCONER_ENDPOINT=example_falconer_service_endpoint
TURNSTILE_SITEKEY=example_turnstile_sitekey
NX_AIRDROP_ENDPOINT=airdrop.local

INDEXER_ENDPOINT=indexer.local

NEXT_PUBLIC_POSTHOG_KEY=ph_project_api_key
NEXT_PUBLIC_POSTHOG_HOST=ph_instance_address
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ jobs:
runs-on: ubuntu-cpu16-ram64
needs: test-and-lint
env:
HAQQ_STORYBLOK_ACCESS_TOKEN: ${{ secrets.HAQQ_STORYBLOK_ACCESS_TOKEN }}
ISLAMIC_STORYBLOK_ACCESS_TOKEN: ${{ secrets.ISLAMIC_STORYBLOK_ACCESS_TOKEN }}
FALCONER_ENDPOINT: ${{ secrets.FALCONER_ENDPOINT }}
TURNSTILE_SITEKEY: ${{ secrets.TURNSTILE_SITEKEY }}
NX_AIRDROP_ENDPOINT: ${{ secrets.NX_AIRDROP_ENDPOINT }}
Expand Down
672 changes: 336 additions & 336 deletions .yarn/releases/yarn-4.0.2.cjs → .yarn/releases/yarn-4.1.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ npmScopes:

tsEnableAutoTypes: true

yarnPath: .yarn/releases/yarn-4.0.2.cjs
yarnPath: .yarn/releases/yarn-4.1.0.cjs
7 changes: 0 additions & 7 deletions apps/haqq-website/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@ export const DEPLOY_URL = process.env['VERCEL_URL']
: process.env['NEXT_PUBLIC_VERCEL_URL']
? `https://${process.env['NEXT_PUBLIC_VERCEL_URL']}`
: 'http://localhost:4200';
export const STORYBLOK_ACCESS_TOKEN =
process.env['HAQQ_STORYBLOK_ACCESS_TOKEN'];
export const VERCEL_ENV = process.env['VERCEL_ENV'];
export const REVALIDATE_TIME = 300;
export const FALCONER_ENDPOINT = process.env['FALCONER_ENDPOINT'];
export const TURNSTILE_SITEKEY = process.env['TURNSTILE_SITEKEY'];
export const NX_WALLETCONNECT_PROJECT_ID =
process.env['NX_WALLETCONNECT_PROJECT_ID'];
export const SITE_URL = 'https://haqq.network';

console.log({
VERCEL_URL: process.env['VERCEL_URL'],
NEXT_PUBLIC_VERCEL_URL: process.env['NEXT_PUBLIC_VERCEL_URL'],
});
33 changes: 14 additions & 19 deletions apps/haqq-website/utils/get-whitepaper.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
import { cache } from 'react';
import { getIslamicWhitepaperData } from '@haqq/data-access-falconer';
import { getHaqqWhitepaperData } from '@haqq/data-access-falconer';
import { REVALIDATE_TIME } from '../constants';

export const revalidate = REVALIDATE_TIME;

export const getWhitepaperContentFromFalconer = cache(
async (locale?: string) => {
try {
const data = await getIslamicWhitepaperData(
{
next: {
revalidate,
},
},
locale ?? 'en',
);
export const getWhitepaperContentFromFalconer = cache(async () => {
try {
const data = await getHaqqWhitepaperData({
next: {
revalidate,
},
});

return data;
} catch (error) {
console.error(error);
}
return data;
} catch (error) {
console.error(error);
}

return '';
},
);
return '';
});
122 changes: 62 additions & 60 deletions apps/islamic-website/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import { Footer } from '../../components/footer/footer';
import Header, { MobileHeader } from '../../components/header/header';
import { DEPLOY_URL, VERCEL_ENV } from '../../constants';
import { alexandriaFont, handjetFont, vcrFont } from '../../fonts';
import { PHProvider } from '../../providers/posthog';
import { SOCIAL_LINKS } from '../../social-links';
import { PostHogPageView } from '../../utils/posthog-page-view';
import 'swiper/css';
import 'swiper/css/navigation';
import '../../styles/global.css';
Expand Down Expand Up @@ -88,35 +90,34 @@ export default async function LocaleLayout({
vcrFont.variable,
)}
>
<body className="bg-islamic-bg-black font-alexandria flex min-h-screen flex-col text-white antialiased">
{isScamBannerShow && <ScamBanner />}

{isMobileUserAgent ? (
<MobileHeader
locale={locale}
isBannerVisible={isScamBannerShow}
isBuyButtonVisible={!isRestrictedByGeo}
/>
) : (
<Header
locale={locale}
isBannerVisible={isScamBannerShow}
isBuyButtonVisible={!isRestrictedByGeo}
/>
)}

<main className="flex-1">{children}</main>
<Footer socialLinks={SOCIAL_LINKS} />

{VERCEL_ENV === 'production' && (
<>
<Script
async={true}
defer={true}
id="fb-pixel"
data-cookiecategory="analytics"
dangerouslySetInnerHTML={{
__html: `
<PHProvider hostname={DEPLOY_URL}>
<body className="bg-islamic-bg-black font-alexandria flex min-h-screen flex-col text-white antialiased">
<PostHogPageView />
{isScamBannerShow && <ScamBanner />}
{isMobileUserAgent ? (
<MobileHeader
locale={locale}
isBannerVisible={isScamBannerShow}
isBuyButtonVisible={!isRestrictedByGeo}
/>
) : (
<Header
locale={locale}
isBannerVisible={isScamBannerShow}
isBuyButtonVisible={!isRestrictedByGeo}
/>
)}
<main className="flex-1">{children}</main>
<Footer socialLinks={SOCIAL_LINKS} />
{VERCEL_ENV === 'production' && (
<>
<Script
async={true}
defer={true}
id="fb-pixel"
data-cookiecategory="analytics"
dangerouslySetInnerHTML={{
__html: `
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
Expand All @@ -128,46 +129,47 @@ export default async function LocaleLayout({
fbq('init', '873030480371387');
fbq('track', 'PageView');
`,
}}
/>
<Script
async={true}
defer={true}
id="gtm"
data-cookiecategory="analytics"
dangerouslySetInnerHTML={{
__html: `
}}
/>
<Script
async={true}
defer={true}
id="gtm"
data-cookiecategory="analytics"
dangerouslySetInnerHTML={{
__html: `
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5H2ZFCN');
`,
}}
/>
<Script
async={true}
src="https://www.googletagmanager.com/gtag/js?id=G-5FLBNV5M30"
id="gtm-haqq"
data-cookiecategory="analytics"
/>
<Script
defer={true}
id="gtm-haqq-2"
data-cookiecategory="analytics"
dangerouslySetInnerHTML={{
__html: `
}}
/>
<Script
async={true}
src="https://www.googletagmanager.com/gtag/js?id=G-5FLBNV5M30"
id="gtm-haqq"
data-cookiecategory="analytics"
/>
<Script
defer={true}
id="gtm-haqq-2"
data-cookiecategory="analytics"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-5FLBNV5M30');
`,
}}
/>
}}
/>

<CookieConsentModal />
<Analytics mode="auto" />
<SpeedInsights />
</>
)}
</body>
<CookieConsentModal />
<Analytics mode="auto" />
<SpeedInsights />
</>
)}
</body>
</PHProvider>
</html>
</NextIntlClientProvider>
);
Expand Down
2 changes: 0 additions & 2 deletions apps/islamic-website/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export const DEPLOY_URL = process.env['VERCEL_URL']
: process.env['NEXT_PUBLIC_VERCEL_URL']
? `https://${process.env['NEXT_PUBLIC_VERCEL_URL']}`
: 'http://localhost:4200';
export const STORYBLOK_ACCESS_TOKEN =
process.env['ISLAMIC_STORYBLOK_ACCESS_TOKEN'];
export const VERCEL_ENV = process.env['VERCEL_ENV'];
export const REVALIDATE_TIME = 300;
export const FALCONER_ENDPOINT = process.env['FALCONER_ENDPOINT'];
Expand Down
22 changes: 13 additions & 9 deletions apps/islamic-website/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { composePlugins, withNx } = require('@nx/next');
const withNextIntl = require('next-intl/plugin')(
// This is the default (also the `src` folder is supported out of the box)
'./i18n.ts',
);
const withNextIntl = require('next-intl/plugin');

/**
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
compress: true,
swcMinify: true,
reactStrictMode: true,
nx: {
// Set this to true if you would like to use SVGR
// See: https://github.com/gregberge/svgr
Expand All @@ -37,12 +37,16 @@ const nextConfig = {
},
],
},
rewrites: async () => {
return [
{
source: '/api/ingest/:path*',
destination: 'https://eu.posthog.com/:path*',
},
];
},
};

const plugins = [
// Add more Next.js plugins to this list if needed.
withNx,
withNextIntl,
];
const plugins = [withNx, withNextIntl('./i18n.ts')];

module.exports = composePlugins(...plugins)(nextConfig);
21 changes: 21 additions & 0 deletions apps/islamic-website/providers/posthog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client';
import { PropsWithChildren } from 'react';
import posthog from 'posthog-js';
import { PostHogProvider } from 'posthog-js/react';

export function PHProvider({
children,
hostname,
}: PropsWithChildren<{ hostname: string }>) {
if (typeof window !== 'undefined') {
console.log('posthog-init', { hostname });

posthog.init(process.env['NEXT_PUBLIC_POSTHOG_KEY']!, {
api_host: new URL('/api/ingest', hostname).toString(),
ui_host: process.env['NEXT_PUBLIC_POSTHOG_HOST'],
capture_pageview: false,
});
}

return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
}
26 changes: 26 additions & 0 deletions apps/islamic-website/utils/posthog-page-view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use client';

import { useEffect } from 'react';
import { usePathname, useSearchParams } from 'next/navigation';
import { usePostHog } from 'posthog-js/react';

export function PostHogPageView() {
const pathname = usePathname();
const searchParams = useSearchParams();
const posthog = usePostHog();

// Track pageviews
useEffect(() => {
if (pathname && posthog) {
let url = window.origin + pathname;
if (searchParams.toString()) {
url = url + `?${searchParams.toString()}`;
}
posthog.capture('$pageview', {
$current_url: url,
});
}
}, [pathname, searchParams, posthog]);

return null;
}
2 changes: 1 addition & 1 deletion libs/data-access/falconer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@haqq/data-access-falconer",
"version": "0.0.1",
"dependencies": {
"@swc/helpers": "~0.5.2"
"@swc/helpers": "0.5.6"
},
"type": "module",
"main": "./src/index.js",
Expand Down
1 change: 1 addition & 0 deletions libs/data-access/falconer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './lib/haqq/get-haqq-partners';
export * from './lib/haqq/get-haqq-blog-posts';
export * from './lib/haqq/get-haqq-privacy-policy';
export * from './lib/haqq/get-haqq-price';
export * from './lib/haqq/get-haqq-whitepaper';
export * from './lib/islamic/get-islamic-members';
export * from './lib/islamic/get-islamic-whitepaper';
export * from './lib/islamic/get-islamic-news';
Expand Down
21 changes: 21 additions & 0 deletions libs/data-access/falconer/src/lib/haqq/get-haqq-whitepaper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { FALCONER_ENDPOINT } from '../../constants';
import { FalconerRequestInit } from '../../types';

export async function getHaqqWhitepaperData(
options: Partial<FalconerRequestInit>,
) {
const requestUrl = new URL('/haqq/wp', FALCONER_ENDPOINT);

const response = await fetch(requestUrl, {
method: 'GET',
...options,
});

if (!response.ok) {
throw new Error('Whitepaper fetch failed');
}

const responseJson = await response.json();

return responseJson.wp as string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function Alert({ children }: PropsWithChildren) {
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
fillRule="evenodd"
clipRule="evenodd"
d="M10.8577 4.37097C11.2 3.66922 11.7672 3.10208 12.4689 2.75977C14.2062 1.91229 16.3016 2.63366 17.1491 4.37097L25.0814 20.6322C25.3146 21.1101 25.4357 21.6349 25.4357 22.1667C25.4357 24.0997 23.8687 25.6667 21.9357 25.6667H6.07111C5.53934 25.6667 5.01456 25.5455 4.53662 25.3124C2.79931 24.4649 2.07794 22.3695 2.92542 20.6322L10.8577 4.37097ZM14.0034 11.6667C13.3591 11.6667 12.8368 12.189 12.8368 12.8334V16.3334C12.8368 16.9777 13.3591 17.5 14.0034 17.5C14.6477 17.5 15.1701 16.9777 15.1701 16.3334V12.8334C15.1701 12.189 14.6477 11.6667 14.0034 11.6667ZM12.8368 19.8334C12.8368 20.4777 13.3591 21 14.0034 21C14.6477 21 15.1701 20.4777 15.1701 19.8334C15.1701 19.189 14.6477 18.6667 14.0034 18.6667C13.3591 18.6667 12.8368 19.189 12.8368 19.8334ZM12.9548 5.39396C13.069 5.16005 13.258 4.971 13.4919 4.85689C14.071 4.5744 14.7695 4.81486 15.052 5.39396L22.9843 21.6552C23.062 21.8145 23.1024 21.9894 23.1024 22.1667C23.1024 22.811 22.5801 23.3334 21.9357 23.3334H6.0711C5.89385 23.3334 5.71892 23.293 5.55961 23.2153C4.9805 22.9328 4.74005 22.2343 5.02254 21.6552L12.9548 5.39396Z"
fill="currentColor"
/>
Expand Down
Loading

0 comments on commit 3f97a21

Please sign in to comment.