✕
Skip to content

[BUG] Missing types for notificationCenter.addNotificationListener #962

Closed

Description

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

5.3.4

Current Behavior

There are no types exported for the 'decisionPayload' that comes back from an notificationCenter.addNotificationListener

Expected Behavior

Precise types should be exported for the object returned to the callback

Steps To Reproduce

  1. setup the SDK in an TypeScript project
  2. add a notificationCenter.addNotificationListener
  3. try to set/infer the type of the parameters in the callback

SDK Type

Browser

Node Version

No response

Browsers impacted

No response

Link

No response

Logs

No response

Severity

No response

Workaround/Solution

No response

Recent Change

No response

Conflicts

No response

Activity

  1. rupesh-checkatrade commented on Nov 18, 2024

    @rupesh-checkatrade
    Author

    I've had to construct my own using a selection of other exported types:

    interface OptimizelyDecisionInfo
      extends Omit<OptimizelyDecision, 'userContext' | 'reasons'> {
      decisionEventDispatched: boolean;
    }
    
    interface OptimizelyDecisionCallbackPayload extends ListenerPayload {
      type: string; // declared enum in but not exposed from @optimizely/optimizely-sdk/dist/utils/enums/index.d.ts
      decisionInfo: OptimizelyDecisionInfo;
    }
  2. junaed-optimizely commented on Dec 8, 2025

    @junaed-optimizely
    Contributor

    Rupesh G (@rupesh-checkatrade) , type definitions have been added in v5.4.1.

    import { DecisionListenerPayload } from "@optimizely/optimizely-sdk";
    
    optimizelyClient.notificationCenter.addNotificationListener(
      enums.NOTIFICATION_TYPES.DECISION,
      (decisionPayload: DecisionListenerPayload) => {
        console.log("Type:", decisionPayload.type);
        if (decisionPayload.type === "flag") {
          const decisionInfo = decisionPayload.decisionInfo;
          console.log("Flag Key:", decisionInfo.flagKey);
        }
      }
    );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions