Skip to content

Commit

Permalink
Merge branch 'master' into dave/move-uuid-check
Browse files Browse the repository at this point in the history
  • Loading branch information
davemurphysf authored Nov 7, 2023
2 parents 26ab733 + ccd53c1 commit a3abd5b
Show file tree
Hide file tree
Showing 489 changed files with 16,807 additions and 7,577 deletions.
32 changes: 20 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
},
],
'react/forbid-dom-props': [
1,
'warn',
{
forbid: [
{
Expand All @@ -98,7 +98,7 @@ module.exports = {
},
],
'posthog/warn-elements': [
1,
'warn',
{
forbid: [
{
Expand All @@ -110,10 +110,6 @@ module.exports = {
element: 'Col',
message: 'use flex utility classes instead - most of the time can simply be a plain <div>',
},
{
element: 'Space',
message: 'use flex or space utility classes instead',
},
{
element: 'Divider',
message: 'use <LemonDivider> instead',
Expand Down Expand Up @@ -143,14 +139,14 @@ module.exports = {
message: 'use <LemonSelect> instead',
},
{
element: 'a',
message: 'use <Link> instead',
element: 'LemonButtonWithDropdown',
message: 'use <LemonMenu> with a <LemonButton> child instead',
},
],
},
],
'react/forbid-elements': [
2,
'error',
{
forbid: [
{
Expand All @@ -161,6 +157,10 @@ module.exports = {
element: 'Tabs',
message: 'use <LemonTabs> instead',
},
{
element: 'Space',
message: 'use flex or space utility classes instead',
},
{
element: 'Spin',
message: 'use Spinner instead',
Expand All @@ -173,6 +173,10 @@ module.exports = {
element: 'Collapse',
message: 'use <LemonCollapse> instead',
},
{
element: 'Checkbox',
message: 'use <LemonCheckbox> instead',
},
{
element: 'MonacoEditor',
message: 'use <CodeEditor> instead',
Expand All @@ -189,12 +193,16 @@ module.exports = {
element: 'ReactMarkdown',
message: 'use <LemonMarkdown> instead',
},
{
element: 'a',
message: 'use <Link> instead',
},
],
},
],
'no-constant-condition': 0,
'no-prototype-builtins': 0,
'no-irregular-whitespace': 0,
'no-constant-condition': 'off',
'no-prototype-builtins': 'off',
'no-irregular-whitespace': 'off',
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
- name: Check for syntax errors, import sort, and code style violations
run: |
ruff check .
ruff check .
- name: Check formatting
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ gen/
.antlr
upgrade/
hogvm/typescript/dist

.wokeignore
4 changes: 3 additions & 1 deletion bin/docker-server-unit
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ trap 'rm -rf "$PROMETHEUS_MULTIPROC_DIR"' EXIT
export PROMETHEUS_METRICS_EXPORT_PORT=8001
export STATSD_PORT=${STATSD_PORT:-8125}

exec /usr/local/bin/docker-entrypoint.sh unitd --no-daemon
# We need to run as --user root so that nginx unit can proxy the control socket for stats
# However each application is run as "nobody"
exec /usr/local/bin/docker-entrypoint.sh unitd --no-daemon --user root
78 changes: 78 additions & 0 deletions bin/unit_metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import http.client
import json
from prometheus_client import CollectorRegistry, Gauge, multiprocess, generate_latest

UNIT_CONNECTIONS_ACCEPTED_TOTAL = Gauge(
"unit_connections_accepted_total",
"",
multiprocess_mode="livesum",
)
UNIT_CONNECTIONS_ACTIVE = Gauge(
"unit_connections_active",
"",
multiprocess_mode="livesum",
)
UNIT_CONNECTIONS_CLOSED = Gauge(
"unit_connections_closed",
"",
multiprocess_mode="livesum",
)
UNIT_CONNECTIONS_IDLE = Gauge(
"unit_connections_idle",
"",
multiprocess_mode="livesum",
)
UNIT_CONNECTIONS_TOTAL = Gauge(
"unit_requests_total",
"",
multiprocess_mode="livesum",
)
UNIT_PROCESSES_RUNNING_GAUGE = Gauge(
"unit_application_processes_running", "", multiprocess_mode="livesum", labelnames=["application"]
)
UNIT_PROCESSES_STARTING_GAUGE = Gauge(
"unit_application_processes_starting", "", multiprocess_mode="livesum", labelnames=["application"]
)
UNIT_PROCESSES_IDLE_GAUGE = Gauge(
"unit_application_processes_idle", "", multiprocess_mode="livesum", labelnames=["application"]
)
UNIT_REQUESTS_ACTIVE_GAUGE = Gauge(
"unit_application_requests_active", "", multiprocess_mode="livesum", labelnames=["application"]
)


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

statj = json.loads(response.read())
connection.close()

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"]
)

start_response("200 OK", [("Content-Type", "text/plain")])
# Create the prometheus multi-process metric registry here
# This will aggregate metrics we send from the Django app
# We prepend our unit metrics here.
registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
yield generate_latest(registry)
44 changes: 44 additions & 0 deletions cypress/e2e/billingv2.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
describe('Billing', () => {
beforeEach(() => {
cy.intercept('/api/billing-v2/', { fixture: 'api/billing-v2/billing-v2.json' })

cy.visit('/organization/billing')
})

it('Show unsubscribe survey', () => {
cy.intercept('/api/billing-v2/deactivate?products=product_analytics', {
fixture: 'api/billing-v2/billing-v2-unsubscribed-product-analytics.json',
})
cy.get('[data-attr=more-button]').first().click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal__content h3').should(
'contain',
'Why are you unsubscribing from Product analytics + data stack?'
)
cy.contains('.LemonModal .LemonButton', 'Unsubscribe').click()

cy.get('[data-attr=upgrade-card-product_analytics]').should('be.visible')
})

it('Unsubscribe survey text area maintains unique state between product types', () => {
cy.get('[data-attr=more-button]').first().click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal__content h3').should(
'contain',
'Why are you unsubscribing from Product analytics + data stack?'
)

cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
cy.contains('.LemonModal .LemonButton', 'Cancel').click()

cy.get('[data-attr=more-button]').eq(1).click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal__content h3').should('contain', 'Why are you unsubscribing from Session replay?')
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Session replay')
cy.contains('.LemonModal .LemonButton', 'Cancel').click()

cy.get('[data-attr=more-button]').first().click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').should('have.value', 'Product analytics')
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/trends.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('Trends', () => {
it('Apply date filter', () => {
cy.get('[data-attr=date-filter]').click()
cy.get('div').contains('Yesterday').should('exist').click()
cy.get('.trends-insights-container .insight-empty-state').should('exist')
cy.get('[data-attr=trend-line-graph]').should('exist')
})

it('Apply property breakdown', () => {
Expand Down
Loading

0 comments on commit a3abd5b

Please sign in to comment.