Extend experiemnt expiration TTL to an hour
This commit is contained in:
parent
dd6f161467
commit
a64844de1a
|
@ -7,7 +7,11 @@ import { apiFetch } from '@wordpress/data-controls';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import TYPES from './action-types';
|
import TYPES from './action-types';
|
||||||
import { EXPERIMENT_NAME_PREFIX, TRANSIENT_NAME_PREFIX } from './constants';
|
import {
|
||||||
|
EXPERIMENT_NAME_PREFIX,
|
||||||
|
TRANSIENT_NAME_PREFIX,
|
||||||
|
TRANSIENT_TIMEOUT_NAME_PREFIX,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
function toggleFrontendExperiment( experimentName, newVariation ) {
|
function toggleFrontendExperiment( experimentName, newVariation ) {
|
||||||
const storageItem = JSON.parse(
|
const storageItem = JSON.parse(
|
||||||
|
@ -15,6 +19,7 @@ function toggleFrontendExperiment( experimentName, newVariation ) {
|
||||||
);
|
);
|
||||||
|
|
||||||
storageItem.variationName = newVariation;
|
storageItem.variationName = newVariation;
|
||||||
|
storageItem.ttl = 3600;
|
||||||
|
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
EXPERIMENT_NAME_PREFIX + experimentName,
|
EXPERIMENT_NAME_PREFIX + experimentName,
|
||||||
|
@ -26,6 +31,9 @@ function* toggleBackendExperiment( experimentName, newVariation ) {
|
||||||
try {
|
try {
|
||||||
const payload = {};
|
const payload = {};
|
||||||
payload[ TRANSIENT_NAME_PREFIX + experimentName ] = newVariation;
|
payload[ TRANSIENT_NAME_PREFIX + experimentName ] = newVariation;
|
||||||
|
payload[ TRANSIENT_TIMEOUT_NAME_PREFIX + experimentName ] =
|
||||||
|
Math.round( Date.now() / 1000 ) + 3600;
|
||||||
|
|
||||||
yield apiFetch( {
|
yield apiFetch( {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: '/wc-admin/options',
|
path: '/wc-admin/options',
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
export const STORE_KEY = 'wc-admin-helper/experiments';
|
export const STORE_KEY = 'wc-admin-helper/experiments';
|
||||||
export const EXPERIMENT_NAME_PREFIX = 'explat-experiment--';
|
export const EXPERIMENT_NAME_PREFIX = 'explat-experiment--';
|
||||||
export const TRANSIENT_NAME_PREFIX = '_transient_abtest_variation_';
|
export const TRANSIENT_NAME_PREFIX = '_transient_abtest_variation_';
|
||||||
|
export const TRANSIENT_TIMEOUT_NAME_PREFIX =
|
||||||
|
'_transient_timeout_abtest_variation';
|
||||||
export const API_NAMESPACE = '/wc-admin-test-helper';
|
export const API_NAMESPACE = '/wc-admin-test-helper';
|
||||||
|
|
Loading…
Reference in New Issue