Skip to content

Commit

Permalink
EventsSDK: Remove Partial Payload (#123)
Browse files Browse the repository at this point in the history
Remove PartialPayload in favor of making all EventPayload properties
optional.
This required refactoring merge.ts.

J=FUS-6203
R=abenno, mtian
TEST=auto

Run automated workflows (which required updating the path for the
run_tests yml) and added a test to merge.test.ts that merges two
payloads without an action property.

---------

Co-authored-by: Ethan Jaffee <[email protected]>
  • Loading branch information
ejaffee01 and Ethan Jaffee authored Jan 26, 2024
1 parent 52aa4b4 commit 98a8795
Show file tree
Hide file tree
Showing 19 changed files with 313 additions and 7,965 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ on: [push, pull_request]

jobs:
call_run_tests:
uses: yext/slapshot-reusable-workflows/.github/workflows/run_tests.yml@v1
uses: yext/slapshot-reusable-workflows/.github/workflows/run_tests.yml@main
with:
test_script: npx jest
2 changes: 1 addition & 1 deletion docs/analytics.action.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The action types accepted by the Analytics Events API.
**Signature:**

```typescript
export declare type Action = `C_${string}` | `c_${string}` | 'ADD_TO_CART' | 'ALL_TAB_NAVIGATION' | 'APPLY' | 'AUTO_COMPLETE_SELECTION' | 'BACKWARD_PAGINATE' | 'BOOK' | 'BRAND_ICON' | 'CASE_START' | 'CASE_SUBMITTED' | 'CHAT_IMPRESSION' | 'CHAT_LINK_CLICK' | 'CHAT_RESPONSE' | 'COLLAPSE' | 'CTA_CLICK' | 'DRIVING_DIRECTIONS' | 'EVENT' | 'EXPAND' | 'FEATURED_MESSAGE' | 'FILTERING_WITHIN_SECTION' | 'FORWARD_PAGINATE' | 'HEADER_LINKS' | 'ITEM_IN_LIST' | 'MAP_CARD' | 'MAP_PIN' | 'MENU' | 'MESSAGE' | 'ORDER' | 'PAGE_VIEW' | 'PAGINATE' | 'POST' | 'PRESET_PROMPT' | 'PRODUCT' | 'PROFILE' | 'QUESTION_FOCUS' | 'QUESTION_SUBMIT' | 'REMOVED_FILTER' | 'REVIEW' | 'SCROLL_TO_BOTTOM_OF_PAGE' | 'SEARCH_BAR_IMPRESSION' | 'SEARCH_CLEAR_BUTTON' | 'TAP_TO_CALL' | 'THUMBS_DOWN' | 'THUMBS_UP' | 'TICKET_URL' | 'TITLE' | 'VERTICAL_TAB_NAVIGATION' | 'VERTICAL_VIEW_ALL' | 'VOICE_START' | 'VOICE_STOP' | 'WEBSITE';
export type Action = `C_${string}` | `c_${string}` | 'ADD_TO_CART' | 'ALL_TAB_NAVIGATION' | 'APPLY' | 'AUTO_COMPLETE_SELECTION' | 'BACKWARD_PAGINATE' | 'BOOK' | 'BRAND_ICON' | 'CASE_START' | 'CASE_SUBMITTED' | 'CHAT_IMPRESSION' | 'CHAT_LINK_CLICK' | 'CHAT_RESPONSE' | 'COLLAPSE' | 'CTA_CLICK' | 'DRIVING_DIRECTIONS' | 'EVENT' | 'EXPAND' | 'FEATURED_MESSAGE' | 'FILTERING_WITHIN_SECTION' | 'FORWARD_PAGINATE' | 'HEADER_LINKS' | 'ITEM_IN_LIST' | 'MAP_CARD' | 'MAP_PIN' | 'MENU' | 'MESSAGE' | 'ORDER' | 'PAGE_VIEW' | 'PAGINATE' | 'POST' | 'PRESET_PROMPT' | 'PRODUCT' | 'PROFILE' | 'QUESTION_FOCUS' | 'QUESTION_SUBMIT' | 'REMOVED_FILTER' | 'REVIEW' | 'SCROLL_TO_BOTTOM_OF_PAGE' | 'SEARCH_BAR_IMPRESSION' | 'SEARCH_CLEAR_BUTTON' | 'TAP_TO_CALL' | 'THUMBS_DOWN' | 'THUMBS_UP' | 'TICKET_URL' | 'TITLE' | 'VERTICAL_TAB_NAVIGATION' | 'VERTICAL_VIEW_ALL' | 'VOICE_START' | 'VOICE_STOP' | 'WEBSITE';
```
4 changes: 2 additions & 2 deletions docs/analytics.analyticseventservice.report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Reports an analytics event. Operand will throw an error if the request fails. Th
**Signature:**

```typescript
report(payload?: PartialPayload): Promise<string>;
report(payload?: EventPayload): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| payload | [PartialPayload](./analytics.partialpayload.md) | _(Optional)_ desired values to be applied. The new payload will override any overlapping values. |
| payload | [EventPayload](./analytics.eventpayload.md) | _(Optional)_ desired values to be applied. The new payload will override any overlapping values. |

**Returns:**

Expand Down
2 changes: 1 addition & 1 deletion docs/analytics.enumorstring.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A TypeScript utility type which creates a union of an enum member and its string
**Signature:**

```typescript
export declare type EnumOrString<T extends string> = T | `${T}`;
export type EnumOrString<T extends string> = T | `${T}`;
```

## Remarks
Expand Down
2 changes: 1 addition & 1 deletion docs/analytics.environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Yext Environments
**Signature:**

```typescript
export declare type Environment = EnumOrString<EnvironmentEnum>;
export type Environment = EnumOrString<EnvironmentEnum>;
```
**References:** [EnumOrString](./analytics.enumorstring.md)<!-- -->, [EnvironmentEnum](./analytics.environmentenum.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/analytics.eventpayload.action.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The user action which caused the event, e.g. ADD\_TO\_CART, THUMBS\_UP, C\_CUSTO
**Signature:**

```typescript
action: Action;
action?: Action;
```
2 changes: 1 addition & 1 deletion docs/analytics.eventpayload.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface EventPayload

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [action](./analytics.eventpayload.action.md) | | [Action](./analytics.action.md) | The user action which caused the event, e.g. ADD\_TO\_CART, THUMBS\_UP, C\_CUSTOM\_ACTION |
| [action?](./analytics.eventpayload.action.md) | | [Action](./analytics.action.md) | _(Optional)_ The user action which caused the event, e.g. ADD\_TO\_CART, THUMBS\_UP, C\_CUSTOM\_ACTION |
| [authorization?](./analytics.eventpayload.authorization.md) | | string | _(Optional)_ The authorization token for the request. This will be setup from the Key or Bearer in the config. |
| [bot?](./analytics.eventpayload.bot.md) | | boolean | _(Optional)_ Whether the event is the result of bot activity. |
| [browserAgent?](./analytics.eventpayload.browseragent.md) | | { browser?: string; browserVersion?: string; device?: string; deviceClass?: string; os?: string; osVersion?: string; userAgent?: string; } | _(Optional)_ Information about the visitors device and browser. |
Expand Down
1 change: 0 additions & 1 deletion docs/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
| [Action](./analytics.action.md) | The action types accepted by the Analytics Events API. |
| [EnumOrString](./analytics.enumorstring.md) | A TypeScript utility type which creates a union of an enum member and its string representation. |
| [Environment](./analytics.environment.md) | The Yext Environments |
| [PartialPayload](./analytics.partialpayload.md) | A Payload that is a subset of the EventPayload |
| [Region](./analytics.region.md) | The physical region of the Yext account |
| [VersionLabel](./analytics.versionlabel.md) | The Search Version Label |

15 changes: 0 additions & 15 deletions docs/analytics.partialpayload.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/analytics.region.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The physical region of the Yext account
**Signature:**

```typescript
export declare type Region = EnumOrString<RegionEnum>;
export type Region = EnumOrString<RegionEnum>;
```
**References:** [EnumOrString](./analytics.enumorstring.md)<!-- -->, [RegionEnum](./analytics.regionenum.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/analytics.versionlabel.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Search Version Label
**Signature:**

```typescript
export declare type VersionLabel = EnumOrString<VersionLabelEnum>;
export type VersionLabel = EnumOrString<VersionLabelEnum>;
```
**References:** [EnumOrString](./analytics.enumorstring.md)<!-- -->, [VersionLabelEnum](./analytics.versionlabelenum.md)

Expand Down
7 changes: 2 additions & 5 deletions etc/analytics.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface AnalyticsConfig {

// @public
export interface AnalyticsEventService {
report(payload?: PartialPayload): Promise<string>;
report(payload?: EventPayload): Promise<string>;
with(payload: EventPayload): AnalyticsEventService;
}

Expand All @@ -41,7 +41,7 @@ export enum EnvironmentEnum {

// @public
export interface EventPayload {
action: Action;
action?: Action;
authorization?: string;
bot?: boolean;
browserAgent?: {
Expand Down Expand Up @@ -99,9 +99,6 @@ export interface EventPayload {
visitor?: Record<string, string>;
}

// @public
export type PartialPayload = Partial<Record<keyof EventPayload, unknown>>;

// @public
export type Region = EnumOrString<RegionEnum>;

Expand Down
Loading

0 comments on commit 98a8795

Please sign in to comment.