Skip to content

Commit d1f4066

Browse files
authored
Merge pull request #31 from stellarcarbon/develop
Fix analytics build problem
2 parents 345b8e7 + c7dd76b commit d1f4066

File tree

7 files changed

+57
-19
lines changed

7 files changed

+57
-19
lines changed

next.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/** @type {import('next').NextConfig} */
22

3-
const { withPlausibleProxy } = require("next-plausible");
4-
53
let output = "export";
64
let trailingSlash = true;
75
if (process.env.NODE_ENV === "test") {
@@ -21,4 +19,4 @@ const nextConfig = {
2119
// reactStrictMode: false,
2220
};
2321

24-
module.exports = withPlausibleProxy(nextConfig);
22+
module.exports = nextConfig;

src/analyticsConfig.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { DetailedHTMLProps, ScriptHTMLAttributes } from "react";
2+
3+
type AnalyticsConfig = {
4+
plausibleDataDomain: string;
5+
plausibleProps: DetailedHTMLProps<
6+
ScriptHTMLAttributes<HTMLScriptElement>,
7+
HTMLScriptElement
8+
>;
9+
};
10+
11+
function buildAnalyticsConfig(): AnalyticsConfig {
12+
let pubnetDeployment = process.env.NEXT_PUBLIC_PRODUCTION === "pubnet";
13+
14+
let plausibleDataDomain = pubnetDeployment
15+
? "new.stellarcarbon.io"
16+
: "test.stellarcarbon.io";
17+
18+
let plausibleProps = {
19+
src:
20+
process.env.NODE_ENV === "development"
21+
? `https://${plausibleDataDomain}/sessionvar/js/script.js`
22+
: "/sessionvar/js/script.js",
23+
...({
24+
"data-api":
25+
process.env.NODE_ENV === "development"
26+
? `https://${plausibleDataDomain}/sessionvar/api/event`
27+
: "/sessionvar/api/event",
28+
} as any),
29+
};
30+
31+
return {
32+
plausibleDataDomain,
33+
plausibleProps,
34+
};
35+
}
36+
37+
const analyticsConfig = buildAnalyticsConfig();
38+
export default analyticsConfig;

src/app/App.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import NavBar from "@/containers/navbar/NavBar";
66
import DemoApp from "../containers/demo/DemoApp";
77
import { SinkingContextProvider } from "@/context/SinkingContext";
88
import appConfig from "@/config";
9-
import Script from "next/script";
10-
import PlausibleProvider from "next-plausible";
119

1210
export default function App({ children }: { children: React.ReactNode }) {
1311
if (appConfig.demo) {

src/app/layout.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import "@fortawesome/fontawesome-svg-core/styles.css";
1212
import { config } from "@fortawesome/fontawesome-svg-core";
1313
import { SinkFormContextProvider } from "@/context/SinkFormContext";
1414
import AnalyticsConsent from "@/components/AnalyticsConsent";
15-
import appConfig from "@/config";
15+
1616
import PlausibleProvider from "next-plausible";
17+
import analyticsConfig from "@/analyticsConfig";
1718

1819
config.autoAddCss = false; /* eslint-disable import/first */
1920

@@ -27,14 +28,21 @@ export default function RootLayout({
2728
}: {
2829
children: React.ReactNode;
2930
}) {
31+
console.log(analyticsConfig.plausibleDataDomain);
32+
console.log(analyticsConfig.plausibleProps);
33+
3034
return (
3135
<html lang="en">
32-
<head>
33-
<PlausibleProvider domain={appConfig.plausibleDataDomain} />
34-
</head>
36+
<head></head>
3537
<AppContextProvider>
3638
<SinkFormContextProvider>
3739
<body className={`${inter.className}`}>
40+
<PlausibleProvider
41+
domain={analyticsConfig.plausibleDataDomain}
42+
scriptProps={analyticsConfig.plausibleProps}
43+
enabled
44+
trackLocalhost
45+
/>
3846
<PostHogProvider>
3947
<AnalyticsConsent />
4048

src/components/dashboard/transactions/PendingRetirements.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function PendingRetirements() {
3737
}, [setHasPendingRounding, walletConnection]);
3838

3939
return (
40-
<div className="bg-darkest w-full flex-1 flex flex-col">
40+
<div className="bg-darkest w-full flex-1 flex flex-col gap-8">
4141
<div className="px-4 flex flex-col">
4242
<div className="mt-12 md:mt-12 flex flex-col items-center">
4343
{/* <DashboardTitle>Pending retirements balance</DashboardTitle> */}
@@ -77,7 +77,7 @@ export default function PendingRetirements() {
7777
</div>
7878
</div>
7979
</div>
80-
<div className="flex-1 flex flex-col gap-1">
80+
<div className="flex-1 flex flex-col items-center gap-1 mb-12 md:px-4">
8181
{pendingTransactions?.length ?? 0 > 0 ? (
8282
<>
8383
{pendingTransactions?.map((transaction, index) => {

src/components/dashboard/transactions/request-certificate/RequestCertificateInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default function RequestCertificateInfo() {
2727
return (
2828
<div className="p-4 flex flex-col gap-4">
2929
<div className="text-center">
30-
You have sufficient balance to create a personal certificate of{" "}
31-
{Math.floor(totalPending)} <CARBONCurrencyIcon className="inline" />
30+
{/* You have sufficient balance to create a personal certificate. */}
31+
You can request a certificate for your pending balance.
3232
</div>
3333

3434
<Button

src/config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import { WalletNetwork } from "@creit.tech/stellar-wallets-kit";
44
import * as StellarSdk from "@stellar/stellar-sdk";
55
import { client } from "@stellarcarbon/sc-sdk";
6+
import { DetailedHTMLProps, ScriptHTMLAttributes } from "react";
67

78
export interface AppConfiguration {
89
network: WalletNetwork;
910
server: StellarSdk.Horizon.Server;
1011
demo: boolean;
1112
apiBaseUrl: string;
1213
pubnetDeployment: boolean;
13-
plausibleDataDomain: string;
14+
1415
usdcXlmLiquidityPoolId?: string;
1516
usdcAssetCode?: string;
1617
}
@@ -31,10 +32,6 @@ function buildConfig(): AppConfiguration {
3132
? "https://api.stellarcarbon.io"
3233
: "https://testnet-api.stellarcarbon.io";
3334

34-
let plausibleDataDomain = pubnetDeployment
35-
? "new.stellarcarbon.io"
36-
: "test.stellarcarbon.io";
37-
3835
if (
3936
process.env.NEXT_PUBLIC_USE_MAINNET === "true" &&
4037
process.env.NODE_ENV === "development"
@@ -55,7 +52,6 @@ function buildConfig(): AppConfiguration {
5552
server,
5653
apiBaseUrl,
5754
demo,
58-
plausibleDataDomain,
5955
usdcXlmLiquidityPoolId,
6056
usdcAssetCode,
6157
};

0 commit comments

Comments
 (0)