Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: Create experiment abstraction for closed beta features #1615

Merged
merged 25 commits into from
Jan 23, 2023

Conversation

victorges
Copy link
Member

@victorges victorges commented Jan 17, 2023

What does this pull request do? Explain your changes. (required)

This is to create a new abstraction called "experiment" to allow us to iterate on
private experiments with specific customers without risking having a feature widely
available to all the users.

This was originally designed here: https://www.notion.so/livepeer/Feature-Experimentation-Playbook-f80717040b254c1ca3591169bcf6611f

Specific updates (required)

  • Create new experiment schema/table
  • Create support for GIN indexes to use in that table
  • Create new experiment API CRUD
  • Create specific endpoints for the more useful experiment actions (checking, adding/removing users etc)

How did you test each of these updates (required)
yarn test, also putting on staging to test the internal api

Does this pull request close any open issues?
Implements #1617

Checklist

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@vercel
Copy link

vercel bot commented Jan 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
livepeer-studio ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 23, 2023 at 10:48PM (UTC)


app.post(
"/:experiment/audience",
authorizer({ anyAdmin: true }),

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited.
packages/api/src/controllers/experiment.ts Fixed Show fixed Hide fixed
}
);

app.patch("/:experiment", authorizer({ anyAdmin: true }), async (req, res) => {

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited.
res.status(204).end();
});

app.get("/:experiment", authorizer({ anyAdmin: true }), async (req, res) => {

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited.
packages/api/src/controllers/experiment.ts Fixed Show fixed Hide fixed

app.post(
"/",
authorizer({ anyAdmin: true }),

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited.
userId: `experiment.data->>'userId'`,
} as const;

app.get("/", authorizer({ anyAdmin: true }), async (req, res) => {

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited.
app.use(`/api/${experiment}`, experimentSubjectsOnly(experiment), api);
}

app.get("/check/:experiment", authorizer({}), async (req, res) => {

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited.
packages/api/src/schema/schema.yaml Outdated Show resolved Hide resolved
packages/api/src/schema/schema.yaml Outdated Show resolved Hide resolved
packages/api/src/controllers/experiment.ts Show resolved Hide resolved
I wanna make the filters actually fail the request if they
are malformed. It's very confusing to get a response that
is completely ignoring some input you provided.
@codecov
Copy link

codecov bot commented Jan 20, 2023

Codecov Report

Merging #1615 (b7d7199) into master (37589b0) will decrease coverage by 0.87027%.
The diff coverage is 19.29825%.

❗ Current head b7d7199 differs from pull request most recent head e918484. Consider uploading reports for the commit e918484 to get more accurate results

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #1615         +/-   ##
===================================================
- Coverage   53.78187%   52.91160%   -0.87027%     
===================================================
  Files             70          73          +3     
  Lines           4667        4774        +107     
  Branches         886         914         +28     
===================================================
+ Hits            2510        2526         +16     
- Misses          1837        1927         +90     
- Partials         320         321          +1     
Impacted Files Coverage Δ
packages/api/src/controllers/api-token.js 65.06024% <ø> (ø)
packages/api/src/controllers/helpers.ts 54.94505% <0.00000%> (-0.61051%) ⬇️
packages/api/src/controllers/webhook.ts 56.55172% <ø> (ø)
packages/api/src/store/cdn-usage-table.ts 21.73913% <ø> (ø)
packages/api/src/store/experiment-table.ts 0.00000% <0.00000%> (ø)
packages/api/src/controllers/experiment.ts 14.45783% <14.45783%> (ø)
packages/api/src/store/table.ts 72.12121% <60.00000%> (-0.54960%) ⬇️
...rc/controllers/experiment/lit-signing-condition.ts 66.66667% <66.66667%> (ø)
packages/api/src/controllers/access-control.ts 83.67347% <100.00000%> (-0.64026%) ⬇️
packages/api/src/store/db.ts 82.41758% <100.00000%> (+0.19536%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 37589b0...e918484. Read the comment docs.

Impacted Files Coverage Δ
packages/api/src/controllers/api-token.js 65.06024% <ø> (ø)
packages/api/src/controllers/helpers.ts 54.94505% <0.00000%> (-0.61051%) ⬇️
packages/api/src/controllers/webhook.ts 56.55172% <ø> (ø)
packages/api/src/store/cdn-usage-table.ts 21.73913% <ø> (ø)
packages/api/src/store/experiment-table.ts 0.00000% <0.00000%> (ø)
packages/api/src/controllers/experiment.ts 14.45783% <14.45783%> (ø)
packages/api/src/store/table.ts 72.12121% <60.00000%> (-0.54960%) ⬇️
...rc/controllers/experiment/lit-signing-condition.ts 66.66667% <66.66667%> (ø)
packages/api/src/controllers/access-control.ts 83.67347% <100.00000%> (-0.64026%) ⬇️
packages/api/src/store/db.ts 82.41758% <100.00000%> (+0.19536%) ⬆️
... and 1 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants