Skip to content

Commit e1c0530

Browse files
authored
Remove pageviews query (growthbook#264)
1 parent 415b707 commit e1c0530

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+472
-1696
lines changed

config/config.sample.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ datasources:
2020
context_location_country as country
2121
FROM
2222
experiment_viewed
23-
pageviewsQuery: >
24-
SELECT
25-
user_id,
26-
anonymous_id,
27-
received_at as timestamp,
28-
path as url
29-
FROM
30-
pages
3123
experimentDimensions:
3224
- country
3325
metrics:

packages/back-end/src/controllers/admin.ts

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ import uniqid from "uniqid";
1616
import { createDimension } from "../models/DimensionModel";
1717
import { getSourceIntegrationObject } from "../services/datasource";
1818
import { ExperimentInterface } from "../../types/experiment";
19-
import { createIdea } from "../services/ideas";
20-
import { createImpactEstimate } from "../models/ImpactEstimateModel";
21-
import { createPresentation } from "../services/presentations";
2219
import {
2320
getOrganizationsWithDatasources,
2421
createDataSource,
2522
} from "../models/DataSourceModel";
2623
import { POSTGRES_TEST_CONN } from "../util/secrets";
27-
import { PresentationSlide } from "../../types/presentation";
2824
import { processPastExperimentQueryResponse } from "../services/queries";
2925

3026
export async function getOrganizations(req: AuthRequest, res: Response) {
@@ -92,13 +88,6 @@ export async function addSampleData(req: AuthRequest, res: Response) {
9288
variation_id
9389
FROM
9490
experiment_viewed`,
95-
pageviewsQuery: `SELECT
96-
user_id,
97-
user_id as anonymous_id,
98-
received_at as timestamp,
99-
'' as url
100-
FROM
101-
pages`,
10291
},
10392
}
10493
);
@@ -369,48 +358,6 @@ export async function addSampleData(req: AuthRequest, res: Response) {
369358
})
370359
);
371360

372-
// Example idea
373-
const estimate = await createImpactEstimate(
374-
org.id,
375-
signup.id,
376-
"",
377-
".*",
378-
153.429,
379-
1901.71,
380-
153.429,
381-
"-- Traffic to selected pages\nSELECT\n COUNT(DISTINCT user_id) as users\nFROM\n pages\nWHERE\n received_at >= '2020-11-13 16:26:12'\n AND received_at <= '2020-11-20 16:26:12'\n AND path ~ '.*';\n\n-- Entire site: Signup (binomial)\nWITH metric as (\n SELECT\n 1 as value\n FROM\n pages u\n JOIN signup m ON (\n m.user_id = u.user_id\n AND m.received_at >= u.received_at\n AND m.received_at <= u.received_at + INTERVAL '3 days'\n )\n WHERE\n u.received_at >= '2020-11-13 16:26:12'\n AND u.received_at <= '2020-11-20 16:26:12'\n GROUP BY\n u.user_id\n)\nSELECT\n SUM(value) as total\nFROM\n metric;\n\n-- Selected pages only: Signup (binomial)\nWITH metric as (\n SELECT\n 1 as value\n FROM\n pages u\n JOIN signup m ON (\n m.user_id = u.user_id\n AND m.received_at >= u.received_at\n AND m.received_at <= u.received_at + INTERVAL '3 days'\n )\n WHERE\n u.received_at >= '2020-11-13 16:26:12'\n AND u.received_at <= '2020-11-20 16:26:12'\n AND u.path ~ '.*'\n GROUP BY\n u.user_id\n)\nSELECT\n SUM(value) as value\nFROM\n metric;",
382-
"sql"
383-
);
384-
await createIdea({
385-
text: "Add Facebook Login",
386-
details: "We saw a huge lift when we added Login with Google",
387-
estimateParams: {
388-
estimate: estimate.id,
389-
improvement: 10,
390-
numVariations: 2,
391-
userAdjustment: 100,
392-
},
393-
experimentLength: 18,
394-
impactScore: 38,
395-
votes: [],
396-
tags: [],
397-
organization: org.id,
398-
userId: "growthbook",
399-
userName: "Example User",
400-
});
401-
402-
// Example presentation
403-
const exp: PresentationSlide = {
404-
id: evidence[0],
405-
type: "experiment",
406-
};
407-
await createPresentation({
408-
title: "Example A/B Test Review",
409-
slides: [exp],
410-
organization: org.id,
411-
description: "",
412-
});
413-
414361
res.json({
415362
status: 200,
416363
});

packages/back-end/src/controllers/ideas.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,18 @@ export async function getIdeas(
4141
}
4242

4343
export async function getEstimatedImpact(
44-
req: AuthRequest<{ regex: string; metric: string; segment?: string }>,
44+
req: AuthRequest<{ metric: string; segment?: string }>,
4545
res: Response
4646
) {
47-
const { regex, metric, segment } = req.body;
47+
const { metric, segment } = req.body;
4848

4949
const { org } = getOrgFromReq(req);
50-
const estimate = await getImpactEstimate(org.id, metric, regex, segment);
50+
const estimate = await getImpactEstimate(
51+
org.id,
52+
metric,
53+
org.settings?.metricAnalysisDays || 30,
54+
segment
55+
);
5156

5257
res.status(200).json({
5358
status: 200,
@@ -60,21 +65,17 @@ export async function postEstimatedImpactManual(
6065
res: Response
6166
) {
6267
const { org } = getOrgFromReq(req);
63-
const { value, metricTotal, users, metric, regex } = req.body;
68+
const { conversionsPerDay, metric } = req.body;
6469

6570
if (!metric) {
6671
throw new Error("Missing required metric.");
6772
}
6873

69-
const estimate = await createImpactEstimate(
70-
org.id,
74+
const estimate = await createImpactEstimate({
75+
organization: org.id,
7176
metric,
72-
null,
73-
regex,
74-
value,
75-
users,
76-
metricTotal
77-
);
77+
conversionsPerDay,
78+
});
7879

7980
res.status(200).json({
8081
status: 200,

packages/back-end/src/controllers/organizations.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,6 @@ export async function postDataSources(
923923
experimentEvent: "$experiment_started",
924924
experimentIdProperty: "Experiment name",
925925
variationIdProperty: "Variant name",
926-
pageviewEvent: "Page view",
927-
urlProperty: "$current_url",
928926
...settings?.events,
929927
};
930928

@@ -939,13 +937,16 @@ export async function postDataSources(
939937
variation_id
940938
FROM
941939
${schema ? schema + "." : ""}experiment_viewed`,
942-
pageviewsQuery: `SELECT
940+
identityJoins: [
941+
{
942+
ids: ["user_id", "anonymous_id"],
943+
query: `SELECT
943944
user_id,
944-
anonymous_id,
945-
received_at as timestamp,
946-
path as url
945+
anonymous_id
947946
FROM
948-
${schema ? schema + "." : ""}pages`,
947+
${schema ? schema + "." : ""}identifies`,
948+
},
949+
],
949950
...settings?.queries,
950951
};
951952

packages/back-end/src/integrations/Athena.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ export default class Athena extends SqlIntegration {
2727
): string {
2828
return `${col} ${sign} INTERVAL '${amount}' ${unit}`;
2929
}
30-
regexMatch(col: string, regex: string) {
31-
return `regexp_like(${col}, '${regex}')`;
32-
}
33-
percentile(col: string, percentile: number) {
34-
return `approx_percentile(${col}, ${percentile})`;
35-
}
3630
formatDate(col: string): string {
3731
return `substr(to_iso8601(${col}),0,10)`;
3832
}

packages/back-end/src/integrations/BigQuery.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ export default class BigQuery extends SqlIntegration {
4343
sign === "+" ? "ADD" : "SUB"
4444
}(${col}, INTERVAL ${amount} ${unit.toUpperCase()})`;
4545
}
46-
regexMatch(col: string, regex: string) {
47-
return `REGEXP_CONTAINS(${col}, "${regex}")`;
48-
}
49-
percentile(col: string, percentile: number) {
50-
return `APPROX_QUANTILES(${col}, 100)[OFFSET(${Math.floor(
51-
percentile * 100
52-
)})]`;
53-
}
5446
convertDate(fromDB: bq.BigQueryDatetime) {
5547
return getValidDate(fromDB.value + "Z");
5648
}

packages/back-end/src/integrations/ClickHouse.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ export default class ClickHouse extends SqlIntegration {
6060
): string {
6161
return `date${sign === "+" ? "Add" : "Sub"}(${unit}, ${amount}, ${col})`;
6262
}
63-
regexMatch(col: string, regex: string) {
64-
return `match(${col}, '${regex.replace(/\\/g, "\\\\")}')`;
65-
}
66-
percentile(col: string, percentile: number) {
67-
return `quantile(${percentile})(${col})`;
68-
}
6963
dateTrunc(col: string) {
7064
return `dateTrunc('day', ${col})`;
7165
}

packages/back-end/src/integrations/GoogleAnalytics.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
SourceIntegrationConstructor,
33
SourceIntegrationInterface,
4-
ImpactEstimationResult,
54
MetricValueParams,
65
ExperimentMetricQueryResponse,
76
PastExperimentResponse,
@@ -73,7 +72,7 @@ const GoogleAnalytics: SourceIntegrationConstructor = class
7372
throw new Error("Method not implemented.");
7473
}
7574
getMetricValueQuery(params: MetricValueParams): string {
76-
// TODO: support segments and url regex
75+
// TODO: support segments
7776
return JSON.stringify(
7877
{
7978
viewId: this.params.viewId,
@@ -146,7 +145,6 @@ const GoogleAnalytics: SourceIntegrationConstructor = class
146145

147146
dates.push({
148147
date,
149-
users,
150148
count,
151149
mean,
152150
stddev,
@@ -198,10 +196,6 @@ const GoogleAnalytics: SourceIntegrationConstructor = class
198196
return client;
199197
}
200198

201-
async getImpactEstimation(): Promise<ImpactEstimationResult> {
202-
throw new Error("Not implemented for GA");
203-
}
204-
205199
getExperimentResultsQuery(
206200
experiment: ExperimentInterface,
207201
phase: ExperimentPhase,

0 commit comments

Comments
 (0)