Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Convert client metrics controller to typescript #831

Merged

Conversation

checketts
Copy link
Contributor

This is intended to just convert the metrics controller/service/store to typescript.

@checketts checketts force-pushed the convert-metrics-controller-to-typescript branch from 2fc75c6 to 01f0977 Compare May 3, 2021 21:24
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 94.13% when pulling 01f0977 on checketts:convert-metrics-controller-to-typescript into d61c724 on Unleash:master.

@ivarconr
Copy link
Member

Thanks, this looks decent. I tried to rebase it against master, but was unable to push back to the PR.

Would you mind rebasing it when you have time?

@ivarconr
Copy link
Member

I will take rebase of this tomorrow.

@checketts checketts force-pushed the convert-metrics-controller-to-typescript branch from 01f0977 to c1b4a9b Compare June 14, 2021 14:58
@checketts
Copy link
Contributor Author

Sorry for the delay. I did a rebase against master and pushed it up. There were quite a few conflicts with index.ts, so I'll look into that some more.

@checketts checketts force-pushed the convert-metrics-controller-to-typescript branch from c1b4a9b to facf85b Compare June 14, 2021 16:38
@checketts
Copy link
Contributor Author

Looks like the tests were migrated to jest (Yay!) So that caused some breakage. I'll try to get back to them later today.

@ivarconr
Copy link
Member

Thanks for updating. Sorry about the jest migration, we just felt the need to get it done to have some more power for our tests 🔥

@ivarconr
Copy link
Member

Looks like the tests were migrated to jest (Yay!) So that caused some breakage. I'll try to get back to them later today.

I took the liberty to convert the test to jest.

@checketts
Copy link
Contributor Author

Sorry I haven't been able to tackle this. Thanks for helping get it in a good state.

private eventStore: EventStore,
private getLogger: LogProvider,
private bulkInterval = FIVE_SECONDS,
private announcementInterval = FIVE_MINUTES,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have prefered the constructor to be in line with the format utilized by all the other services converted to typescript, something in the line of:

---
constructor(
        stores: Pick<IUnleashStores,
           | 'clientMetricsStore'
          | 'strategyStore'
          | 'featureToggleStore'
          | 'clientApplicationsStore'
          | 'clientInstanceStore'
          | 'eventStore'
        >,
        config: Pick<IUnleashConfig, 'getLogger'>,
    ) {
        this.clientMetricsStore = stores.clientMetricsStore;
        this.strategyStore = stores.strategyStore;
        this.toggleStore = stores.featureToggleStore;
        this.clientAppStore = stores.clientApplicationsStore;
        this.clientInstanceStore = stores.clientInstanceStore;
        this.eventStore = stores.eventStore;
----

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your proposal mirrors the JS approach, but I don't think it makes the class easier to use, especially since the stores variable is immediately unwrapped into the individual stores.

My change just moved the unwrapping to outside the constructor.

I'm fine if you want it changed back for consistency, but I think simplifying the classes for clarity and testing is worth doing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the Pick format it will actually be the same from the test perspective. You will only have to provide the requirements from the Picks and you will get the type-support from TypeScript.

Copy link
Contributor Author

@checketts checketts Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! So in the tests I won't have to create an IUnleashStores with all keys before the pick? Or would you use an any type on that?

Learning more here: https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys

Since you are in the code, are you going to make that change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are in the code, are you going to make that change?

On it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see the result here, basically the test provides the same as before, just wrappted in objects.

644cd27

stores.clientInstanceStore,
stores.eventStore,
config.getLogger,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my previous comment, this would the be new ClientMetricsService(stores, config)

@ivarconr
Copy link
Member

Sorry I haven't been able to tackle this. Thanks for helping get it in a good state.

No worries. Had some extra time to finally get this one moving.

@ivarconr ivarconr requested a review from chriswk June 23, 2021 20:51
variants: any[];
createdAt: Date;
lastSeenAt: Date;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up @chriswk here we get a definition of a feature toggle that will be changed in upcomming envrionments features on branch

@ivarconr ivarconr self-requested a review June 23, 2021 20:56
Copy link
Member

@ivarconr ivarconr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid to me now.

Copy link
Contributor

@chriswk chriswk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job. LGTM :)

@ivarconr ivarconr merged commit 2f013ba into Unleash:master Jun 24, 2021
Tymek pushed a commit that referenced this pull request Aug 26, 2022
* fix: toast in mobile view

* fix: feature settings mobile view

* fix: feedback in mobile

* fix: add space for ts expect error

* fix: change breakpoint to xs instead of sm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants