Skip to content

Commit d167e03

Browse files
committed
leave configuration meta uncompressed
1 parent d919d46 commit d167e03

File tree

3 files changed

+55
-24
lines changed

3 files changed

+55
-24
lines changed

local-install.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
4+
## Example:
5+
##
6+
## ./scripts/local-install.sh ./js-client-sdk-common ./react-native-sdk && ./scripts/local-install.sh ./react-native-sdk ../TestReactNative0720
7+
##
8+
9+
if [[ "$1" = "" || "$2" = "" ]]; then
10+
echo 'USAGE: ./local-install.sh <package-to-install-path> <consuming-app-path>'
11+
ehco ''
12+
echo ''
13+
exit 1
14+
fi
15+
16+
if [ ! -d "$1" ]; then
17+
echo "$1 is not a directory"
18+
exit 1
19+
fi
20+
21+
if [ ! -f "$1/package.json" ]; then
22+
echo "$1 is not an npm package"
23+
exit 1
24+
fi
25+
26+
if [ ! -d "$2" ]; then
27+
echo "$2 is not a directory"
28+
exit 1
29+
fi
30+
31+
### Create local package via "npm pack"
32+
pushd "$1" > /dev/null
33+
rm -rf package pack.out pack.err && npm pack 2> pack.err > pack.out
34+
COMPRESSED_PACKAGE="$(tail -1 pack.out)"
35+
tar -xzf "${COMPRESSED_PACKAGE}"
36+
rm "${COMPRESSED_PACKAGE}"
37+
PACKAGE_DIR="$(pwd)/package"
38+
popd > /dev/null
39+
40+
### Install local package to target package
41+
pushd "$2" > /dev/null
42+
TARGET_DIR="$(pwd)"
43+
yarn add "${PACKAGE_DIR}" --exact
44+
popd > /dev/null
45+
46+
echo "$PACKAGE_DIR installed in $TARGET_DIR"

src/local-storage-engine.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,21 @@ describe('LocalStorageEngine Compression Migration', () => {
178178
consoleSpy.mockRestore();
179179
});
180180

181-
it('should compress and decompress meta data', async () => {
181+
it('should store and retrieve meta data without compression', async () => {
182182
const metaData = JSON.stringify({ lastUpdated: Date.now() });
183183

184184
await engine.setMetaJsonString(metaData);
185185

186+
// Meta data should be stored uncompressed
186187
expect(mockLocalStorage.setItem).toHaveBeenCalledWith(
187188
'eppo-configuration-meta-test',
188-
LZString.compress(metaData),
189+
metaData,
189190
);
190191

191192
// Test reading back
192-
const compressedMeta = LZString.compress(metaData);
193193
(mockLocalStorage.getItem as jest.Mock).mockImplementation((key) => {
194194
if (key === 'eppo-meta') return JSON.stringify({ version: 1, migratedAt: Date.now() });
195-
if (key === 'eppo-configuration-meta-test') return compressedMeta;
195+
if (key === 'eppo-configuration-meta-test') return metaData;
196196
return null;
197197
});
198198

src/local-storage-engine.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,7 @@ export class LocalStorageEngine implements IStringStorageEngine {
4949
};
5050

5151
public getMetaJsonString = async (): Promise<string | null> => {
52-
const stored = this.localStorage.getItem(this.metaKey);
53-
if (!stored) return null;
54-
55-
try {
56-
return LZString.decompress(stored) || null;
57-
} catch (e) {
58-
console.warn('Failed to decompress meta, removing corrupted data');
59-
this.localStorage.removeItem(this.metaKey);
60-
return null;
61-
}
52+
return this.localStorage.getItem(this.metaKey);
6253
};
6354

6455
public setContentsJsonString = async (configurationJsonString: string): Promise<void> => {
@@ -67,8 +58,7 @@ export class LocalStorageEngine implements IStringStorageEngine {
6758
};
6859

6960
public setMetaJsonString = async (metaJsonString: string): Promise<void> => {
70-
const compressed = LZString.compress(metaJsonString);
71-
this.localStorage.setItem(this.metaKey, compressed);
61+
this.localStorage.setItem(this.metaKey, metaJsonString);
7262
};
7363

7464
private ensureCompressionMigration(): void {
@@ -78,10 +68,6 @@ export class LocalStorageEngine implements IStringStorageEngine {
7868
return; // Already migrated
7969
}
8070

81-
console.log(
82-
`Running storage migration from v${globalMeta.version} to v${LocalStorageEngine.MIGRATION_VERSION}`,
83-
);
84-
8571
try {
8672
this.deleteAllConfigurations();
8773

@@ -90,9 +76,8 @@ export class LocalStorageEngine implements IStringStorageEngine {
9076
version: LocalStorageEngine.MIGRATION_VERSION,
9177
});
9278

93-
console.log('Configuration cleanup completed - fresh configs will be compressed');
9479
} catch (e) {
95-
console.warn('Migration failed:', e);
80+
// Migration failed, continue silently
9681
}
9782
}
9883

@@ -112,7 +97,7 @@ export class LocalStorageEngine implements IStringStorageEngine {
11297
this.localStorage.removeItem(key);
11398
});
11499

115-
console.log(`Deleted ${keysToDelete.length} old configuration keys.`);
100+
// Deleted old configuration keys for compression migration
116101
}
117102

118103
private getGlobalMeta(): EppoGlobalMeta {
@@ -122,7 +107,7 @@ export class LocalStorageEngine implements IStringStorageEngine {
122107
return JSON.parse(stored);
123108
}
124109
} catch (e) {
125-
console.warn('Failed to parse global meta:', e);
110+
// Failed to parse global meta, will use default
126111
}
127112

128113
return { version: 0 }; // Default to version 0

0 commit comments

Comments
 (0)