-
Notifications
You must be signed in to change notification settings - Fork 83
[FSSDK-12115] Notification center type definition update #1119
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
junaed-optimizely
merged 5 commits into
5.x.x
from
junaed/fssdk-12115-notification-center-type
Dec 8, 2025
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b80447
[FSSDK-12115] type def update
junaed-optimizely 4fb49e5
[FSSDK-12115] review update
junaed-optimizely bd5de4e
[FSSDK-12115] review update
junaed-optimizely 952c0d1
Merge branch '5.x.x' into junaed/fssdk-12115-notification-center-type
junaed-optimizely 37c9675
update
junaed-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
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
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
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 |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ import { ErrorHandler, LogHandler, LogLevel, LoggerFacade } from './modules/logg | |
| import { EventProcessor } from './modules/event_processor'; | ||
|
|
||
| import { NotificationCenter as NotificationCenterImpl } from './core/notification_center'; | ||
| import { NOTIFICATION_TYPES } from './utils/enums'; | ||
| import { NOTIFICATION_TYPES, DECISION_NOTIFICATION_TYPES, DECISION_SOURCES } from './utils/enums'; | ||
|
|
||
| import { IOptimizelyUserContext as OptimizelyUserContext } from './optimizely_user_context'; | ||
|
|
||
|
|
@@ -120,9 +120,96 @@ export interface ListenerPayload { | |
| attributes?: UserAttributes; | ||
| } | ||
|
|
||
| export type NotificationListener<T extends ListenerPayload> = (notificationData: T) => void; | ||
| export type DecisionNotificationType = typeof DECISION_NOTIFICATION_TYPES[keyof typeof DECISION_NOTIFICATION_TYPES]; | ||
|
|
||
| export type DecisionSource = | ||
| | typeof DECISION_SOURCES.FEATURE_TEST | ||
| | typeof DECISION_SOURCES.ROLLOUT | ||
| | typeof DECISION_SOURCES.EXPERIMENT; | ||
|
|
||
| export type DecisionSourceInfo = { | ||
| experimentKey?: string; | ||
| variationKey?: string; | ||
| }; | ||
|
|
||
| export type VariablesMap = { [variableKey: string]: unknown }; | ||
|
|
||
| export type AbTestDecisionInfo = { | ||
| experimentKey: string; | ||
| variationKey: string | null; | ||
| }; | ||
|
|
||
| // NotificationCenter-related types | ||
| export type FeatureDecisionInfo = { | ||
| featureKey: string; | ||
| featureEnabled: boolean; | ||
| source: DecisionSource; | ||
| sourceInfo: DecisionSourceInfo; | ||
| }; | ||
|
|
||
| export type FeatureTestDecisionInfo = { | ||
| experimentKey: string; | ||
| variationKey: string | null; | ||
| }; | ||
|
|
||
| export type FeatureVariableDecisionInfo = { | ||
| featureKey: string; | ||
| featureEnabled: boolean; | ||
| source: DecisionSource; | ||
| variableKey: string; | ||
| variableValue: FeatureVariableValue; | ||
| variableType: VariableType; | ||
| sourceInfo: DecisionSourceInfo; | ||
| }; | ||
|
|
||
| export type AllFeatureVariablesDecisionInfo = { | ||
| featureKey: string; | ||
| featureEnabled: boolean; | ||
| source: DecisionSource; | ||
| variableValues: VariablesMap; | ||
| sourceInfo: DecisionSourceInfo; | ||
| }; | ||
|
|
||
| export type FlagDecisionInfo = { | ||
| flagKey: string; | ||
| enabled: boolean; | ||
| variationKey: string | null; | ||
| ruleKey: string | null; | ||
| variables: VariablesMap; | ||
| reasons: string[]; | ||
| decisionEventDispatched: boolean; | ||
| experimentId?: string; | ||
| variationId?: string; | ||
| }; | ||
|
|
||
| export type DecisionInfoMap = { | ||
| [DECISION_NOTIFICATION_TYPES.AB_TEST]: AbTestDecisionInfo; | ||
| [DECISION_NOTIFICATION_TYPES.FEATURE]: FeatureDecisionInfo; | ||
| [DECISION_NOTIFICATION_TYPES.FEATURE_TEST]: FeatureTestDecisionInfo; | ||
| [DECISION_NOTIFICATION_TYPES.FEATURE_VARIABLE]: FeatureVariableDecisionInfo; | ||
| [DECISION_NOTIFICATION_TYPES.ALL_FEATURE_VARIABLES]: AllFeatureVariablesDecisionInfo; | ||
| [DECISION_NOTIFICATION_TYPES.FLAG]: FlagDecisionInfo; | ||
| }; | ||
|
|
||
| export type DecisionListenerPayloadForType<T extends DecisionNotificationType> = ListenerPayload & { | ||
| type: T; | ||
| decisionInfo: DecisionInfoMap[T]; | ||
| }; | ||
|
|
||
| export type DecisionListenerPayload = { | ||
| [T in DecisionNotificationType]: DecisionListenerPayloadForType<T>; | ||
| }[DecisionNotificationType]; | ||
|
|
||
| export type LogEventListenerPayload = Event; | ||
|
|
||
| export type NotificationPayloadMap = { | ||
| [NOTIFICATION_TYPES.ACTIVATE]: ActivateListenerPayload; | ||
| [NOTIFICATION_TYPES.DECISION]: DecisionListenerPayload; | ||
| [NOTIFICATION_TYPES.TRACK]: TrackListenerPayload; | ||
| [NOTIFICATION_TYPES.LOG_EVENT]: LogEventListenerPayload; | ||
| [NOTIFICATION_TYPES.OPTIMIZELY_CONFIG_UPDATE]: undefined; | ||
| }; | ||
|
|
||
| export type NotificationListener<T extends ListenerPayload> = (notificationData: T) => void; | ||
| export interface NotificationCenter { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot modify this interface, it would be a breaking change |
||
| addNotificationListener<T extends ListenerPayload>( | ||
| notificationType: string, | ||
|
|
||
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
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.
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.
can we do
type DecisionSource = typeof DECISION_SOURCES[keyof typeof DECISION_SOURCES];