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

1539 Commits

Author SHA1 Message Date
Thomas Heartman
f8db9098fc
Revert "Fix: add the right change"
This reverts commit 9dc64659b7.

Wasn't intended to push to main.
2023-11-21 12:54:45 +01:00
Thomas Heartman
9dc64659b7
Fix: add the right change 2023-11-21 12:53:35 +01:00
Nuno Góis
ae375703d2
fix: scheduler job runtime control (#5363)
## PR Description


https://linear.app/unleash/issue/2-1645/address-post-mortem-action-point-all-flags-should-be-runtime

Refactor with the goal of ensuring that flags are runtime controllable,
mostly focused on the current scheduler logic.

This includes the following changes:
 - Moves scheduler into its own "scheduler" feature folder
- Reverts dependency: SchedulerService takes in the MaintenanceService,
not the other way around
- Scheduler now evaluates maintenance mode at runtime instead of relying
only on its mode state (active / paused)
- Favors flag checks to happen inside the scheduled methods, instead of
controlling whether the method is scheduled at all (favor runtime over
startup)
 - Moves "account last seen update" to scheduler
 - Updates tests accordingly
 - Boyscouting

Here's a manual test showing this behavior, where my local instance was
controlled by a remote instance. Whenever I toggle `maintenanceMode`
through a flag remotely, my scheduled functions stop running:


https://github.com/Unleash/unleash/assets/14320932/ae0a7fa9-5165-4c0b-9b0b-53b9fb20de72


Had a look through all of our current flags and it *seems to me* that
they are all used in a runtime controllable way, but would still feel
more comfortable if this was double checked, since it can be complex to
ensure this.

The only exception to this was `migrationLock`, which I believe is OK,
since the migration only happens at the start anyways.

## Discussion / Questions

~~Scheduler `mode` (active / paused) is currently not *really* being
used, along with its respective methods, except in tests. I think this
could be a potential footgun. Should we remove it in favor of only
controlling the scheduler state through maintenance mode?~~ Addressed in
7c52e3f638

~~The config property `disableScheduler` is still a startup
configuration, but perhaps that makes sense to leave as is?~~
[Answered](https://github.com/Unleash/unleash/pull/5363#issuecomment-1819005445)
by @FredrikOseberg, leaving as is.

Are there any other tests we should add?

Is there anything I missed?

Identified some `setInterval` and `setTimeout` that may make sense to
leave as is instead of moving over to the scheduler service:
- ~~`src/lib/metrics` - This is currently considered a `MetricsMonitor`.
Should this be refactored to a service instead and adapt these
setIntervals to use the scheduler instead? Is there anything special
with this we need to take into account? @chriswk @ivarconr~~
[Answered](https://github.com/Unleash/unleash/pull/5363#issuecomment-1820501511)
by @ivarconr, leaving as is.
- ~~`src/lib/proxy/proxy-repository.ts` - This seems to have a complex
and specific logic currently. Perhaps we should leave it alone for now?
@FredrikOseberg~~
[Answered](https://github.com/Unleash/unleash/pull/5363#issuecomment-1819005445)
by @FredrikOseberg, leaving as is.
- `src/lib/services/user-service.ts` - This one also seems to be a bit
more specific, where we generate new timeouts for each receiver id.
Might not belong in the scheduler service. @Tymek
2023-11-21 10:06:38 +00:00
Thomas Heartman
27252f7728
chore: find segment strategies in CRs (#5365)
This PR adds the ability to detect which strategies use a specific
segment in active change requests.

It does not wire this functionality up to anything just yet. Follow-up
PRs will integrate this with the segment service and eventually with the
front end.
2023-11-21 10:29:43 +01:00
Jaanus Sellin
e79e30de96
fix: total number should be correct now in search (#5355)
The issue was that we all features were created exactly in same time,
and our feature counter waas expecting time to be unique to feature,
which was not the case.
2023-11-21 09:08:20 +01:00
Fredrik Strand Oseberg
11533bf97a
refactor: remove feature flag for Dora (#5367) 2023-11-21 08:18:00 +01:00
Thomas Heartman
0ba99a6162
fix: handle check against non existing projects (#5368)
Instead of throwing an error when the project doesn't exist, we say that
the names are valid, because we have nothing to say that they're not.
Presumably there is already something in place to prevent you from
importing into a non-existent project.
2023-11-20 16:02:41 +00:00
Thomas Heartman
90d6c7c0ba
chore: remove usage of feature naming pattern flag (#5364)
In preparation for this feature going GA
2023-11-20 12:42:24 +01:00
Gastón Fournier
9ef78a5a18
fix: Banners ga (#5361)
It looks like auto-merge is merging before all checks are green.... Fixing the snapshot from https://github.com/Unleash/unleash/pull/5348
2023-11-17 15:09:18 +01:00
Gastón Fournier
4801b64824
feat(banners): enable customer banners (#5348)
## About the changes
This feature allows our Enterprise customers to configure banners to be
displayed on their Unleash instance for all their users to see and
interact with. Previously known as "internal message banners".
2023-11-17 13:56:09 +00:00
Fredrik Strand Oseberg
fd453f5af7
fix: hardcoded stickiness and mode fields (#5342)
This PR fixes an issue where project overview would return hardcoded
project mode and stickiness fields.
2023-11-17 12:32:13 +01:00
Gastón Fournier
02da9b1d34
fix: handle concurrent service account updates (#5349) 2023-11-16 11:03:27 +00:00
Jaanus Sellin
f3df3a31bf
feat: fix paging in sql by using common table expressions (#5343)
Optimizations:

1. Removed extra round trip to database  to count environments
2. Removed extra round trip to database to count features

Fixes:

Currently, we were using a very optimistic query to set correct limit
and offset. This breaks as soon we we join tags.

` query = query
            .select(selectColumns)
            .limit(limit * environmentCount)
            .offset(offset * environmentCount);` 

The solution was to use common table expressions, so we could count and
rank features.
2023-11-16 10:34:44 +02:00
Jaanus Sellin
4e1040c849
feat: connect sort table to backend (#5338)
Now FE sorting is done in backend.
2023-11-15 16:01:02 +02:00
andreas-unleash
7281e8b2d3
fix: new SCHEDULED_CHANGE_REQUEST_EXECUTED on scheduled cr execution (#5330)
Rename event to SCHEDULED_CHANGE_REQUEST_EXECUTED

This event will be triggered when the executor runs a scheduled change
request.
The ChangeRequestApplied event will remain as is (going out to project
members - but will have a scheduled = true property in the data if it
scheduled.
This new event will fire on execution of the schedule and have a result
= "failed" | "succeeded" property.
Because notifications are tied to events, this notification will go out
to the creator and the applier

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-11-14 14:58:48 +02:00
Tymoteusz Czech
fd3a7f12cb
chore: remove featureSwitchRefactor flag (#5329)
Cleanup. This change has been rolled out to significant number of
customers already, and we have another parallel version behind a flag.
2023-11-14 13:03:23 +01:00
Thomas Heartman
a115f89183
feat: include segment usage in CRs when showing usage in projects and flags (#5327)
This PR updates the segment usage counting to also include segment usage
in pending change requests.

The changes include:
- Updating the schema to explicitly call out that change request usage
is included.
- Adding two tests to verify the new features
- Writing an alternate query to count this data

Specifically, it'll update the part of the UI that tells you how many
places a segment is used:


![image](https://github.com/Unleash/unleash/assets/17786332/a77cf932-d735-4a13-ae43-a2840f7106cb)

## Implementation

Implementing this was a little tricky. Previously, we'd just count
distinct instances of feature names and project names on the
feature_strategy table. However, to merge this with change request data,
we can't just count existing usage and change request usage separately,
because that could cause duplicates.

Instead of turning this into a complex DB query, I've broken it up into
a few separate queries and done the merging in JS. I think that's more
readable and it was easier to reason about.

Here's the breakdown:
1. Get the list of pending change requests. We need their IDs and their
project.
2. Get the list of updateStrategy and addStrategy events that have
segment data.
3. Take the result from step 2 and turn it into a dictionary of segment
id to usage data.
4. Query the feature_strategy_segment and feature_strategies table, to
get existing segment usage data
5. Fold that data into the change request data.
6. Perform the preexisting segment query (without counting logic) to get
other segment data
7. Enrich the results of the query from step 2 with usage data.

## Discussion points

I feel like this could be done in a nicer way, so any ideas on how to
achieve that (whether that's as a db query or just breaking up the code
differently) is very welcome.

Second, using multiple queries obviously yields more overhead than just
a single one. However, I do not think this is in the hot path, so I
don't consider performance to be critical here, but I'm open to hearing
opposing thoughts on this of course.
2023-11-14 08:49:32 +01:00
Jaanus Sellin
5d762dcb39
feat: sort favorites on the backend (#5326)
Now favorites will be always on first page, if pinned.
2023-11-14 09:22:35 +02:00
Mateusz Kwasniewski
ce7644e0af
chore: log unerlying DB error in set user root role (#5324) 2023-11-13 12:16:01 +01:00
Jaanus Sellin
5782efa6c0
chore: move sort order validation closer to store due to possible SQL injection (#5322) 2023-11-13 12:43:12 +02:00
Jaanus Sellin
00327c359d
chore: optimize sql query to not concatenate (#5321) 2023-11-13 08:42:19 +02:00
Nuno Góis
15f77f5b8b
fix: project settings flag limit not properly set (#5317)
https://linear.app/unleash/issue/SR-169/ticket-1107-project-feature-flag-limit-is-not-correctly-updated

Fixes #5315, an issue where it would not be possible to set an empty
flag limit.
This also fixes the UI behavior: Before, when the flag limit field was
emptied, it would disappear from the UI.

I'm a bit unsure of the original intent of the `(data.defaultStickiness
!== undefined || data.featureLimit !== undefined)` condition. We're in
an update method, triggered by a PUT endpoint - I think it's safe to
assume that we'll always want to set these values to whatever they come
as, we just need to convert them to `null` in case they are not present
(i.e. `undefined`).
2023-11-10 09:57:20 +00:00
andreas-unleash
180c0dceae
Fix/scheduled request UI (#5318)
Change timezone format
Fixes a bug where the Edit button on hover being elongated

Before:
<img width="755" alt="Screenshot 2023-11-09 at 21 36 01"
src="https://github.com/Unleash/unleash/assets/104830839/189f21d5-8a68-4d6b-b094-b518749a9b2f">

After:
<img width="812" alt="Screenshot 2023-11-09 at 22 09 26"
src="https://github.com/Unleash/unleash/assets/104830839/9056f995-bd2b-4353-8526-77160e49e990">

Adds the missed onClick to the edit button to show the dialog

Fixes a bug with ScheduleChangesDialog onClose

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-11-10 11:22:03 +02:00
Nuno Góis
de638b5b8e
fix: segment project fetch when global (#5311)
This fixes an edge case not caught originally in
https://github.com/Unleash/unleash/pull/5304 - When creating a new
segment on the global level:
 - There is no `projectId`, either in the params or body
- The `UPDATE_PROJECT_SEGMENT` is still a part of the permissions
checked on the endpoint
 - There is no `id` on the params

This made it so that we would run `segmentStore.get(id)` with an
undefined `id`, causing issues.

The fix was simply checking for the presence of `params.id` before
proceeding.
2023-11-09 13:27:12 +00:00
Thomas Heartman
ece5a634bf
feat: API prevents you from deleting segments in crs (#5308)
This PR hooks up the changes introduced in #5301 to the API and puts
them behind a feature flag. A new test has been added and the test setup
has been slightly tweaked to allow this test.

When the flag is enabled, the API will now not let you delete a segment
that's used in any active CRs.
2023-11-09 12:09:39 +01:00
Nuno Góis
4d1f76e61b
fix: take into account project segments permission (#5304)
https://linear.app/unleash/issue/SR-164/ticket-1106-user-with-createedit-project-segment-is-not-able-to-edit-a

Fixes a bug where the `UPDATE_PROJECT_SEGMENT` permission is not
respected, both on the UI and on the API. The original intention was
stated
[here](https://github.com/Unleash/unleash/pull/3346#discussion_r1140434517).

This was easy to fix on the UI, since we were simply missing the extra
permission on the button permission checks.

Unfortunately the API can be tricky. Our auth middleware tries to grab
the `project` information from either the params or body object, but our
`DELETE` method does not contain this information. There is no body and
the endpoint looks like `/admin/segments/:id`, only including the
segment id.

This means that, in the rbac middleware when we check the permissions,
we need to figure out if we're in such a scenario and fetch the project
information from the DB, which feels a bit hacky, but it's something
we're seemingly already doing for features, so at least it's somewhat
consistent.

Ideally what we could do is leave this API alone and create a separate
one for project segments, with endpoints where we would have project as
a param, like so:
`http://localhost:4242/api/admin/projects/:projectId/segments/1`.

This PR opts to go with the quick and hacky solution for now since this
is an issue we want to fix quickly, but this is something that we should
be aware of. I'm also unsure if we want to create a new API for project
segments. If we decide that we want a different solution I don't mind
either adapting this PR or creating a follow up.
2023-11-09 09:37:47 +00:00
Jaanus Sellin
8c2a052a68
fix: project overview and search returning just single tag (#5305) 2023-11-09 10:58:34 +02:00
Thomas Heartman
2695e38ed5
fix: make test for last seen by env not rely on array order (#5303)
This test was flaky because it relied on the order of the array
returned. To make it less flaky, we now turn the array into an object
instead and compare that.
2023-11-08 15:23:24 +01:00
Thomas Heartman
ebf3102244
chore: add detect segment usage in CRs flag (#5302)
As the title says, this PR adds a flag to unleash for detecting segment
usage in CRs.
2023-11-08 15:06:01 +01:00
Jaanus Sellin
a5288ae0b1
feat: also allow searching partial tags (#5299) 2023-11-08 16:05:22 +02:00
Thomas Heartman
f45454fbfd
refactor: extract segment usage read model (#5301)
This PR adds a way to tell if a specific segment is being used in any
active change requests. It's the first step towards preventing segments
that are being used in change requests from being deleted.

It does that by checking the db for any unclosed CRs and using those CR
ids to look for "addStrategy" and "updateStrategy" events in the cr
events table.

## Upcoming PRs

This only puts in a way to detect it, but doesn't add that to anything.
That'll be in an upcoming iteration.
2023-11-08 14:50:12 +01:00
Jaanus Sellin
24f9fa3058
feat: connect search and filter with server api (#5297) 2023-11-08 14:19:40 +02:00
Fredrik Strand Oseberg
fa85e10eac
refactor: remove separate admin api feature flag (#5228)
This PR will remove the feature flag to separate the admin and client
api
2023-11-08 12:24:11 +01:00
Jaanus Sellin
4bacd3e055
feat: introduce offset based search instead of cursor (#5274) 2023-11-08 11:12:42 +02:00
Gastón Fournier
1dc7dd646d
chore: expose custom-handler-auth type (#5287)
This will help us get type checking on the auth handler function
2023-11-07 10:37:09 +01:00
Thomas Heartman
b3054c9277
Chore: remove "dataPath" from data OpenAPI data errors. (#5272)
The `dataPath` was present (but not in the type) in previous versions of
the
error library that we use. But with the recent major upgrade, it's
been removed and the `instancePath` property has finally come into use.

This PR removes all the handling for the previous property and
replaces it with `instancePath`. Because the `dataPath` used full
stops and the `instancePath` uses slashes, we need to change a little
bit of the handling too.
2023-11-07 09:26:14 +01:00
Nuno Góis
1539cb7553
fix: correctly query roles to be removed (#5275)
Fixes / refactors the way roles are being fetched in
`removeRolesOfTypeForUser` to be more consistent with the rest of our
code base.
2023-11-06 13:38:12 +00:00
Gastón Fournier
f16ad4e899
chore: import IUser instead of User for auth (#5269)
## About the changes
A very subtle change in the way we import IUser makes a huge difference
because previously, instead of importing IUser interface we were
importing User and naming it IUser here:

6f8f21fd48/src/lib/routes/unleash-types.ts (L2)
whereas the correct way of importing the interface is:

eec64b119e/src/lib/routes/unleash-types.ts (L2)
2023-11-06 10:46:59 +01:00
Thomas Heartman
78cf9d03aa
refactor: switch to upstream express-openapi (#5259)
Switch the express-openapi implementation from our internal fork to the
upstream version. We have upstreamed our changes and a new version has
been released, so this should be the last step before we can retire our
fork.

Because some of the dependencies have been updated since our internal
fork, we also need to update some of our error handling to reflect this.
2023-11-06 08:22:02 +01:00
Gastón Fournier
6f8f21fd48
chore: expose type and more fixes (#5268)
Expose new interface while also getting rid of unneeded compiler ignores

None of the changes should add new security risks, despite this report:
> Code scanning results / CodeQL Failing after 4s — 2 new alerts
including 2 high severity security vulnerabilities

Not sure what that means, maybe a removed ignore...
2023-11-03 17:36:50 +01:00
Fredrik Strand Oseberg
1d9a67189a
fix: last seen deadlocks (#5264)
Sort the items before inserting them into the database in order to
reduce the chance of deadlocks happening when multiple pods are
inserting at the same time.
2023-11-03 14:06:13 +01:00
Mateusz Kwasniewski
43298e16e2
feat: Server side sort by (#5250) 2023-11-03 13:15:12 +01:00
Gastón Fournier
9688955d4b
chore: expose types so we can use them properly (#5251)
Expose types to be used in enterprise and cloud addons
2023-11-03 12:00:24 +01:00
Nuno Góis
a2b0507459
feat: add banners OpenAPI tag (#5257)
https://linear.app/unleash/issue/2-1515/create-new-api-tag-banners-for-ga

Adds a new OpenAPI tag "Banners" in preparation for GA.
2023-11-03 09:05:19 +00:00
Mateusz Kwasniewski
cbc89f6a92
feat: sort parent options alphabetically (#5238) 2023-11-01 21:18:19 +01:00
Mateusz Kwasniewski
bc66fb649f
feat: infinite scroll API trigger (#5242) 2023-11-01 15:56:06 +01:00
Mateusz Kwasniewski
d074254b61
feat: connect project overview table to search api (#5237) 2023-11-01 12:05:42 +01:00
Jaanus Sellin
598d022a5a
fix: do not allow segment deletion when used in private projects (#5236) 2023-11-01 11:01:23 +02:00
Mateusz Kwasniewski
74bbc7799e
feat: total count in search results (#5235) 2023-11-01 09:19:42 +01:00
Mateusz Kwasniewski
e5bbe5829f
feat: Cursor based hateoas (#5230) 2023-10-31 14:10:31 +01:00
Gastón Fournier
b1ea2c3b88
chore: expose instanceId so it can be used from addons (#5231)
## About the changes
A bit of boy scouting trying to expose the instanceId
2023-10-31 12:38:21 +01:00
Jaanus Sellin
406b2383da
fix: private projects early exit when not root viewer (#5232) 2023-10-31 13:37:09 +02:00
Simon Hornby
9f8f94b06b
chore: remove access overview toggle (#5166) 2023-10-30 14:57:20 +02:00
Fredrik Strand Oseberg
7d65615335
refactor: remove deep diff (#5217)
For a while we ran a diffing algorithm in production to verify that the
results of the refactor did not differ from the previous results. As the
experiment has run it's course and new attributes have been added on top
of the new flow, this will remove the logging and associated code.
2023-10-30 13:30:21 +01:00
Fredrik Strand Oseberg
28c72ec957
fix: ft overview last seen at (#5212)
Fixes an issue where the query in the feature toggle overview would
return excess rows
2023-10-30 13:09:27 +01:00
Mateusz Kwasniewski
b54d481fc8
fix: variant hashing in playground (#5213) 2023-10-30 12:38:32 +01:00
Mateusz Kwasniewski
6d17c3b320
feat: cursor based pagination in search (#5174) 2023-10-27 14:16:29 +02:00
Simon Hornby
c9f9fc7521
fix: flaky test (#5172) 2023-10-27 12:52:49 +02:00
Mateusz Kwasniewski
1c8fab63e2
feat: filter by environment status (#5165) 2023-10-27 08:54:03 +02:00
Mateusz Kwasniewski
46d7cb236d
feat: filter by tags (#5163) 2023-10-26 17:20:57 +02:00
andreas-unleash
66cc526855
feat: add scheduledConfigurationChanges flag (#5161)
add scheduledConfigurationChanges flag

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-10-26 14:00:53 +00:00
Thomas Heartman
acb23e8b87
chore: add CHANGE_REQUEST_SCHEDULED to event types. (#5162)
This is a new event type that will be used to schedule a change
request. It's required in enterprise for the build to work as expected.
2023-10-26 13:41:18 +00:00
Mateusz Kwasniewski
0c8d0704f3
feat: filter features by type (#5160) 2023-10-26 15:29:30 +02:00
Fredrik Strand Oseberg
87fd924be3
refactor: optimize queries (#5158)
This commit will change the join to only get results for either archived
or non-archived features based on the query
2023-10-26 13:38:22 +02:00
Mateusz Kwasniewski
065e588e64
Search by tag (#5156)
add tag search for feature search API
2023-10-26 12:50:02 +02:00
Mateusz Kwasniewski
2c7b7c90e0
refactor: type query params (#5153) 2023-10-26 10:05:47 +02:00
Christopher Kolstad
1bba76413f
feat: make all internal rate limits configurable (#5095)
### What
This PR makes the rate limit for user creation and simple login (our
password based login) configurable in the same way you can do
metricsRateLimiting.

### Worth noting
In addition this PR adds a `rate_limit{endpoint, method}` prometheus
gauge, which gets the data from the UnleashConfig.
2023-10-26 09:20:29 +02:00
David Leek
6fe4740e67
feat: remove feature flag for datadog json template (#5105)
## About the changes

Removes the feature flag for the datadog json template
2023-10-26 09:09:26 +02:00
Mateusz Kwasniewski
de540e09f3
feat: feature search basic functionality (#5150) 2023-10-25 16:12:21 +02:00
Fredrik Strand Oseberg
3ee250ee7d
feat: add feature search service (#5149) 2023-10-25 15:18:52 +02:00
Jaanus Sellin
7039160af0
fix: project mode can not be set to null anymore (#5145) 2023-10-25 14:09:34 +03:00
Mateusz Kwasniewski
705ca1514e
feat: feature search stub (#5143) 2023-10-25 10:50:59 +02:00
Fredrik Strand Oseberg
898c1b4bc7
fix: only get rows for toggles in project (#5141) 2023-10-24 17:26:18 +02:00
Jaanus Sellin
bb136783a3
bug: fix broken links from lychee (#5127)
Fixed https://github.com/Unleash/unleash/issues/5115
2023-10-24 13:22:49 +03:00
Christopher Kolstad
c60bca777f
feat: replace gravatar-url with inline function (#5128)
As #4475 says, MD5 is not available in secure places anymore. This PR
swaps out gravatar-url with an inline function using crypto:sha256 which
is FIPS-140-2 compliant. Since we only used this method for generating
avatar URLs the extra customization wasn't needed and we could hard code
the URL parameters.
 
fixes: Linear
https://linear.app/unleash/issue/SR-112/gh-support-swap-out-gravatar-url-lib
closes: #4475
2023-10-24 10:07:26 +02:00
Mateusz Kwasniewski
8bc04c59f3
refactor: move metrics service scheduling (#5129) 2023-10-23 16:28:19 +02:00
Mateusz Kwasniewski
8d8a975c6c
Client instance service (#5126) 2023-10-23 15:22:30 +02:00
Mateusz Kwasniewski
1d1aa27ca3
refactor: proxy service scheduler (#5125) 2023-10-23 15:11:38 +02:00
Christopher Kolstad
314a08b4e6
feat: Make multiple roles per group/user GA by removing the flag (#5109)
To prepare for 5.6 GA, 
I've done a find through both Frontend and Backend here to remove the
usages of the flag. Seems like the flag was only in use in the frontend.
@nunogois can you confirm?
2023-10-23 12:32:15 +00:00
Mateusz Kwasniewski
828e463e38
refactor: move version service scheduling to scheduler (#5120) 2023-10-23 09:34:03 +00:00
Fredrik Strand Oseberg
08a1d053dc
feat: add job that cleans last seen every 24 hours (#5114)
This PR adds a cleanup job that removes unknown feature flags from
last_seen_at_metrics table every 24 hours since we no longer have a
foreign key on the name column in the features table.
2023-10-23 11:26:48 +02:00
Jaanus Sellin
ddcd7f47d8
chore: remove invite link flag (#5119) 2023-10-23 12:11:11 +03:00
Gastón Fournier
2aebc8c58e
fix: don't clean up settings when optional data is not present (#5118)
## About the changes
This fixes a bug updating a project, when optional data
(defaultStickiness and featureLimit are not part of the payload).

The problem happens due to:
1. ProjectController does not use the type: UpdateProjectSchema for the
request body (will be addressed in another PR in unleash-enterprise)
2. Project Store interface does not match UpdateProjectSchema (but it
relies on accepting `additional properties: true`, which is what we
agreed on for input)
3. Feature limit is not defined in UpdateProjectSchema (also addressed
in the other PR)
2023-10-23 10:15:25 +02:00
Fredrik Strand Oseberg
71431c7a1d
refactor/last seen at archived (#5102)
Refactor global archive view and project archive view to include last
seen at by environment
2023-10-20 13:17:41 +02:00
Mateusz Kwasniewski
433f3e2760
feat: promise timeout on lock (#5108) 2023-10-20 12:10:18 +02:00
Tymoteusz Czech
6fab6633c9
feat: add hasStrategies and hasEnabledStrategies on feature environments (#5012) 2023-10-20 10:50:57 +02:00
Mateusz Kwasniewski
b890df6e12
feat: show warning about dependencies removed on archive (#5104) 2023-10-20 08:58:03 +02:00
Nuno Góis
ba53d392b2
refactor: rename message banners to banners - events (#5100)
https://linear.app/unleash/issue/2-1531/rename-message-banners-to-banners

Follow up to https://github.com/Unleash/unleash/pull/5098
This one adapts the existing events.
2023-10-19 13:53:40 +01:00
Nuno Góis
957546e305
refactor: rename message banners to banners (#5098)
https://linear.app/unleash/issue/2-1531/rename-message-banners-to-banners

This renames "message banners" to "banners".

I also added support for external banners coming from a `banner` flag
instead of only `messageBanner` flag, so we can eventually migrate to
the new one in the future if we want.
2023-10-19 13:18:25 +01:00
Gastón Fournier
3d9f31f839
feat: ensure at least one owner on remove user/group access (#5085)
## About the changes
This makes sure that projects have at least one owner, either a group or
a user. This is to prevent accidentally losing access to a project.

We check this when removing a user/group or when changing the role of a
user/group

**Note**: We can still leave a group empty as the only owner of the
project, but that's okay because we can still add more users to the
group
2023-10-19 14:14:59 +02:00
andreas-unleash
6760fc0723
fix: add project filter to feature-toggle-list-builder (#5099)
Adds `forProject` filter to FeatureToggleQueryBuilder
Filters playground results for an array of projects

Closes #
[1-1525](https://linear.app/unleash/issue/1-1525/getting-results-for-all-projects-when-defining-a-single-project-in-the)

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-10-19 15:05:56 +03:00
Mateusz Kwasniewski
de237d844d
feat: detect grandchild dependency (#5094) 2023-10-19 13:14:32 +02:00
Mateusz Kwasniewski
56892c54d9
feat: check if child and parent are in the same project (#5093) 2023-10-19 11:11:05 +02:00
Fredrik Strand Oseberg
7195a63e56
Refactor/last seen at ft list (#5089)
Refactor last seen at for the feature toggle list
2023-10-19 10:58:10 +02:00
Simon Hornby
1ca3e8d893
fix: force deletion of archived toggles when deleting a project (#5080) 2023-10-19 10:45:09 +02:00
Mateusz Kwasniewski
f8855f8234
feat: prevent self dependencies (#5090) 2023-10-19 08:57:23 +02:00
Fredrik Strand Oseberg
cd864ed09e
fix: add sort to deep diff (#5084)
Sort array items before running compare. Feature flag certain properties
of strategy that were previously not present in the /api/admin/features
endpoint.
2023-10-18 16:34:42 +02:00
Mateusz Kwasniewski
1f8d12bcdc
feat: default session id in frontend api (#5083) 2023-10-18 16:19:03 +02:00
Christopher Kolstad
f8fba501ae
fix: update failing snapshot 2023-10-18 14:30:55 +02:00
Christopher Kolstad
b06613d1b0
feat: Adds rate limiting to metric POST endpoints (#5075)
### What
The heaviest requests we serve are the register and metrics POSTs from
our SDKs/clients.
This PR adds ratelimiting to /api/client/register, /api/client/metrics,
/api/frontend/register and /api/frontend/metrics with a default set to
6000 requests per minute (or 100 rps) for each of the endpoints.

It will be overrideable by the environment variables documented.

### Points of discussion
@kwasniew already suggested using featuretoggles with variants to
control the rate per clientId. I struggled to see if we could
dynamically update the middleware after initialisation, so this attempt
will need a restart of the pod to update the request limit.
2023-10-18 13:00:44 +02:00
Fredrik Strand Oseberg
3ac8ab898a
fix: log diff (#5072)
Add a deep diff function to investigate diff in logs
2023-10-18 09:25:25 +02:00
Mateusz Kwasniewski
75b131162e
feat: dependent features use new transaction mechanism (#5073) 2023-10-18 08:59:26 +02:00
Gastón Fournier
db04a1eaa8
chore: introduce type to prevent potential issues (#5066)
## About the changes
This small improvement aims to help developers when instantiating
services. They need to be constructed without injecting services or
stores created elsewhere so they can be bound to the same transactional
scope.

This suggests that you need to create the services and stores on your
own
2023-10-17 12:30:44 +02:00
andreas-unleash
cf42a829f4
feat: add option to return disabled strategies (#5059)
Adds the option to include disabled strategies (behind the
playgroundImprovements flag

Closes #
[1-1505](https://linear.app/unleash/issue/1-1505/return-disabled-strategies-in-the-playground-features-request)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-10-17 12:35:07 +03:00
Gastón Fournier
08116d008a
chore: GA transactional decorator (#5020)
## About the changes
After testing with the flag enabled and fixing a bug, this is ready to
be GA
2023-10-17 10:47:18 +02:00
Nuno Góis
fd580c9539
fix: extract username from user should not return undefined (#5061)
This fixes a return type error by changing the logic of
`extractUsernameFromUser` to never return undefined.

In the previous code, `user` could be truthy, but that doesn't mean
`email` or `username` were defined. This assumes we always fallback to
"unknown" in those scenarios.
2023-10-17 09:18:44 +01:00
Jaanus Sellin
5619db33ed
feat: import dependencies (#5044) 2023-10-17 08:22:54 +03:00
Mateusz Kwasniewski
e9e110f702
feat: show dependencies only when using pro/enterprise or at least on… (#5052) 2023-10-16 20:56:06 +02:00
Fredrik Strand Oseberg
0064c9e1be
refactor: add tests for /api/client/features (#5057)
add more robust tests for /api/client/features
2023-10-16 16:18:41 +02:00
Gastón Fournier
675ec2e836
chore: add enterprise event (#5056)
This just adds a new event type
2023-10-16 15:37:11 +02:00
Nuno Góis
364e315a3c
feat: add new message banner events (#5055)
https://linear.app/unleash/issue/2-1516/add-new-message-banner-events

Adds new message banner events to help us keep track of changes related
to the new feature.
2023-10-16 14:30:40 +01:00
Fredrik Strand Oseberg
9e493f56a0
refactor: create builder class for converting rows to avoid duplication (#5050)
Create a builder for creating the data structures for feature toggle
list and playground api
2023-10-16 14:19:46 +02:00
Fredrik Strand Oseberg
1a46ab7b12
refactor: add test coverage (#5046)
Adds test coverage for different feature flag paths temporarily
2023-10-16 13:17:26 +02:00
andreas-unleash
8561ba8df7
feat: add playground imrpovements flag (#5045)
Adds the playgroundImprovements flag

Close #
[1-1508](https://linear.app/unleash/issue/1-1508/add-playgroundimprovements-feature-flag)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-10-16 14:08:21 +03:00
Fredrik Strand Oseberg
b58d900c2d
fix: feature flag playground features in new store (#5013)
Have playground use the method in the feature-toggle-service instead of
asking the client-feature-toggle-store
2023-10-16 12:29:31 +02:00
Nuno Góis
6c21ed5f74
feat: make maintenance-related 503s more intuitive (#5018)
This makes maintenance-related 503s more intuitive on our UI by
mentioning that maintenance banner is currently enabled.


![image](https://github.com/Unleash/unleash/assets/14320932/43142c58-6b87-4b2d-9239-50f2bb1409e6)
2023-10-16 09:27:29 +01:00
Mateusz Kwasniewski
c41f23ae54
feat: remove dependency on archive (#5040) 2023-10-16 08:59:34 +02:00
Jaanus Sellin
2263a1f062
feat: dependencies import validation (#5023) 2023-10-13 14:17:54 +03:00
Fredrik Strand Oseberg
b6d945befc
refactor: feature toggle list query (#5022)
Cean up huge query method in feature-toggle-store
2023-10-13 12:29:14 +02:00
Mateusz Kwasniewski
3eeafba5f9
feat: validate archive dependent features (#5019) 2023-10-13 12:09:46 +02:00
andreas-unleash
a9a75d5e82
fix: disable all environments when reviving a feature (#4999)
Disable all environments when reviving a feature

Closes #
[SR-93](https://linear.app/unleash/issue/SR-93/disable-all-environments-when-reviving-a-feature)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-10-13 10:38:18 +03:00
Jaanus Sellin
a7dd0d6c1a
fix: import segment test and fix (#5017) 2023-10-13 09:40:34 +03:00
Fredrik Strand Oseberg
f34d187cd9
Refactor/separate client and admin store (#5006)
This PR is the first step in separating the client and admin stores.
Currently our feature toggle services uses the client store to serve
multiple purposes. 

Admin API uses the feature toggle service to serve both the feature
toggle list and playground features, while the client API uses the
feature toggle service to serve client features. The admin API can
change often and have very different requirements than the client API,
which changes infrequently and generally keeps the same stable structure
for long periods of time. This architecture is error prone, because when
you need to make changes to the admin API, you can very easily affect
the client API.

I aim to put up a stone wall between the two APIs. Complete separation
between the two APIs, at the cost of some duplication.

In this PR I have created a feature oriented architecture for client
features and disconnected the client API from the feature toggle
service. It now goes through it's own service to it's own store. For
feature toggle service I have duplicated and replaced the functionality
that serves /api/admin/features, I have kept a lot of the ugliness in
the code and haven't removed anything in order to avoid breaking
changes.

Next steps: 
* Move playground to admin API
* Remove client-feature-toggle-store from feature-toggle-service
2023-10-12 13:58:23 +02:00
Jaanus Sellin
7b7a2a706c
fix: enable segment importing for oss (#5010) 2023-10-12 13:43:43 +03:00
Jaanus Sellin
2059706e77
feat: export dependent feature toggles (#5007) 2023-10-12 12:56:10 +03:00
Gastón Fournier
7343183f2d
chore: split interfaces for import and export (#5004)
## About the changes
This splits the interfaces for import and export, especially because the
import functionality has to be replaced in enterprise repo.

This is a breaking change because of the service renames, but I'll have
the PR for the other repository ready so we reduce the time to fix. I
intentionally avoided doing it backward compatible because of time.
2023-10-12 11:34:09 +02:00
Mateusz Kwasniewski
cfcf9de65a
feat: Protect archive feature (#5003) 2023-10-12 08:38:03 +02:00
Mateusz Kwasniewski
30e9fb87e9
feat: prevent adding dependency to archived or removed parent (#4987) 2023-10-11 16:21:57 +02:00
andreas-unleash
4e8c0478bf
fix: export NotFoundError and ISegmentService in internals.ts (#4997)
export NotFoundError and ISegmentService in internals.ts

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-10-11 14:31:45 +03:00
Jaanus Sellin
69286339fc
feat: make invite link more visible (#4984) 2023-10-11 14:31:32 +03:00
Nuno Góis
65f424156c
feat: re-order message banners (#4995)
https://linear.app/unleash/issue/2-1494/re-order-message-banners

- Re-orders message banners to fit into this logic:

>1. Maintenance banner
>2. External message banner(s) - Most likely coming from Unleash
>3. Internal message banner(s)

- Renames the feature flag to better reflect the feature behavior;
- Lays a basic skeleton structure for this new feature;
2023-10-11 11:55:54 +01:00
Fredrik Strand Oseberg
bc96216daa
Refactor/move features to feature oriented architecture (#4994)
This PR gathers feature related files in the same folder.
2023-10-11 09:38:57 +02:00
Nuno Góis
2222c47d10
feat: add internalMessageBanner feature flag (#4990)
https://linear.app/unleash/issue/2-1487/feature-flag-add-a-new-internalmessagebanner-feature-flag-for-this

Adds a new `internalMessageBanner` feature flag.
2023-10-10 20:03:59 +01:00
Fredrik Strand Oseberg
a2ca7b0d35
Refactor/last seen at read feature overview (#4986)
Refactor feature overview to use the last seen store
2023-10-10 14:40:36 +02:00
Christopher Kolstad
0c069b1385
fix: added await to getActiveUsers tests 2023-10-10 13:23:20 +02:00
Christopher Kolstad
1edd73db45
feat: feature changes counted in new table (#4958)
As part of more telemetry on the usage of Unleash. 

This PR adds a new `stat_` prefixed table as well as a trigger on the
events table trigger on each insert to increment a counter per
environment per day.

The trigger will trigger on every insert into the events base, but will
filter and only increment the counter for events that actually have the
environment set. (there are events, like user-created, that does not
relate to a specific environment).

Bit wary on this, but since we truncate down to row per (day,
environment) combo, finding conflict and incrementing shouldn't take too
long here.

@ivarconr was it something like this you were considering?
2023-10-10 12:32:23 +02:00
Mateusz Kwasniewski
b4c8f92a26
feat: do not allow to manage dependencies directly with cr enabled (#4971) 2023-10-10 09:25:03 +02:00
Fredrik Strand Oseberg
30d8444c80
fix: refactor getProjectOverview store method (#4972)
This PR cleans up and refactors the feature-strategy-store method
getFeatureOverview to join on the new table and attempts to make the
function more readable by extracting some of the logic into separate
functions. Keeping the LastSeenMapper for now in case there is a reason
to use it for the other endpoints.
2023-10-10 07:34:21 +02:00
Fredrik Strand Oseberg
d896dbd0c7
Fix/last seen at by environment (#4939)
Initial architecture for last seen at by environment.
2023-10-09 10:54:00 +02:00
Gastón Fournier
34fc17146e
chore: improve type on import service (#4962)
## About the changes
Limit import type to what matters
2023-10-09 10:45:19 +02:00
David Leek
e065e2a455
feat: render segments changes in feature strategy update event messages (#4950)
## About the changes

Segment changes in predata and data columns were both showing the new
segments list

Adds formatting of what's changed with segments to feature strategy
update events, so when a user changes the strategy from using
constraints, to using segments instead, it's communicated in event
updates

results in: 

admin updated
[sample-toggle](http://localhost/projects/default/features/sample-toggle)
in project [default](http://localhost/projects/default) by updating
strategy Sample Strategy in development constraints from [userId is one
of (1,2,3)] to empty set of constraints; segments from empty set of
segments to (1)


Closes #
#4912 

### Important files

- `src/lib/services/feature-toggle-service.ts` - Segment changes in
preData and data
- `src/lib/addons/feature-event-formatter-md.ts` - Formatting segments

## Discussion points

This is an SR least effort PR - we should plan a task where we look at
how to render this list of segments in a more comprehensible way (it's
just rendering ids now)
2023-10-09 09:11:39 +02:00
Nuno Góis
e0faa3e842
fix: typo in enabled event (#4960)
Fixes a typo where we would send `disabled` for `enabled` events.


https://unleash-community.slack.com/archives/C03GWTN7XMG/p1696631381409369
2023-10-08 19:22:12 +02:00
Gastón Fournier
c3e8d743bc
chore: Improve UI Config type (#4959)
Fix link types
2023-10-06 16:31:39 +02:00
Mateusz Kwasniewski
8b0cf8b11d
feat: allow to delete dependencies when no orphans (#4952) 2023-10-06 13:39:16 +02:00
Gastón Fournier
52fa872fe6
chore: handle transactions already started at the controller layer (#4953)
## About the changes
This PR adds a method to safeguard us from opening a new transaction
while inside another transaction, resulting in two isolated transactions
that will not be atomic (if one fails, the other might still complete
successfully).


bbbe4d4637/lib/knex-builder/make-knex.js (L143C5-L144C88)

We're currently opening transactions at the controller layer 

2746bd1517/src/lib/features/export-import-toggles/export-import-controller.ts (L206-L208)

but in some other places, we do it at the store level:

2746bd1517/src/lib/db/access-store.ts (L577)


## Alternative
We can remove store-level transactions and move them to the controller
following this approach:


cb034976b9/src/lib/services/index.ts (L282-L284)


cb034976b9/src/lib/features/export-import-toggles/export-import-controller.ts (L206-L208)

This option is more expensive because we have to:
1. Write the factory methods that propagate the transaction to the
stores (therefore creating the store factory methods as well)
2. Identify the methods for creating the transactions at the store level
and backtrack the calls until the controller layer
2023-10-06 13:38:32 +02:00
Jonas Strømsodd
80c4a8277c
feat: allow defining initial admin user as env variable (#4927)
Closes #4560
2023-10-06 09:07:06 +02:00
David Leek
40ebb7ef95
fix: only delete SSO-synced group membership where membership was added by SSO sync (#4929)
Fixes an issue where SSO group sync would delete a syncable group that a
user was manually added to

## Discussion points

Is this the longterm fix for this? Or would we want another column in
the mapping table for future-proofing this?
2023-10-05 13:22:46 +02:00
Mateusz Kwasniewski
2c7587ba4b
feat: dependent features in playground (#4930) 2023-10-05 13:05:20 +02:00
Gastón Fournier
0da48cc0d1
chore: revamp transactional impl (#4916)
## About the changes
This transactional implementation decorates a service with a
transactional method that removes the need to start transactions in the
method using the service.

This is a gradual rollout with a feature toggle, just because
transactions are not easy.
2023-10-04 15:16:37 +02:00
Mateusz Kwasniewski
bc650ffe3f
feat: flag for clone dependencies (#4922) 2023-10-04 13:29:36 +02:00
Mateusz Kwasniewski
257414424d
feat: copy feature with parent (#4918) 2023-10-04 12:20:27 +02:00
Mateusz Kwasniewski
5141d9db67
feat: change project with feature dependencies (#4915) 2023-10-04 12:16:52 +02:00
andreas-unleash
b07c032d56
fix: update potentially-stale status dynamically (#4905)
Fixes 2 bugs:

- project-health-service keeping the feature types as an instance
variable and only updating it once was preventing real calculation to
happen if the lifetime value changed for a feature toggle type
- the ui was reading from a predefined map for the lifetime values so
they would never reflect the BE change

Closes #
[SR-66](https://linear.app/unleash/issue/SR-66/slack-question-around-potentially-stale-and-its-uses)

<img width="1680" alt="Screenshot 2023-10-02 at 14 37 17"
src="https://github.com/Unleash/unleash/assets/104830839/7bee8d4a-9054-4214-a1a2-11ad8169c3d5">
<img width="1660" alt="Screenshot 2023-10-02 at 14 37 06"
src="https://github.com/Unleash/unleash/assets/104830839/23bf55c7-a380-4423-a732-205ad81d5c3c">

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-10-04 12:47:16 +03:00
Mateusz Kwasniewski
88305a6388
feat: prevent delete and archive on parent feature (#4913) 2023-10-04 09:27:53 +02:00
Mateusz Kwasniewski
296cc9a9f2
feat: update dependency permission (#4910) 2023-10-04 09:27:14 +02:00
Mateusz Kwasniewski
751bc465d6
feat: generate orval types with dependent features (#4902) 2023-10-02 12:35:20 +02:00
Nuno Góis
521cc24a22
feat: add more events in integrations (#4815)
https://linear.app/unleash/issue/2-1253/add-support-for-more-events-in-the-slack-app-integration

Adds support for a lot more events in our integrations. Here is how the
full list looks like:

- ADDON_CONFIG_CREATED
- ADDON_CONFIG_DELETED
- ADDON_CONFIG_UPDATED
- API_TOKEN_CREATED
- API_TOKEN_DELETED
- CHANGE_ADDED
- CHANGE_DISCARDED
- CHANGE_EDITED
- CHANGE_REQUEST_APPLIED
- CHANGE_REQUEST_APPROVAL_ADDED
- CHANGE_REQUEST_APPROVED
- CHANGE_REQUEST_CANCELLED
- CHANGE_REQUEST_CREATED
- CHANGE_REQUEST_DISCARDED
- CHANGE_REQUEST_REJECTED
- CHANGE_REQUEST_SENT_TO_REVIEW
- CONTEXT_FIELD_CREATED
- CONTEXT_FIELD_DELETED
- CONTEXT_FIELD_UPDATED
- FEATURE_ARCHIVED
- FEATURE_CREATED
- FEATURE_DELETED
- FEATURE_ENVIRONMENT_DISABLED
- FEATURE_ENVIRONMENT_ENABLED
- FEATURE_ENVIRONMENT_VARIANTS_UPDATED
- FEATURE_METADATA_UPDATED
- FEATURE_POTENTIALLY_STALE_ON
- FEATURE_PROJECT_CHANGE
- FEATURE_REVIVED
- FEATURE_STALE_OFF
- FEATURE_STALE_ON
- FEATURE_STRATEGY_ADD
- FEATURE_STRATEGY_REMOVE
- FEATURE_STRATEGY_UPDATE
- FEATURE_TAGGED
- FEATURE_UNTAGGED
- GROUP_CREATED
- GROUP_DELETED
- GROUP_UPDATED
- PROJECT_CREATED
- PROJECT_DELETED
- SEGMENT_CREATED
- SEGMENT_DELETED
- SEGMENT_UPDATED
- SERVICE_ACCOUNT_CREATED
- SERVICE_ACCOUNT_DELETED
- SERVICE_ACCOUNT_UPDATED
- USER_CREATED
- USER_DELETED
- USER_UPDATED

I added the events that I thought were relevant based on my own
discretion. Know of any event we should add? Let me know and I'll add it
🙂

For now I only added these events to the new Slack App integration, but
we can add them to the other integrations as well since they are now
supported.

The event formatter was refactored and changed quite a bit in order to
make it easier to maintain and add new events in the future. As a
result, events are now posted with different text. Do we consider this a
breaking change? If so, I can keep the old event formatter around,
create a new one and only use it for the new Slack App integration.

I noticed we don't have good 404 behaviors in the UI for things that are
deleted in the meantime, that's why I avoided some links to specific
resources (like feature strategies, integration configurations, etc),
but we could add them later if we improve this.

This PR also tries to add some consistency to the the way we log events.
2023-09-29 16:11:59 +01:00
Kamil Zegier
486c174004
fix: Add condition for getting max revision id from store (#4549)
## About the changes
In our staging setup, we create ad-hoc environments and import Unleash
state from production. After unleash is deployed on such environment,
the import job kicks in and feeds Unleash instance with feature flags
from production.

Between Unleash being up and running and the import job running, some
applications start polling Unleash. They get an empty feature toggle
list with `meta.revisionId=0`. Then apps use this as part of `eTag`
header in subsequent requests. Even though after import Unleash server
finally has toggles to serve, it doesn't because it calculates _max
revision id_ based on toggle updates (not null `feature_name` column in
query) or `SEGMENT_UPDATED`.

This change adds an extra condition to query so feature toggles import
is considered something that should invalidate the cache.
2023-09-29 12:59:28 +00:00
Christopher Kolstad
6673d131fe
feat: biome lint (#4853)
This commit changes our linter/formatter to biome (https://biomejs.dev/)
Causing our prehook to run almost instantly, and our "yarn lint" task to
run in sub 100ms.

Some trade-offs:
* Biome isn't quite as well established as ESLint
* Are we ready to install a different vscode plugin (the biome plugin)
instead of the prettier plugin


The configuration set for biome also has a set of recommended rules,
this is turned on by default, in order to get to something that was
mergeable I have turned off a couple the rules we seemed to violate the
most, that we also explicitly told eslint to ignore.
2023-09-29 14:18:21 +02:00
Mateusz Kwasniewski
fbc571dffc
feat: events for dependencies (#4864) 2023-09-29 14:02:15 +02:00
Mateusz Kwasniewski
72cca4f450
feat: display dependencies and parents in project details (#4859) 2023-09-28 13:37:52 +02:00
Gastón Fournier
f9c3259083
fix: partial index on events announced (#4856)
## About the changes
Add partial index on events by announced. This should help avoid `Seq
Scan on events` when the majority of events are announced=true

---
Co-authored-by: Ivar Østhus <ivar@getunleash.io>
Co-authored-by: Gard Rimestad <gard@getunleash.io>
2023-09-28 10:21:16 +02:00
Gastón Fournier
e2ffbee468
chore: limit the amount of unannounced events we announce (#4845)
## About the changes
When the events table is large we might be doing a full table scan
searching for unannounced events. We spotted it due to a performance
alert and confirmed in AWS performance insights

![image](https://github.com/Unleash/unleash/assets/455064/8e815fa3-7a1b-4453-881a-98a148eae119)

The proposal is to limit this operation to 500 events (rule of thumb)
per round
f82ae354eb/src/lib/services/index.ts (L141-L147)
and also ignore the events older than a day (because it seems
reasonable)


## Discussion points
**Idea**: split the `events` table into `recent_events` and
`historical_events`. Recent can be anything from a day/week/month. This
would help with recurrent queries that rely on recent data from the
event's table such as optimal 304 calculation or event this scheduled
task that sends unannounced events.
2023-09-27 15:38:00 +02:00
Nuno Góis
87d9497be9
refactor: prefer eventService.storeEvent methods (#4830)
https://linear.app/unleash/issue/2-1403/consider-refactoring-the-way-tags-are-fetched-for-the-events

This adds 2 methods to `EventService`:
 - `storeEvent`;
 - `storeEvents`;

This allows us to run event-specific logic inside these methods. In the
case of this PR, this means fetching the feature tags in case the event
contains a `featureName` and there are no tags specified in the event.

This prevents us from having to remember to fetch the tags in order to
store feature-related events except for very specific cases, like the
deletion of a feature - You can't fetch tags for a feature that no
longer exists, so in that case we need to pre-fetch the tags before
deleting the feature.

This also allows us to do any event-specific post-processing to the
event before reaching the DB layer.
In general I think it's also nicer that we reference the event service
instead of the event store directly.

There's a lot of changes and a lot of files touched, but most of it is
boilerplate to inject the `eventService` where needed instead of using
the `eventStore` directly.

Hopefully this will be a better approach than
https://github.com/Unleash/unleash/pull/4729

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-09-27 14:23:05 +01:00
Mateusz Kwasniewski
a06037625d
refactor: expicit names in queries (#4850) 2023-09-27 15:17:04 +02:00
Mateusz Kwasniewski
87a81120d2
feat: feature admin API returns dependencies and children (#4848) 2023-09-27 15:07:20 +02:00
Mateusz Kwasniewski
fd8775f13d
feat: read model for dependent features (#4846) 2023-09-27 14:33:51 +02:00
Jaanus Sellin
960bc110ce
feat: enterprise project settings (#4844) 2023-09-27 13:10:10 +03:00
Mateusz Kwasniewski
76a2ec53f1
feat: Enforce one dependency (#4835) 2023-09-26 14:31:13 +02:00
Mateusz Kwasniewski
e030b67a19
feat: Api to list available parent options (#4833) 2023-09-26 14:03:24 +02:00
David Leek
0938b2e545
docs: improve datadog integration docs (#4802)
## About the changes

Improvement to the description of the datadog integration. Adds 2
missing event types, removes an event type that is deprecated and about
to be completely removed, adds missing description of extra json headers
and source type name, and adds description for the new configuration
option for JSON body support

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-09-26 11:15:22 +01:00
Mateusz Kwasniewski
d49ff03464
feat: delete all feature dependencies (#4832) 2023-09-26 09:38:34 +02:00
Fredrik Strand Oseberg
b919c445b4
feat: add kill switch for client metrics (#4829)
This PR adds a killswitch for client metrics that we can use to disable
metrics in our cloud offering.
2023-09-26 09:37:42 +02:00
Mateusz Kwasniewski
a9805b312b
feat: Delete dependency api (#4824) 2023-09-25 15:50:05 +02:00
Jaanus Sellin
2bf995e731
feat: context/segment usage private (#4826) 2023-09-25 15:50:44 +03:00
Jaanus Sellin
c84f39ad7c
fix: project mode count even if no settings exist (#4825) 2023-09-25 12:44:02 +03:00
Jaanus Sellin
f7d87a2339
feat: add project collaboration mode to prometheus (#4819) 2023-09-25 12:07:59 +03:00
Mateusz Kwasniewski
06ea70ef00
feat: enforce no transitive parents (#4818) 2023-09-25 10:12:32 +02:00
Nuno Góis
b9946ee35c
docs: Unleash Slack App integration (#4801)
https://linear.app/unleash/issue/2-1235/docs-slack-app-integration-documentation

This adds a new reference doc for the new Unleash Slack App integration
and marks the previous Slack integration as deprecated.

As a side-effect this PR also fixes an issue where we wouldn't be able
to delete tags with special characters.

---------

Co-authored-by: David Leek <david@getunleash.io>
Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2023-09-22 23:19:17 +01:00
Nuno Góis
91edae3ccf
refactor: contract event group deleted after #4816 (#4817)
As mentioned in
https://github.com/Unleash/unleash/pull/4816#discussion_r1334162284
2023-09-22 12:57:09 +01:00
Nuno Góis
b6b0f83e3d
feat: add group-deleted event (#4816)
Adds a missing `group-deleted` event.
2023-09-22 11:04:46 +01:00
Mateusz Kwasniewski
b4742df8be
feat: UI stub for adding dependent features (#4814) 2023-09-22 11:26:45 +02:00
Jaanus Sellin
ac018447f9
feat: optimize private projects for enterprise (#4812) 2023-09-22 11:54:33 +03:00
Nuno Góis
7eae1f8382
fix: datadog addon needs flagResolver (#4806)
Fixes what this breaks: https://github.com/Unleash/unleash/pull/4765 -
The Datadog integration needs a `flagResolver`.
2023-09-21 15:07:24 +02:00
Nuno Góis
ea9901c968
chore: GA (remove flag) for Slack App integration (#4765)
https://linear.app/unleash/issue/2-1405/remove-slackappaddon-feature-flag-and-make-this-ga

GA's the new Slack App integration by removing the feature flag 🚀
2023-09-21 13:55:58 +01:00
Jaanus Sellin
5e6ed0baac
feat: private projects handle in playground (#4791) 2023-09-21 11:22:29 +03:00
Tymoteusz Czech
18f7d0f9e1
Remove integrationsRework flag (#4770)
https://linear.app/unleash/issue/1-1359/remove-integrationsrework-flag
2023-09-20 16:27:40 +02:00
Mateusz Kwasniewski
85c7f84f8d
feat: Client api dependent features (#4778) 2023-09-20 11:53:43 +02:00
Nuno Góis
39b0c089d1
feat: simpler integration filters (#4766)
https://linear.app/unleash/issue/2-1407/remove-the-all-checkboxes-from-project-and-environment-filters

Simplifies integration event filters by removing the "ALL" checkboxes
from these components. Whether you opted to check the "ALL" checkbox, or
not to filter at all, the result is the same - The selected options
would act as a filter.

Includes some refactoring and clean up.


![image](https://github.com/Unleash/unleash/assets/14320932/2e30c5c5-12e1-4bc6-bd4a-8be4226d625d)
2023-09-20 09:21:30 +01:00
Jaanus Sellin
e4f8e1692a
feat: make application usage private through project (#4786) 2023-09-20 10:35:30 +03:00
Jaanus Sellin
e4577362bc
feat: move middleware to enterprise (#4767) 2023-09-20 08:37:52 +03:00
Gastón Fournier
bed0a2962f
chore: Improve access service iter 2 (#4779)
## About the changes
In https://github.com/Unleash/unleash/pull/4689 I forgot to add backward
compatibility for a public method that was being used in Enterprise.
2023-09-19 16:15:27 +02:00
Ivar Conradi Østhus
013efac46b
feat: open-source segments 🚀 (#4690)
We love all open-source Unleash users. in 2022 we built the [segment
capability](https://docs.getunleash.io/reference/segments) (v4.13) as an
enterprise feature, simplify life for our customers.

Now it is time to contribute it to the world 🌏

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2023-09-19 11:24:26 +00:00
David Leek
bff1bd1026
feat: implement optional json payload and template (#4752)
## About the changes

Adds optional support for specifying JSON templates for datadog message
payload


![image](https://github.com/Unleash/unleash/assets/707867/eb7c838a-7abf-441e-972e-ddd7ada07efa)


### 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? -->

`frontend/src/component/integrations/IntegrationForm/IntegrationParameters/IntegrationParameter/IntegrationParameterEnableWithDropdown.tsx`
- a new component comprising of a text field and a dropdown menu
`src/lib/addons/datadog.ts` - Where the integration is taking place

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

- Should I have implemented the new component type as a specifiable
addon parameter type in definitions? Felt a bit YAGNI/Premature
- Would like input on naming and the new component etc
2023-09-19 13:08:10 +02:00
Mateusz Kwasniewski
be7f0d8b4e
feat: Persist dependent features (#4772) 2023-09-19 13:01:38 +02:00
Gastón Fournier
12d9297f68
Revert "chore: improve access service" (#4773)
Reverts Unleash/unleash#4689 temporarily to figure out what's the
problem with the failing test
2023-09-19 11:03:16 +01:00
Gastón Fournier
2186e2b568
chore: improve access service (#4689)
## About the changes
This enables us to use names instead of permission ids across all our
APIs at the computational cost of searching for the ids in the DB but
improving the API user experience

## Open topics
We're using methods that are test-only and circumvent our business
logic. This makes our test to rely on assumptions that are not always
true because these assumptions are not validated frequently.

i.e. We are expecting that after removing a permission it's no longer
there, but to test this, the permission has to be there before:

78273e4ff3/src/test/e2e/services/access-service.e2e.test.ts (L367-L375)

But it seems that's not the case.

We'll look into improving this later.
2023-09-19 11:36:29 +02:00
Mateusz Kwasniewski
2843388673
refactor: feature oriented architecture for feature dependencies (#4771) 2023-09-19 11:23:21 +02:00
Mateusz Kwasniewski
59f2ae435e
feat: stub for create dependent features (#4769) 2023-09-19 10:04:05 +02:00
Fredrik Strand Oseberg
a71c3fe43a
feat: add ids to scheduled jobs (#4764)
* Adds an ID to scheduled jobs so that they are easier to identify in
the future
2023-09-18 16:31:42 +02:00