From f854c0ee63d1aab509d7a391a734baaf294cfb2b Mon Sep 17 00:00:00 2001 From: Jethro Nederhof Date: Fri, 4 Oct 2024 13:08:09 +1000 Subject: [PATCH] Fix SelfDescribingJson type regression from #1330 --- api-docs/docs/browser-tracker/browser-tracker.api.md | 10 +++------- api-docs/docs/node-tracker/node-tracker.api.md | 6 ++---- libraries/tracker-core/src/core.ts | 8 ++++---- plugins/browser-plugin-snowplow-ecommerce/src/types.ts | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/api-docs/docs/browser-tracker/browser-tracker.api.md b/api-docs/docs/browser-tracker/browser-tracker.api.md index 2a40e49a3..85e0d7bef 100644 --- a/api-docs/docs/browser-tracker/browser-tracker.api.md +++ b/api-docs/docs/browser-tracker/browser-tracker.api.md @@ -137,9 +137,7 @@ export interface ClientSession extends Record { } // @public -export interface CommonEventProperties> { +export interface CommonEventProperties> { context?: Array> | null; timestamp?: Timestamp | null; } @@ -438,11 +436,9 @@ export interface SelfDescribingEvent { } // @public -export type SelfDescribingJson> = { +export type SelfDescribingJson> = { schema: string; - data: T; + data: T extends any[] ? never : T; }; // @public diff --git a/api-docs/docs/node-tracker/node-tracker.api.md b/api-docs/docs/node-tracker/node-tracker.api.md index 2f19d0301..ab54246db 100644 --- a/api-docs/docs/node-tracker/node-tracker.api.md +++ b/api-docs/docs/node-tracker/node-tracker.api.md @@ -464,11 +464,9 @@ export interface SelfDescribingEvent { } // @public -export type SelfDescribingJson> = { +export type SelfDescribingJson> = { schema: string; - data: T; + data: T extends any[] ? never : T; }; // @public diff --git a/libraries/tracker-core/src/core.ts b/libraries/tracker-core/src/core.ts index f9000fef7..bb3445a63 100644 --- a/libraries/tracker-core/src/core.ts +++ b/libraries/tracker-core/src/core.ts @@ -45,7 +45,7 @@ import { LOG } from './logger'; * Export interface for any Self-Describing JSON such as context or Self Describing events * @typeParam T - The type of the data object within a SelfDescribingJson */ -export type SelfDescribingJson> = { +export type SelfDescribingJson> = { /** * The schema string * @example 'iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0' @@ -54,14 +54,14 @@ export type SelfDescribingJson> = { +export type SelfDescribingJsonArray> = { /** * The schema string * @example 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1' @@ -119,7 +119,7 @@ function getTimestamp(timestamp?: Timestamp | null): TimestampPayload { } /** Additional data points to set when tracking an event */ -export interface CommonEventProperties> { +export interface CommonEventProperties> { /** Add context to an event by setting an Array of Self Describing JSON */ context?: Array> | null; /** Set the true timestamp or overwrite the device sent timestamp on an event */ diff --git a/plugins/browser-plugin-snowplow-ecommerce/src/types.ts b/plugins/browser-plugin-snowplow-ecommerce/src/types.ts index f46908fac..89080f6d9 100644 --- a/plugins/browser-plugin-snowplow-ecommerce/src/types.ts +++ b/plugins/browser-plugin-snowplow-ecommerce/src/types.ts @@ -317,7 +317,7 @@ export interface User { email?: string; } -export interface CommonEcommerceEventProperties> +export interface CommonEcommerceEventProperties> extends CommonEventProperties { /** Add context to an event by setting an Array of Self Describing JSON */ context?: Array>;