Skip to content

Commit

Permalink
feat: Evaluation Details
Browse files Browse the repository at this point in the history
  • Loading branch information
greghuels committed Jul 11, 2024
1 parent 2c12f83 commit 0c449aa
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eppo/react-native-sdk",
"version": "3.0.2",
"version": "3.1.0",
"description": "Eppo React Native SDK",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down Expand Up @@ -51,7 +51,7 @@
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"@eppo/js-client-sdk-common": "3.2.0",
"@eppo/js-client-sdk-common": "4.0.0",
"@react-native-async-storage/async-storage": "^1.18.0",
"md5": "^2.3.0"
},
Expand Down
41 changes: 40 additions & 1 deletion src/async-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
ISyncStore,
} from '@eppo/js-client-sdk-common';
import type {
Environment,

Check failure on line 7 in src/async-storage.ts

View workflow job for this annotation

GitHub Actions / lint

Module '"@eppo/js-client-sdk-common/dist/interfaces"' has no exported member 'Environment'.
Flag,
ObfuscatedFlag,
} from '@eppo/js-client-sdk-common/dist/interfaces';
Expand Down Expand Up @@ -35,6 +36,10 @@ class AsyncStorageStore<T> implements ISyncStore<T> {
return Object.keys(this.cache);
}

entries(): Record<string, T> {
return this.cache;
}

public setEntries(entries: Record<string, T>): void {
for (var key in entries) {
this.cache[key] = entries[key];
Expand All @@ -51,11 +56,16 @@ export class EppoAsyncStorage
servingStore: ISyncStore<Flag | ObfuscatedFlag>;
persistentStore: IAsyncStore<Flag | ObfuscatedFlag> | null;
private initialized: boolean;
private environment: Environment | null = null;
private configFetchedAt: string | null = null;
private configPublishedAt: string | null = null;

constructor() {
this.servingStore = new AsyncStorageStore<Flag | ObfuscatedFlag>();
this.persistentStore = null;
this.initialized = false;
this.configFetchedAt = '';
this.configPublishedAt = '';
}

init(): Promise<void> {
Expand All @@ -79,10 +89,39 @@ export class EppoAsyncStorage
return this.initialized;
}

entries(): Record<string, Flag | ObfuscatedFlag> {
return this.servingStore.entries();

Check failure on line 93 in src/async-storage.ts

View workflow job for this annotation

GitHub Actions / lint

Property 'entries' does not exist on type 'ISyncStore<Flag | ObfuscatedFlag>'.
}

async setEntries(

Check failure on line 96 in src/async-storage.ts

View workflow job for this annotation

GitHub Actions / lint

Property 'setEntries' in type 'EppoAsyncStorage' is not assignable to the same property in base type 'IConfigurationStore<Flag | ObfuscatedFlag>'.
entries: Record<string, Flag | ObfuscatedFlag>
): Promise<void> {
): Promise<boolean> {
this.servingStore.setEntries(entries);
this.initialized = true;
return true;
}

getEnvironment(): Environment | null {
return this.environment;
}

setEnvironment(environment: Environment): void {
this.environment = environment;
}

public getConfigFetchedAt(): string | null {
return this.configFetchedAt;
}

public setConfigFetchedAt(configFetchedAt: string): void {
this.configFetchedAt = configFetchedAt;
}

public getConfigPublishedAt(): string | null {
return this.configPublishedAt;
}

public setConfigPublishedAt(configPublishedAt: string): void {
this.configPublishedAt = configPublishedAt;
}
}
9 changes: 5 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
IAssignmentLogger,
IAssignmentEvent,
validation,
IEppoClient,
EppoClient,
FlagConfigurationRequestParameters,
} from '@eppo/js-client-sdk-common';
Expand Down Expand Up @@ -56,7 +55,7 @@ export interface IClientConfig {
numPollRequestRetries?: number;
}

export { IAssignmentLogger, IAssignmentEvent, IEppoClient };
export { IAssignmentLogger, IAssignmentEvent, EppoClient };

const asyncStorage = new EppoAsyncStorage();

Expand All @@ -66,6 +65,8 @@ export class EppoReactNativeClient extends EppoClient {
public static instance: EppoReactNativeClient = new EppoReactNativeClient(
asyncStorage,
undefined,
undefined,
undefined,

Check failure on line 69 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected 1-3 arguments, but got 5.
true
);
}
Expand All @@ -76,7 +77,7 @@ export class EppoReactNativeClient extends EppoClient {
* @param config client configuration
* @public
*/
export async function init(config: IClientConfig): Promise<IEppoClient> {
export async function init(config: IClientConfig): Promise<EppoClient> {
validation.validateNotBlank(config.apiKey, 'API key required');

try {
Expand Down Expand Up @@ -127,6 +128,6 @@ export async function init(config: IClientConfig): Promise<IEppoClient> {
* Use the method after calling init() to initialize the client.
* @returns a singleton client instance
*/
export function getInstance(): IEppoClient {
export function getInstance(): EppoClient {
return EppoReactNativeClient.instance;
}
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@
"skipLibCheck": true,
"strict": true,
"target": "esnext"
}
},
"exclude": [
"node_modules",
"dist",
]
}

0 comments on commit 0c449aa

Please sign in to comment.