Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventsSDK: Remove Enums #125

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions docs/analytics.enumorstring.md

This file was deleted.

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' | '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 |

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' | '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' | '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' | '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' | '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' | '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
12 changes: 7 additions & 5 deletions src/setupRequestUrl.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
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';
const lowerRegion = region?.toLowerCase();
if (isSandbox && lowerRegion === 'eu') {
throw new Error('Sandbox environment is not available in the EU region.');
}
return (
'https://' +
(env === EnvironmentEnum.Sandbox ? 'sbx.' : '') +
(region ?? 'us') +
(isSandbox ? 'sbx.' : '') +
(lowerRegion ?? 'us') +
'.' +
urlBase
);
Expand Down
2 changes: 1 addition & 1 deletion test-cdn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const analyticsProvider = window.AnalyticsSDK.analytics({
key: '<INSERT YEXT API KEY HERE>',
sessionTrackingEnabled: false,
region: 'eu'
region: 'EU'
}).with({
action: 'CHAT_LINK_CLICK',
pageUrl: 'http://www.yext-test-pageurl.com',
Expand Down
10 changes: 5 additions & 5 deletions test-site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading