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

build: add & setup growthbook #9

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
on:
push:
branches: [main]

jobs:
call-release-please:
uses: pure-js/reusable-workflows/.github/workflows/release-please.yml@main
secrets: inherit
15 changes: 15 additions & 0 deletions app/growthbook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { GrowthBook } from '@growthbook/growthbook-react';

export const growthbook = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: 'sdk-NTekJ6Q3mZPZungM',
enableDevMode: true,
subscribeToChanges: true,
trackingCallback: (experiment, result) => {
// TODO: Use your real analytics tracking system
console.log('Viewed Experiment', {
experimentId: experiment.key,
variationId: result.key,
});
},
});
13 changes: 11 additions & 2 deletions app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
'use client';
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { GrowthBookProvider } from '@growthbook/growthbook-react';

import { growthbook } from './growthbook';

type ProvidersProps = React.PropsWithChildren<{}>;

export default function Providers({ children }: ProvidersProps) {
const [queryClient] = useState(() => new QueryClient());

useEffect(() => {
growthbook.loadFeatures();
}, []);

return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
<GrowthBookProvider growthbook={growthbook}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</GrowthBookProvider>
);
}
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion components/hello-world/hello-world.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';
import { HelloWorld } from './hello-world';

const meta = {
title: 'Example/Header',
title: 'Hello World',
component: HelloWorld,
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ['autodocs'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "react-hello-world-enterprise-edition",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
Expand All @@ -11,6 +10,7 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@growthbook/growthbook-react": "0.18.0",
"@tanstack/react-query": "4.35.3",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
Expand Down
25 changes: 25 additions & 0 deletions pnpm-lock.yaml

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