Skip to content

AnalyticsEngineDataPoint.doubles should allow null values #5889

@cmackenzie1

Description

@cmackenzie1

Description

Currently, the doubles property in AnalyticsEngineDataPoint is strictly typed as number[]. This is inconsistent with the indexes and blobs fields, which both allow null values to represent missing data in specific positions.

Since Workers Analytics Engine supports sparse arrays, the current type definition forces a friction point for TypeScript users.

Impact

TypeScript users wishing to record sparse double fields are currently prohibited from passing arrays containing null (e.g., [0, null, 1]). To work around this, users are forced to use type casting:

// Current workaround required:
doubles: [10, null, 20] as unknown as number[]

Proposed Change

Update the doubles property to allow null values within the array to align with the underlying capabilities and other property definitions.

export interface AnalyticsEngineDataPoint {
  indexes?: ((ArrayBuffer | string) | null)[];
- doubles?: number[];
+ doubles?: (number | null)[];
  blobs?: ((ArrayBuffer | string) | null)[];
}

https://github.com/cloudflare/workerd/blob/main/src/workerd/api/analytics-engine.h#L33-L49

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions