Skip to content

Conversation

@ZamoraEmmanuel
Copy link
Contributor

JavaScript commons library

What did you accomplish?

How do we test the changes introduced in this PR?

Extra Notes

@ZamoraEmmanuel ZamoraEmmanuel requested a review from a team as a code owner January 5, 2026 23:23
@ZamoraEmmanuel ZamoraEmmanuel marked this pull request as draft January 6, 2026 20:19
@ZamoraEmmanuel ZamoraEmmanuel marked this pull request as ready for review January 22, 2026 19:14
* Metadata keys for SDK update events.
* Use the string literals directly: 'FLAGS_UPDATE' or 'SEGMENTS_UPDATE'
*/
type SdkUpdateMetadataKeys = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this type in order to simplify the Public API. This type is not used anywhere internally, and from the perspective of the TypeScript user, it doesn't seem very useful:

client.on(client.Event.SDK_UPDATE, (metadata) => {
  if (metadata.type === 'FLAGS_UPDATED' as SplitIO.SdkUpdateMetadataKeys['FLAGS_UPDATE']) {
    doSomethingForFlagsUpdated
  }
});

vs

client.on(client.Event.SDK_UPDATE, (metadata) => {
  if (metadata.type === 'FLAGS_UPDATED') {
    doSomethingForFlagsUpdated
  }
});

I would remove it for now and reconsider adding it or something else in the future.
Besides, we are using union types for similar string enum types (example SDKMode, StorageType, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about replacing it with something like

  /**
   * Metadata for the update event emitted when the SDK cache is updated with new data for flags or segments.
   */
  type SdkUpdateMetadata = {
    /**
     * The type of update event.
     */
    type: SdkUpdateMetadataKey
    /**
     * The names of the flags or segments that were updated.
     */
    names: string[]
  }

  /**
   * Metadata keys for SDK update events.
   * Use the string literals directly: 'FLAGS_UPDATE' or 'SEGMENTS_UPDATE'
   */
  type SdkUpdateMetadataKey = 'FLAGS_UPDATE' | 'SEGMENTS_UPDATE';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants