-
Notifications
You must be signed in to change notification settings - Fork 83
feat: Added a Lite bundle excluding Data file manager and Event Processor packages. #699
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
Conversation
…nctionality to forwarding event processor.
86950ba
to
59855e6
Compare
@@ -0,0 +1,257 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a License header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does event_v1 means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v1 is the version of event on logx end point
tags?: EventTags | ||
} | ||
|
||
type Attributes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this type being used anywhere, so we should delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have an Attribute type called UserAttributes
in shared_types, can't we use that?
ep.stop().then(done); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: remove blank line
createInstance, | ||
OptimizelyDecideOption, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: extra blank line
* @export | ||
* @interface EventBuilderV1 | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Extra blank line here
@@ -0,0 +1,27 @@ | |||
import { DatafileManager, DatafileUpdateListener} from '../../shared_types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem like we use these types anywhere else outside of this module, so we can define them here. The intension for shared_types
to only contain types that are shared across modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are generic interfaces and are being used in the main optimizely class in its constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for a couple of minor comments. I also tested it locally and it works as expected!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have some questions.
@@ -0,0 +1,257 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does event_v1 means?
tags?: EventTags | ||
} | ||
|
||
type Attributes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have an Attribute type called UserAttributes
in shared_types, can't we use that?
} | ||
} | ||
|
||
function makeConversionSnapshot(conversion: ConversionEvent): Snapshot { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming this whole code is copied from buildEventV1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! copied from event processor because we wanted to create a forwarding event processor without importing that package and we still needed this to build the payload.. I know this is not the best way to do it but we plan to consolidate those packages into one anyway. this redundancy will be solved then.
OnReadyResult, | ||
OptimizelyConfig | ||
OptimizelyConfig, | ||
DatafileManager, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you are preparing ConfigManager outside and importing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building datafileManager
outside and including here. The DatafileManager
in this particular import is the interface.
const errorHandler = getErrorHandler(); | ||
const notificationCenter = createNotificationCenter({ logger: logger, errorHandler: errorHandler }); | ||
|
||
const eventProcessorConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a lot of common code in index.browser / react / node . ts file, It would be good if we can have a separate util class from where we create eventProcess/ Config & other stuff which is common.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! you are right in principle. There is some common code but there are some subtle differences too. I would recommend to leave it like this for this PR and take it up separately later. what do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -424,6 +436,7 @@ describe('lib/core/project_config/project_config_manager', function() { | |||
var manager = projectConfigManager.createProjectConfigManager({ | |||
datafile: testData.getTestProjectConfig(), | |||
sdkKey: '12345', | |||
datafileManager: createHttpPollingDatafileManager('12345', logger, testData.getTestProjectConfig()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if necessary but would it make sense to pull out the test value of '12345' and move to a constant?
sandbox.stub(projectConfig, 'tryCreatingProjectConfig').returns({ configObj: null, error: 'Error creating config'}); | ||
sandbox.stub(projectConfig, 'toDatafile'); | ||
}); | ||
it('Should log error when error is thrown while creating project config', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: used a capital here but not on other it( statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple very small things but LGTM!
Summary
Some platforms (such as edge providers), do not need extended functionality offered by data file manager and event processor. This PR creates a lite bundle which uses a
NoOpDatafileManager
and aForwardingEventProcessor
which immediately dispatches events when a custom event dispatcher is provided. This results in up to 20% reduction in bundle size. This also fixes the errors that SDK was throwing on edge platforms.Usage
To use the lite bundle, user needs to explicitly import from it.
import { createInstance } from '@optimizely/optimizely-sdk/dist/optimizely.lite.es.mins.js'
Test plan
lite
entry point.