Skip to content

Commit

Permalink
EventsSDK: Remove Enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Jaffee committed Jan 26, 2024
1 parent e5bd3d6 commit ac48e6c
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 259 deletions.
1 change: 1 addition & 0 deletions docs/analytics.enumorstring.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export type EnumOrString<T extends string> = T | `${T}`;

Allows interfaces to support both enums and strings.


3 changes: 1 addition & 2 deletions docs/analytics.environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ The Yext Environments
**Signature:**

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

## Remarks

Expand Down
25 changes: 0 additions & 25 deletions docs/analytics.environmentenum.md

This file was deleted.

11 changes: 1 addition & 10 deletions docs/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@

## analytics package

## Enumerations

| Enumeration | Description |
| --- | --- |
| [EnvironmentEnum](./analytics.environmentenum.md) | An enum for the Yext Environments |
| [RegionEnum](./analytics.regionenum.md) | An enum of the physical region the Yext account |
| [VersionLabelEnum](./analytics.versionlabelenum.md) | An enum for the Search Version Labels |

## Functions

| Function | Description |
Expand All @@ -32,8 +24,7 @@
| Type Alias | Description |
| --- | --- |
| [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 |
| [Region](./analytics.region.md) | The physical region of the Yext account |
| [VersionLabel](./analytics.versionlabel.md) | The Search Version Label |
| [VersionLabel](./analytics.versionlabel.md) | An enum for the Search Version Labels |

16 changes: 16 additions & 0 deletions docs/analytics.partialpayload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/analytics](./analytics.md) &gt; [PartialPayload](./analytics.partialpayload.md)

## PartialPayload type

A Payload that is a subset of the EventPayload

**Signature:**

```typescript
export type PartialPayload = Partial<Record<keyof EventPayload, unknown>>;
```
**References:** [EventPayload](./analytics.eventpayload.md)


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

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

## Remarks

Expand Down
25 changes: 0 additions & 25 deletions docs/analytics.regionenum.md

This file was deleted.

5 changes: 2 additions & 3 deletions docs/analytics.versionlabel.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

## VersionLabel type

The Search Version Label
An enum for the Search Version Labels

**Signature:**

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

## Remarks

Expand Down
25 changes: 0 additions & 25 deletions docs/analytics.versionlabelenum.md

This file was deleted.

32 changes: 3 additions & 29 deletions etc/analytics.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,7 @@ export interface AnalyticsEventService {
}

// @public
export type EnumOrString<T extends string> = T | `${T}`;

// @public
export type Environment = EnumOrString<EnvironmentEnum>;

// @public
export enum EnvironmentEnum {
// (undocumented)
Production = "PRODUCTION",
Sandbox = "SANDBOX"
}
export type Environment = 'PRODUCTION' | 'SANDBOX';

// @public
export interface EventPayload {
Expand Down Expand Up @@ -100,29 +90,13 @@ export interface EventPayload {
}

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

// @public
export enum RegionEnum {
// (undocumented)
EU = "eu",
// (undocumented)
US = "us"
}
export type Region = 'us' | 'eu';

// @public
export function reportBrowserAnalytics(): Promise<string>;

// @public
export type VersionLabel = EnumOrString<VersionLabelEnum>;

// @public
export enum VersionLabelEnum {
// (undocumented)
Production = "PRODUCTION",
// (undocumented)
Staging = "STAGING"
}
export type VersionLabel = 'PRODUCTION' | 'STAGING';

// (No @packageDocumentation comment for this package)

Expand Down
9 changes: 0 additions & 9 deletions src/EnumOrString.ts

This file was deleted.

17 changes: 1 addition & 16 deletions src/Environment.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
import { EnumOrString } from './EnumOrString';
/**
* An enum for the Yext Environments
*
* @remarks
* Affects the domain the requests are sent to.
*
* @public
*/
export enum EnvironmentEnum {
Production = 'PRODUCTION',
/** unsupported in the EU region */
Sandbox = 'SANDBOX'
}

/**
* The Yext Environments
*
Expand All @@ -21,4 +6,4 @@ export enum EnvironmentEnum {
*
* @public
*/
export type Environment = EnumOrString<EnvironmentEnum>;
export type Environment = 'PRODUCTION' | 'SANDBOX';
17 changes: 2 additions & 15 deletions src/Region.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
import { EnumOrString } from './EnumOrString';
/**
* An enum of the physical region the Yext account
*
* @remarks
* Affects the domain the requests are sent to.
*
* @public
*/
export enum RegionEnum {
US = 'us',
EU = 'eu'
}

/**
* The physical region of the Yext account
*
Expand All @@ -20,4 +6,5 @@ export enum RegionEnum {
*
* @public
*/
export type Region = EnumOrString<RegionEnum>;

export type Region = 'us' | 'eu';
17 changes: 1 addition & 16 deletions src/VersionLabel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { EnumOrString } from './EnumOrString';

/**
* An enum for the Search Version Labels
*
Expand All @@ -8,17 +6,4 @@ import { EnumOrString } from './EnumOrString';
*
* @public
*/
export enum VersionLabelEnum {
Production = 'PRODUCTION',
Staging = 'STAGING'
}

/**
* The Search Version Label
*
* @remarks
* Affects the contents of the versionLabel field in the search object field in the event payload.
*
* @public
*/
export type VersionLabel = EnumOrString<VersionLabelEnum>;
export type VersionLabel = 'PRODUCTION' | 'STAGING';
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export * from './AnalyticsEventService';
export * from './Environment';
export * from './Region';
export * from './EventPayload';
export * from './EnumOrString';
export * from './Action';
export * from './VersionLabel';

Expand Down
13 changes: 5 additions & 8 deletions src/setupRequestUrl.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { Environment, EnvironmentEnum } from './Environment';
import { Region, RegionEnum } from './Region';
import { Environment } from './Environment';
import { Region } from './Region';

const urlBase = 'yextevents.com/accounts/me/events';

export function setupRequestUrl(env?: Environment, region?: Region): string {
if (env === EnvironmentEnum.Sandbox && region === RegionEnum.EU) {
const isSandbox = env === 'SANDBOX';
if (isSandbox && region === 'eu') {
throw new Error('Sandbox environment is not available in the EU region.');
}
return (
'https://' +
(env === EnvironmentEnum.Sandbox ? 'sbx.' : '') +
(region ?? 'us') +
'.' +
urlBase
'https://' + (isSandbox ? 'sbx.' : '') + (region ?? 'us') + '.' + urlBase
);
}
Loading

0 comments on commit ac48e6c

Please sign in to comment.