Skip to content

Commit 3e903f1

Browse files
authored
feat: Evaluation Details (#51)
1 parent 2c12f83 commit 3e903f1

File tree

5 files changed

+57
-12
lines changed

5 files changed

+57
-12
lines changed

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eppo/react-native-sdk",
3-
"version": "3.0.2",
3+
"version": "3.1.0",
44
"description": "Eppo React Native SDK",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
@@ -51,7 +51,7 @@
5151
"registry": "https://registry.npmjs.org/"
5252
},
5353
"dependencies": {
54-
"@eppo/js-client-sdk-common": "3.2.0",
54+
"@eppo/js-client-sdk-common": "4.0.0",
5555
"@react-native-async-storage/async-storage": "^1.18.0",
5656
"md5": "^2.3.0"
5757
},

Diff for: src/async-storage.ts

+40-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
ISyncStore,
55
} from '@eppo/js-client-sdk-common';
66
import type {
7+
Environment,
78
Flag,
89
ObfuscatedFlag,
910
} from '@eppo/js-client-sdk-common/dist/interfaces';
@@ -35,6 +36,10 @@ class AsyncStorageStore<T> implements ISyncStore<T> {
3536
return Object.keys(this.cache);
3637
}
3738

39+
entries(): Record<string, T> {
40+
return this.cache;
41+
}
42+
3843
public setEntries(entries: Record<string, T>): void {
3944
for (var key in entries) {
4045
this.cache[key] = entries[key];
@@ -51,11 +56,16 @@ export class EppoAsyncStorage
5156
servingStore: ISyncStore<Flag | ObfuscatedFlag>;
5257
persistentStore: IAsyncStore<Flag | ObfuscatedFlag> | null;
5358
private initialized: boolean;
59+
private environment: Environment | null = null;
60+
private configFetchedAt: string | null = null;
61+
private configPublishedAt: string | null = null;
5462

5563
constructor() {
5664
this.servingStore = new AsyncStorageStore<Flag | ObfuscatedFlag>();
5765
this.persistentStore = null;
5866
this.initialized = false;
67+
this.configFetchedAt = '';
68+
this.configPublishedAt = '';
5969
}
6070

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

92+
entries(): Record<string, Flag | ObfuscatedFlag> {
93+
return this.servingStore.entries();
94+
}
95+
8296
async setEntries(
8397
entries: Record<string, Flag | ObfuscatedFlag>
84-
): Promise<void> {
98+
): Promise<boolean> {
8599
this.servingStore.setEntries(entries);
86100
this.initialized = true;
101+
return true;
102+
}
103+
104+
getEnvironment(): Environment | null {
105+
return this.environment;
106+
}
107+
108+
setEnvironment(environment: Environment): void {
109+
this.environment = environment;
110+
}
111+
112+
public getConfigFetchedAt(): string | null {
113+
return this.configFetchedAt;
114+
}
115+
116+
public setConfigFetchedAt(configFetchedAt: string): void {
117+
this.configFetchedAt = configFetchedAt;
118+
}
119+
120+
public getConfigPublishedAt(): string | null {
121+
return this.configPublishedAt;
122+
}
123+
124+
public setConfigPublishedAt(configPublishedAt: string): void {
125+
this.configPublishedAt = configPublishedAt;
87126
}
88127
}

Diff for: src/index.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import {
22
IAssignmentLogger,
33
IAssignmentEvent,
44
validation,
5-
IEppoClient,
65
EppoClient,
76
FlagConfigurationRequestParameters,
7+
IAssignmentDetails,
88
} from '@eppo/js-client-sdk-common';
99

1010
import { EppoAsyncStorage } from './async-storage';
@@ -56,7 +56,7 @@ export interface IClientConfig {
5656
numPollRequestRetries?: number;
5757
}
5858

59-
export { IAssignmentLogger, IAssignmentEvent, IEppoClient };
59+
export { IAssignmentDetails, IAssignmentLogger, IAssignmentEvent, EppoClient };
6060

6161
const asyncStorage = new EppoAsyncStorage();
6262

@@ -66,6 +66,8 @@ export class EppoReactNativeClient extends EppoClient {
6666
public static instance: EppoReactNativeClient = new EppoReactNativeClient(
6767
asyncStorage,
6868
undefined,
69+
undefined,
70+
undefined,
6971
true
7072
);
7173
}
@@ -76,7 +78,7 @@ export class EppoReactNativeClient extends EppoClient {
7678
* @param config client configuration
7779
* @public
7880
*/
79-
export async function init(config: IClientConfig): Promise<IEppoClient> {
81+
export async function init(config: IClientConfig): Promise<EppoClient> {
8082
validation.validateNotBlank(config.apiKey, 'API key required');
8183

8284
try {
@@ -127,6 +129,6 @@ export async function init(config: IClientConfig): Promise<IEppoClient> {
127129
* Use the method after calling init() to initialize the client.
128130
* @returns a singleton client instance
129131
*/
130-
export function getInstance(): IEppoClient {
132+
export function getInstance(): EppoClient {
131133
return EppoReactNativeClient.instance;
132134
}

Diff for: tsconfig.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,9 @@
2424
"skipLibCheck": true,
2525
"strict": true,
2626
"target": "esnext"
27-
}
27+
},
28+
"exclude": [
29+
"node_modules",
30+
"dist",
31+
]
2832
}

Diff for: yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1213,10 +1213,10 @@
12131213
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
12141214
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
12151215

1216-
"@eppo/js-client-sdk-common@3.2.0":
1217-
version "3.2.0"
1218-
resolved "https://registry.yarnpkg.com/@eppo/js-client-sdk-common/-/js-client-sdk-common-3.2.0.tgz#e96895e3c74471f41892feb31d56c67f36c1b3e6"
1219-
integrity sha512-ua+4Mez7Ti/4XDPSKWbR8gg611UN9XnvModWAE7sjrHP60QNfmhvW6m+jXepDgQFRsybU0xXrddZQiVbDcCrUQ==
1216+
"@eppo/js-client-sdk-common@4.0.0":
1217+
version "4.0.0"
1218+
resolved "https://registry.yarnpkg.com/@eppo/js-client-sdk-common/-/js-client-sdk-common-4.0.0.tgz#39dea02745b641915fa4e925d75a12ca5b1e9503"
1219+
integrity sha512-aMru8KESyNJDU/fm5jVENUhpa1jB88FUncT/xnjgiWPuTLLrpi10Qshoj7Lloi8IjlwFSFMjDjtpuQoLKPpQXA==
12201220
dependencies:
12211221
js-base64 "^3.7.7"
12221222
md5 "^2.3.0"

0 commit comments

Comments
 (0)