Skip to content

Commit

Permalink
Fix SelfDescribingJson type regression from snowplow#1330
Browse files Browse the repository at this point in the history
  • Loading branch information
jethron committed Oct 4, 2024
1 parent baec2a9 commit f854c0e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
10 changes: 3 additions & 7 deletions api-docs/docs/browser-tracker/browser-tracker.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ export interface ClientSession extends Record<string, unknown> {
}

// @public
export interface CommonEventProperties<T extends {
[_: string]: unknown;
} = Record<string, unknown>> {
export interface CommonEventProperties<T extends {} = Record<string, unknown>> {
context?: Array<SelfDescribingJson<T>> | null;
timestamp?: Timestamp | null;
}
Expand Down Expand Up @@ -438,11 +436,9 @@ export interface SelfDescribingEvent {
}

// @public
export type SelfDescribingJson<T extends {
[_: string]: unknown;
} = Record<string, unknown>> = {
export type SelfDescribingJson<T extends {} = Record<string, unknown>> = {
schema: string;
data: T;
data: T extends any[] ? never : T;
};

// @public
Expand Down
6 changes: 2 additions & 4 deletions api-docs/docs/node-tracker/node-tracker.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,9 @@ export interface SelfDescribingEvent {
}

// @public
export type SelfDescribingJson<T extends {
[_: string]: unknown;
} = Record<string, unknown>> = {
export type SelfDescribingJson<T extends {} = Record<string, unknown>> = {
schema: string;
data: T;
data: T extends any[] ? never : T;
};

// @public
Expand Down
8 changes: 4 additions & 4 deletions libraries/tracker-core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends { [_: string]: unknown } = Record<string, unknown>> = {
export type SelfDescribingJson<T extends {} = Record<string, unknown>> = {
/**
* The schema string
* @example 'iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0'
Expand All @@ -54,14 +54,14 @@ export type SelfDescribingJson<T extends { [_: string]: unknown } = Record<strin
/**
* The data object which should conform to the supplied schema
*/
data: T;
data: T extends any[] ? never : T;
};

/**
* Export interface for any Self-Describing JSON which has the data attribute as an array
* @typeParam T - The type of the data object within the SelfDescribingJson data array
*/
export type SelfDescribingJsonArray<T extends { [_: string]: unknown } = Record<string, unknown>> = {
export type SelfDescribingJsonArray<T extends {} = Record<string, unknown>> = {
/**
* The schema string
* @example 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1'
Expand Down Expand Up @@ -119,7 +119,7 @@ function getTimestamp(timestamp?: Timestamp | null): TimestampPayload {
}

/** Additional data points to set when tracking an event */
export interface CommonEventProperties<T extends { [_: string]: unknown } = Record<string, unknown>> {
export interface CommonEventProperties<T extends {} = Record<string, unknown>> {
/** Add context to an event by setting an Array of Self Describing JSON */
context?: Array<SelfDescribingJson<T>> | null;
/** Set the true timestamp or overwrite the device sent timestamp on an event */
Expand Down
2 changes: 1 addition & 1 deletion plugins/browser-plugin-snowplow-ecommerce/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export interface User {
email?: string;
}

export interface CommonEcommerceEventProperties<T extends { [_: string]: unknown } = Record<string, unknown>>
export interface CommonEcommerceEventProperties<T extends {} = Record<string, unknown>>
extends CommonEventProperties<T> {
/** Add context to an event by setting an Array of Self Describing JSON */
context?: Array<SelfDescribingJson<T>>;
Expand Down

0 comments on commit f854c0e

Please sign in to comment.