refact: Integrate code from utils package into optimizely-sdk#749
refact: Integrate code from utils package into optimizely-sdk#749zashraf1985 merged 38 commits intomasterfrom
utils package into optimizely-sdk#749Conversation
zashraf1985
left a comment
There was a problem hiding this comment.
Looks great Overall! I have a couple of requests other than the explicit comments.
- Can you update the copyright header wherever applicable.
- Please add description to the PR.
| sendNotifications(notificationType: NOTIFICATION_TYPES, notificationData?: any): void | ||
| } | ||
|
|
||
| export default { |
There was a problem hiding this comment.
Can you add the new additions to default exports as well.
| typescript(typescriptPluginOptions), | ||
| ], | ||
| external: ['json-schema', '@optimizely/js-sdk-utils'], | ||
| external: ['json-schema', './lib/utils/fns', 'uuid'], |
There was a problem hiding this comment.
./libs/utils/fns should not be needed as an external bundle here
zashraf1985
left a comment
There was a problem hiding this comment.
This is getting really close. A couple of more changes to go.
- Move NotificationCenter interface and types from utils to
NotificationCentermodule. - Copyright should be updated to reflect only the years in which the file was changed. For example a file containing
2016, 2018will be changed to2016, 2018, 2022. A file containing2016, 2018-2021will be changed to2016, 2018-2022. Use commas to separate the years where there is a break in between. Use dashes where there is continuity.
| * - logEvent {Object} | ||
| * | ||
| */ | ||
| export enum NOTIFICATION_TYPES { |
There was a problem hiding this comment.
NOTIFICATION_TYPES and NotificationCenter interface can be moved to NotificationCenter module?
|
|
||
| const MODULE_NAME = 'NOTIFICATION_CENTER'; | ||
|
|
||
| export enum NOTIFICATION_TYPES { |
There was a problem hiding this comment.
move this to utils/enums.ts
| return new NotificationCenter(options); | ||
| } | ||
|
|
||
| export interface NotificationCenter { |
There was a problem hiding this comment.
remove this as this interface is already available in shared_types
There was a problem hiding this comment.
NotificationCenter in shared type does not have sendNotifications function which is required in Optimizely class. This Notification Center contains sendNotifications
There was a problem hiding this comment.
There has to be a name conflict because this file now exports a class and an interface both with the same name. can you fix this
|
@ozayr-zaviar Can you update this branch with master. Looks like there are some conflicts after you merged your GIT actions PR |
| import { assert } from 'chai'; | ||
| import { getLogger } from '@optimizely/js-sdk-logging'; | ||
| import { sprintf } from '@optimizely/js-sdk-utils'; | ||
| import { sprintf } from '../../utils/fns'; |
There was a problem hiding this comment.
Any thoughts on using path aliases in the optimizely-sdk/tsconfig.json file to make these imports a bit easier to read?
Example tsconfig.js:
"paths": {
"*": [ "./typings/*" ],
"@utils": [ "./lib/utils/*" ],
},
Usage:
import { sprint } from '@utils/fns'
| ProcessableEvent, | ||
| } from '@optimizely/js-sdk-event-processor'; | ||
| import { NotificationCenter } from '@optimizely/js-sdk-utils'; | ||
| import { NotificationSender } from '../../core/notification_center'; |
There was a problem hiding this comment.
Same comment as above, we should consider configuring tsconfig.json to add a path alias for the utils directory.
| private NotificationSender?: NotificationSender; | ||
|
|
||
| constructor(dispatcher: EventDispatcher, notificationCenter?: NotificationCenter) { | ||
| constructor(dispatcher: EventDispatcher, notificationCenter?: NotificationSender) { |
There was a problem hiding this comment.
Should we refactor notificationCenter to notificationSender?
| } | ||
|
|
||
| export function createForwardingEventProcessor(dispatcher: EventDispatcher, notificationCenter?: NotificationCenter): EventProcessor { | ||
| export function createForwardingEventProcessor(dispatcher: EventDispatcher, notificationCenter?: NotificationSender): EventProcessor { |
There was a problem hiding this comment.
Consider notificationCenter => notificationSender
| * @param {*} value | ||
| * @returns {boolean} | ||
| */ | ||
| export function isValidEnum(enumToCheck: { [key: string]: any }, value: number | string): boolean { |
There was a problem hiding this comment.
Is the lint warning here being ignored purposefully?
There was a problem hiding this comment.
For now, the warning has been suppressed but the any type will be removed in another refactor activity described in theTODO.
opti-jnguyen
left a comment
There was a problem hiding this comment.
Items to be reviewed:
- Path alias implementation for
utils(import "@utils"). - Should
notificationCenterbe refactored tonotificationSender? - utils/fns/index.ts > Is line 82's linting warning being ignored on purpose?
Items for later:
- Consider import order linting.
zashraf1985
left a comment
There was a problem hiding this comment.
@ozayr-zaviar can you update the @utils path alias every where.. i see many files are still using ../../utls
| @@ -0,0 +1,17 @@ | |||
| module.exports = { | |||
| // "roots": [ | |||
| } | ||
| }) | ||
| } | ||
| /* |
There was a problem hiding this comment.
Move these comments to notificationcenter where you moved the code that was below these comments originally.
…vascript-sdk into uzair/consolidate-packages
zashraf1985
left a comment
There was a problem hiding this comment.
LGTM! Great work @ozayr-zaviar
|
Saw latest two commits - LGTM! |
utils package into optimizely-sdk
Summary
Integrated code from
@optimizely/js-sdk-utilsinto@optimizely/optimizely-sdkpackage to reduce unnecessary external dependency.Test plan
All existing unit and E2E tests pass.