Skip to content

Commit

Permalink
Merge branch 'master' into rm-unused-py-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Apr 22, 2024
2 parents 68e4282 + 0cf2955 commit 0ca5a77
Show file tree
Hide file tree
Showing 42 changed files with 526 additions and 228 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,33 @@ jobs:
sudo apt-get update
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
- name: Install python dependencies
run: |
uv pip install --system -r requirements.txt -r requirements-dev.txt
# First running migrations from master, to simulate the real-world scenario

- uses: actions/checkout@v3
- name: Checkout master
uses: actions/checkout@v3
with:
ref: master

- name: Run migrations up to master
- name: Install python dependencies for master
run: |
# We need to ensure we have requirements for the master branch
# now also, so we can run migrations up to master.
uv pip install --system -r requirements.txt -r requirements-dev.txt
- name: Run migrations up to master
run: |
python manage.py migrate
- uses: actions/checkout@v3
# Now we can consider this PR's migrations

- name: Checkout this PR
uses: actions/checkout@v3

- name: Install python dependencies for this PR
run: |
uv pip install --system -r requirements.txt -r requirements-dev.txt
- name: Run migrations for this PR
run: |
python manage.py migrate
- name: Check migrations
run: |
Expand Down
4 changes: 2 additions & 2 deletions bin/deploy-hobby
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ curl -o /dev/null -L --header "Content-Type: application/json" -d "{
\"properties\": {\"domain\": \"${DOMAIN}\"},
\"type\": \"capture\",
\"event\": \"magic_curl_install_start\"
}" https://app.posthog.com/batch/ &> /dev/null
}" https://us.i.posthog.com/batch/ &> /dev/null

# update apt cache
echo "Grabbing latest apt caches"
Expand Down Expand Up @@ -223,7 +223,7 @@ curl -o /dev/null -L --header "Content-Type: application/json" -d "{
\"properties\": {\"domain\": \"${DOMAIN}\"},
\"type\": \"capture\",
\"event\": \"magic_curl_install_complete\"
}" https://app.posthog.com/batch/ &> /dev/null
}" https://us.i.posthog.com/batch/ &> /dev/null
echo ""
echo "To stop the stack run 'docker-compose stop'"
echo "To start the stack again run 'docker-compose start'"
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/auto-redirect.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Redirect to other subdomain if logged in', () => {

cy.visit(`/login?next=${redirect_path}`)

cy.setCookie('ph_current_instance', `"app.posthog.com"`)
cy.setCookie('ph_current_instance', `"us.posthog.com"`)
cy.setCookie('is-logged-in', '1')
cy.reload()

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% include "head.html" %}

<script>
!function (t, e) { var o, n, p, r; e.__SV || (window.posthog = e, e._i = [], e.init = function (i, s, a) { function g(t, e) { var o = e.split("."); 2 == o.length && (t = t[o[0]], e = o[1]), t[e] = function () { t.push([e].concat(Array.prototype.slice.call(arguments, 0))) } } (p = t.createElement("script")).type = "text/javascript", p.async = !0, p.src = s.api_host + "/static/array.js", (r = t.getElementsByTagName("script")[0]).parentNode.insertBefore(p, r); var u = e; for (void 0 !== a ? u = e[a] = [] : a = "posthog", u.people = u.people || [], u.toString = function (t) { var e = "posthog"; return "posthog" !== a && (e += "." + a), t || (e += " (stub)"), e }, u.people.toString = function () { return u.toString(1) + ".people (stub)" }, o = "capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "), n = 0; n < o.length; n++)g(u, o[n]); e._i.push([i, s, a]) }, e.__SV = 1) }(document, window.posthog || []);
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init({{ js_posthog_api_key | safe}}, { api_host: {{ js_posthog_host | safe}}, persistence: 'localStorage+cookie'})
</script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const sidePanelDocsLogic = kea<sidePanelDocsLogicType>([
}

if (event.data.type === 'external-navigation') {
// This should only be triggered for app|eu.posthog.com links
// This should only be triggered for us|eu.posthog.com links
actions.handleExternalUrl(event.data.url)
return
}
Expand Down
22 changes: 15 additions & 7 deletions frontend/src/lib/components/JSSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ import { CodeSnippet, Language } from 'lib/components/CodeSnippet'
import { apiHostOrigin } from 'lib/utils/apiHost'
import { teamLogic } from 'scenes/teamLogic'

export function JSSnippet(): JSX.Element {
export function useJsSnippet(indent = 0): string {
const { currentTeam } = useValues(teamLogic)

return (
<CodeSnippet language={Language.HTML}>{`<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('${currentTeam?.api_token}',{api_host:'${apiHostOrigin()}'})
</script>`}</CodeSnippet>
)
return [
'<script>',
` !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);`,
` posthog.init('${currentTeam?.api_token}',{api_host:'${apiHostOrigin()}'})`,
'</script>',
]
.map((x) => ' '.repeat(indent) + x)
.join('\n')
}

export function JSSnippet(): JSX.Element {
const snippet = useJsSnippet()

return <CodeSnippet language={Language.HTML}>{snippet}</CodeSnippet>
}
7 changes: 5 additions & 2 deletions frontend/src/lib/utils/apiHost.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export function apiHostOrigin(): string {
let apiHost = window.location.origin
// similar to https://github.com/PostHog/posthog-js/blob/b79315b7a4fa0caded7026bda2fec01defb0ba73/src/posthog-core.ts#L1742

if (apiHost === 'https://us.posthog.com') {
apiHost = 'https://app.posthog.com'
apiHost = 'https://us.i.posthog.com'
} else if (apiHost === 'https://eu.posthog.com') {
apiHost = 'https://eu.i.posthog.com'
}

return apiHost
}
3 changes: 2 additions & 1 deletion frontend/src/scenes/data-warehouse/new/sourceWizardLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
}),
listeners(({ actions, values }) => ({
onBack: () => {
if (values.currentStep <= 2) {
if (values.currentStep <= 1) {
actions.selectConnector(null)
}
},
Expand Down Expand Up @@ -447,6 +447,7 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
})
lemonToast.success('New Data Resource Created')
actions.setSourceId(id)
actions.resetSourceConnectionDetails()
actions.onNext()
} catch (e: any) {
lemonToast.error(e.data?.message ?? e.message)
Expand Down
84 changes: 44 additions & 40 deletions frontend/src/scenes/experiments/ExperimentView/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export function ExperimentLoadingAnimation(): JSX.Element {
}

export function PageHeaderCustom(): JSX.Element {
const { experiment, isExperimentRunning } = useValues(experimentLogic)
const { experiment, isExperimentRunning, isExperimentStopped } = useValues(experimentLogic)
const {
launchExperiment,
resetRunningExperiment,
Expand Down Expand Up @@ -307,38 +307,44 @@ export function PageHeaderCustom(): JSX.Element {
)}
{experiment && isExperimentRunning && (
<div className="flex flex-row gap-2">
<>
<More
overlay={
<>
<LemonButton
onClick={() => (exposureCohortId ? undefined : createExposureCohort())}
fullWidth
data-attr={`${exposureCohortId ? 'view' : 'create'}-exposure-cohort`}
to={exposureCohortId ? urls.cohort(exposureCohortId) : undefined}
targetBlank={!!exposureCohortId}
>
{exposureCohortId ? 'View' : 'Create'} exposure cohort
</LemonButton>
<LemonButton
onClick={() => loadExperimentResults(true)}
fullWidth
data-attr="refresh-experiment"
>
Refresh experiment results
</LemonButton>
<LemonButton
onClick={() => loadSecondaryMetricResults(true)}
fullWidth
data-attr="refresh-secondary-metrics"
>
Refresh secondary metrics
</LemonButton>
</>
}
/>
<LemonDivider vertical />
</>
{!isExperimentStopped && !experiment.archived && (
<>
<More
overlay={
<>
<LemonButton
onClick={() =>
exposureCohortId ? undefined : createExposureCohort()
}
fullWidth
data-attr={`${
exposureCohortId ? 'view' : 'create'
}-exposure-cohort`}
to={exposureCohortId ? urls.cohort(exposureCohortId) : undefined}
targetBlank={!!exposureCohortId}
>
{exposureCohortId ? 'View' : 'Create'} exposure cohort
</LemonButton>
<LemonButton
onClick={() => loadExperimentResults(true)}
fullWidth
data-attr="refresh-experiment"
>
Refresh experiment results
</LemonButton>
<LemonButton
onClick={() => loadSecondaryMetricResults(true)}
fullWidth
data-attr="refresh-secondary-metrics"
>
Refresh secondary metrics
</LemonButton>
</>
}
/>
<LemonDivider vertical />
</>
)}
<ResetButton experiment={experiment} onConfirm={resetRunningExperiment} />
{!experiment.end_date && (
<LemonButton
Expand All @@ -350,13 +356,11 @@ export function PageHeaderCustom(): JSX.Element {
Stop
</LemonButton>
)}
{experiment?.end_date &&
dayjs().isSameOrAfter(dayjs(experiment.end_date), 'day') &&
!experiment.archived && (
<LemonButton type="secondary" status="danger" onClick={() => archiveExperiment()}>
<b>Archive</b>
</LemonButton>
)}
{isExperimentStopped && (
<LemonButton type="secondary" status="danger" onClick={() => archiveExperiment()}>
<b>Archive</b>
</LemonButton>
)}
</div>
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/experiments/experimentLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export const experimentLogic = kea<experimentLogicType>([
// the new query with any existing query and that causes validation problems when there are
// unsupported properties in the now merged query.
const newQuery = filtersToQueryNode(newInsightFilters)
if (filters?.insight === InsightType.FUNNELS) {
if (newInsightFilters?.insight === InsightType.FUNNELS) {
;(newQuery as TrendsQuery).trendsFilter = undefined
} else {
;(newQuery as FunnelsQuery).funnelsFilter = undefined
Expand Down
Loading

0 comments on commit 0ca5a77

Please sign in to comment.