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

feat: Add frameworks to onboarding part 3 #21158

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
31 changes: 26 additions & 5 deletions frontend/src/scenes/onboarding/sdks/allSDKs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export const allSDKs: SDK[] = [
image: require('./logos/bubble.svg'),
docsLink: 'https://posthog.com/docs/libraries/bubble',
},
{
name: 'Django',
key: SDKKey.DJANGO,
tags: [SDKTag.SERVER],
image: require('./logos/django.svg'),
docsLink: 'https://posthog.com/docs/libraries/django',
},
{
name: 'Elixir',
key: SDKKey.ELIXIR,
Expand Down Expand Up @@ -180,6 +187,20 @@ export const allSDKs: SDK[] = [
image: require('./logos/ruby.svg'),
docsLink: 'https://posthog.com/docs/libraries/ruby',
},
{
name: 'Rust',
key: SDKKey.RUST,
tags: [SDKTag.SERVER],
image: require('./logos/rust.svg'),
docsLink: 'https://posthog.com/docs/libraries/rust',
},
{
name: 'Svelte',
key: SDKKey.SVELTE,
tags: [SDKTag.WEB],
image: require('./logos/svelte.svg'),
docsLink: 'https://posthog.com/docs/libraries/svelte',
},
{
name: 'Vue.js',
key: SDKKey.VUE_JS,
Expand All @@ -188,11 +209,11 @@ export const allSDKs: SDK[] = [
docsLink: 'https://posthog.com/docs/libraries/vue-js',
},
{
name: 'Rust',
key: SDKKey.RUST,
tags: [SDKTag.SERVER],
image: require('./logos/rust.svg'),
docsLink: 'https://posthog.com/docs/libraries/rust',
name: 'Webflow',
key: SDKKey.WEBFLOW,
tags: [SDKTag.WEB],
image: require('./logos/webflow.svg'),
docsLink: 'https://posthog.com/docs/libraries/webflow',
},
// integrations
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FeatureFlagsAPIInstructions,
FeatureFlagsAstroInstructions,
FeatureFlagsBubbleInstructions,
FeatureFlagsDjangoInstructions,
FeatureFlagsFlutterInstructions,
FeatureFlagsFramerInstructions,
FeatureFlagsGoInstructions,
Expand All @@ -21,6 +22,9 @@ import {
FeatureFlagsRemixJSInstructions,
FeatureFlagsRNInstructions,
FeatureFlagsRubyInstructions,
FeatureFlagsSvelteInstructions,
FeatureFlagsVueInstructions,
FeatureFlagsWebflowInstructions,
} from '.'

export const FeatureFlagsSDKInstructions: SDKInstructionsMap = {
Expand All @@ -30,6 +34,7 @@ export const FeatureFlagsSDKInstructions: SDKInstructionsMap = {
[SDKKey.API]: FeatureFlagsAPIInstructions,
[SDKKey.ASTRO]: FeatureFlagsAstroInstructions,
[SDKKey.BUBBLE]: FeatureFlagsBubbleInstructions,
[SDKKey.DJANGO]: FeatureFlagsDjangoInstructions,
[SDKKey.FLUTTER]: FeatureFlagsFlutterInstructions,
[SDKKey.FRAMER]: FeatureFlagsFramerInstructions,
[SDKKey.GO]: FeatureFlagsGoInstructions,
Expand All @@ -44,5 +49,7 @@ export const FeatureFlagsSDKInstructions: SDKInstructionsMap = {
[SDKKey.REACT_NATIVE]: FeatureFlagsRNInstructions,
[SDKKey.REMIX]: FeatureFlagsRemixJSInstructions,
[SDKKey.RUBY]: FeatureFlagsRubyInstructions,
// add rust, gatsby, nuxt, vue, svelte, and others here
[SDKKey.SVELTE]: FeatureFlagsSvelteInstructions,
[SDKKey.VUE_JS]: FeatureFlagsVueInstructions,
[SDKKey.WEBFLOW]: FeatureFlagsWebflowInstructions,
}
13 changes: 13 additions & 0 deletions frontend/src/scenes/onboarding/sdks/feature-flags/django.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SDKKey } from '~/types'

import { SDKInstallDjangoInstructions } from '../sdk-install-instructions'
import { FlagImplementationSnippet } from './flagImplementationSnippet'

export function FeatureFlagsDjangoInstructions(): JSX.Element {
return (
<>
<SDKInstallDjangoInstructions />
<FlagImplementationSnippet sdkKey={SDKKey.PYTHON} />
</>
)
}
4 changes: 4 additions & 0 deletions frontend/src/scenes/onboarding/sdks/feature-flags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './angular'
export * from './api'
export * from './astro'
export * from './bubble'
export * from './django'
export * from './flutter'
export * from './framer'
export * from './go'
Expand All @@ -18,3 +19,6 @@ export * from './react'
export * from './react-native'
export * from './remix'
export * from './ruby'
export * from './svelte'
export * from './vue'
export * from './webflow'
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function FeatureFlagsRemixJSInstructions(): JSX.Element {
<>
<SDKInstallRemixJSInstructions />
<h3>Client-side rendering</h3>
<FlagImplementationSnippet sdkKey={SDKKey.REACT} />
<FlagImplementationSnippet sdkKey={SDKKey.JS_WEB} />
<h3>Server-side rendering</h3>
<h4>Install</h4>
<NodeInstallSnippet />
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/scenes/onboarding/sdks/feature-flags/svelte.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SDKKey } from '~/types'

import { NodeInstallSnippet, NodeSetupSnippet } from '../sdk-install-instructions'
import { SDKInstallSvelteJSInstructions } from '../sdk-install-instructions/svelte'
import { FlagImplementationSnippet } from './flagImplementationSnippet'

export function FeatureFlagsSvelteInstructions(): JSX.Element {
return (
<>
<SDKInstallSvelteJSInstructions />
<h3>Client-side rendering</h3>
<FlagImplementationSnippet sdkKey={SDKKey.JS_WEB} />
<h3>Server-side rendering</h3>
<h4>Install</h4>
<NodeInstallSnippet />
<h4>Configure</h4>
<NodeSetupSnippet />
<FlagImplementationSnippet sdkKey={SDKKey.NODE_JS} />
</>
)
}
13 changes: 13 additions & 0 deletions frontend/src/scenes/onboarding/sdks/feature-flags/vue.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SDKKey } from '~/types'

import { SDKInstallVueInstructions } from '../sdk-install-instructions/vue'
import { FlagImplementationSnippet } from './flagImplementationSnippet'

export function FeatureFlagsVueInstructions(): JSX.Element {
return (
<>
<SDKInstallVueInstructions />
<FlagImplementationSnippet sdkKey={SDKKey.JS_WEB} />
</>
)
}
13 changes: 13 additions & 0 deletions frontend/src/scenes/onboarding/sdks/feature-flags/webflow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SDKKey } from '~/types'

import { SDKInstallWebflowInstructions } from '../sdk-install-instructions/webflow'
import { FlagImplementationSnippet } from './flagImplementationSnippet'

export function FeatureFlagsWebflowInstructions(): JSX.Element {
return (
<>
<SDKInstallWebflowInstructions />
<FlagImplementationSnippet sdkKey={SDKKey.JS_WEB} />
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ProductAnalyticsAPIInstructions,
ProductAnalyticsAstroInstructions,
ProductAnalyticsBubbleInstructions,
ProductAnalyticsDjangoInstructions,
ProductAnalyticsElixirInstructions,
ProductAnalyticsFlutterInstructions,
ProductAnalyticsFramerInstructions,
Expand All @@ -22,6 +23,9 @@ import {
ProductAnalyticsRemixJSInstructions,
ProductAnalyticsRNInstructions,
ProductAnalyticsRubyInstructions,
ProductAnalyticsSvelteJSInstructions,
ProductAnalyticsVueInstructions,
ProductAnalyticsWebflowInstructions,
} from '.'

export const ProductAnalyticsSDKInstructions: SDKInstructionsMap = {
Expand All @@ -31,6 +35,7 @@ export const ProductAnalyticsSDKInstructions: SDKInstructionsMap = {
[SDKKey.API]: ProductAnalyticsAPIInstructions,
[SDKKey.ASTRO]: ProductAnalyticsAstroInstructions,
[SDKKey.BUBBLE]: ProductAnalyticsBubbleInstructions,
[SDKKey.DJANGO]: ProductAnalyticsDjangoInstructions,
[SDKKey.ELIXIR]: ProductAnalyticsElixirInstructions,
[SDKKey.FLUTTER]: ProductAnalyticsFlutterInstructions,
[SDKKey.FRAMER]: ProductAnalyticsFramerInstructions,
Expand All @@ -46,4 +51,7 @@ export const ProductAnalyticsSDKInstructions: SDKInstructionsMap = {
[SDKKey.REACT_NATIVE]: ProductAnalyticsRNInstructions,
[SDKKey.REMIX]: ProductAnalyticsRemixJSInstructions,
[SDKKey.RUBY]: ProductAnalyticsRubyInstructions,
[SDKKey.SVELTE]: ProductAnalyticsSvelteJSInstructions,
[SDKKey.VUE_JS]: ProductAnalyticsVueInstructions,
[SDKKey.WEBFLOW]: ProductAnalyticsWebflowInstructions,
}
21 changes: 21 additions & 0 deletions frontend/src/scenes/onboarding/sdks/product-analytics/django.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { CodeSnippet, Language } from 'lib/components/CodeSnippet'

import { SDKInstallDjangoInstructions } from '../sdk-install-instructions'

function DjangoCaptureSnippet(): JSX.Element {
return (
<CodeSnippet language={Language.Python}>{`import posthog

posthog.capture('test-id', 'test-event')`}</CodeSnippet>
)
}

export function ProductAnalyticsDjangoInstructions(): JSX.Element {
return (
<>
<SDKInstallDjangoInstructions />
<h3>Send an Event</h3>
<DjangoCaptureSnippet />
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './angular'
export * from './api'
export * from './astro'
export * from './bubble'
export * from './django'
export * from './elixir'
export * from './flutter'
export * from './framer'
Expand All @@ -19,3 +20,6 @@ export * from './python'
export * from './react-native'
export * from './remix'
export * from './ruby'
export * from './svelte'
export * from './vue'
export * from './webflow'
11 changes: 11 additions & 0 deletions frontend/src/scenes/onboarding/sdks/product-analytics/svelte.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SDKInstallSvelteJSInstructions } from '../sdk-install-instructions/svelte'
import { ProductAnalyticsAllJSFinalSteps } from './AllJSFinalSteps'

export function ProductAnalyticsSvelteJSInstructions(): JSX.Element {
return (
<>
<SDKInstallSvelteJSInstructions />
<ProductAnalyticsAllJSFinalSteps />
</>
)
}
11 changes: 11 additions & 0 deletions frontend/src/scenes/onboarding/sdks/product-analytics/vue.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SDKInstallVueInstructions } from '../sdk-install-instructions/vue'
import { ProductAnalyticsAllJSFinalSteps } from './AllJSFinalSteps'

export function ProductAnalyticsVueInstructions(): JSX.Element {
return (
<>
<SDKInstallVueInstructions />
<ProductAnalyticsAllJSFinalSteps />
</>
)
}
11 changes: 11 additions & 0 deletions frontend/src/scenes/onboarding/sdks/product-analytics/webflow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SDKInstallWebflowInstructions } from '../sdk-install-instructions/webflow'
import { ProductAnalyticsAllJSFinalSteps } from './AllJSFinalSteps'

export function ProductAnalyticsWebflowInstructions(): JSX.Element {
return (
<>
<SDKInstallWebflowInstructions />
<ProductAnalyticsAllJSFinalSteps />
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { useValues } from 'kea'
import { CodeSnippet, Language } from 'lib/components/CodeSnippet'
import { apiHostOrigin } from 'lib/utils/apiHost'
import { teamLogic } from 'scenes/teamLogic'

function DjangoInstallSnippet(): JSX.Element {
return <CodeSnippet language={Language.Bash}>pip install posthog</CodeSnippet>
}

function DjangoAppConfigSnippet(): JSX.Element {
const { currentTeam } = useValues(teamLogic)

return (
<CodeSnippet language={Language.Python}>
{`from django.apps import AppConfig
import posthog

class YourAppConfig(AppConfig):
name = "your_app_name"
def ready(self):
posthog.api_key = '${currentTeam?.api_token}'
posthog.host = '${apiHostOrigin()}'`}
</CodeSnippet>
)
}

function DjangoSettingsSnippet(): JSX.Element {
return (
<CodeSnippet language={Language.Python}>
{`INSTALLED_APPS = [
# other apps
'your_app_name.apps.MyAppConfig', # Add your app config
] `}
</CodeSnippet>
)
}

export function SDKInstallDjangoInstructions(): JSX.Element {
return (
<>
<h3>Install</h3>
<DjangoInstallSnippet />
<h3>Configure</h3>
<p>
Set the PostHog API key and host in your <code>AppConfig</code> in <code>apps.py</code> so that's it's
available everywhere:
</p>
<DjangoAppConfigSnippet />
<p />
Next, if you haven't done so already, make sure you add your <code>AppConfig</code> to your{' '}
<code>settings.py</code> under <code>INSTALLED_APPS</code>:
<DjangoSettingsSnippet />
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './android'
export * from './angular'
export * from './astro'
export * from './bubble'
export * from './django'
export * from './elixir'
export * from './flutter'
export * from './framer'
Expand All @@ -16,3 +17,6 @@ export * from './python'
export * from './react-native'
export * from './remix'
export * from './ruby'
export * from './svelte'
export * from './vue'
export * from './webflow'
Loading
Loading