Skip to content

Commit

Permalink
Merge pull request #9 from hreinberger/feature/analytics
Browse files Browse the repository at this point in the history
add product analytics with posthog
  • Loading branch information
hreinberger authored Jan 21, 2025
2 parents 0771413 + 74a6f50 commit e4ad29a
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 39 deletions.
46 changes: 46 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"next": "^15.1.5",
"next-themes": "^0.4.4",
"postcss-import": "^16.1.0",
"posthog-js": "^1.207.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"zod": "^3.24.1"
Expand Down
113 changes: 75 additions & 38 deletions src/app/components/form/methods/hostedpaymentmethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Separator,
Text,
Callout,
Switch,
} from '@radix-ui/themes';

import React from 'react';
Expand All @@ -18,45 +19,81 @@ export default async function HostedPaymentMethods() {
const methods = await mollieGetMethods();

return (
<RadioGroup.Root
defaultValue={methods[0]?.id}
name="payment_method"
>
<Card m="1">
<Flex direction="column">
{methods.map((method) => (
<React.Fragment key={method.id}>
<Flex
align="center"
justify="between"
gap="4"
<>
<RadioGroup.Root
defaultValue={methods[0]?.id}
name="payment_method"
>
<Card m="1">
<Flex direction="column">
{methods.map((method) => (
<React.Fragment key={method.id}>
<Flex
align="center"
justify="between"
gap="4"
>
<Text as="label">
<Flex
gap="2"
align="center"
>
<RadioGroup.Item
value={method.id}
/>
{method.description}
</Flex>
</Text>
<PaymentLogo method={method.id} />
</Flex>
<Separator
my="3"
size="4"
/>
</React.Fragment>
))}

<Callout.Root>
<Callout.Icon>
<InfoCircledIcon />
</Callout.Icon>
<Callout.Text>Test Mode only!</Callout.Text>
</Callout.Root>
<Separator
my="3"
size="4"
/>
<Flex>
<Text
as="label"
size="2"
>
<Text as="label">
<Flex
gap="2"
align="center"
>
<RadioGroup.Item value={method.id} />
{method.description}
<Flex
gap="2"
direction="column"
>
<Flex gap="2">
<Switch
radius="full"
name="captureMode"
value={'manual'}
/>
Authorize payment (Cards and Klarna
only)
</Flex>
</Text>
<PaymentLogo method={method.id} />
</Flex>
<Separator
my="3"
size="4"
/>
</React.Fragment>
))}

<Callout.Root>
<Callout.Icon>
<InfoCircledIcon />
</Callout.Icon>
<Callout.Text>Test Mode only!</Callout.Text>
</Callout.Root>
</Flex>
</Card>
</RadioGroup.Root>
<Text
size="1"
color="gray"
>
Authorized payments need to be captured
later
</Text>
</Flex>
</Text>
</Flex>
</Flex>
</Card>
</RadioGroup.Root>
</>
);
}
15 changes: 14 additions & 1 deletion src/app/components/ui/providers.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
'use client';

import { ThemeProvider } from 'next-themes';
import posthog from 'posthog-js';
import { PostHogProvider } from 'posthog-js/react';

if (typeof window !== 'undefined') {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
person_profiles: 'always', // or 'always' to create profiles for anonymous users as well
});
}

export function Providers({ children }) {
return <ThemeProvider attribute="class">{children}</ThemeProvider>;
return (
<PostHogProvider client={posthog}>
<ThemeProvider attribute="class">{children}</ThemeProvider>
</PostHogProvider>
);
}

0 comments on commit e4ad29a

Please sign in to comment.