@omniconvert/server-side-testing-sdk
Version:
TypeScript SDK for server-side A/B testing and experimentation
56 lines • 1.77 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebsiteStorage = void 0;
/**
* Website storage implementation
* Handles persistence of website-specific data and metadata
*/
class WebsiteStorage {
constructor(driver) {
this.driver = driver;
}
/**
* Get website ID
*/
getWebsiteId() {
const websiteId = this.driver.get(WebsiteStorage.WEBSITE_ID_KEY);
if (!websiteId) {
return null;
}
return typeof websiteId === 'string' ? websiteId : String(websiteId);
}
/**
* Save website ID
*/
saveWebsiteId(websiteId) {
return this.driver.save(WebsiteStorage.WEBSITE_ID_KEY, websiteId);
}
/**
* Get the timestamp of the last time experiments were fetched
*/
getLastExperimentsFetchTime() {
const timestamp = this.driver.get(WebsiteStorage.LAST_EXPERIMENTS_FETCH_TIME_KEY);
if (!timestamp) {
return null;
}
try {
const parsedTimestamp = typeof timestamp === 'string'
? JSON.parse(timestamp)
: timestamp;
return typeof parsedTimestamp === 'number' ? parsedTimestamp : parseInt(String(parsedTimestamp), 10);
}
catch {
return null;
}
}
/**
* Set the timestamp of the last time experiments were fetched
*/
saveLastExperimentsFetchTime(timestamp) {
return this.driver.save(WebsiteStorage.LAST_EXPERIMENTS_FETCH_TIME_KEY, timestamp);
}
}
exports.WebsiteStorage = WebsiteStorage;
WebsiteStorage.WEBSITE_ID_KEY = 'website_id';
WebsiteStorage.LAST_EXPERIMENTS_FETCH_TIME_KEY = 'last_experiments_fetch_time';
//# sourceMappingURL=WebsiteStorage.js.map
;