Skip to content

Commit 7e643ee

Browse files
committed
feat(setup): updated setup to include nodejs
1 parent fb07f1d commit 7e643ee

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

apps/web/components/environment/setup-guide.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import type { FullEnvironment } from "@/types/environment";
1212
type Framework = "nextjs" | "react" | "js";
1313

1414
const frameworkNames: Record<Framework, string> = {
15-
js: "JavaScript",
16-
react: "React",
1715
nextjs: "Next.js",
16+
react: "React",
17+
js: "Node.js / JS",
1818
};
1919

2020
export function SetupGuide({ environment }: { environment: FullEnvironment }) {
@@ -32,14 +32,6 @@ export function SetupGuide({ environment }: { environment: FullEnvironment }) {
3232
return selectedFramework === "nextjs" ? `"use client";\n\n${code}` : code;
3333
};
3434

35-
const getProviderTitle = () => {
36-
if (selectedFramework === "nextjs") {
37-
return "2. Configure the Provider (app/providers.tsx)";
38-
}
39-
40-
return "2. Configure the Provider (main.tsx)";
41-
};
42-
4335
const CodeBlock = ({
4436
code,
4537
section,
@@ -66,8 +58,8 @@ export function SetupGuide({ environment }: { environment: FullEnvironment }) {
6658
className={cn(
6759
"h-7 rounded px-2 text-xs transition-all",
6860
isCopied
69-
? "bg-emerald-50 text-emerald-600"
70-
: "bg-gray-100 text-gray-600"
61+
? "bg-emerald-50 text-emerald-600 hover:bg-emerald-100"
62+
: "bg-gray-100 text-gray-600 hover:bg-gray-200"
7163
)}
7264
onClick={() => handleCopy(code, section)}
7365
variant="ghost"
@@ -116,7 +108,7 @@ export function SetupGuide({ environment }: { environment: FullEnvironment }) {
116108
</div>
117109

118110
<div className="flex items-center space-x-6 border-gray-100 border-b">
119-
{(Object.keys(frameworkNames) as Framework[]).map((fw) => {
111+
{(["nextjs", "react", "js"] as Framework[]).map((fw) => {
120112
const isActive = selectedFramework === fw;
121113
return (
122114
<Button
@@ -150,14 +142,18 @@ export function SetupGuide({ environment }: { environment: FullEnvironment }) {
150142
<CodeBlock
151143
code={SNIPPETS.vanilla(environment.apiKey)}
152144
section="vanilla"
153-
title="2. Initialize & Use"
145+
title="2. Initialize & Use (Browser or Node.js)"
154146
/>
155147
) : (
156148
<>
157149
<CodeBlock
158150
code={withDirective(SNIPPETS.provider(environment.apiKey))}
159151
section="provider"
160-
title={getProviderTitle()}
152+
title={
153+
selectedFramework === "nextjs"
154+
? "2. Configure the Provider (app/providers.tsx)"
155+
: "2. Configure the Provider (main.tsx)"
156+
}
161157
/>
162158
<CodeBlock
163159
code={withDirective(SNIPPETS.usage)}

apps/web/components/environment/setup-snippets.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,28 @@ export default function MyComponent() {
4242

4343
vanilla: (apiKey: string) => `import { Flagix } from "@flagix/js-sdk";
4444
45-
// Initialize the SDK
45+
/**
46+
* Initialize the SDK.
47+
* Works in Browser and Node.js (v18+).
48+
*/
4649
await Flagix.initialize({
4750
apiKey: "${apiKey}",
4851
apiBaseUrl: "http://localhost:5000",
49-
initialContext: { userId: "user_123" }
52+
initialContext: {
53+
userId: "server_user_01",
54+
internal: true
55+
}
5056
});
5157
5258
// Evaluate a flag
5359
const isEnabled = Flagix.evaluate("my-feature-flag");
5460
5561
// Listen for real-time updates
5662
Flagix.onFlagUpdate((key) => {
57-
if (key === "my-feature-flag") {
58-
const updatedValue = Flagix.evaluate(key);
59-
console.log("Flag updated to:", updatedValue);
60-
}
63+
const updatedValue = Flagix.evaluate(key);
64+
console.log(\`Flag \${key} updated to:\`, updatedValue);
6165
});
6266
63-
// Track events
64-
Flagix.track("conversion_event", { source: "web" });`,
67+
// Track events (Conversions)
68+
Flagix.track("server_init", { environment: process.env.NODE_ENV });`,
6569
};

0 commit comments

Comments
 (0)