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

2544 Commits

Author SHA1 Message Date
sjaanus
0bee07ddec
chore: update texts 2024-11-28 13:48:07 +02:00
Mateusz Kwasniewski
61cb218d4d
fix: stop changing null to empty string when reading empty title (#8878) 2024-11-28 12:16:45 +01:00
David Leek
db02918a35
chore: make milestone_strategies.title nullable (#8864) 2024-11-27 09:16:24 +01:00
Jaanus Sellin
7906bfb177
chore: rename toggle to flag (#8854) 2024-11-26 09:57:43 +02:00
weekwith.me
d75c63b6e8
feat: Add PROJECT_ARCHIVED event to send message to Slack (#8848)
<!-- 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. -->

### Summary

- Add `PROJECT_ARCHIVED` event on `EVENT_MAP` to use
- Add a test case for `PROJECT_ARCHIVED` event formatting 
- Add `PROJECT_ARCHIVED` event when users choose which events they send
to Slack
- Fix Slack integration document by adding `PROJECT_ARCHIVED`

### Example

The example message looks like the image below. I covered my email with
a black rectangle to protect my privacy 😄
The link refers `/projects-archive` to see archived projects.

<img width="529" alt="Slack message example"
src="https://github.com/user-attachments/assets/938c639f-f04a-49af-9b4a-4632cdea9ca7">

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

I considered the reason why Unleash didn't implement to send
`PROJECT_ARCHIVED` message to Slack integration.

One thing I assumed that it is impossible to create a new project with
open source codes, which means it is only enabled in the enterprise
plan. However,
[document](https://docs.getunleash.io/reference/integrations/slack-app#events)
explains that users can send `PROJECT_CREATED` and `PROJECT_DELETED`
events to Slack, which are also available only in the enterprise plan,
hence it means we need to embrace all worthwhile events.

I think it is reasonable to add `PROJECT_ARCHIVED` event to Slack
integration because users, especially operators, need to track them
through Slack by separating steps, `_CREATED`, `_ARCHIVED`, and
`_DELETED`.
2024-11-25 14:33:50 +00:00
Christopher Kolstad
0f76a8a5a6
task: added unique index for release plan templates (#8846)
We want to prevent our users from defining multiple templates with the
same name. So this adds a unique index on the name column when
discriminator is template.
2024-11-25 11:25:55 +01:00
gitar-bot[bot]
9b4e646a98
[Gitar] Cleaning up stale flag: onboardingUI with value true (#8832)
[![Gitar](https://raw.githubusercontent.com/gitarcode/.github/main/assets/gitar-banner.svg)](https://gitar.ai)
  This automated PR permanently enables the `onboardingUI` feature flag.
  
  ---
This automated PR was generated by [Gitar](https://gitar.ai). View
[docs](https://gitar.ai/docs).

---------

Co-authored-by: Gitar <noreply@gitar.ai>
2024-11-22 11:55:24 +02:00
gitar-bot[bot]
6844984610
[Gitar] Cleaning up stale flag: trackLifecycleMetrics with value false (#8833)
[![Gitar](https://raw.githubusercontent.com/gitarcode/.github/main/assets/gitar-banner.svg)](https://gitar.ai)
This automated PR permanently removes the `trackLifecycleMetrics`
feature flag.
  
  ---
This automated PR was generated by [Gitar](https://gitar.ai). View
[docs](https://gitar.ai/docs).

Co-authored-by: Gitar <noreply@gitar.ai>
2024-11-22 11:54:28 +02:00
Thomas Heartman
5d553d0c7b
chore: allow openapi "date" format of strings (#8837)
This change opens up the possibility of using the "date" format for
strings in our OpenAPI spec. According to the official docs, [`date` is
a built-in string
format](https://swagger.io/docs/specification/v3_0/data-models/data-types/#string-formats).
2024-11-22 10:18:39 +01:00
Mateusz Kwasniewski
5c7f4d5fc1
feat: backfill archived features lifecycle (#8824) 2024-11-21 14:41:20 +01:00
Jaanus Sellin
c18952f374
feat: licensed users ui rework (#8809)
1. Moved link creation bottom next to licensed users view
2. Created licensed users component
3. Added flag

OSS:

![image](https://github.com/user-attachments/assets/cfb2b971-3861-4093-91a5-f3118b906029)
All others

![image](https://github.com/user-attachments/assets/e8cf712f-7e66-44f6-9965-1bb785e4f3fc)
2024-11-21 11:46:40 +02:00
Thomas Heartman
6d75ad73d4
fix: count lifecycle more accurately (#8816)
This PR fixes three things that were wrong with the lifecycle summary
count query:

1. When counting the number of flags in each stage, it does not take
into account whether a flag has moved out of that stage. So if you have
a flag that's gone through initial -> pre-live -> live, it'll be counted
for each one of those steps, not just the last one.

2. Some flags that have been archived don't have the corresponding
archived state row in the db. This causes them to count towards their
other recorded lifecycle stages, even when they shouldn't. This is
related to the previous one, but slightly different. Cross-reference the
features table's archived_at to make sure it hasn't been archived

3. The archived number should probably be all flags ever archived in the
project, regardless of whether they were archived before or after
feature lifecycles. So we should check the feature table's archived_at
flag for the count there instead
2024-11-21 08:12:53 +00:00
David Leek
4db1b5df03
chore: disable flagOVerviewRedesign on OSS (#8808) 2024-11-20 14:08:04 +01:00
Thomas Heartman
a59a031362
chore: minor cleanup of project health and status (#8806)
This PR:
- conditionally deprecates the project health report endpoint. We only
use this for technical debt dashboard that we're removing. Now it's
deprecated once you turn the simplifiy flag on.
- extracts the calculate project health function into the project health
functions file in the appropriate domain folder. That same function is
now shared by the project health service and the project status service.

For the last point, it's a little outside of how we normally do things,
because it takes its stores as arguments, but it slots in well in that
file. An option would be to make a project health read model and then
wire that up in a couple places. It's more code, but probably closer to
how we do things in general. That said, I wanted to suggest this because
it's quick and easy (why do much work when little work do trick?).
2024-11-20 13:59:44 +01:00
Thomas Heartman
04b2b488f6
chore(1-3133): change avg health to current health in project status (#8803)
This PR updates the project status service (and schemas and UI) to use
the project's current health instead of the 4-week average.

I nabbed the `calculateHealthRating` from
`src/lib/services/project-health-service.ts` instead of relying on the
service itself, because that service relies on the project service,
which relies on pretty much everything in the entire system.

However, I think we can split the health service into a service that
*does* need the project service (which is used for 1 of 3 methods) and a
service (or read model) that doesn't. We could then rely on the second
one for this service without too much overhead. Or we could extract the
`calculateHealthRating` into a shared function that takes its stores as
arguments. ... but I suggest doing that in a follow-up PR.

Because the calculation has been tested other places (especially if we
rely on a service / shared function for it), I've simplified the tests
to just verify that it's present.

I've changed the schema's `averageHealth` into an object in case we want
to include average health etc. in the future, but this is up for debate.
2024-11-20 11:41:45 +01:00
Thomas Heartman
20749cf771
1-3121: fix wrong counting for unhealthy flags (#8772)
This PR fixes the counting of unhealthy flags for the project status
page. The issue was that we were looking for `archived = false`, but we
don't set that flag in the db anymore. Instead, we set the `archived_at`
date, which should be null if the flag is unarchived.
2024-11-20 10:16:53 +01:00
Mateusz Kwasniewski
ec44c5b5e4
chore: remove personal dashboard UI flag (#8795) 2024-11-20 09:24:08 +01:00
Jaanus Sellin
4234020b8d
feat: backfill licensed users (#8791)
**This migration introduces a query that calculates the licensed user
counts and inserts them into the licensed_users table.**

**The logic ensures that:**

1. All users created up to a specific date are included as active users
until they are explicitly deleted.
2. Deleted users are excluded after their deletion date, except when
their deletion date falls within the last 30 days or before their
creation date.
3. The migration avoids duplicating data by ensuring records are only
inserted if they don’t already exist in the licensed_users table.


**Logic Breakdown:**

**Identify User Events (user_events):** Extracts email addresses from
user-related events (user-created and user-deleted) and tracks the type
and timestamp of the event. This step ensures the ability to
differentiate between user creation and deletion activities.
**Generate a Date Range (dates):** Creates a continuous range of dates
spanning from the earliest recorded event up to the current date. This
ensures we analyze every date, even those without events.
**Determine Active Users (active_emails):** Links dates with user events
to calculate the status of each email address (active or deleted) on a
given day. This step handles:

- The user's creation date.
- The user's deletion date (if applicable).

**Calculate Daily Active User Counts (result):** 
For each date, counts the distinct email addresses that are active based
on the conditions:

- The user has no deletion date.
- The user's deletion date is within the last 30 days relative to the
current date.
- The user's creation date is before the deletion date.
2024-11-20 09:10:07 +02:00
Thomas Heartman
b23dd940af
feat: add potentially stale filter to flags filter (#8798)
This PR adds the option to select potentially stale flags from the UI.

It also updates the name we use for parsing from the API: instead of
`potentiallyStale` we use `potentially-stale`. This follows the
precedent set by "kill switch" (which we send as 'kill-switch'), the
only other multi-word option that I could find in our filters.
2024-11-19 16:37:32 +02:00
Thomas Heartman
8da201aed8
feat: add potentiallyStale filter (#8784)
This PR adds support for the `potentiallyStale` value in the feature
search API. The value is added as a third option for `state` (in
addition to `stale` and `active`). Potentially stale is a subset of
active flags, so stale flags are never considered potentially stale,
even if they have the flag set in the db.

Because potentially stale is a separate column in the db, this
complicates the query a bit. As such, I've created a specialized
handling function in the feature search store: if the query doesn't
include `potentiallyStale`, handle it as we did before (the mapping has
just been moved). If the query *does* contain potentially stale, though,
the handling is quite a bit more involved because we need to check
multiple different columns against each other.

In essence, it's based on this logic:

when you’re searching for potentially stale flags, you should only get flags that are active and marked as potentially stale. You should not get stale flags.

This can cause some confusion, because in the db, we don’t clear the potentially stale status when we mark a flag as stale, so we can get flags that are both stale and potentially stale.

However, as a user, if you’re looking for potentially stale flags, I’d be surprised to also get (only some) stale flags, because if a flag is stale, it’s definitely stale, not potentially stale.

This leads us to these six different outcomes we need to handle when your search includes potentially stale and stale or active:

1. You filter for “potentially stale” flags only. The API will give you only flags that are active and marked as potentially stale. You will not get stale flags.
2. You filter only for flags that are not potentially stale. You will get all flags that are active and not potentially stale and all stale flags.
3. You search for “is any of stale, potentially stale”. This is our “unhealthy flags” metric. You get all stale flags and all flags that are active and potentially stale
4. You search for “is none of stale, potentially stale”: This gives you all flags that are active and not potentially stale. Healthy flags, if you will.
5. “is any of active, potentially stale”: you get all active flags. Because we treat potentially stale as a subset of active, this is the same as “is active”
6. “is none of active, potentially stale”: you get all stale flags. As in the previous point, this is the same as “is not active”
2024-11-19 14:53:01 +01:00
Thomas Heartman
82e752be45
1-3131: db migration to make potentially stale non-nullable (#8796)
This change adds a db migration to make the potentially_stale column
non-nullable. It'll set any NULL values to `false`.

In the down-migration, make the column nullable again.
2024-11-19 12:27:22 +01:00
Tymoteusz Czech
7820ca62ad
feat: show max count of sessions that users have to an admin (#8781)
Add info about large number of parallel sessions per user.
2024-11-18 15:15:56 +00:00
weekwith.me
695873132e
fix: Remove idNumberMiddleware and change to use parameters in validPath method instead (#8734)
## About the changes

- Remove `idNumberMiddleware` method and change to use `parameters`
field in `openApiService.validPath` method for the flexibility.
- Remove unnecessary `Number` type converting method and change them to
use `<{id: number}>` to specify the type.

### Reference

The changed response looks like the one below.

```JSON
{
   "id":"8174a692-7427-4d35-b7b9-6543b9d3db6e",
   "name":"BadDataError",
   "message":"Request validation failed: your request body or params contain invalid data. Refer to the `details` list for more information.",
   "details":[
      {
         "message":"The `/params/id` property must be integer. You sent undefined.",
         "path":"/params/id"
      }
   ]
}
```

I think it might be better to customize the error response, especially
`"You sent undefined."`, on another pull request if this one is
accepted. I prefer to separate jobs to divide the context and believe
that it helps reviewer easier to understand.
2024-11-18 15:08:07 +01:00
Thomas Heartman
a55a956772
1-3120: remove project connected environments (#8775)
Remove everything related to the connected environment count for project
status. We decided that because we don't have anywhere to link it to at
the moment, we don't want to show it yet.
2024-11-18 12:01:25 +01:00
Gastón Fournier
f297d861ea
chore: use memoized stats for version (#8776)
## About the changes
Builds on top of #8766 to use memoized results from stats-service.
Because stats service depends on version service, and to avoid making
the version service depend on stats service creating a cyclic
dependency. I've introduced a telemetry data provider. It's not clean
code, but it does the job.

After validating this works as expected I'll clean up

Added an e2e test validating that the replacement is correct:
[8475492](847549234c)
and it did:
https://github.com/Unleash/unleash/actions/runs/11861854341/job/33060032638?pr=8776#step:9:294

Finally, cleaning up version service
2024-11-18 10:47:29 +01:00
Gastón Fournier
39d227c33b
chore: improve the performance of our instance stats (#8766)
## About the changes
Our stats are used for many places and many times to publish prometheus
metrics and some other things.

Some of these queries are heavy, traversing all tables to calculate
aggregates.

This adds a feature flag to be able to memoize 1 minute (by default) how
long to keep the calculated values in memory.

We can use the key of the function to individually control which ones
are memoized or not and for how long using a numeric variant.

Initially, this will be disabled and we'll test in our instances first
2024-11-18 08:45:34 +00:00
Mateusz Kwasniewski
56db988a86
feat: log excessive logins (#8774) 2024-11-18 09:01:41 +01:00
Tymoteusz Czech
2ffff25a4a
test: device count without experimental env key (#8771) 2024-11-15 11:28:17 +00:00
Tymoteusz Czech
9d5fceb5bf
feat: show users with multiple parallel sessions (#8756) 2024-11-15 10:34:38 +00:00
Thomas Heartman
5d32d149cd
feat: add stale flag count to project status payload (#8751)
This PR adds stale flag count to the project status payload. This is
useful for the project status page to show the number of stale flags in
the project.
2024-11-14 14:10:10 +00:00
Tymoteusz Czech
3699646680
Restore additional feedback page (#8750)
Partial revert of 656483d819
Reuse search feedback.
2024-11-14 12:01:45 +02:00
Mateusz Kwasniewski
4fabf49706
feat: show deleted user sessions (#8749) 2024-11-14 10:30:31 +01:00
Jaanus Sellin
ec9be77383
feat: licensed users migration table (#8748) 2024-11-14 10:59:29 +02:00
Tymoteusz Czech
60fb647489
Count active browser sessions per user (#8736)
Show info on how many devices a user is logged in to an admin.
2024-11-13 15:49:25 +00:00
Mateusz Kwasniewski
bcbbd5c3e6
refactor: sessions for user without error (#8742) 2024-11-13 16:37:05 +01:00
Mateusz Kwasniewski
c6519cd95d
feat: delete stale user sessions (#8738) 2024-11-13 15:41:07 +01:00
Jaanus Sellin
d2daae5857
feat: prometheus now gets licensed users data (#8740)
We have the licensed users service implemented, this just spread the
data to prometheus.
2024-11-13 16:00:47 +02:00
Jaanus Sellin
940182aaf0
feat: introduce new term licensed users (#8737)
Introducing new term Licensed users.
Added query to read it from database and extensive tests to cover the
logic.
2024-11-13 14:32:58 +02:00
Mateusz Kwasniewski
61e297dd22
fix: password auth metrics (#8735) 2024-11-13 12:10:53 +01:00
Mateusz Kwasniewski
bb0403d551
feat: metrics for password and scim enabled (#8730) 2024-11-13 10:07:06 +01:00
Thomas Heartman
a964868e00
1-3093: round the project health (#8718)
This PR rounds the average health score we show for a project. With
fractional numbers, it'd often overflow the graph. It also doesn't
really give you much extra info, so we can round it. The rounding is
then used both in the text, in the graph, and to calculate the graph
fill percentage.

Before:

![image](https://github.com/user-attachments/assets/8d0fea3d-411d-42fb-bd80-d2683a63cdf2)

After:

![image](https://github.com/user-attachments/assets/f5c51742-8a2c-4b1a-bca3-7e812b9a1072)
2024-11-12 15:44:29 +02:00
Jaanus Sellin
c8bc40146a
feat: email will be stored hashed now for all users (#8720)
Adding email_hash column to users table.
We will update all existing users to have hashed email. 
All new users will also get the hash.

We are fine to use md5, because we just need uniqueness. We have emails
in events table stored anyways, so it is not sensitive.
2024-11-12 13:28:19 +02:00
Thomas Heartman
24a30e5ec3
Update orval for project status lifecycle (#8716)
Update schema and orval for project status to add lifecycle information
2024-11-12 09:28:27 +00:00
Nuno Góis
11d264541d
chore: add release plan events (#8715)
Adds new release plan events. 

These will be triggered by the new release plans API.
2024-11-12 08:59:36 +00:00
Thomas Heartman
8493bee272
feat(1-3085): hook up lifecycle read model data to endpoint (#8709)
This PR hooks up the project lifecycle summary read model to the service
and exposes the lifecycle summary data in the controller.
2024-11-11 11:22:28 +01:00
Christopher Kolstad
92f7acbfc4
task: added release plan template permissions to permissions.ts (#8708) 2024-11-11 11:05:19 +01:00
Christopher Kolstad
d417dda229
task: added migration for release plan template permissions (#8707)
Due to the cascade on the permission in role_permission, the down
migration does not need to remove the rows from role_permission.
2024-11-11 10:42:38 +01:00
Jaanus Sellin
961501567c
feat: remove excessing debug logging (#8701)
This debugger has been spamming me locally and I think this was
forgotten during some development. Removing.
2024-11-08 14:57:26 +02:00
Thomas Heartman
f92441fa50
chore: put project lifecycle read model in own directory + add fake (#8700)
This PR moves the project lifecycle summary to its own subdirectory and
adds files for types (interface) and a fake implementation.

It also adds a query for archived flags within the last 30 days taken
from `getStatusUpdates` in `src/lib/features/project/project-service.ts`
and maps the gathered data onto the expected structure. The expected
types have also been adjusted to account for no data.

Next step will be hooking it up to the project status service, adding
schema, and exposing it in the controller.
2024-11-08 11:33:03 +00:00
Thomas Heartman
b141981f91
1-3085: count flags in each stage (#8699)
This PR adds the next query to the lifecycle read model: how many flags
are in each stage.
2024-11-08 10:41:42 +00:00