Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ logs/
temp
.env
yarn-error.log

test/assignmentTestData
17 changes: 0 additions & 17 deletions docs/js-client-sdk.dummy.md

This file was deleted.

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

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [getInstance](./js-client-sdk.getinstance.md)

## getInstance() function

Used to access a singleton SDK client instance. Use the method after calling init() to initialize the client.

<b>Signature:</b>

```typescript
export declare function getInstance(): IEppoClient;
```
<b>Returns:</b>

[IEppoClient](./js-client-sdk.ieppoclient.md)

a singleton client instance

13 changes: 13 additions & 0 deletions docs/js-client-sdk.iclientconfig.apikey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IClientConfig](./js-client-sdk.iclientconfig.md) &gt; [apiKey](./js-client-sdk.iclientconfig.apikey.md)

## IClientConfig.apiKey property

Eppo API key

<b>Signature:</b>

```typescript
apiKey: string;
```
13 changes: 13 additions & 0 deletions docs/js-client-sdk.iclientconfig.baseurl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IClientConfig](./js-client-sdk.iclientconfig.md) &gt; [baseUrl](./js-client-sdk.iclientconfig.baseurl.md)

## IClientConfig.baseUrl property

Base URL of the Eppo API. Clients should use the default setting in most cases.

<b>Signature:</b>

```typescript
baseUrl?: string;
```
21 changes: 21 additions & 0 deletions docs/js-client-sdk.iclientconfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IClientConfig](./js-client-sdk.iclientconfig.md)

## IClientConfig interface

Configuration used for initializing the Eppo client

<b>Signature:</b>

```typescript
export interface IClientConfig
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [apiKey](./js-client-sdk.iclientconfig.apikey.md) | string | Eppo API key |
| [baseUrl?](./js-client-sdk.iclientconfig.baseurl.md) | string | <i>(Optional)</i> Base URL of the Eppo API. Clients should use the default setting in most cases. |

28 changes: 28 additions & 0 deletions docs/js-client-sdk.ieppoclient.getassignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IEppoClient](./js-client-sdk.ieppoclient.md) &gt; [getAssignment](./js-client-sdk.ieppoclient.getassignment.md)

## IEppoClient.getAssignment() method

Maps a subject to a variation for a given experiment.

<b>Signature:</b>

```typescript
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: Record<string, any>): string;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| subjectKey | string | an identifier of the experiment subject, for example a user ID. |
| experimentKey | string | experiment identifier |
| subjectAttributes | Record&lt;string, any&gt; | <i>(Optional)</i> optional attributes associated with the subject, for example name and email. The subject attributes are used for evaluating any targeting rules tied to the experiment. |

<b>Returns:</b>

string

a variation value if the subject is part of the experiment sample, otherwise null

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

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [IEppoClient](./js-client-sdk.ieppoclient.md)

## IEppoClient interface

Client for assigning experiment variations.

<b>Signature:</b>

```typescript
export interface IEppoClient
```

## Methods

| Method | Description |
| --- | --- |
| [getAssignment(subjectKey, experimentKey, subjectAttributes)](./js-client-sdk.ieppoclient.getassignment.md) | Maps a subject to a variation for a given experiment. |

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

[Home](./index.md) &gt; [@eppo/js-client-sdk](./js-client-sdk.md) &gt; [init](./js-client-sdk.init.md)

## init() function

Initializes the Eppo client with configuration parameters. This method should be called once on application startup. After invocation of this method, the SDK will poll Eppo's API at regular intervals to retrieve assignment configurations.

<b>Signature:</b>

```typescript
export declare function init(config: IClientConfig): Promise<IEppoClient>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| config | [IClientConfig](./js-client-sdk.iclientconfig.md) | client configuration |

<b>Returns:</b>

Promise&lt;[IEppoClient](./js-client-sdk.ieppoclient.md)<!-- -->&gt;

10 changes: 9 additions & 1 deletion docs/js-client-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,13 @@

| Function | Description |
| --- | --- |
| [dummy()](./js-client-sdk.dummy.md) | Test documentation |
| [getInstance()](./js-client-sdk.getinstance.md) | Used to access a singleton SDK client instance. Use the method after calling init() to initialize the client. |
| [init(config)](./js-client-sdk.init.md) | Initializes the Eppo client with configuration parameters. This method should be called once on application startup. After invocation of this method, the SDK will poll Eppo's API at regular intervals to retrieve assignment configurations. |

## Interfaces

| Interface | Description |
| --- | --- |
| [IClientConfig](./js-client-sdk.iclientconfig.md) | Configuration used for initializing the Eppo client |
| [IEppoClient](./js-client-sdk.ieppoclient.md) | Client for assigning experiment variations. |

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
globalSetup: './test/globalSetup.ts',
collectCoverageFrom: ['**/*.(t|j)s'],
coverageDirectory: 'coverage/',
testEnvironment: 'node',
Expand Down
16 changes: 15 additions & 1 deletion js-client-sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@
```ts

// @public
export function dummy(): string;
export function getInstance(): IEppoClient;

// @public
export interface IClientConfig {
apiKey: string;
baseUrl?: string;
}

// @public
export interface IEppoClient {
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: Record<string, any>): string;
}

// @public
export function init(config: IClientConfig): Promise<IEppoClient>;

// (No @packageDocumentation comment for this package)

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"homepage": "https://github.com/Eppo-exp/js-client-sdk#readme",
"devDependencies": {
"@google-cloud/storage": "^6.1.0",
"@microsoft/api-documenter": "^7.17.17",
"@microsoft/api-extractor": "^7.25.0",
"@types/jest": "^28.1.1",
Expand All @@ -44,8 +45,10 @@
"jest": "^28.1.1",
"jest-environment-jsdom": "^28.1.1",
"prettier": "^2.7.1",
"testdouble": "^3.16.6",
"ts-jest": "^28.0.5",
"typescript": "^4.7.3"
"typescript": "^4.7.3",
"xhr-mock": "^2.5.1"
},
"dependencies": {
"axios": "^0.27.2"
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const REQUEST_TIMEOUT_MILLIS = 5000;
export const BASE_URL = 'https://eppo.cloud/api';
Loading