-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
frontend/src/scenes/onboarding/sdks/feature-flags/django.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.DJANGO} /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
frontend/src/scenes/onboarding/sdks/product-analytics/django.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
frontend/src/scenes/onboarding/sdks/sdk-install-instructions/django.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters