1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
Commit Graph

2294 Commits

Author SHA1 Message Date
David Leek
74133395cc
chore: change integration events api tag to addons (#7932) 2024-08-20 14:00:58 +02:00
Mateusz Kwasniewski
02c8250905
fix: delete project action (#7934) 2024-08-20 11:46:12 +02:00
Thomas Heartman
7c774b22e8
fix: don't count flags multiple times (bonus: don't count non-project events) (#7931)
This PR fixes an issue where the number of flags belonging to a project
was wrong in the new getProjectsForAdminUi.

The cause was that we now join with the events table to get the most
"lastUpdatedAt" data. This meant that we got multiple rows for each
flag, so we counted the same flag multiple times. The fix was to use a
"distinct".

Additionally, I used this as an excuse to write some more tests that I'd
been thinking about. And in doing so also uncovered another bug that
would only ever surface in verrry rare conditions: if a flag had been
created in project A, but moved to project B AND the
feature-project-change event hadn't fired correctly, project B's last
updated could show data from that feature in project A.

I've also taken the liberty of doing a little bit of cleanup.
2024-08-20 09:31:45 +00:00
Mateusz Kwasniewski
4e11e57f7f
feat: project actions count metric (#7929) 2024-08-20 09:46:39 +02:00
David Leek
e714a7fe2b
feat:metrics for outgoing integrations (#7921) 2024-08-20 09:00:28 +02:00
Gastón Fournier
106e1d1376
fix: last seen metrics exceeding table limits (#7923)
## About the changes
When storing last seen metrics we no longer validate at insert time that
the feature exists. Instead, there's a job cleaning up on a regular
interval.

Metrics for features with more than 255 characters, makes the whole
batch to fail, resulting in metrics being lost.

This PR helps mitigate the issue while also logs long name feature names
2024-08-19 20:17:52 +00:00
gitar-bot[bot]
662c7ab4dc
[Gitar] Cleaning up stale flag: changeRequestPlayground with value true (#7920) 2024-08-19 15:33:55 +02:00
David Leek
205aeb5265
feat: feature flags for metrics and service name logging (#7916) 2024-08-19 14:16:31 +02:00
Thomas Heartman
7008070fc1
chore: impl empty results for fake project read model (#7912)
Implements empty responses for the fake project read model. Instead of
throwing a not implemented error, we'll return empty results.

This makes some of the tests in enterprise pass.
2024-08-19 10:53:05 +02:00
Thomas Heartman
f965246b83
chore: minor cleanup in new project read model (#7911)
This PR touches up a few small things in the project read model.

Fixes:
Use the right method name in the query/method timer for
`getProjectsForAdminUi`. I'd forgotten to change the timer name from the
original method name.

Spells the method name correctly for the `getMembersCount` timer (it
used to be `getMemberCount`, but the method is callled `getMembersCount`
with a plural s).

Changes:
Call the `getMembersCount` timer from within the `getMembersCount`
method itself. Instead of setting that timer up from two different
places, we can call it in the method we're timing. This wasn't a problem
previously, because the method was only called from a single place.
Assuming we always wanna time that query, it makes more sense to put the
timing in the actual method.
2024-08-19 10:13:30 +03:00
Thomas Heartman
79c3f8e975
refactor: switch projectStore.getProjects with projectReadModel.getProjectsForAdminUi in project service (#7904)
Hooks up the new project read model and updates the existing project
service to use it instead when the flag is on.

In doing:
- creates a composition root for the read model
- includes it in IUnleashStores
- updates some existing methods to accept either the old or the new
model
- updates the OpenAPI schema to deprecate the old properties
2024-08-19 08:46:50 +02:00
Thomas Heartman
abd077aaf7
chore: add flags projectListImprovements and useProjectReadModel (#7905)
These are both related to the work on the project list improvements
project.

The `projectListImprovements` flag will be used to enable disable the
new project list improvements.

The `useProjectReadModel` flag will be used to enable/disable the use
of the new project read model and is mostly a safety feature.
2024-08-16 11:54:11 +02:00
Thomas Heartman
0847a395dc
chore: Extract project read model (#7887)
Creates a new project read model exposing data to be used for the UI and
for the insights module.

The model contains two public methods, both based on the project store's
`getProjectsWithCounts`:
- `getProjectsForAdminUi`
- `getProjectsForInsights`

This mirrors the two places where the base query is actually in use
today and adapts the query to those two explicit cases.

The new `getProjectsForAdminUi` method also contains data for last flag
update and last flag metric reported, as required for the new projects
list screen.

Additionally the read model contains a private `getMembersCount` method,
which is also lifted from the project store. This method was only used
in the old `getProjectsWithCounts` method, so I have also removed the
method from the public interface.

This PR does *not* hook up the new read model to anything or delete any
existing uses of the old method.

## Why?

As mentioned in the background, this query is used in two places, both
to get data for the UI (directly or indirectly). This is consistent with
the principles laid out in our [ADR on read vs write
models](https://docs.getunleash.io/contributing/ADRs/back-end/write-model-vs-read-models).

There is an argument to be made, however, that the insights module uses
this as an **internal** read model, but the description of an internal
model ("Internal read models are typically narrowly focused on answering
one question and usually require simple queries compared to external
read models") does not apply here. It's closer to the description of
external read models: "View model will typically join data across a few
DB tables" for display in the UI.

## Discussion points

### What about properties on the schema that are now gone?

The `project-schema`, which is delivered to the UI through the
`getProjects` endpoint (and nowhere else, it seems), describes
properties that will no longer be sent to the front end, including
`defaultStickiness`, `avgTimeToProduction`, and more. Can we just stop
sending them or is that a breaking change?

The schema does not define them as required properties, so in theory,
not sending them isn't breaking any contracts. We can deprecate the
properties and just not populate them anymore.

At least that's my thought on it. I'm open to hearing other views.

### Can we add the properties in fewer lines of code? 

Yes! The [first commit in this PR
(b7534bfa)](b7534bfa07)
adds the two new properties in 8 lines of code.

However, this comes at the cost of diluting the `getProjectsWithCounts`
method further by adding more properties that are not used by the
insights module. That said, that might be a worthwhile tradeoff.

## Background

_(More [details in internal slack
thread](https://unleash-internal.slack.com/archives/C046LV6HH6W/p1723716675436829))_

I noticed that the project store's `getProjectWithCounts` is used in
exactly two places:

1. In the project service method which maps directly to the project
controller (in both OSS and enterprise).
2.  In the insights service in enterprise.

In the case of the controller, that’s the termination point. I’d guess
that when written, the store only served the purpose of showing data to
the UI.

In the event of the insights service, the data is mapped in
getProjectStats.
But I was a little surprised that they were sharing the same query, so I
decided to dig a little deeper to see what we’re actually using and what
we’re not (including the potential new columns). Here’s what I found.

Of the 14 already existing properties, insights use only 7 and the
project list UI uses only 10 (though the schema mentions all 14 (as far
as I could tell from scouring the code base)). Additionally, there’s two
properties that I couldn’t find any evidence of being used by either:
-   default stickiness
-   updatedAt (this is when the project was last updated; not its flags)
2024-08-16 10:52:57 +02:00
gitar-bot[bot]
977f969b80
[Gitar] Cleaning up stale flag: improveCreateFlagFlow with value true (#7895)
[![Gitar](https://raw.githubusercontent.com/gitarcode/.github/main/assets/gitar-banner.svg)](https://gitar.co)
  
  ---
This automated PR was generated by [Gitar](https://gitar.co). View
[docs](https://gitar.co/docs).

---------

Co-authored-by: Gitar <noreply@gitar.co>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2024-08-15 15:53:36 +03:00
Mateusz Kwasniewski
30cbde573b
feat: return archived at in project overview (#7888) 2024-08-15 14:15:06 +02:00
gitar-bot[bot]
413df42555
[Gitar] Cleaning up stale flag: commandBarUI with value true (#7894)
[![Gitar](https://raw.githubusercontent.com/gitarcode/.github/main/assets/gitar-banner.svg)](https://gitar.co)
  
  ---
This automated PR was generated by [Gitar](https://gitar.co). View
[docs](https://gitar.co/docs).

---------

Co-authored-by: Gitar <noreply@gitar.co>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2024-08-15 14:29:07 +03:00
Mateusz Kwasniewski
c2e6f74bfa
fix: exclude archived features in segments count (#7897) 2024-08-15 13:27:18 +02:00
David Leek
cf83043d8a
feat: resolve useragent source and add as source label to metrics (#7883) 2024-08-15 13:25:42 +02:00
Jaanus Sellin
183a9fc737
feat: support private projects for event search (#7884)
Adds private projects support for event search. Unit test should cover
the usecases.
2024-08-15 12:51:04 +03:00
Mateusz Kwasniewski
a89f05181d
fix: exclude archived features in segments count (#7886) 2024-08-15 11:32:46 +02:00
Tymoteusz Czech
3baeb4c541
feat: dialogs for project revive and delete (#7863)
Dialog needed to confirm revive/delete actions
2024-08-15 07:25:49 +00:00
Jaanus Sellin
627768b96c
feat: start using event service composition root (#7871)
During adding privateProjectsChecker, I saw that events composition root
is not used almost at all.
Refactored code so we do not call new EventService anymore.
2024-08-15 08:33:46 +03:00
Mateusz Kwasniewski
94605646f6
fix: always provide empty segments list in feature env strategies (#7880)
<!-- 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

When reading feature env strategies and there's no segments it returns
empty list of segments now. Previously it was undefined leading to
overly verbose change request diffs.

<img width="669" alt="Screenshot 2024-08-14 at 16 06 14"
src="https://github.com/user-attachments/assets/1ac6121b-1d6c-48c6-b4ce-3f26c53c6694">


### 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? -->
2024-08-14 19:13:06 +02:00
Simon Hornby
f276728688
feat: allow editing root role/description on SCIM group (#7874) 2024-08-14 15:11:56 +02:00
Mateusz Kwasniewski
94a05eecc0
fix: change request enabled check should ignore disabled envs (#7869) 2024-08-14 13:13:31 +02:00
Gastón Fournier
cac621c450
fix: messed up on merge-conflicts (#7873)
When fixing conflicts accidentally I've undone my changes
2024-08-14 12:00:57 +02:00
Mateusz Kwasniewski
cb6ba743ac
fix: make archivedAt nullable (#7872) 2024-08-14 11:36:48 +02:00
Mateusz Kwasniewski
b042afb7dd
feat: archived projects query improved (#7866) 2024-08-14 11:01:17 +02:00
Nuno Góis
585eb30730
chore: initial admin email (#7795)
https://linear.app/unleash/issue/2-2518/figure-out-how-to-create-the-initial-admin-user-in-unleash

The logic around `initAdminUser` that was introduced in
https://github.com/Unleash/unleash/pull/4927 confused me a bit. I wrote
new tests with what I assume are our expectations for this feature and
refactored the code accordingly, but would like someone to confirm that
it makes sense to them as well.

The logic was split into 2 different methods: one to get the initial
invite link, and another to send a welcome email. Now these two methods
are more granular than the previous alternative and can be used
independently of creating a new user.

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2024-08-14 10:05:11 +02:00
Mateusz Kwasniewski
4738d4a61f
feat: query archived projects (#7862) 2024-08-13 15:33:31 +02:00
gitar-bot[bot]
caac8f3fcb
[Gitar] Cleaning up stale flag: parseProjectFromSession with value true (#7854)
[![Gitar](https://raw.githubusercontent.com/gitarcode/.github/main/assets/gitar-banner.svg)](https://gitar.co)
  
  ---
This automated PR was generated by [Gitar](https://gitar.co). View
[docs](https://gitar.co/docs).

Co-authored-by: Gitar <noreply@gitar.co>
2024-08-13 14:15:59 +03:00
Jaanus Sellin
bbdb5e635b
feat: update feature completed payload to have boolean instead of string (#7855)
For easy gitar integration, we need to have boolean in the event
payload.
We might rethink it when we add variants, but currently enabled with
variants is not used.
2024-08-13 12:43:49 +03:00
Mateusz Kwasniewski
bb30032f2e
feat: revive project (#7847) 2024-08-13 10:25:42 +02:00
Mateusz Kwasniewski
fcf1329816
feat: exclude archived projects from insights and project stats (#7843) 2024-08-13 10:00:04 +02:00
Thomas Heartman
0934c6ccd8
fix: search events by user ID, not by user name (#7846)
Changes the event search handling, so that searching by user uses the
user's ID, not the "createdBy" name in the event. This aligns better
with what the OpenAPI schema describes it.
2024-08-13 09:32:51 +02:00
Mateusz Kwasniewski
9b781b781a
feat: prevent move feature to archived project (#7839) 2024-08-12 13:29:38 +02:00
Mateusz Kwasniewski
67fa28f05a
feat: prevent revive flag/flags in archived project (#7826) 2024-08-12 13:29:24 +02:00
Jaanus Sellin
624c6ce9c3
feat: events table type column index (#7838)
Adding index on even table type column, since we are running queries on
top of it.
2024-08-12 13:46:27 +03:00
Tymoteusz Czech
e77bb1b2e7
Fix: time to production (#7835)
- filter out time to production data points of `0 days to production`
- allow for gathering data for quickly enabled feature flags
2024-08-12 09:47:06 +00:00
Jaanus Sellin
ea057d1777
feat: add index on events created at (#7836)
After adding an index, the time for the new event search on 100k events
decreased from 5000ms to 4ms. This improvement is due to the query using
an index scan instead of a sequence scan.
2024-08-12 12:46:50 +03:00
Gastón Fournier
f9d077209f
fix: after encryption some emails end up being too long (#7828)
Encountered this case after encrypting an already long email address.
This should mitigate the issue in demo instance. I don't think it's a
big issue to ignore the length when validating an email address cause
this is already limited at the DB layer by the column length
2024-08-09 19:18:19 +02:00
Jaanus Sellin
3fbb64511a
fix: event creators, distinct on two users with same id (#7824)
Previously distinct was not working properly, because we were joining
users table.
You needed to do distinctOn. Now fixed.
2024-08-09 14:32:55 +03:00
Thomas Heartman
1db222a5b9
feat: add collaborators to feature schema (#7821)
Update the feature schema to include collaborator information
2024-08-09 11:18:37 +02:00
gitar-bot[bot]
5aaa4920dd
chore: [Gitar] Cleaning up stale flag: featureCollaborators with value true (#7820)
[![Gitar](https://raw.githubusercontent.com/gitarcode/.github/main/assets/gitar-banner.svg)](https://gitar.co)
  
  ---
This automated PR was generated by [Gitar](https://gitar.co). View
[docs](https://gitar.co/docs).

---------

Co-authored-by: Gitar <noreply@gitar.co>
Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2024-08-09 11:12:26 +02:00
Jaanus Sellin
2f92dac14e
feat: event creators (#7809)
Adds an endpoint to return all event creators.

An interesting point is that it does not return the user object, but
just created_by as a string. This is because we do not store user IDs
for events, as they are not strictly bound to a user object, but rather
a historical user with the name X.
2024-08-09 10:32:31 +03:00
Mateusz Kwasniewski
bde81b940c
feat: prevent adding flags to archived project (#7811) 2024-08-09 09:00:19 +02:00
Tymoteusz Czech
413da2aa27
fix: don't show link stubs in slack notifications (#7810)
Slack is trying to add not useful link previews
2024-08-08 15:29:42 +02:00
Mateusz Kwasniewski
b65e593c23
chore: remove featureLifecycle and featureLifecycleMetrics flags (#7808) 2024-08-08 13:45:23 +02:00
Mateusz Kwasniewski
fffed5d8dc
feat: filter out archived projects from the main project list (#7803) 2024-08-08 13:22:44 +02:00
Mateusz Kwasniewski
3fe385e127
chore: remove flagCreator flag (#7807) 2024-08-08 12:19:32 +02:00