1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
Commit Graph

1085 Commits

Author SHA1 Message Date
Jaanus Sellin
f140b0253d
feat: allow trust proxy (#4396) 2023-08-03 13:47:19 +03:00
andreas-unleash
a09c6dcaea
feat: add lastSeenByEnvironment flag (#4393)
Closes:
[1-1193](https://linear.app/unleash/issue/1-1193/add-lastseenbyenvironment-flag)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-08-03 12:59:23 +03:00
Tymoteusz Czech
a01aa7e355
Update admin menu (#4389)
## About the changes
- add divider
- reorder items
- add flag for project
https://linear.app/unleash/project/[high][s][none]-improved-menu-aefaca264034

Closes https://linear.app/unleash/issue/1-1101/improved-menu-enterprise
2023-08-03 09:01:49 +02:00
Ivar Conradi Østhus
5377243afc
fix: Password hash is null should yield PasswordMissmatch (#4392)
We are giving a strange error message if the user does not have a
password_hash defined in the database.
2023-08-03 08:51:13 +02:00
Gastón Fournier
1017260c00
chore: add more debug logs (#4388)
This add more debug logs to help us trace how channels are being
filtered out
2023-08-02 15:03:51 +02:00
Gastón Fournier
55c785c2ff
chore: Add debug information to slack addon (#4379)
Logs to help us debug the addon
2023-08-02 10:33:44 +00:00
Arne-Christian Rundereim
8aec4a02cb
fix: EventStore#getMaxRevisionId can return null (#4384)
In a new fresh Unleash instance with cache enabled this can cause
feature toggles to never get updated.

We saw in our client that the ETag was ETag: "60e35fba:null" Which
looked incorrect for us.

I also did manual testing and if the andWhere had a value of largerThan
higher than whatever the id was then we would get back { max: null }.

This should fix that issue.
2023-08-01 23:59:09 +02:00
Thomas Heartman
452b5a6748
OpenAPI: add operation tests: require summaries and descriptions (#4377)
This PR adds an e2e test to the OpenAPI tests that checks that all
openapi operations have both summaries and descriptions. It also fixes
the few schemas that were missing one or the other.
2023-08-01 15:58:15 +02:00
Mateusz Kwasniewski
da5e18233c
feat: segments service DI (#4376) 2023-08-01 11:20:59 +02:00
Mateusz Kwasniewski
ce468dcdce
chore: clean client api flag removed (#4368) 2023-07-31 12:27:31 +02:00
Thomas Heartman
1481c13b61
openapi: enable strict schema validation by default and fix (#4355)
Enable strict schema validation by default. It can still be overridden
by explicitly setting it to false.

I've also fixed the validation errors that appeared when turning it on.
I've opted for the simplest route and changed the schemas to comply with
the tests.
2023-07-31 11:04:13 +02:00
Thomas Heartman
4ab8accf5c
OpenAPI: remaining schema updates (#4354)
This fixes the last few exceptions to our meta schema validation
2023-07-28 07:25:34 +00:00
Thomas Heartman
df59b10fb6
OpenAPI: more schema cleanup (#4353)
This PR fixes additional schemas that hadn't been described properly
2023-07-28 06:59:05 +00:00
Thomas Heartman
12209ae21c
OpenAPI: clean up remaining schemas, part 1 (#4351)
Part of linear task 1-1167. Fixes the first slew of schemas missing
descriptions/examples, etc.
2023-07-28 08:45:56 +02:00
Mateusz Kwasniewski
f053be427b
test: matching variants (#4349) 2023-07-26 20:03:30 +02:00
Mateusz Kwasniewski
7095e87061
fix: do not split non string values (#4346) 2023-07-26 12:32:08 +02:00
Mateusz Kwasniewski
9f35c2187f
fix: sync enabled and variant status (#4345) 2023-07-26 12:23:39 +02:00
Mateusz Kwasniewski
2b565aeef7
feat: incrementing sort order for strategies (#4343) 2023-07-26 11:31:26 +02:00
Gastón Fournier
9398bd969e
fix: Client metrics name validation (#4339) (#4342)
1. Add a test for the failing use case (we can see it
[here](https://github.com/Unleash/unleash/actions/runs/5656229196/job/15322845002?pr=4339#step:5:783)):
```
FAIL src/lib/services/client-metrics/metrics-service-v2.test.ts
  ● process metrics properly even when some names are not url friendly

    ValidationError: "name" must be URL friendly
```
2. Fix and handle this gracefully
3. Added a new toggle to silently ignore bad names:
filterInvalidClientMetrics

Fixes: https://github.com/Unleash/unleash/pull/4193
2023-07-25 13:33:21 +00:00
Mateusz Kwasniewski
88b935fdba
fix: global role is called root role (#4336) 2023-07-24 15:27:07 +02:00
Gastón Fournier
ed5a7960a5
fix: missing events in the event store (#4335)
## About the changes
We are losing some events because of not having "created by" which is
required by a constraint in the DB. One scenario where this can happen
is with the default user admin, because it doesn't have a username or an
email (unless configured by the administrator).

Our code makes assumptions on the existence of one of these 2 attributes
(e.g.
248118af7c/src/lib/services/user-service.ts (L220-L222)).

Event lost metrics:
![Screenshot from 2023-07-24
14-17-20](https://github.com/Unleash/unleash/assets/455064/9b406ad0-bbcb-4263-98dc-74ddd307a5a2)


## Discussion points
The solution proposed here is falling back to a default value. I've
chosen `"admin"` because it covers one of the use cases, but it can also
be `"system"` mimicking
248118af7c/src/lib/services/user-service.ts (L32)
which is used as a default, or `"unknown"` which is sometimes used as a
default:
248118af7c/src/lib/services/project-service.ts (L57)

Anyway, I believe it's better not to lose the event rather than be
accurate with the "created by" that can be fixed later
2023-07-24 13:04:23 +00:00
Mateusz Kwasniewski
5de4958b0f
fix: group cleanup (#4334) 2023-07-24 11:05:55 +02:00
Nuno Góis
d6c8493156
feat: slack app addon default channels (#4308)
https://linear.app/unleash/issue/2-1249/add-support-for-default-slack-channels

Adds support for default Slack channels (multiple, comma-separated). 

Some of the events we are handling do not have associated tags, or maybe
the tags are empty. This adds a "default Slack channels" parameter to
the addon configuration in order to post messages to those channels in
those cases.

<img width="643" alt="image"
src="https://github.com/Unleash/unleash/assets/14320932/ee23d6c7-33b7-4968-a0b1-13b546b5b2a2">

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-07-21 14:15:43 +01:00
Mateusz Kwasniewski
eaf002ff7a
fix: variant table deadlocks (#4309) 2023-07-21 11:34:32 +02:00
Mateusz Kwasniewski
f1d1d7d49a
feat: strategy variants in playground (#4281) 2023-07-21 08:15:15 +02:00
Nuno Góis
bb58a516bd
feat: improve slack app addon scalability (#4284)
https://linear.app/unleash/issue/2-1237/explore-slack-app-addon-scalability-and-limitations

Relevant document:
https://linear.app/unleash/document/894e12b7-802c-4bc5-8c22-75af0e66fa4b

 - Implements 30s cache layer for Slack channels;
 - Adds error logging;
 - Adds respective tests;
 - Slight refactors and improvements for overall robustness;

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-07-20 13:37:06 +01:00
Thomas Heartman
5dd78f3c15
openapi: remove all the extra data info (#4277) 2023-07-19 17:20:17 +02:00
Thomas Heartman
87cec6c9b7
openapi: update ui-config endpoints (#4280) 2023-07-19 17:18:47 +02:00
Thomas Heartman
fc25bc6b82
Feat(#4205): add potentially stale events to addons (#4279)
This PR adds potentially stale events as available to all addons and
adds a formatted message.

## Discussion

I'd still be interested in hearing input on whether the event type
should be selectable by addons or not before we start emitting the
event. I'm leaning towards "yes", but I'll take your thoughts into
consideration.
2023-07-19 13:52:19 +00:00
Thomas Heartman
4bca470543
feat(#4205): update potentially stale events (#4270)
This PR does **one** thing:
it changes the events for potentially stale to:
  - Only being emitted when potentially stale gets turned on
- In doing so, it also simplifies the event that's getting emitted,
removing the `data` property.
- The event is also renamed to better match the existing
`feature-stale-on` and `...-off` events.

The addon listening was broken out into a separate PR (#4279)

## Old description

This change lets all addons listen for events when features get marked
or unmarked as potentially stale.

### Discussion

#### All addons?

Should this be available to all addons? I can't see a reason why it
shouldn't be available to all addons, but I might be missing
something.

**Update**: spoke to a couple people. Can see no reason why this isn't
okay.

#### Should it be behind a flag?

The feature is still behind a flag, but the event type is not. Should
we gate the event being available until we actually emit the event?
That would require some more code, but could yield less potential
confusion.

Open to hearing your thoughts.
2023-07-19 15:20:18 +02:00
andreas-unleash
3ee9c4b4a1
Fix: wrap reorder event to strategy variant feature (#4265)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
wrap reorder event creation to strategy variant feature
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-07-18 09:41:54 +00:00
andreas-unleash
dde8ba1a58
fix: unwrap create strategy event creation (bug) (#4264)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
Fixes a bug around createStrategy
Fix: Create/Store strategy reorder event only when feature is on
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-07-18 12:27:58 +03:00
Thomas Heartman
b990c6dfe0
feat(#4205): implement configurable lifetimes (#4263)
This PR updates the feature type service by adding a new
`updateLifetime` method. This method handles the connection between the
API (#4256) and the store (#4252).

I've also added some new e2e tests to ensure that the API behaves as
expected.
2023-07-18 09:26:32 +00:00
Mateusz Kwasniewski
276261c913
feat: Group schema updates (#4258) 2023-07-18 11:08:45 +02:00
Thomas Heartman
34aeca2418
#4205: add openapi definition for the new endpoint (#4256)
This PR adds an operation and accompanying openapi docs for the new
"update feature type lifetime" API operation.

It also fixes an oversight where the other endpoint on the same
controller didn't use `respondWithValidation`.

Note: the API here is a suggestion. I'd like to hear whether you agree
with this implementation or not.
2023-07-18 09:00:51 +00:00
Nuno Góis
3b20978eb2
test: add some basic tests to the new slack app (#4259)
https://linear.app/unleash/issue/2-1244/write-some-tests-for-the-new-slack-app-addon

Pretty self-explanatory. These are based on the tests we have for the
other addons.

If you're reading this and have any suggestions of tests we could add at
this stage, please let me know.
Thanks!
2023-07-18 08:12:15 +01:00
Mateusz Kwasniewski
593f83d5d3
feat: advancedPlayground flag used only for runtime control (#4262) 2023-07-18 08:49:04 +02:00
andreas-unleash
1f21770977
Feat/feature environment strategy execution reorder (#4248)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
When reordering strategies for a feature environment:
- Adds stop when CR are enabled
- Emits an event 

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-07-17 17:12:59 +03:00
Thomas Heartman
02635a32ef
feat(#4205): modify feature type store to allow lifetime updates (#4252)
This PR updates the feature type store to allow for lifetime updates,
laying the foundation required to make it user-configurable (#4205).
2023-07-17 14:36:43 +02:00
Thomas Heartman
209cf01477
Chore: add configurable feature type lifetimes flag (#4253)
Relates to #4205
2023-07-17 14:34:10 +02:00
Thomas Heartman
11f77a21de
#4205: activate event emission (#4240)
This PR activates the event emission that was prepared for in
https://github.com/Unleash/unleash/pull/4239.

It emits events (behind a flag) when something is marked as potentially
stale or the opposite.
It takes the features returned from the store and creates events out of
them.

The events only contain data, no preData. This is because the preData
can easily be inferred and because it gives a nicer event in the event
log.

Here is an image of the difference. The top event uses only data, so it
shows the name of the feature and the new potentiallyStale status. The
bottom event uses both preData and data, so it only shows the new
potentiallyStale status and not the feature name (unless you show the
raw event):


![image](https://github.com/Unleash/unleash/assets/17786332/5ec0fbef-f4cf-4dc6-9af6-9203fca30e5d)


Should not be merged before #4239. Merge that and then rebase this off
main or cherry the commit.

## Discussion 


### `preData`

Should we also use preData or is it enough to use only data? It seems
unnecessary in this event, but I'm open to hearing your thoughts.

### event author: `createdBy`

I've set `unleash-system` as the `createdBy` property on these events
because they are generated by the system. I found the same string used
some other places. However, it may be that there we want to use a
different author.
2023-07-17 08:10:15 +00:00
Thomas Heartman
333c0c0db1
#4205: update to prepare for emitting potentially stale events (#4239)
This PR adds updates the potentially stale status change events whenever
the potentially stale update function is run.

No events are emitted yet. While the emission is only a few lines of
code, I'd like to do that in a separate PR so that we can give it the
attention it deserves in the form of tests, etc.

This PR also moves the potentially stale update functionality from the
`update` method to only being done in the
`updatePotentiallyStaleFeatures` method. This keeps all functionality
related to marking `potentiallyStale` in one place.

The emission implementation was removed in
4fb7cbde03

## The update queries

While it would be possible to do the state updates in a single query
instead of three separate ones, wrangling this into knex proved to be
troublesome (and would also probably be harder to understand and reason
about). The current solution uses three smaller queries (one select, two
updates), as Jaanus suggested in a private slack thread.
2023-07-17 09:53:32 +02:00
Tymoteusz Czech
f91c8a338a
fix: feature OpenAPI endpoints - project related (#4212)
Update OpenAPI for `/api/admin/projects/{projectId}/features/` and
related endpoints

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-07-14 16:48:35 +02:00
Mateusz Kwasniewski
e8ea79c967
feat: client api with proper client segments and strategy variants (#4244) 2023-07-14 13:25:31 +02:00
Jaanus Sellin
4cd4153412
chore: remove split button strategy flag (#4245) 2023-07-14 14:23:23 +03:00
Jaanus Sellin
8de7dfc488
chore: remove context/segment usage flag (#4242) 2023-07-14 13:30:15 +03:00
andreas-unleash
5e45ec25e9
Revert "Feat/add strategy update event on strategy ordering (#4234)" (#4243)
This reverts commit 16e3799b9a.


<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->
2023-07-14 09:11:32 +00:00
Nuno Góis
383e522127
feat: Slack App addon (#4238)
https://linear.app/unleash/issue/2-1232/implement-first-iteration-of-the-new-slack-app-addon

This PR implements the first iteration of the new Slack App addon.
Unlike the old Slack addon, this one uses a Slack App (bot) that is
installed to Slack workspaces in order to post messages. This uses
`@slack/web-api`, which internally uses the latest Slack API endpoints
like `postMessage`.

This is currently behind a flag: `slackAppAddon`.

The current flow is that the Unleash Slack App is installed from
whatever source:
 - Unleash addons page;
 - Direct link;
 - https://unleash-slack-app.vercel.app/ (temporary URL);
 - Slack App Directory (in the future);
 - Etc;

After installed, we resolve the authorization to an `access_token` that
the user can paste into the Unleash Slack App addon configuration form.


https://github.com/Unleash/unleash/assets/14320932/6a6621b9-5b8a-4921-a279-30668be6d46c

Co-authored by: @daveleek

---------

Co-authored-by: David Leek <david@getunleash.io>
2023-07-14 09:49:34 +01:00
andreas-unleash
16e3799b9a
Feat/add strategy update event on strategy ordering (#4234)
Adds a `feature-strategy-update-event` when the strategy sort-order is
changed.

Makes all fields in the eventDataSchema nullable

Closes #
[1-11120](https://linear.app/unleash/issue/1-1112/we-should-have-event-for-re-ordering-strategies)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-07-14 04:46:13 +03:00
Mateusz Kwasniewski
87b46ea734
feat: Persist strategy variants (#4236) 2023-07-13 16:04:55 +02:00