-
Notifications
You must be signed in to change notification settings - Fork 83
feat: Added ODPEventManager implementation #789
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
6569fdf
WIP initial ODP config and event manager
mikechu-optimizely cfc2938
Merge branch 'master' into mike/odp-event-manager
mikechu-optimizely 3f1594c
WIP skeleton of methods
mikechu-optimizely cecfe65
WIP task queue
mikechu-optimizely f587aca
Remove task queue work
mikechu-optimizely 9cb9f3a
WIP event manager
mikechu-optimizely a5ca291
WIP ODP event manager
mikechu-optimizely 6c6ff2f
Async and lint warns silenced
mikechu-optimizely 010370e
ODP Event Manager test layout
mikechu-optimizely 11659c8
Finish bug fixes
mikechu-optimizely bbe5013
Merge branch 'master' into mike/odp-event-manager
mikechu-optimizely e9ac4b1
Merge branch 'master' into mike/odp-event-manager
mikechu-optimizely c83d584
WIP ODP event manager unit tests
mikechu-optimizely f28430a
WIP help from John
mikechu-optimizely dfda1cd
WIP observer patternizification
mikechu-optimizely e2808d5
Event manager and dispatcher with unit tests
mikechu-optimizely b2b8be0
Fixes to for unit tests
mikechu-optimizely 0668890
Merge branch 'master' into mike/odp-event-manager
mikechu-optimizely 74032bf
Update packages/optimizely-sdk/lib/plugins/odp/odp_config.ts
mikechu-optimizely 7e0a881
Review code changes
mikechu-optimizely d87ed4f
Update packages/optimizely-sdk/lib/plugins/odp/odp_event_dispatcher.ts
mikechu-optimizely 471a9c8
Update packages/optimizely-sdk/lib/plugins/odp/odp_event_dispatcher.ts
mikechu-optimizely a8f7df2
Update packages/optimizely-sdk/lib/plugins/odp/odp_event_manager.ts
mikechu-optimizely 0157b90
Update packages/optimizely-sdk/lib/plugins/odp/odp_event_manager.ts
mikechu-optimizely 98c75d7
Code review changes
mikechu-optimizely 58a6bd5
Code review edits and JS Doc
mikechu-optimizely 60d435a
Fix message
mikechu-optimizely ab63fab
Code review requested changes
mikechu-optimizely b50d357
JS Docs
mikechu-optimizely dc14b73
Fix data_source_version
mikechu-optimizely 1d2abb8
Remove tsconfig.spec.json
mikechu-optimizely f82fbff
Read client engine and version from OptiOptions
mikechu-optimizely 46c2720
Code review changes
mikechu-optimizely 554773e
Require client engine & version for ODP Event Manager
mikechu-optimizely 32a0c10
Code review changes
mikechu-optimizely 346da4e
Fix setting timeout; add multiple flush test
mikechu-optimizely File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** | ||
* Copyright 2022, Optimizely | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export class OdpConfig { | ||
/** | ||
* Host of ODP audience segments API. | ||
* @private | ||
*/ | ||
private _apiHost: string; | ||
|
||
/** | ||
* Getter to retrieve the ODP server host | ||
* @public | ||
*/ | ||
public get apiHost(): string { | ||
return this._apiHost; | ||
} | ||
|
||
/** | ||
* Public API key for the ODP account from which the audience segments will be fetched (optional). | ||
* @private | ||
*/ | ||
private _apiKey: string; | ||
|
||
/** | ||
* Getter to retrieve the ODP API key | ||
* @public | ||
*/ | ||
public get apiKey(): string { | ||
return this._apiKey; | ||
} | ||
|
||
/** | ||
* All ODP segments used in the current datafile (associated with apiHost/apiKey). | ||
* @private | ||
*/ | ||
private _segmentsToCheck: string[]; | ||
|
||
/** | ||
* Getter for ODP segments to check | ||
* @public | ||
*/ | ||
public get segmentsToCheck(): string[] { | ||
return this._segmentsToCheck; | ||
} | ||
|
||
constructor(apiKey: string, apiHost: string, segmentsToCheck?: string[]) { | ||
this._apiKey = apiKey; | ||
this._apiHost = apiHost; | ||
this._segmentsToCheck = segmentsToCheck ?? []; | ||
} | ||
|
||
/** | ||
* Update the ODP configuration details | ||
* @param apiKey Public API key for the ODP account | ||
* @param apiHost Host of ODP audience segments API | ||
* @param segmentsToCheck Audience segments | ||
* @returns true if configuration was updated successfully | ||
*/ | ||
public update(apiKey: string, apiHost: string, segmentsToCheck: string[]): boolean { | ||
if (this._apiKey === apiKey && this._apiHost === apiHost && this._segmentsToCheck === segmentsToCheck) { | ||
return false; | ||
} else { | ||
this._apiKey = apiKey; | ||
this._apiHost = apiHost; | ||
this._segmentsToCheck = segmentsToCheck; | ||
|
||
return true; | ||
} | ||
} | ||
|
||
/** | ||
* Determines if ODP configuration has the minimum amount of information | ||
*/ | ||
public isReady(): boolean { | ||
return !!this._apiKey && !!this._apiHost; | ||
mikechu-optimizely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.