landing-page-experiments
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -1,2 +0,113 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StatsigABHelper=e():t.StatsigABHelper=e()}(self,(()=>(()=>{"use strict";var t={d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>o});class o{static getCookie(t){const e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]+)"));if(e)return e[2]}static setCookie(t,e){document.cookie=`${t}=${e}; max-age=31536000; path=/`}static getStableID(){const t="statsig_stable_id";let e=this.getCookie(t);return e||(e=Date.now().toString(36)+Math.random().toString(36).substring(2),this.setCookie(t,e)),e}static getExperimentConfig(t,e){return o=this,n=void 0,r=function*(){const o=this.getStableID(),n=yield fetch("https://featuregates.org/v1/get_config",{method:"POST",headers:{"Content-Type":"application/json","statsig-api-key":t},body:JSON.stringify({user:{userId:o,customIDs:{stableID:o}},configName:e})});if(n.ok)return yield n.json()},new((i=void 0)||(i=Promise))((function(t,e){function a(t){try{c(r.next(t))}catch(t){e(t)}}function s(t){try{c(r.throw(t))}catch(t){e(t)}}function c(e){var o;e.done?t(e.value):(o=e.value,o instanceof i?o:new i((function(t){t(o)}))).then(a,s)}c((r=r.apply(o,n||[])).next())}));var o,n,i,r}static redirectToUrl(t){const e=new URL(window.location.href),o=new URL(t,window.location.href);e.pathname!=o.pathname&&window.location.replace(t)}static performRedirect(t,e){this.getExperimentConfig(t,e).then((t=>{var e;const o=null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.page_url;o&&this.redirectToUrl(o)})).catch((t=>{console.log(t)}))}}return window.StatsigABHelper=o,e.default})())); | ||
//# sourceMappingURL=index.js.map | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
window["StatsigABHelper"] = window["StatsigABHelper"] || { | ||
getCookie: function (name) { | ||
var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); | ||
if (match) { | ||
return match[2]; | ||
} | ||
}, | ||
setCookie: function (name, value) { | ||
document.cookie = "".concat(name, "=").concat(value, "; max-age=31536000; path=/"); | ||
}, | ||
getStableID: function () { | ||
var key = 'statsig_stable_id'; | ||
var sid = this.getCookie(key); | ||
if (!sid) { | ||
sid = Date.now().toString(36) + Math.random().toString(36).substring(2); | ||
this.setCookie(key, sid); | ||
} | ||
return sid; | ||
}, | ||
getExperimentConfig: function (apiKey, experimentName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var sid, resp; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
sid = this.getStableID(); | ||
return [4 /*yield*/, fetch('https://featuregates.org/v1/get_config', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'statsig-api-key': apiKey, | ||
}, | ||
body: JSON.stringify({ | ||
user: { | ||
userId: sid, | ||
customIDs: { | ||
stableID: sid, | ||
} | ||
}, | ||
configName: experimentName, | ||
}), | ||
})]; | ||
case 1: | ||
resp = _a.sent(); | ||
if (!resp.ok) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, resp.json()]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}, | ||
redirectToUrl: function (url) { | ||
var currentUrl = new URL(window.location.href); | ||
var newUrl = new URL(url, window.location.href); | ||
if (currentUrl.pathname == newUrl.pathname) { | ||
return; | ||
} | ||
window.location.replace(url); | ||
}, | ||
performRedirect: function (apiKey, experimentName) { | ||
var _this = this; | ||
this.getExperimentConfig(apiKey, experimentName) | ||
.then(function (config) { | ||
var _a; | ||
var url = (_a = config === null || config === void 0 ? void 0 : config.value) === null || _a === void 0 ? void 0 : _a.page_url; | ||
if (url) { | ||
_this.redirectToUrl(url); | ||
return; | ||
} | ||
}) | ||
.catch(function (reason) { | ||
console.log(reason); | ||
}); | ||
} | ||
}; |
{ | ||
"name": "landing-page-experiments", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "Statsig helps run landing page experiments by redirecting users to two or more landing pages based on an ABn Test.", | ||
@@ -8,5 +8,3 @@ "jsdelivr": "dist/index.js", | ||
"scripts": { | ||
"prepare": "rm -rf dist/ && npm run build", | ||
"prepublish": "npm run build", | ||
"build": "webpack", | ||
"prepare": "rm -rf dist/ && tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -26,6 +24,4 @@ }, | ||
"ts-loader": "^9.4.2", | ||
"typescript": "^4.9.4", | ||
"webpack": "^5.75.0", | ||
"webpack-cli": "^5.0.1" | ||
"typescript": "^4.9.4" | ||
} | ||
} |
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"strict": true, | ||
"outDir": "dist", | ||
"sourceMap": false, | ||
"esModuleInterop": true, | ||
"target": "es6", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"outDir": "dist", | ||
"allowJs": true, | ||
"checkJs": false, | ||
"declaration": false, | ||
"skipLibCheck": true, | ||
"moduleResolution": "node" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": [ | ||
"node_modules", | ||
"typings", | ||
"src/__tests__/*", | ||
"src/utils/__tests__/*", | ||
"dist", | ||
"build" | ||
], | ||
"lib": ["es2015"] | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
223
10331
8
3