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

2119 Commits

Author SHA1 Message Date
Christopher Kolstad
af54e272d2
fix: added a check to avoid double counting (#6925)
Due to how we handle redirects of embedded proxy, we ended up counting
the same request twice. This PR adds a boolean to res.locals which we
then check if set to avoid double counting.
2024-04-25 10:08:23 +02:00
Mateusz Kwasniewski
574eb284b9
fix: client metrics structure lifecycle (#6924) 2024-04-25 09:27:20 +02:00
Tymoteusz Czech
477da7d514
Project owners read model - db read (#6916)
Implementation of the logic for fetching project owners.

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2024-04-25 09:23:11 +02:00
Mateusz Kwasniewski
f5061bc3ff
feat: return lifecycle state in feature overview (#6920) 2024-04-24 14:27:26 +02:00
Jaanus Sellin
e0ec5ed4b0
fix: now metrics in search will be aggregated across applications (#6915) 2024-04-24 12:10:39 +03:00
Jaanus Sellin
d578deab7f
chore: remove new frontend api feature flag (#6906)
The flag has been 100% for a bit now, we need to prepare for GA.
2024-04-24 09:15:57 +03:00
Gastón Fournier
8ec9a0f62d
chore: remove log (#6911)
This log is also not needed because we have the API status code 401 that
shows the same data
2024-04-23 12:48:34 +00:00
Gastón Fournier
61a689ccc7
chore: remove unnecessary logs (#6909) 2024-04-23 12:27:38 +00:00
Gastón Fournier
3e4ed38e2b
chore: remove logs for secret and change invalid token query logic (#6907)
## About the changes
What's going on is the following:
1. When a token is not found in the token's cache we try to find it in
the db
2. To prevent a denial of service attack using invalid tokens, we cache
the invalid tokens so we don't hit the db.
3. The issue is that we stored this token in the cache regardless we
found it or not. And if the token was valid the first time we'd add a
timestamp to avoid querying this token again the next time.
4. The next iteration the token should be in the cache:
54383a6578/src/lib/services/api-token-service.ts (L162)
but for some reason it is not and therefore we have to make a query. But
this is where the query prevention mechanism kicks in because it finds
the token in the cache and kicks us out. This PR fixes this by only
storing in the cache for misses if not found:
54383a6578/src/lib/services/api-token-service.ts (L164-L165)

The token was added to the cache because we were not checking if it had
expired. Now we added a check and we also have a log for expired tokens.
Some improvement opportunities:
- I don't think we display that a token has expired in the UI which
probably led to this issue
- When a token expired we don't display a specific error message or
error response saying that which is not very helpful for users
2024-04-23 11:44:59 +00:00
Gastón Fournier
dec107a597
chore: add a bunch of logs to validate api token validation behavior (#6905)
This change is meant to test something in sandbox. It will be reverted
after the investigation.
2024-04-23 11:14:54 +02:00
00Chaotic
13aa58e0e9
feat: allow admin login using demo auth (#6808)
This PR introduces a configuration option (`authentication.demoAllowAdminLogin`) that allows you to log in as admin when using demo authentication. To do this, use the username `admin`. 

## About the changes
The `admin` user currently cannot be accessed in `demo` authentication
mode, as the auth mode requires only an email to log in, and the admin
user is not created with an email. This change allows for logging in as
the admin user only if an `AUTH_DEMO_ALLOW_ADMIN_LOGIN` is set to `true`
(or the corresponding `authDemoAllowAdminLogin` config is enabled).

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

### Important files

[demo-authentication.ts](https://github.com/Unleash/unleash/compare/main...00Chaotic:unleash:feat/allow_admin_login_using_demo_auth?expand=1#diff-c166f00f0a8ca4425236b3bcba40a8a3bd07a98d067495a0a092eec26866c9f1R25)


## Discussion points
Can continue discussion of [this
comment](https://github.com/Unleash/unleash/pull/6447#issuecomment-2042405647)
in this PR.

---------

Co-authored-by: Thomas Heartman <thomasheartman+github@gmail.com>
2024-04-23 08:39:33 +02:00
Thomas Heartman
9ba6be6000
feat: add environments to project created payload (#6901)
This commit adds an `environments` property to the project created
payload. The list contains only the projects that the project has
enabled.

The point of adding it is that it gives you a better overview over
what you have created.
2024-04-22 14:37:45 +02:00
Thomas Heartman
b8380a0b5b
chore: add the projectListNewCards flag (#6898)
This PR adds the `projectListNewCards` flag to the constant defined in
`experimental.ts`. This should allow the API to pass that value to the
front end.
2024-04-22 10:50:21 +00:00
Gastón Fournier
ef91a5a8da
feat: crud time queries (#6895)
## About the changes
Add time metrics to relevant queries:
- get
- getAll
- bulkInsert
- count
- exists
- get

Ignored because might not be that relevant:
- insert
- delete
- deleteAll
- update
2024-04-22 09:31:37 +02:00
Gastón Fournier
126b78896e
feat: make edge use token's cache (#6893)
## About the changes
This PR removes the feature flag `queryMissingTokens` that was fully
rolled out.
It introduces a new way of checking edgeValidTokens controlled by the
flag `checkEdgeValidTokensFromCache` that relies in the cached data but
hits the DB if needed.

The assumption is that most of the times edge will find tokens in the
cache, except for a few cases in which a new token is queried. From all
tokens we expect at most one to hit the DB and in this case querying a
single token should be better than querying all the tokens.
2024-04-19 15:40:15 +02:00
Christopher Kolstad
ff6297d338
feat: Make Database SSL Configurable through files (#6892)
This makes it configurable either through a single JSON file with all
three certificates as separate keys or via separate files per
ca/cert/key key.

fixes #6718
2024-04-19 14:38:33 +02:00
Gastón Fournier
e6764a43c0
chore: Remove unused type (#6887)
This type was added to try to consolidate events now we're moving in a
different direction and this type is not used.
2024-04-18 16:52:14 +02:00
Christopher Kolstad
cf2bd28ff6
feat: use audit info in events (#6872)
I've tried to use/add the audit info to all events I could see/find.
This makes this PR necessarily huge, because we do store quite a few
events. 

I realise it might not be complete yet, but tests
run green, and I think we now have a pattern to follow for other events.
2024-04-18 16:32:35 +02:00
Thomas Heartman
bf4c29b621
chore: add enterprise extension point to enable change requests on project creation (#6881)
This PR adds an optional function parameter to the `createProject`
function that is intended to enable change requests for the newly
created project.

The assumption is that all the logic within will be decided in the
enterprise impl. The only thing we want to verify here is that it is
called after the project has been created.
2024-04-18 13:49:08 +02:00
Thomas Heartman
bda5eda224
chore: select enabled environments on project creation (#6869)
This PR adds functionality to the `createProject` function to choose
which environments should be enabled when you create a new project. The
new `environments` property is optional and omitting it will make it
work exactly as it does today.

The current implementation is fairly strict. We have some potential
ideas to make it easier to work with, but we haven't agreed on any yet.
Making it this strict means that we can always relax the rules later.

The rules are (codified in tests):
- If `environments` is not provided, all non-deprecated environments are
enabled
- If `environments` is provided, only the environments listed are
enabled, regardless of whether they're deprecated or not
- If `environments` is provided and is an empty array, the service
throws an error. The API should dilsallow that via the schema anyway,
but this catches it in case it sneaks in some other way.
- If `environments` is provided and contains one or more environments
that don't exist, the service throws an error. While we could ignore
them, that would lead to more complexity because we'd have to also check
that the at least one of the environments is valid. It also leads to
silent ignoring of errors, which may or may not be good for the user
experience.

The API endpoint for this sits in enterprise, so no customer-facing
changes are part of this.
2024-04-18 13:48:40 +02:00
Tymoteusz Czech
fd4bcfffa5
Feat: new projects list (#6873)
New card view for list of projects.

Co-authored-by: Thomas Heartman <thomas@getunleash.io>
2024-04-18 11:20:01 +02:00
Christopher Kolstad
633cae6f0d
feat: added IAuditUser to request with middleware (#6857)
Adds a middleware which adds our needed audit info as a separate object
to the request.
2024-04-18 10:13:40 +02:00
Jaanus Sellin
06f2f06f38
feat: optimize applications overview query (#6883)
We encountered an issue with a customer because this query was returning
3 million rows. The problem arose from each instance reporting
approximately 100 features, with a total of 30,000 instances. The query
was joining these, thus multiplying the data. This approach was fine for
a reasonable number of instances, but in this extreme case, it did not
perform well.

This PR modifies the logic; instead of performing outright joins, we are
now grouping features by environment into an array, resulting in just
one row returned per instance.

I tested locally with the same dataset. Previously, loading this large
instance took about 21 seconds; now it has reduced to 2 seconds.
Although this is still significant, the dataset is extensive.
2024-04-18 09:02:33 +03:00
Thomas Heartman
ef23cc0cc1
chore: add flag for improved project creation (#6870)
This PR adds the flag for the improved project creation flag to Unleash.
2024-04-16 14:57:52 +02:00
Jaanus Sellin
023e1594e9
feat: validate that id is number or we throw our our source code (#6860)
Previously, we were not validating that the ID was a number, which
sometimes resulted in returning our database queries (source code) to
the frontend. Now, we have validation middleware.
2024-04-16 15:48:57 +03:00
Jaanus Sellin
f45593176c
feat: start extracting project from session object (#6856)
Previously, we were extracting the project from the token, but now we
will retrieve it from the session, which contains the full list of
projects.

This change also resolves an issue we encountered when the token was a
multi-project token, formatted as []:dev:token. Previously, it was
unable to display the exact list of projects. Now, it will show the
exact project names.
2024-04-16 15:47:45 +03:00
gitar-bot[bot]
8dbd680326
[Gitar] Cleaning up stale feature flag: stripClientHeadersOn304 with value true (#6868)
<details>
  <summary>Feature Flag Cleanup</summary>

  | Stale Flag |  Value  |
  | ---------- | ------- |
  |   stripClientHeadersOn304   | true |

  </details>

  <details>
  <summary>Trigger</summary>

  https://github.com/Unleash/unleash/issues/6559#issuecomment-2058848984

  </details>

  <details>
  <summary>Bot Commands</summary>

`@gitar-bot cleanup stale_flag=value` will cleanup a stale feature flag.
Replace `stale_flag` with the name of the stale feature flag and `value`
with either `true` or `false`.

  </details>

---------

Co-authored-by: Gitar Bot <noreply@gitar.co>
2024-04-16 13:42:31 +02:00
Nuno Góis
31bf7825c0
chore: SCIM guard for groups (#6845)
https://linear.app/unleash/issue/2-2111/api-should-not-allow-manual-management-of-scim-managed-groups-in

Introduces a SCIM guard for SCIM groups. SCIM groups should be managed
exclusively by the SCIM client, not Unleash.

We decided to be restrictive for now, completely covering all of the
write methods, but may fine-tune some of this at a later stage.

Will eventually be followed up by a UI-centric PR.
2024-04-12 10:01:57 +01:00
Nuno Góis
f4ef06f69b
chore: SCIM guard for users (#6836)
https://linear.app/unleash/issue/2-2093/api-should-not-allow-manual-management-of-scim-managed-users-in

Introduces a SCIM guard for SCIM users. SCIM users should be managed
exclusively by the SCIM client, not Unleash.

We decided to be restrictive for now, completely covering all of the
write methods, but may fine-tune some of this at a later stage.

Will eventually be followed up by a UI-centric PR.
2024-04-12 08:23:35 +01:00
David Leek
88b5bfcb29
chore(ui): add a separate feature flag for traffic visibility UI (#6832)
## About the changes

Adds a separate feature flag for the traffic data usage UI
2024-04-11 10:37:53 +02:00
Thomas Heartman
1a05bdad2e
chore: add flag for project list filter updates (#6825)
This PR adds the flag for the project list filter feature we're working
on at the moment.
2024-04-10 14:40:50 +02:00
Gastón Fournier
e6ec78fdac
chore: job-service handle exceptions (#6818)
## About the changes
This allows failed functions to record that they've failed when wrapped
with a job.
2024-04-10 14:34:16 +02:00
David Leek
02b3805ca6
Feat/configure scheduled created by migration (#6821)
## About the changes

- Removes the feature flag for the created_by migrations.
- Adds a configuration option in IServerOption for
`ENABLE_SCHEDULED_CREATED_BY_MIGRATION` that defaults to `false`
- the new configuration option when set on startup enables scheduling of
the two created_by migration services (features+events)
- Removes the dependency on flag provider in EventStore as it's no
longer needed
- Adds a brief description of the new configuration option in
`configuring-unleash.md`
- Sets the events created_by migration interval to 15 minutes, up from
2.

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2024-04-10 14:12:58 +02:00
Gastón Fournier
f3cd1be9df
chore: remove response time metrics fix (#6779)
## About the changes
The feature `responseTimeMetricsFix` has been enabled for a while. Since
it's released in 5.11 this prepares the removal for the next major
version.


![image](https://github.com/Unleash/unleash/assets/455064/cc49ba3f-f775-45b2-998c-ef7a02c537b4)
2024-04-10 12:34:05 +02:00
Gastón Fournier
0a2d40fb8b
feat: allow schedulers to run in a single node (#6794)
## About the changes
This PR provides a service that allows a scheduled function to run in a
single instance. It's currently not in use but tests show how to wrap a
function to make it single-instance:

65b7080e05/src/lib/features/scheduler/job-service.test.ts (L26-L32)

The key `'test'` is used to identify the group and most likely should
have the same name as the scheduled job.

---------

Co-authored-by: Christopher Kolstad <chriswk@getunleash.io>
2024-04-10 11:47:22 +02:00
Thomas Heartman
cfd9e4894a
chore: Establish a baseline for the number of envs disabled per project (#6807)
This PR adds a counter in Prometheus for counting the number of
"environment disabled" events we get per project. The purpose of this is
to establish a baseline for one of the "project management UI" project's
key results.

## On gauges vs counters

This PR uses a counter. Using a gauge would give you the total number of
envs disabled, not the number of disable events. The difference is
subtle, but important.

For projects that were created before the new feature, the gauge might
be appropriate. Because each disabled env would require at least one
disabled event, we can get a floor of how many events were triggered for
each project.

However, for projects created after we introduce the planned change,
we're not interested in the total envs anymore, because you can disable
a hundred envs on creation with a single action. In this case, a gauge
showing 100 disabled envs would be misleading, because it didn't take
100 events to disable them.

So the interesting metric here is how many times did you specifically
disable an environment in project settings, hence the counter.

## Assumptions and future plans

To make this easier on ourselves, we make the follow assumption: people
primarily disable envs **when creating a project**.

This means that there might be a few lagging indicators granting some
projects a smaller number of events than expected, but we may be able to
filter those out.

Further, if we had a metric for each project and its creation date, we
could correlate that with the metrics to answer the question "how many
envs do people disable in the first week? Two weeks? A month?". Or
worded differently: after creating a project, how long does it take for
people to configure environments?

Similarly, if we gather that data, it will also make filtering out the
number of events for projects created **after** the new changes have
been released much easier.

The good news: Because the project creation metric with dates is a
static aggregate, it can be applied at any time, even retroactively, to
see the effects.
2024-04-10 08:49:15 +02:00
andreas-unleash
5a5d909137
fix: environment_type_trends table data (#6796)
Creates a migration to fix the environment_type_trends table data.


---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2024-04-09 12:37:05 +03:00
Mateusz Kwasniewski
7cb9910b05
feat: handle invalid metrics (#6795) 2024-04-08 12:09:20 +02:00
Mateusz Kwasniewski
9dc9fb3586
feat: Feature lifecycle sql store (#6790) 2024-04-08 08:54:41 +02:00
Thomas Heartman
c59d28ad6c
feat: playground api returns removed context values under a new warnings property (#6784)
This PR expands upon #6773 by returning the list of removed properties
in the API response. To achieve this, I added a new top-level `warnings`
key to the API response and added an `invalidContextProperties` property
under it. This is a list with the keys that were removed.

## Discussion points

**Should we return the type of each removed key's value?** We could
expand upon this by also returning the type that was considered invalid
for the property, e.g. `invalidProp: 'object'`. This would give us more
information that we could display to the user. However, I'm not sure
it's useful? We already return the input as-is, so you can always
cross-check. And the only type we allow for non-`properties` top-level
properties is `string`. Does it give any useful info? I think if we want
to display this in the UI, we might be better off cross-referencing with
the input?

**Can properties be invalid for any other reason?** As far as I can
tell, that's the only reason properties can be invalid for the context.
OpenAPI will prevent you from using a type other than string for the
context fields we have defined and does not let you add non-string
properties to the `properties` object. So all we have to deal with are
top-level properties. And as long as they are strings, then they should
be valid.

**Should we instead infer the diff when creating the model?** In this
first approach, I've amended the `clean-context` function to also return
the list of context fields it has removed. The downside to this approach
is that we need to thread it through a few more hoops. Another approach
would be to compare the input context with the context used to evaluate
one of the features when we create the view model and derive the missing
keys from that. This would probably work in 98 percent of cases.
However, if your result contains no flags, then we can't calculate the
diff. But maybe that's alright? It would likely be fewer lines of code
(but might require additional testing), although picking an environment
from feels hacky.
2024-04-08 08:47:22 +02:00
Mateusz Kwasniewski
e868c3291f
feat: feature lifecycle metrics from event bus (#6789) 2024-04-05 15:34:08 +02:00
Mateusz Kwasniewski
28a3a064b9
feat: Feature lifecycle controller (#6788) 2024-04-05 13:57:27 +02:00
Mateusz Kwasniewski
efda70ac5d
feat: feature lifecycle usage behind a flag (#6786) 2024-04-05 13:42:03 +02:00
Mateusz Kwasniewski
e2fabcafd4
feat: initial design for feature lifecycle service (#6777) 2024-04-05 11:47:30 +02:00
Thomas Heartman
ac6c05def1
fix: handle objects in top-level context in playground (#6773)
Don't include invalid context properties in the contexts that we
evaluate.

This PR removes any non-`properties` fields that have a non-string
value.

This prevents the front end from crashing when trying to render an
object.

Expect follow-up PRs to include more warnings/diagnostics we can show to
the end user to inform them of what fields have been removed and why.
2024-04-05 08:56:57 +02:00
andreas-unleash
e9f9cd1147
chore: add default implementation to fake methods (#6776)
Mock implements function in fake project store

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2024-04-04 16:02:55 +03:00
Mateusz Kwasniewski
0422e5b5b0
feat: private projects in application overview (#6775) 2024-04-04 14:56:21 +02:00
Gastón Fournier
d7ab8863f0
chore: cache query misses to protect against DDoS (#6771)
## About the changes
This PR establishes a simple yet effective mechanism to avoid DDoS
against our DB while also protecting against memory leaks.

This will enable us to release the flag `queryMissingTokens` to make our
token validation consistent across different nodes

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2024-04-03 15:43:11 +02:00
andreas-unleash
d466f608c2
chore: convert newContextFieldUI to kill switch (#6752)
Converts `newContextFieldUI` release flag to
`disableShowContextFieldSelectionValues` kill switch.

The kill switch controls whether we show the value selection above the
search filed when > 100 values

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2024-04-03 15:02:05 +02:00
Mateusz Kwasniewski
501acd080a
chore: project overview refactor feedback behind a flag (#6772) 2024-04-03 13:55:12 +02:00
Nuno Góis
86d86f58b0
chore: fix bearer token middleware signal endpoint logic (#6767)
This should make it so that the `signal-endpoint` route match is
slightly less strict.
2024-04-03 11:29:09 +01:00
Jaanus Sellin
a664a449ef
chore: remove strategy form feedback (#6769) 2024-04-03 12:16:58 +02:00
Gastón Fournier
0a0f5a73ab
chore: stop using deprecated method (#6764)
`storeUserEvent` from event-service was deprecated. We stop using it and
remove the method completely
2024-04-03 09:55:09 +02:00
Gastón Fournier
e845459034
chore: Better randomness (#6755)
## About the changes
This change is irrelevant as it doesn't pose a security risk, but
there's no reason for us not to use a different type of random
generation for the `sessionId`

**Note:** the magic number 18 was picked because that's the length of
the string we get from `String(Math.random())`

Closes https://github.com/Unleash/unleash/security/code-scanning/68 and
https://github.com/Unleash/unleash/security/code-scanning/69
2024-04-02 16:21:33 +02:00
Gastón Fournier
783c83173f
chore: when some promise fails others might hang and leave open conns (#6636)
This was identified during some tests where we noticed jest did not
complete properly (notice how after linking unleash-server to this
commit it didn't have that issue):

![image](https://github.com/Unleash/unleash/assets/455064/306e57b8-6473-459a-8104-7223d1de40c3)
2024-04-02 11:25:38 +02:00
Nuno Góis
a30ddd81c5
chore: bearer token middleware (#6624)
Adds a bearer token middleware that adds support for tokens prefixed
with "Bearer" scheme. Prefixing with "Bearer" is optional and the old
way of authenticating still works, so we now support both ways.

Also, added as part of our OpenAPI spec which now displays authorization
as follows:

![image](https://github.com/Unleash/unleash/assets/455064/77b17342-2315-4c08-bf34-4655e12a1cc3)

Related to #4630. Doesn't fully close the issue as we're still using
some invalid characters for the RFC, in particular `*` and `[]`

For safety reasons this is behind a feature flag

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2024-04-02 10:21:38 +01:00
Jaanus Sellin
8942cda901
refactor: fix return type for getFeatureOverviewData (#6750)
Brought up by https://github.com/Unleash/unleash/issues/6738
2024-04-02 10:36:30 +03:00
Gastón Fournier
fc43391184
chore: adapted IUser to our DB schema (#6627)
## About the changes
Our schema allows us to have null username or email. With this change at
least we'll get a compiler warning when using either of these properties

![Screenshot from 2024-03-20
12-20-45](https://github.com/Unleash/unleash/assets/455064/7e1b7846-43a4-4532-be39-5a7bbc14e9fc)
2024-04-02 09:22:26 +02:00
andreas-unleash
c868b5a868
Feat: context field search and filter improvements (#6732)
Adds highlighting to search values 
Search also looks in `description`

behind a flag - it could possibly degrade performance when too many
items. Tested with 200 and it's ok but anything above might degrade:
Adds a Select/Unselect all button
Shows the selected values above the search 

Closes #
[1-2232](https://linear.app/unleash/issue/1-2232/context-field-ui-filter-and-search)



https://github.com/Unleash/unleash/assets/104830839/ba2fe56f-c5db-4ce7-bc3c-1e7988682984

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2024-03-29 15:44:34 +02:00
Mateusz Kwasniewski
11f4155d5a
fix: revert archived column for backwards migration compatibility (#6737) 2024-03-29 13:00:33 +01:00
Mateusz Kwasniewski
42355b0c89
feat: List possible parent variants (#6733) 2024-03-28 16:53:30 +01:00
Mateusz Kwasniewski
664ceaea09
feat: disabled feature dependency (#6731) 2024-03-28 16:02:25 +01:00
Jaanus Sellin
d3847fd8ee
feat: collect prometheus data about archived features (#6728) 2024-03-28 13:40:30 +02:00
gitar-bot[bot]
4932ae0539
[Gitar] Cleaning up stale feature flag: increaseUnleashWidth with value true (#6724)
Co-authored-by: Gitar Bot <noreply@gitar.co>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2024-03-28 11:04:00 +02:00
gitar-bot[bot]
ca6946df86
chore: [Gitar] Cleaning up stale feature flag: sdkReporting with value true (#6717)
Co-authored-by: Gitar Bot <noreply@gitar.co>
Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2024-03-28 09:19:11 +02:00
Jaanus Sellin
ab82543f54
Revert "fix: prevent non-string properties from being passed as context values" (#6702)
Reverts Unleash/unleash#6676
2024-03-26 16:18:35 +02:00
Mateusz Kwasniewski
6762703db9
chore: remove extended usage metrics ui flag (#6701) 2024-03-26 15:14:39 +01:00
Christopher Kolstad
8e08df5c19
feat: add index on group name (#6696)
As the title says, adds an index on the group name. Scim (in particular
Azure) uses group names to find correct group to sync.
2024-03-26 14:48:05 +01:00
Ivar Conradi Østhus
a6643e4721
Revert "fix: Add metrics for old proxy forward (#6695)"
This reverts commit d065905e73.
2024-03-26 14:13:18 +01:00
Ivar Conradi Østhus
d065905e73
fix: Add metrics for old proxy forward (#6695)
This change adds a new prometheus counter to all us to capture when we
automatically forward traffic from old /proxy paths to the /api/frontend
path.


![image](https://github.com/Unleash/unleash/assets/158948/639a4ade-4758-41e6-b87b-a497f00313fa)
2024-03-26 12:25:15 +01:00
Tymoteusz Czech
d3eac6caf8
feat(integrations): ability to add stringified event (#6642)
You might want to include entire event, but as a different field.
2024-03-26 09:25:16 +01:00
Jaanus Sellin
283a8f4d8b
feat: dependant flag on feature search (#6684) 2024-03-25 15:45:18 +02:00
Mateusz Kwasniewski
d4f52cdb54
refactor: remove change requests from project insights api (#6685) 2024-03-25 14:44:32 +01:00
Thomas Heartman
9ecd81ebb4
fix: prevent non-string properties from being passed as context values (#6676)
This change fixes the OpenAPI schema to disallow non-string properties
on the top level of the context (except, of course, the `properties`
object).

This means that we'll no longer be seeing issues with rendering
invalid contexts, because we don't accept them in the first place.

This solution comes with some tradeoffs discussed in the [PR](https://github.com/Unleash/unleash/pull/6676). Following on from that, this solution isn't optimal, but it's a good stop gap. A better solution (proposed in the PR discussion) has been added as an idea for future projects.

The bulk of the discussion around the solution is included here for reference:

@kwasniew:
Was it possible to pass non string properties with our UI before?
Is there a chance that something will break after this change?

@thomasheartman:
Good question and good looking out 😄 

You **could** pass non-string, top-level properties into the API before. In other words, this would be allowed:

```js
{ 
  appName: "my-app",
  nested: { object: "accepted" }
}
```

But notably, non-string values under `properties` would **not** be accepted:

```js
{ 
  appName: "my-app",
  properties: {
    nested: { object: "not accepted" }
  }
}
```

**However**, the values would not contribute to the evaluation of any constraints (because their type is invalid), so they would effectively be ignored. 

Now, however, you'll instead get a 400 saying that the "nested" value must be a string.

I would consider this a bug fix because:
- if you sent a nested object before, it was most likely an oversight
- if you sent the nested object on purpose, expecting it to work, you would be perplexed as to why it didn't work, as the API accepted it happily

Furthermore, the UI will also tell you that the property must be a string now if you try to do it from the UI.

On the other hand, this does mean that while you could send absolute garbage in before and we would just ignore it, we don't do that anymore. This does go against how we allow you to send anything for pretty much all other objects in our API.

However, the SDK context is special. Arbitrary keys aren't ignored, they're actually part of the context itself and as such should have a valid value.

So if anything breaks, I think it breaks in a way that tells you why something wasn't working before. However, I'd love to hear your take on it and we can re-evaluate whether this is the right fix, if you think it isn't.

@kwasniew:
Coming from the https://en.wikipedia.org/wiki/Robustness_principle mindset I'm thinking if ignoring the fields that are incorrect wouldn't be a better option. So we'd accept incorrect value and drop it instead of:
* failing with client error (as this PR) or
* saving incorrect value (as previous code we had)

@thomasheartman:
Yeah, I considered that too. In fact, that was my initial idea (for the reason you stated). However, there's a couple tradeoffs here (as always):

1. If we just ignore those values, the end user doesn't know what's happened unless they go and dig through the responses. And even then, they don't necessarily know why the value is gone.
2. As mentioned, for the context, arbitrary keys can't be ignored, because we use them to build the context. In other words, they're actually invalid input.

Now, I agree that you should be liberal in what you accept and try to handle things gracefully, but that means you need to have a sensible default to fall back to. Or, to quote the Wikipedia article (selectively; with added emphasis):

> programs that receive messages should accept non-conformant input **as long as the meaning is clear**. 

In this case, the meaning isn't clear when you send extra context values that aren't strings. 
For instance, what's the meaning here:

```js
{ 
  appName: "my-app",
  nested: { object: "accepted", more: { further: "nesting" } }
}
```

If you were trying to use the `nested` value as an object, then that won't work. Ideally, you should be alerted.

Should we "unwind" the object and add all string keys as context values? That doesn't sound very feasible **or** necessarily like the right thing.

Did you just intend to use the `appName` and for the `nested` object to be ignored?

And it's because of this caveat that I'm not convinced just ignoring the keys are the right thing to do. Because if you do, the user never knows they were ignored or why.

----

**However**, I'd be in favor of ignoring they keys if we could **also** give the users warnings at the same time. (Something like what we do in the CR api, right? Success with warnings?) 

If we can tell the user that "we ignored the `a`, `b`, and `c` keys in the context you sent because they are invalid values. Here is the result of the evaluation without taking those keys into account: [...]", then I think that's the ideal solution.

But of course, the tradeoff is that that increases the complexity of the API and the complexity of the task. It also requires UI adjustments etc. This means that it's not a simple fix anymore, but more of a mini-project.

But, in the spirit of the playground, I think it would be a worthwhile thing to do because it helps people learn and understand how Unleash works.
2024-03-25 11:58:23 +01:00
Simon Hornby
2747dcaba9
chore: add scim id migration for groups (#6682) 2024-03-25 11:39:11 +02:00
Christopher Kolstad
79fcfc26b8
fix: use defaults when creating gradualRollout strategies (#6623)
Via the API you can currently create gradualRollout strategies without
any parameters set, when visiting the UI afterwards, you can edit this,
because the UI reads the parameter list from the database and sees that
some parameters are required, and refuses to accept the data. This PR
adds defaults for gradualRollout strategies created from the API, making
sure gradual rollout strategies always have `rollout`, `groupId` and
`stickiness` set.
2024-03-25 10:38:41 +01:00
Jaanus Sellin
a2a9a84974
feat: search includes feature last seen data last hour (#6677) 2024-03-25 10:32:19 +02:00
David Leek
e0994b088a
feat: traffic visibility UI and store (#6659)
Provides store method for retrieving traffic usage data based on
period parameter, and UI + ui hook with the new chart for displaying
traffic usage data spread out over selectable month.

![Skjermbilde 2024-03-21 kl 12 40
38](https://github.com/Unleash/unleash/assets/707867/539c6c98-b6f6-488a-97fb-baf4fccec687)

In this PR we copied and adapted a plugin written by DX for highlighting
a column in the chart:


![image](https://github.com/Unleash/unleash/assets/707867/70532b22-44ed-44c0-a9b4-75f65ed6a63d)

There are some minor improvements planned which will come in a separate
PR, reversing the order in legend and tooltip so the colors go from
light to dark, and adding a month -sum below the legend

## Discussion points

- Should any of this be extracted as a separate reusable component?

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2024-03-22 11:54:33 +01:00
Mateusz Kwasniewski
86f229a69d
test: project insights service test (#6661) 2024-03-22 09:48:29 +01:00
Jaanus Sellin
2f7580e6b1
feat: project members not hardcoded (#6658) 2024-03-21 14:33:23 +02:00
Mateusz Kwasniewski
3241d14a05
test: project insights read model test (#6657) 2024-03-21 12:09:13 +01:00
Mateusz Kwasniewski
85454bf488
refactor: reduce project insights coupling (#6655) 2024-03-21 11:37:25 +01:00
Jaanus Sellin
c41ec49615
feat: remove active/inactive members (#6654)
![image](https://github.com/Unleash/unleash/assets/964450/769ef8bb-834d-4917-898f-b2ba17a9062b)
2024-03-21 11:27:37 +02:00
Mateusz Kwasniewski
8080a1d907
feat: read change requests for insights (#6651) 2024-03-21 09:08:19 +01:00
andreas-unleash
84707e2bf3
chore: create new flag to hide insights ui (#6638)
Creates a new flag to control the executive dashboard ui

Closes #
[1-2208](https://linear.app/unleash/issue/1-2208/create-separate-ui-flag-decoupled-from-the-backend-flag)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2024-03-20 17:21:46 +02:00
Mateusz Kwasniewski
87b9f4f713
refactor: Project insights subdomain (#6634) 2024-03-20 15:06:11 +01:00
Mateusz Kwasniewski
6dc6e36084
feat: expose stats, health and flag types insights (#6630) 2024-03-20 13:34:48 +01:00
Mateusz Kwasniewski
03a84e2d42
feat: project insights resource with hardcoded data (#6610) 2024-03-19 20:23:29 +01:00
Gastón Fournier
085adaaa51
fix: authorization header typo (#6609)
## About the changes
There seems to be a typo in the authorization header. We're keeping the
old typo as preferred just in case, but if not present we'll default to
the authorization header (not authorisation).

Not sure about the impact of this bug, as all registrations might be
using default project.
2024-03-19 16:08:39 +01:00
Fredrik Strand Oseberg
911b918817
fix: set log level to error for db migrate (#6601)
This PR sets the log level of db-migrate to error, because it interferes
with the indexing of our logs in Loki when the logs are not in JSON
format.
2024-03-19 14:45:27 +01:00
Christopher Kolstad
b4bf84d5b0
chore: Upgrade to typescript 5.4.2 (#6605)
The changes to arbitraries here is to make typescript agree with our
schema types. Seems like somewhere between 4.8.4 and 5.4.2, typescript
got stricter.
2024-03-19 10:46:08 +00:00
Gastón Fournier
26e696a090
chore: log error properly (#6596)
## About the changes
We see some logs with: `Failed to store events: Error: The query is
empty` which suggests we're not sending events to batchStore. This will
help us confirm that and will give us better insights
2024-03-18 17:11:36 +01:00
Christopher Kolstad
53354224fc
chore: Bump biome and configure husky (#6589)
Upgrades biome to 1.6.1, and updates husky pre-commit hook.

Most changes here are making type imports explicit.
2024-03-18 13:58:05 +01:00
Fredrik Strand Oseberg
3621c7282d
feat: setup ff (#6532)
Setup feature flag for the new refactoring of the project overview page

---------

Co-authored-by: sjaanus <sellinjaanus@gmail.com>
2024-03-18 13:38:59 +02:00
Nuno Góis
a86b8d36b3
chore: redesign action configurations (#6588)
https://linear.app/unleash/issue/2-2050/redesign-action-definitions-oss

Depends on a PR on Enterprise that will provide a new endpoint with
action configurations.

We should also clean up the now unnecessary constants and hook.
2024-03-18 11:09:49 +00:00
Mateusz Kwasniewski
f45dbc647e
refactor: make outdated sdk finding simpler (#6587) 2024-03-15 15:38:57 +01:00
Mateusz Kwasniewski
06e2c6e514
fix: outdated sdk version handles non semver versions (#6586) 2024-03-15 14:58:53 +01:00
Christopher Kolstad
d5bc3585aa
feat: Added shutdown hook option (#6585)
An entrypoint for enterprise to register a hook which will be called
before the database and scheduler services are torn down. That way
enterprise can also perform graceful shutdown.
2024-03-15 13:05:35 +00:00
Mateusz Kwasniewski
2716f72ea6
feat: separate new frontend api path for perf measurements (#6583) 2024-03-15 13:31:08 +02:00
gitar-bot[bot]
3d4aa4abcb
[Remix] Cleaning up stale feature flag: proPlanAutoCharge with value true (#6581) 2024-03-15 11:53:30 +02:00
Nuno Góis
de34497478
chore: drop action definition required (#6567)
https://linear.app/unleash/issue/2-2046/implement-dynamic-action-parameters

Follow up to https://github.com/Unleash/unleash/pull/6554

Cleans up the `required` property in action definitions after adapting
to using the `parameters` property instead.
2024-03-14 16:32:14 +00:00
Nuno Góis
7a3d2d6d87
chore: dynamic action parameters (#6554)
https://linear.app/unleash/issue/2-2046/implement-dynamic-action-parameters

Implements dynamic action parameters.

Also improves the action dropdown to better prepare for future actions.

<img width="771" alt="image"
src="https://github.com/Unleash/unleash/assets/14320932/ec3fcaf2-40c8-4dc8-8834-7a0d54671fd2">
2024-03-14 15:25:23 +00:00
Mateusz Kwasniewski
98c1c101ee
fix: handle sdk versions with nulls (#6558) 2024-03-14 15:47:34 +01:00
Mateusz Kwasniewski
dc1d5ce4f2
chore: update outdated sdks list (#6556) 2024-03-14 15:30:23 +01:00
Gastón Fournier
7c69500cd0
chore: mark resource limits config type fields mandatory (#6550)
## About the changes
All fields should be defined in the configuration to either a
user-provided value or a sensible default
2024-03-14 13:59:20 +01:00
Mateusz Kwasniewski
2b2089f7b5
feat: clickable banner modal links (#6552) 2024-03-14 13:19:27 +01:00
Simon Hornby
a2c4b8c320
refactor: allow user events to take in only what they need (#6545) 2024-03-14 12:14:33 +02:00
Jaanus Sellin
ba53bd7bf9
refactor: optimize applications overview (#6548)
There was no need to join the entire metrics table, as it is a huge
table. We only needed all combinations of app_name, environment, and
feature_name. The new query retrieves all this data, which will then be
joined into the main query.
2024-03-14 12:11:15 +02:00
Mateusz Kwasniewski
c6fd558da4
feat: show outdated sdks banner (#6541) 2024-03-14 10:15:33 +01:00
Jaanus Sellin
8c87e27b8a
feat: enable frontend cache for everyone (#6546) 2024-03-14 10:55:49 +02:00
Nuno Góis
bc6a96cf6b
chore: suggest nested properties in action filters (#6533)
https://linear.app/unleash/issue/2-2029/support-filtering-on-nested-properties

Suggests nested properties in action filters. Also sorts them
alphabetically.

Follow up to https://github.com/Unleash/unleash/pull/6531

<img width="381" alt="image"
src="https://github.com/Unleash/unleash/assets/14320932/4e2c900d-335b-4360-8be4-186f3887e42b">
2024-03-13 16:07:01 +00:00
Mateusz Kwasniewski
9438400e77
feat: outdated sdks api (#6539) 2024-03-13 15:56:22 +01:00
Jaanus Sellin
3c22a302c7
fix: fix frontend api timings (#6536)
Just a typo
2024-03-13 15:10:48 +02:00
Jaanus Sellin
c4412d8276
fix: measure frontend times only when flag enabled (#6535)
Moving to controller level to measure only for flag. Other option would
have been to check flag also at service.
2024-03-13 14:28:59 +02:00
Nuno Góis
422af36d2d
chore: flatten payload util (#6531)
https://linear.app/unleash/issue/2-2029/support-filtering-on-nested-properties

This will allow us to support and suggest payload subproperties in the
action filters.
2024-03-13 11:10:44 +00:00
Jaanus Sellin
570af43615
feat: share context between both frontend apis (#6529)
We are sharing contexts because we want both clients to use same session
ID.
2024-03-13 11:17:40 +02:00
Jaanus Sellin
259fde09db
feat: add possibility to see differences for frontend API (#6528) 2024-03-13 09:41:48 +02:00
Gastón Fournier
16507a971b
chore: re-add max listeners (#6522)
## About the changes
Some tests are reporting this error:

`MaxListenersExceededWarning: Possible EventEmitter memory leak
detected. 11 UPDATE_REVISION listeners added to
[ConfigurationRevisionService]. Use emitter.setMaxListeners() to
increase limit`

I thought it's because of this change
https://github.com/Unleash/unleash/pull/6400#discussion_r1511494201 but
it was not.

I've managed to get a trace of the issue following this
https://stackoverflow.com/q/62897235/239613 and now we can identify
`ConfigurationRevisionService` as one explanation. The reason is that
it's a singleton that should be cleaned up after tests.

E.g.:
https://github.com/Unleash/unleash/actions/runs/8248332132/job/22558419656?pr=6517#step:8:15
2024-03-12 16:34:55 +01:00
Mateusz Kwasniewski
6278cdb6c7
feat: better logging for old and new frontend api differences (#6524) 2024-03-12 16:22:16 +01:00
Fredrik Strand Oseberg
bfbd18eb97
fix: allow deletion of segments referencing strategies in archived f… (#6406)
Subset of #6392, allowing you to delete segments that are referenced in
strategies on archived features.
2024-03-12 15:03:53 +01:00
Jaanus Sellin
a08bada1de
feat: do not return disabled features to FE api (#6520) 2024-03-12 14:41:25 +02:00
Christopher Kolstad
ca329da4b4
fix: scim id was not unique (#6450)
This PR drops the previous PRs scim_id idx and replaces it with an
actual UNIQUE index
2024-03-12 13:36:21 +01:00
Jaanus Sellin
2a57acca41
feat: start monitoring total time to update cache (#6517) 2024-03-12 14:27:04 +02:00
Mateusz Kwasniewski
1d526e707b
test: compare frontend api implementations (#6515) 2024-03-12 12:22:27 +01:00
Jaanus Sellin
b7915171ff
feat: start tracking operation duration (#6514) 2024-03-12 12:30:30 +02:00
Christopher Kolstad
55da9b8133
fix: admin token requests does not automatically have id (#6501)
To check that users do indeed have permissions to update the roles from
project-service, we've been depending on req.user.id.
We had one error on Friday March 8th, where we managed to send
undefined/null to a method that requires a number. This PR assumes that
if we have an API token, and we have admin permissions and userId is not
set we're a legacy admin token.

It uses the util method for extractUserId(req: IAuthRequest | IApiRequest), so if we've passed through the apiTokenMiddleware first, we'll have userId -42, if we haven't, we'll get -1337.
2024-03-12 10:39:37 +01:00
Mateusz Kwasniewski
bc83a4d66e
refactor: rename proxy to frontend api in openapi schemas (#6511) 2024-03-12 10:15:24 +01:00
Mateusz Kwasniewski
1f374ea20e
refactor: rename proxy to frontend api (#6502) 2024-03-11 17:30:46 +01:00
Gastón Fournier
977b0e4e28
chore: rename parametric types to make them clearer (#6500)
## About the changes
Just renaming to bring more clarity based on
https://github.com/Unleash/unleash/pull/6436#discussion_r1517334796
2024-03-11 15:41:34 +01:00
Mateusz Kwasniewski
160eec18a0
feat: compare old and new proxy results (#6497) 2024-03-11 14:00:18 +01:00
Jaanus Sellin
a544a8a4ad
feat: count frontend api requests (#6495)
Now frontend API requests will be counted separately under
getAllByfrontend. We are already tracking new FE db calls, so we can
build grafana dashboard.
2024-03-11 14:54:14 +02:00
Jaanus Sellin
184e0e5190
feat: add returnGlobalFrontendApiCache flag (#6494) 2024-03-11 14:27:17 +02:00
Mateusz Kwasniewski
eae373f386
fix: Configuration revision service singleton (#6493) 2024-03-11 13:22:52 +01:00
Mateusz Kwasniewski
c841e72244
fix: revert composition root (#6492) 2024-03-11 13:09:13 +01:00
Jaanus Sellin
0cf7b324a5
feat: frontend api clean up not needed columns (#6489)
1. Clean up not used fields
2. Fix a bug where segment was not attached
2024-03-11 13:41:41 +02:00
Jaanus Sellin
2997faecf6
refactor: remove client from frontend api (#6490)
There was extra call getClient().getAll() not needed and complicating
readability.
2024-03-11 13:30:32 +02:00
Mateusz Kwasniewski
17ea8b3734
feat: compare feture definitions not evaluations (#6486) 2024-03-11 12:05:17 +01:00
Mateusz Kwasniewski
48fa39c9fc
feat: Compositon root for proxy service (#6488) 2024-03-11 11:22:04 +01:00
Mateusz Kwasniewski
2a3959082c
refactor: proxy/frontend api in feature oriented architecture (#6487) 2024-03-11 09:28:40 +01:00
Nuno Góis
7d827442ee
fix: add actions validation (#6481)
https://linear.app/unleash/issue/2-2022/improve-actions-validation

Improves our current actions form validation. 

Empty actions are now ignored on the payload and we get errors in
actions where any of the required fields are empty.

Also refactored our current actions into a constant map that can be
shared across frontend and backend.
2024-03-11 08:18:36 +00:00
Gastón Fournier
da41d3dbcf
chore: automate openapi schema list (#6463)
## About the changes
This PR automates the generation of exported open api schemas on
pre-commit, removing some manual steps and also standardizing the
process. The schema list definition now looks way simpler:

b6f3877296/src/lib/openapi/index.ts (L37-L49)

Also added
2817e66b29/src/lib/openapi/spec/index.ts (L1-L4)
for devs
2024-03-08 14:58:22 +01:00
Jaanus Sellin
381af7835b
feat: sort frontend api features by name (#6479) 2024-03-08 15:34:33 +02:00
Jaanus Sellin
2e6d91846b
feat: make frontend api complexity O(n) instead of O(n2) (#6477) 2024-03-08 14:00:38 +01:00
David Leek
6f2bd546a6
fix: await trafficDataUsageStore.deleteAll where its being used (#6478)
## About the changes

trafficDataUsageStore.deleteAll() wasn't being awaited in tests, leading
to flaky tests. This PR ensures it's being awaited
2024-03-08 13:34:46 +01:00
Mateusz Kwasniewski
8f105f9d30
feat: Compare old results with new frontend api (#6476) 2024-03-08 13:03:41 +01:00
Gastón Fournier
1949d0134f
fix: mapper function should be partial (#6475)
Small fix to make mapper function partial as it should be
2024-03-08 11:20:41 +01:00
Gastón Fournier
82f4093c04
feat: adapted CRUD store from enterprise into OSS (#6474)
## About the changes
This ports the CRUD store into OSS which is an abstraction to reduce the
amount of boilerplate code we have to write in stores.

By extending CRUDStore, the store becomes simply the type definition:
```typescript
 type ActionModel = { 
     actionSetId: number; 
     action: string; 
     executionParams: Record<string, unknown>; 
     createdByUserId: number; 
     sortOrder: number; 
 }; 
  
 export class ActionStore extends CRUDStore< 
     ActionModel & { id: number; createdAt: Date }, 
     ActionModel 
 > { 
}
```

And eventually specific mappings between those types can be provided (if
the mapping is more complex than camelCase -> snake_case):
```typescript
 toRow: ({ project, name, actor, match, createdByUserId }) => ({ 
     created_by_user_id: createdByUserId, 
     project, 
     name, 
     actor_id: actor, 
     source: match.source, 
     source_id: match.sourceId, 
     payload: match.payload, 
 }), 
 fromRow: ({ 
     id, 
     created_at, 
     created_by_user_id, 
     project, 
     name, 
     actor_id, 
     source, 
     source_id, 
     payload, 
 }) => ({ 
     id, 
     createdAt: created_at, 
     createdByUserId: created_by_user_id, 
     project, 
     name, 
     actor: actor_id, 
     match: { 
         source, 
         sourceId: source_id, 
         payload, 
     }, 
 }), 
```
Stores can also be extended to include additional functionality in case
you need to join with another table or do an aggregation, but it
significantly reduces the amount of boilerplate code needed to create a
basic store
2024-03-08 10:39:29 +01:00
Mateusz Kwasniewski
8f2631e418
feat: stabilize global frontend api cache (#6466) 2024-03-08 08:41:22 +01:00
Jaanus Sellin
7b402ad6b3
feat: create global repository for frontend repositories (#6460)
Co-authored-by: kwasniew <kwasniewski.mateusz@gmail.com>
2024-03-07 16:48:52 +02:00
Gastón Fournier
5b87ca6b75
chore: consider execution limits per minute and actions limit per (#6462)
## About the changes
Define a schema that works both for the frontend and the backend to
define soft limits in the resource usage.
2024-03-07 13:02:49 +01:00