Skip to content

Commit

Permalink
Merge branch 'master' into color-theme-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Dec 18, 2023
2 parents fad3ee8 + 8c5086e commit dba9ae3
Show file tree
Hide file tree
Showing 704 changed files with 14,964 additions and 4,288 deletions.
10 changes: 2 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,14 @@ module.exports = {
'plugin:eslint-comments/recommended',
'plugin:storybook/recommended',
'plugin:compat/recommended',
'prettier',
'prettier', // Disables any formatting rules to let prettier do its job
],
globals,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
project: 'tsconfig.json',
},
plugins: [
'prettier',
'react',
'cypress',
'@typescript-eslint',
Expand Down Expand Up @@ -132,7 +126,7 @@ module.exports = {
},
],
'react/forbid-dom-props': [
'warn',
'error',
{
forbid: [
{
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/run-backend-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ runs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm

- name: Install plugin-transpiler
Expand Down
39 changes: 32 additions & 7 deletions .github/pr-deploy/hobby.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ spec:
imagePullPolicy: Always
securityContext:
privileged: true
resources:
requests:
cpu: 250m
memory: 500M
ports:
- containerPort: 2375
- containerPort: 80
Expand All @@ -28,23 +32,44 @@ spec:
value: $REGISTRY_URL
- name: DOCKER_TAG
value: $DOCKER_TAG
- name: SUBDOMAIN
value: $HOSTNAME

---
apiVersion: v1
kind: Service
metadata:
name: hobby-service-$HOSTNAME
annotations:
tailscale.com/expose: "true"
tailscale.com/hostname: hobby-$HOSTNAME
tailscale.com/tags: tag:service
finalizers:
- tailscale.com/finalizer
spec:
selector:
app: hobby-$HOSTNAME
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP
type: NodePort

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hobby-ingress-$HOSTNAME
annotations:
kubernetes.io/ingress.class: "alb"
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]'
alb.ingress.kubernetes.io/ssl-redirect: '443'
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-1:169684386827:certificate/698851fd-36de-4d28-8d75-cb75cc7a92f2
external-dns.alpha.kubernetes.io/hostname: $HOSTNAME.dev.posthog.dev
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hobby-service-$HOSTNAME
port:
number: 80
2 changes: 1 addition & 1 deletion .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1

- name: Get pnpm cache directory path
if: needs.changes.outputs.shouldTriggerCypress == 'true'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
filters: |
frontend:
# Avoid running frontend tests for irrelevant changes
# NOTE: we are at risk of missing a dependency here.
# NOTE: we are at risk of missing a dependency here.
- 'bin/**'
- 'frontend/**'
- 'ee/frontend/**'
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
if: needs.changes.outputs.frontend == 'true'
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1

- name: Get pnpm cache directory path
if: needs.changes.outputs.frontend == 'true'
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
if: needs.changes.outputs.frontend == 'true'
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm

- name: Install package.json dependencies with pnpm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-plugin-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm

- name: Install package.json dependencies with pnpm
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
if: needs.changes.outputs.plugin-server == 'true'
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm
cache-dependency-path: plugin-server/pnpm-lock.yaml

Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm
cache-dependency-path: plugin-server/pnpm-lock.yaml

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
kubectl -n $NAMESPACE delete -f .github/pr-deploy/hobby.yaml || true
kubectl -n $NAMESPACE apply -f .github/pr-deploy/hobby.yaml
echo "url=$NAMESPACE-${HOSTNAME}.hedgehog-kitefin.ts.net" >> $GITHUB_OUTPUT
echo "url=$HOSTNAME.dev.posthog.dev" >> $GITHUB_OUTPUT
- name: update deployment status
uses: bobheadxi/deployments@v1
Expand All @@ -104,5 +104,5 @@ jobs:
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
ref: ${{ github.head_ref }}
env_url: http://${{ steps.deploy_hobby.outputs.url }}
env_url: https://${{ steps.deploy_hobby.outputs.url }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
10 changes: 5 additions & 5 deletions .github/workflows/storybook-chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm

- name: Install dependencies and Chromatic
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
- name: Set up Node.js
uses: buildjet/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm

- name: Install package.json dependencies with pnpm
Expand All @@ -124,7 +124,7 @@ jobs:
run: pnpm install http-server wait-on

- name: Build Storybook
run: pnpm build-storybook --quiet # Silence since progress logging results in a massive wall of spam
run: pnpm build-storybook --test --quiet # Silence since progress logging results in a massive wall of spam

- name: Serve Storybook in the background
run: |
Expand Down Expand Up @@ -180,12 +180,12 @@ jobs:
echo "Snapshots updated ($ADDED new, $MODIFIED changed), running OptiPNG"
apt update && apt install -y optipng
optipng -clobber -o4 -strip all
# we don't want to _always_ run OptiPNG
# so, we run it after checking for a diff
# but, the files we diffed might then be changed by OptiPNG
# and as a result they might no longer be different...
# we check again
git diff --name-status frontend/__snapshots__/ # For debugging
ADDED=$(git diff --name-status frontend/__snapshots__/ | grep '^A' | wc -l)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/storybook-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 18.12.1
cache: pnpm
cache-dependency-path: posthog/pnpm-lock.yaml

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ frontend/__snapshots__/__failures__/
*Type.ts
frontend/pnpm-error.log
frontend/tmp
**/*.tsbuildinfo
.idea
celerybeat-schedule
celerybeat.pid
Expand Down
2 changes: 2 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const config: StorybookConfig = {
docs: {
autodocs: 'tag',
},

typescript: { reactDocgen: 'react-docgen' }, // Shouldn't be needed in Storybook 8
}

export default config
33 changes: 14 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@
- Gather insights by capturing session replays, console logs, and network monitoring
- Improve your product with A/B testing that automatically analyzes performance
- Safely roll out features to select users or cohorts with feature flags
- Send out fully customizable surveys to specific cohorts of users
- Connect to external services and manage data flows with PostHog CDP

PostHog is available with hosting in the EU or US and is fully SOC 2 compliant. It's free to get started and your first 1 million events (and 15k replays) are free every month. We're constantly adding new features, such as user surveys!
PostHog is available with hosting in the EU or US and is fully SOC 2 compliant. It's free to get started and comes with a generous monthly free tier:
- 1 million product analytics events
- 15k session replays
- 1 million feature flag requests
- 250 survey responses

We're constantly adding new features, with web analytics and data warehouse now in beta!

## Table of Contents

- [Get started for free](#get-started-for-free)
- [Features](#features)
- [Docs and support](#docs-and-support)
- [Docs](#docs)
- [Contributing](#contributing)
- [Philosophy](#philosophy)
- [Open-source vs paid](#open-source-vs-paid)
Expand All @@ -49,11 +55,9 @@ You can deploy a hobby instance in one line on Linux with Docker (recommended 4G
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/deploy-hobby)"
```

Open source deployments should scale to approximately 100k events per month, after which we recommend migrating to a PostHog Cloud instance. See our [docs for more info and limitations](https://posthog.com/docs/self-host/open-source/deployment).

PostHog has [sunset support for self-hosted K8s deployments](https://posthog.com/blog/sunsetting-helm-support-posthog).
Open source deployments should scale to approximately 100k events per month, after which we recommend migrating to a PostHog Cloud instance. See our [docs for more info and limitations](https://posthog.com/docs/self-host/open-source/deployment). Please note that we do not provide customer support for open source deployments.

## Features
## Docs
![ui-demo](https://user-images.githubusercontent.com/85295485/144591577-fe97e4a5-5631-4a60-a684-45caf421507f.gif)
<p align="center">Want to find out more? <a href="https://posthog.com/book-a-demo">Request a demo!</a>

Expand All @@ -64,12 +68,13 @@ PostHog brings all the tools and data you need to build better products.
- **Event-based analytics:** Capture your product's usage [automatically](https://posthog.com/docs/integrate/client/js#autocapture), or [customize](https://posthog.com/docs/integrate) it to your needs
- **User and group tracking:** Understand the [people](https://posthog.com/manual/persons) and [groups](https://posthog.com/manual/group-analytics) behind the events and track properties about them
- **Data visualizations:** Create and share [graphs](https://posthog.com/docs/features/trends), [funnels](https://posthog.com/docs/features/funnels), [paths](https://posthog.com/docs/features/paths), [retention](https://posthog.com/docs/features/retention), and [dashboards](https://posthog.com/docs/features/dashboards)
- **SQL access:** Use SQL to get a deeper understanding of your users, breakdown information and create completely tailored visualizations
- **SQL access:** Use [SQL](https://posthog.com/docs/product-analytics/sql) to get a deeper understanding of your users, breakdown information and create completely tailored visualizations
- **Session replays:** [Watch videos](https://posthog.com/docs/features/session-recording) of your users' behavior, with fine-grained filters and privacy controls, as well as network monitoring and captured console logs
- **Heatmaps:** See where users click and get a visual representation of their behaviour with the [PostHog Toolbar](https://posthog.com/docs/features/toolbar)
- **Feature flags:** Test and manage the rollout of new features to specific users and groups, or deploy flags as kill-switches
- **Feature flags:** Test and manage the rollout of [new features](https://posthog.com/docs/feature-flags/installation) to specific users and groups, or deploy flags as kill-switches
- **A/B and multivariate experimentation:** run simple or complex changes as [experiments](https://posthog.com/manual/experimentation) and get automatic significance calculations
- **Correlation analysis:** Discover what events and properties [correlate](https://posthog.com/manual/correlation) with success and failure
- **Surveys:** Collect qualitative feedback from your users using fully customizable [surveys](https://posthog.com/docs/surveys/installation)

### Data and infrastructure tools

Expand All @@ -79,16 +84,6 @@ PostHog brings all the tools and data you need to build better products.

[Read a full list of PostHog features](https://posthog.com/product).

## Docs and support

Read how to [integrate](https://posthog.com/docs/integrate), and [extend](https://posthog.com/docs/apps) an open-source 'Hobby' deployment of PostHog in our [documentation](https://posthog.com/docs).

Check out our [tutorials](https://posthog.com/docs/apps) for step-by-step guides, how-to's, and best practices.

Learn more about getting the most out of PostHog's features in [our product manual](https://posthog.com/using-posthog).

[Ask a question](https://posthog.com/questions) to get support.

## Contributing

We <3 contributions big and small. In priority order (although everything is appreciated) with the most helpful first:
Expand Down
46 changes: 28 additions & 18 deletions bin/unit_metrics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import http.client
import json
import time
import logging
from prometheus_client import CollectorRegistry, Gauge, multiprocess, generate_latest


logger = logging.getLogger(__name__)

UNIT_CONNECTIONS_ACCEPTED_TOTAL = Gauge(
"unit_connections_accepted_total",
"",
Expand Down Expand Up @@ -42,32 +47,37 @@


def application(environ, start_response):
connection = http.client.HTTPConnection("localhost:8181")
connection.request("GET", "/status")
response = connection.getresponse()
retries = 5
try:
connection = http.client.HTTPConnection("localhost:8181")
connection.request("GET", "/status")
response = connection.getresponse()

statj = json.loads(response.read())
connection.close()
statj = json.loads(response.read())
except Exception as e:
if retries > 0:
retries -= 1
time.sleep(1)
return application(environ, start_response)
else:
raise e
finally:
try:
connection.close()
except Exception as e:
logger.error("Failed to close connection to unit: ", e)

UNIT_CONNECTIONS_ACCEPTED_TOTAL.set(statj["connections"]["accepted"])
UNIT_CONNECTIONS_ACTIVE.set(statj["connections"]["active"])
UNIT_CONNECTIONS_IDLE.set(statj["connections"]["idle"])
UNIT_CONNECTIONS_CLOSED.set(statj["connections"]["closed"])
UNIT_CONNECTIONS_TOTAL.set(statj["requests"]["total"])

for application in statj["applications"].keys():
UNIT_PROCESSES_RUNNING_GAUGE.labels(application=application).set(
statj["applications"][application]["processes"]["running"]
)
UNIT_PROCESSES_STARTING_GAUGE.labels(application=application).set(
statj["applications"][application]["processes"]["starting"]
)
UNIT_PROCESSES_IDLE_GAUGE.labels(application=application).set(
statj["applications"][application]["processes"]["idle"]
)
UNIT_REQUESTS_ACTIVE_GAUGE.labels(application=application).set(
statj["applications"][application]["requests"]["active"]
)
for app in statj["applications"].keys():
UNIT_PROCESSES_RUNNING_GAUGE.labels(application=app).set(statj["applications"][app]["processes"]["running"])
UNIT_PROCESSES_STARTING_GAUGE.labels(application=app).set(statj["applications"][app]["processes"]["starting"])
UNIT_PROCESSES_IDLE_GAUGE.labels(application=app).set(statj["applications"][app]["processes"]["idle"])
UNIT_REQUESTS_ACTIVE_GAUGE.labels(application=app).set(statj["applications"][app]["requests"]["active"])

start_response("200 OK", [("Content-Type", "text/plain")])
# Create the prometheus multi-process metric registry here
Expand Down
Loading

0 comments on commit dba9ae3

Please sign in to comment.