@obelism/improve-sdk 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0});var t=require("ua-parser-js"),i=t&&t.__esModule?t:{default:t};const e={device:["wearable","mobile","tablet","console","smarttv","embedded","desktop"],browser:["chrome","safari","firefox","edge","ie","samsung internet","social","other"],os:["mac os","ios","android","windows","unix"]},s=t=>t&&e.device.includes(t)?t:"desktop",r=["tiktok","wechat","weibo","snapchat","klarna","Line","instagram","facebook","alipay","Baidu"],o=(t="")=>{if(!t)return"other";let i=t.toLowerCase();return e.browser.find(t=>i.includes(t))||(r.includes(i)?"social":"other")},n=["wearable","mobile","tablet"],l=t=>n.includes(t)?"coarse":"fine",a=(t="")=>{if(!t)return"unix";let i=t.toLowerCase();return e.os.find(t=>i.includes(t))||"unix"},u=t=>{if(!t||"string"!=typeof t)return null;let e=new i.default(t).getResult(),r=s(e.device.type);return{pointer:l(r),device:r,browser:o(e.browser.name),os:a(e.os.name)}},h=(t,i)=>!t||Object.entries(t).every(([t,e])=>i[t]===e),c=t=>{if(0===t.length)return null;if(1===t.length)return t[0].slug;let i=Math.floor(Math.random()*t.reduce((t,i)=>t+=i.split,0)),e=0,s=t.find(t=>{let s=e,r=e+t.split;return i>=s&&i<r||(e=r,!1)});return s?.slug||t.at(-1)?.slug},d="https://improve.obelism.studio",f=`${d}/config`,g=`${d}/api/log`,v="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",p=t=>new Promise(i=>setTimeout(i,t)),m=async(t=1e3,i)=>(await p(t),i?.abort(),null),w=(t=3e3,i,e)=>{let s=new AbortController;return Promise.race([fetch(i,{...e,signal:s.signal}),m(t,s)])};class b{#t;constructor({organizationId:t,environment:i,config:e,fetchTimeout:s}){this.organizationId="",this.environment="develop",this.#t=null,this.config=null,this.fetchConfig=async()=>{if(this.config)return;if(!this.#t){console.log("No config fetch setup provided");return}let t=await w(this.#t.timeout,this.#t.url);if(!t){console.log("Configuration fetch timed-out");return}this.config=await t.json()},this.generateVisitorId=()=>`visi_${(function(t=5){return t&&"number"==typeof t?Array(t).fill("").reduce(t=>t+=v.charAt(Math.floor(Math.random()*v.length)),""):""})(26).toUpperCase()}`,this.getVisitorCookieName=()=>"visitorId",this.organizationId=t,this.environment=i,e?this.config=e:this.#t={url:[f,t,i].join("/"),timeout:s||3e3}}}const y=t=>{if(!t)return!1;let i=document.cookie.split("; ").find(i=>{let[e]=i.split("=");return t===e});return!!i&&i.split("=")[1]},I=(t,i)=>{let e=new Date;e.setMonth(e.getMonth()+1),document.cookie=`${t}=${i};path=/;expires=${e.toUTCString()}`},V=()=>{let t=window.innerWidth;return t<=768?"small":t<=1024?"medium":t<=1200?"large":"huge"};exports.ImproveClientSDK=class extends b{#i;#e;#s;#r;#o;constructor(...t){super(...t),this.#e=!1,this.#s="",this.#r={},this.#o=g,this.setupVisitor=(t=window.navigator.userAgent)=>{let i=y(this.getVisitorCookieName());this.#e=!!i,this.#s=i||this.generateVisitorId();let e=u(t);return e?(this.#i=e,I(this.getVisitorCookieName(),this.#s),this.#s):null},this.getFlagValue=t=>{if(!this.config)return null;let i=this.config.flags[t];if(!i)return null;if(this.#i||this.setupVisitor(),!this.#s||!this.#i)return i.options[0].slug;if(this.#i?.[t])return this.#i[t];if(!h(this.config.audience[i.audience],this.#i))return i.options[0].slug;let e=y(t)||c(i.options);return e?(this.#i[t]=e,I(t,e),e):null},this.getTestValue=t=>{if(!this.config)return null;let i=this.config.tests[t];if(!i)return null;if(this.#i||this.setupVisitor(),!this.#s||!this.#i)return i.defaultValue;if(this.#i?.[t])return this.#i[t];if(!h(this.config.audience[i.audience],this.#i))return i.defaultValue;if(i.allocation<100&&100*Math.random()>i.allocation)return this.#i[t]=i.defaultValue,this.#i?.[t];let e=y(t)||c(i.options);return e?(this.#i[t]=e,I(t,e),e):null},this.setAnalyticsUrls=t=>{this.#o=t},this.postAnalytic=(t,i,e)=>{if(!this.config)return null;let s=this.config.tests[t];if(this.#i||this.setupVisitor(),!s||!this.#i||this.#r?.[t]?.[i])return null;this.#r[t]=this.#r[t]||{},this.#r[t][i]=!0,this.#i?.[t]||this.getTestValue(t);let r={organizationId:this.organizationId,environment:this.environment,test_id:s.id,test_value:this.#i[t],visitor_id:this.#s,pointer:this.#i.pointer,device:this.#i.device,screen:V(),browser:this.#i.browser,os:this.#i.os,visitor:this.#e?"recurring":"new",event:i,message:e||""};return fetch(this.#o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}}};
1
+ Object.defineProperty(exports,"__esModule",{value:!0});var t=require("ua-parser-js"),i=t&&t.__esModule?t:{default:t};const e={device:["wearable","mobile","tablet","console","smarttv","embedded","desktop"],browser:["chrome","safari","firefox","edge","ie","samsung internet","social","other"],os:["mac os","ios","android","windows","unix"]},s=t=>t&&e.device.includes(t)?t:"desktop",r=["tiktok","wechat","weibo","snapchat","klarna","Line","instagram","facebook","alipay","Baidu"],o=(t="")=>{if(!t)return"other";let i=t.toLowerCase();return e.browser.find(t=>i.includes(t))||(r.includes(i)?"social":"other")},n=["wearable","mobile","tablet"],l=t=>n.includes(t)?"coarse":"fine",a=(t="")=>{if(!t)return"unix";let i=t.toLowerCase();return e.os.find(t=>i.includes(t))||"unix"},u=t=>{if(!t||"string"!=typeof t)return null;let e=new i.default(t).getResult(),r=s(e.device.type);return{pointer:l(r),device:r,browser:o(e.browser.name),os:a(e.os.name)}},h=(t,i)=>!t||Object.entries(t).every(([t,e])=>i[t]===e),c=t=>{if(0===t.length)return null;if(1===t.length)return t[0].slug;let i=Math.floor(Math.random()*t.reduce((t,i)=>t+=i.split,0)),e=0,s=t.find(t=>{let s=e,r=e+t.split;return i>=s&&i<r||(e=r,!1)});return s?.slug||t.at(-1)?.slug},d="https://improve.obelism.studio",f=`${d}/config`,g=`${d}/api/log`,v="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",p=t=>new Promise(i=>setTimeout(i,t)),m=async(t=1e3,i)=>(await p(t),i?.abort(),null),w=(t=3e3,i,e)=>{let s=new AbortController;return Promise.race([fetch(i,{...e,signal:s.signal}),m(t,s)])};class b{#t;constructor({organizationId:t,environment:i,config:e,fetchTimeout:s}){this.organizationId="",this.environment="develop",this.#t=null,this.config=null,this.fetchConfig=async()=>{if(this.config)return;if(!this.#t){console.log("No config fetch setup provided");return}let t=await w(this.#t.timeout,this.#t.url);if(!t){console.log("Configuration fetch timed-out");return}this.config=await t.json()},this.generateVisitorId=()=>`visi_${(function(t=5){return t&&"number"==typeof t?Array(t).fill("").reduce(t=>t+=v.charAt(Math.floor(Math.random()*v.length)),""):""})(26).toUpperCase()}`,this.getVisitorCookieName=()=>"visitorId",this.organizationId=t,this.environment=i,e?this.config=e:this.#t={url:[f,t,i].join("/"),timeout:s||3e3}}}const y=t=>{if(!t)return!1;let i=document.cookie.split("; ").find(i=>{let[e]=i.split("=");return t===e});return!!i&&i.split("=")[1]},I=(t,i)=>{let e=new Date;e.setMonth(e.getMonth()+1),document.cookie=`${t}=${i};path=/;expires=${e.toUTCString()}`},V=()=>{let t=window.innerWidth;return t<=768?"small":t<=1024?"medium":t<=1200?"large":"huge"};exports.ImproveClientSDK=class extends b{#i;#e;#s;#r;#o;constructor(...t){super(...t),this.#e=!1,this.#s="",this.#r={},this.#o=g,this.setupVisitor=(t=window.navigator.userAgent)=>{let i=y(this.getVisitorCookieName());this.#e=!!i,this.#s=i||this.generateVisitorId();let e=u(t);return e?(this.#i=e,I(this.getVisitorCookieName(),this.#s),this.#s):null},this.getFlagValue=t=>{if(!this.config)return null;let i=this.config.flags[t];if(!i)return null;if(this.#i||this.setupVisitor(),!this.#s||!this.#i)return i.options[0].slug;if(this.#i?.[t])return this.#i[t];if(!h(this.config.audience[i.audience],this.#i))return i.options[0].slug;let e=y(t)||c(i.options);return e?(this.#i[t]=e,I(t,e),e):null},this.getTestValue=t=>{if(!this.config)return null;let i=this.config.tests[t];if(!i)return null;if(this.#i||this.setupVisitor(),!this.#s||!this.#i)return i.defaultValue;if(this.#i?.[t])return this.#i[t];if(!h(this.config.audience[i.audience],this.#i))return i.defaultValue;if(i.allocation<100&&100*Math.random()>i.allocation)return this.#i[t]=i.defaultValue,this.#i?.[t];let e=y(t)||c(i.options);return e?(this.#i[t]=e,I(t,e),e):null},this.setAnalyticsUrls=t=>{this.#o=t},this.postAnalytic=(t,i,e)=>{if(!this.config)return null;let s=this.config.tests[t];if(this.#i||this.setupVisitor(),!s||!this.#i||this.#r?.[t]?.[i])return null;this.#r[t]=this.#r[t]||{},this.#r[t][i]=!0,this.#i?.[t]||this.getTestValue(t);let r={organizationId:this.organizationId,environment:this.environment,testId:s.id,testValue:this.#i[t],visitorId:this.#s,pointer:this.#i.pointer,device:this.#i.device,screen:V(),browser:this.#i.browser,os:this.#i.os,visitor:this.#e?"recurring":"new",event:i,message:e||""};return fetch(this.#o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}}};
package/dist/client.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { EnvironmentOption, Configuration, ImproveArgs } from '@obelism/improve-sdk/types';
1
+ import { EnvironmentOption, Configuration, ImproveArgs } from './types.ts';
2
2
 
3
3
  declare class BaseImproveSDK {
4
4
  #private;
@@ -14,9 +14,9 @@ declare class BaseImproveSDK {
14
14
  type CreateAnalytic = {
15
15
  organizationId: string;
16
16
  environment: EnvironmentOption;
17
- test_id: string;
18
- test_value: string;
19
- visitor_id: string;
17
+ testId: string;
18
+ testValue: string;
19
+ visitorId: string;
20
20
  pointer: string;
21
21
  device: string;
22
22
  screen: string;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EnvironmentOption, Configuration, ImproveArgs } from '@obelism/improve-sdk/types';
1
+ import { EnvironmentOption, Configuration, ImproveArgs } from './types.ts';
2
2
 
3
3
  declare class BaseImproveSDK {
4
4
  #private;
@@ -14,9 +14,9 @@ declare class BaseImproveSDK {
14
14
  type CreateAnalytic = {
15
15
  organizationId: string;
16
16
  environment: EnvironmentOption;
17
- test_id: string;
18
- test_value: string;
19
- visitor_id: string;
17
+ testId: string;
18
+ testValue: string;
19
+ visitorId: string;
20
20
  pointer: string;
21
21
  device: string;
22
22
  screen: string;
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- import i from"ua-parser-js";let t={device:["wearable","mobile","tablet","console","smarttv","embedded","desktop"],browser:["chrome","safari","firefox","edge","ie","samsung internet","social","other"],os:["mac os","ios","android","windows","unix"]},e=i=>i&&t.device.includes(i)?i:"desktop",s=["tiktok","wechat","weibo","snapchat","klarna","Line","instagram","facebook","alipay","Baidu"],r=(i="")=>{if(!i)return"other";let e=i.toLowerCase();return t.browser.find(i=>e.includes(i))||(s.includes(e)?"social":"other")},o=["wearable","mobile","tablet"],n=i=>o.includes(i)?"coarse":"fine",l=(i="")=>{if(!i)return"unix";let e=i.toLowerCase();return t.os.find(i=>e.includes(i))||"unix"},a=t=>{if(!t||"string"!=typeof t)return null;let s=new i(t).getResult(),o=e(s.device.type);return{pointer:n(o),device:o,browser:r(s.browser.name),os:l(s.os.name)}},h=(i,t)=>!i||Object.entries(i).every(([i,e])=>t[i]===e),u=i=>{if(0===i.length)return null;if(1===i.length)return i[0].slug;let t=Math.floor(Math.random()*i.reduce((i,t)=>i+=t.split,0)),e=0,s=i.find(i=>{let s=e,r=e+i.split;return t>=s&&t<r||(e=r,!1)});return s?.slug||i.at(-1)?.slug},c="https://improve.obelism.studio",d=`${c}/config`,f=`${c}/api/log`,g="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",v=i=>new Promise(t=>setTimeout(t,i)),p=async(i=1e3,t)=>(await v(i),t?.abort(),null),m=(i=3e3,t,e)=>{let s=new AbortController;return Promise.race([fetch(t,{...e,signal:s.signal}),p(i,s)])};class w{#i;constructor({organizationId:i,environment:t,config:e,fetchTimeout:s}){this.organizationId="",this.environment="develop",this.#i=null,this.config=null,this.fetchConfig=async()=>{if(this.config)return;if(!this.#i){console.log("No config fetch setup provided");return}let i=await m(this.#i.timeout,this.#i.url);if(!i){console.log("Configuration fetch timed-out");return}this.config=await i.json()},this.generateVisitorId=()=>`visi_${(function(i=5){return i&&"number"==typeof i?Array(i).fill("").reduce(i=>i+=g.charAt(Math.floor(Math.random()*g.length)),""):""})(26).toUpperCase()}`,this.getVisitorCookieName=()=>"visitorId",this.organizationId=i,this.environment=t,e?this.config=e:this.#i={url:[d,i,t].join("/"),timeout:s||3e3}}}let b=i=>{if(!i)return!1;let t=document.cookie.split("; ").find(t=>{let[e]=t.split("=");return i===e});return!!t&&t.split("=")[1]},y=(i,t)=>{let e=new Date;e.setMonth(e.getMonth()+1),document.cookie=`${i}=${t};path=/;expires=${e.toUTCString()}`},I=()=>{let i=window.innerWidth;return i<=768?"small":i<=1024?"medium":i<=1200?"large":"huge"};class V extends w{#t;#e;#s;#r;#o;constructor(...i){super(...i),this.#e=!1,this.#s="",this.#r={},this.#o=f,this.setupVisitor=(i=window.navigator.userAgent)=>{let t=b(this.getVisitorCookieName());this.#e=!!t,this.#s=t||this.generateVisitorId();let e=a(i);return e?(this.#t=e,y(this.getVisitorCookieName(),this.#s),this.#s):null},this.getFlagValue=i=>{if(!this.config)return null;let t=this.config.flags[i];if(!t)return null;if(this.#t||this.setupVisitor(),!this.#s||!this.#t)return t.options[0].slug;if(this.#t?.[i])return this.#t[i];if(!h(this.config.audience[t.audience],this.#t))return t.options[0].slug;let e=b(i)||u(t.options);return e?(this.#t[i]=e,y(i,e),e):null},this.getTestValue=i=>{if(!this.config)return null;let t=this.config.tests[i];if(!t)return null;if(this.#t||this.setupVisitor(),!this.#s||!this.#t)return t.defaultValue;if(this.#t?.[i])return this.#t[i];if(!h(this.config.audience[t.audience],this.#t))return t.defaultValue;if(t.allocation<100&&100*Math.random()>t.allocation)return this.#t[i]=t.defaultValue,this.#t?.[i];let e=b(i)||u(t.options);return e?(this.#t[i]=e,y(i,e),e):null},this.setAnalyticsUrls=i=>{this.#o=i},this.postAnalytic=(i,t,e)=>{if(!this.config)return null;let s=this.config.tests[i];if(this.#t||this.setupVisitor(),!s||!this.#t||this.#r?.[i]?.[t])return null;this.#r[i]=this.#r[i]||{},this.#r[i][t]=!0,this.#t?.[i]||this.getTestValue(i);let r={organizationId:this.organizationId,environment:this.environment,test_id:s.id,test_value:this.#t[i],visitor_id:this.#s,pointer:this.#t.pointer,device:this.#t.device,screen:I(),browser:this.#t.browser,os:this.#t.os,visitor:this.#e?"recurring":"new",event:t,message:e||""};return fetch(this.#o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}}}export{V as ImproveClientSDK};
1
+ import i from"ua-parser-js";let t={device:["wearable","mobile","tablet","console","smarttv","embedded","desktop"],browser:["chrome","safari","firefox","edge","ie","samsung internet","social","other"],os:["mac os","ios","android","windows","unix"]},e=i=>i&&t.device.includes(i)?i:"desktop",s=["tiktok","wechat","weibo","snapchat","klarna","Line","instagram","facebook","alipay","Baidu"],r=(i="")=>{if(!i)return"other";let e=i.toLowerCase();return t.browser.find(i=>e.includes(i))||(s.includes(e)?"social":"other")},o=["wearable","mobile","tablet"],n=i=>o.includes(i)?"coarse":"fine",l=(i="")=>{if(!i)return"unix";let e=i.toLowerCase();return t.os.find(i=>e.includes(i))||"unix"},a=t=>{if(!t||"string"!=typeof t)return null;let s=new i(t).getResult(),o=e(s.device.type);return{pointer:n(o),device:o,browser:r(s.browser.name),os:l(s.os.name)}},h=(i,t)=>!i||Object.entries(i).every(([i,e])=>t[i]===e),u=i=>{if(0===i.length)return null;if(1===i.length)return i[0].slug;let t=Math.floor(Math.random()*i.reduce((i,t)=>i+=t.split,0)),e=0,s=i.find(i=>{let s=e,r=e+i.split;return t>=s&&t<r||(e=r,!1)});return s?.slug||i.at(-1)?.slug},c="https://improve.obelism.studio",d=`${c}/config`,f=`${c}/api/log`,g="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",v=i=>new Promise(t=>setTimeout(t,i)),p=async(i=1e3,t)=>(await v(i),t?.abort(),null),m=(i=3e3,t,e)=>{let s=new AbortController;return Promise.race([fetch(t,{...e,signal:s.signal}),p(i,s)])};class w{#i;constructor({organizationId:i,environment:t,config:e,fetchTimeout:s}){this.organizationId="",this.environment="develop",this.#i=null,this.config=null,this.fetchConfig=async()=>{if(this.config)return;if(!this.#i){console.log("No config fetch setup provided");return}let i=await m(this.#i.timeout,this.#i.url);if(!i){console.log("Configuration fetch timed-out");return}this.config=await i.json()},this.generateVisitorId=()=>`visi_${(function(i=5){return i&&"number"==typeof i?Array(i).fill("").reduce(i=>i+=g.charAt(Math.floor(Math.random()*g.length)),""):""})(26).toUpperCase()}`,this.getVisitorCookieName=()=>"visitorId",this.organizationId=i,this.environment=t,e?this.config=e:this.#i={url:[d,i,t].join("/"),timeout:s||3e3}}}let b=i=>{if(!i)return!1;let t=document.cookie.split("; ").find(t=>{let[e]=t.split("=");return i===e});return!!t&&t.split("=")[1]},y=(i,t)=>{let e=new Date;e.setMonth(e.getMonth()+1),document.cookie=`${i}=${t};path=/;expires=${e.toUTCString()}`},I=()=>{let i=window.innerWidth;return i<=768?"small":i<=1024?"medium":i<=1200?"large":"huge"};class V extends w{#t;#e;#s;#r;#o;constructor(...i){super(...i),this.#e=!1,this.#s="",this.#r={},this.#o=f,this.setupVisitor=(i=window.navigator.userAgent)=>{let t=b(this.getVisitorCookieName());this.#e=!!t,this.#s=t||this.generateVisitorId();let e=a(i);return e?(this.#t=e,y(this.getVisitorCookieName(),this.#s),this.#s):null},this.getFlagValue=i=>{if(!this.config)return null;let t=this.config.flags[i];if(!t)return null;if(this.#t||this.setupVisitor(),!this.#s||!this.#t)return t.options[0].slug;if(this.#t?.[i])return this.#t[i];if(!h(this.config.audience[t.audience],this.#t))return t.options[0].slug;let e=b(i)||u(t.options);return e?(this.#t[i]=e,y(i,e),e):null},this.getTestValue=i=>{if(!this.config)return null;let t=this.config.tests[i];if(!t)return null;if(this.#t||this.setupVisitor(),!this.#s||!this.#t)return t.defaultValue;if(this.#t?.[i])return this.#t[i];if(!h(this.config.audience[t.audience],this.#t))return t.defaultValue;if(t.allocation<100&&100*Math.random()>t.allocation)return this.#t[i]=t.defaultValue,this.#t?.[i];let e=b(i)||u(t.options);return e?(this.#t[i]=e,y(i,e),e):null},this.setAnalyticsUrls=i=>{this.#o=i},this.postAnalytic=(i,t,e)=>{if(!this.config)return null;let s=this.config.tests[i];if(this.#t||this.setupVisitor(),!s||!this.#t||this.#r?.[i]?.[t])return null;this.#r[i]=this.#r[i]||{},this.#r[i][t]=!0,this.#t?.[i]||this.getTestValue(i);let r={organizationId:this.organizationId,environment:this.environment,testId:s.id,testValue:this.#t[i],visitorId:this.#s,pointer:this.#t.pointer,device:this.#t.device,screen:I(),browser:this.#t.browser,os:this.#t.os,visitor:this.#e?"recurring":"new",event:t,message:e||""};return fetch(this.#o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}}}export{V as ImproveClientSDK};
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @constant AUDIENCE_PARAMS
3
+ * @description All posibile audience tracking options
4
+ */
5
+ declare const AUDIENCE_PARAMS: {
6
+ readonly pointer: readonly ["coarse", "fine"];
7
+ readonly device: readonly ["wearable", "mobile", "tablet", "console", "smarttv", "embedded", "desktop"];
8
+ readonly browser: readonly ["chrome", "safari", "firefox", "edge", "ie", "samsung internet", "social", "other"];
9
+ readonly os: readonly ["mac os", "ios", "android", "windows", "unix"];
10
+ };
11
+ type AudienceParamKey = keyof typeof AUDIENCE_PARAMS;
12
+
13
+ type EnvironmentOption = 'develop' | 'staging' | 'production';
14
+ type ImproveArgs = {
15
+ organizationId: string;
16
+ environment: EnvironmentOption;
17
+ config?: Configuration;
18
+ fetchTimeout?: number;
19
+ };
20
+ type TestState = 'draft' | 'active' | 'finished' | 'archived';
21
+ type FlagOption = {
22
+ name: string;
23
+ slug: string;
24
+ value: string | undefined;
25
+ split: number;
26
+ };
27
+ type TestOption = {
28
+ name: string;
29
+ slug: string;
30
+ value: string | undefined;
31
+ split: number;
32
+ };
33
+ type Flag = {
34
+ id: string;
35
+ name: string;
36
+ audience: string;
37
+ options: FlagOption[];
38
+ };
39
+ type Flags = {
40
+ [flagSlug in string]: Flag;
41
+ };
42
+ type Events = {
43
+ start: string;
44
+ metrics: string[];
45
+ conversion: string;
46
+ };
47
+ type Result = {
48
+ result: {
49
+ [variant: string]: {
50
+ [metric: string]: number;
51
+ };
52
+ };
53
+ resultsByDay: {
54
+ label: string;
55
+ values: {
56
+ [x in string]: string | number;
57
+ }[];
58
+ }[];
59
+ };
60
+ type Test = {
61
+ id: string;
62
+ name: string;
63
+ defaultValue: string;
64
+ audience: string;
65
+ allocation: number;
66
+ options: TestOption[];
67
+ events: Events;
68
+ };
69
+ type Tests = {
70
+ [testSlug in string]: Test;
71
+ };
72
+ type AudienceValue = {
73
+ [Key in AudienceParamKey]: string;
74
+ };
75
+ type Audience = {
76
+ [audienceSlug in string]: AudienceValue;
77
+ };
78
+ type Configuration = {
79
+ name: string;
80
+ version: number;
81
+ flags: Flags;
82
+ tests: Tests;
83
+ audience: Audience;
84
+ };
85
+
86
+ export type { Audience, AudienceValue, Configuration, EnvironmentOption, Events, Flag, FlagOption, Flags, ImproveArgs, Result, Test, TestOption, TestState, Tests };
package/dist/server.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import * as __types from '@obelism/improve-sdk/types';
2
- import { EnvironmentOption, Configuration, ImproveArgs } from '@obelism/improve-sdk/types';
1
+ import * as __types from './types.ts';
2
+ import { EnvironmentOption, Configuration, ImproveArgs } from './types.ts';
3
3
 
4
4
  declare class BaseImproveSDK {
5
5
  #private;
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import * as __types from '@obelism/improve-sdk/types';
2
- import { EnvironmentOption, Configuration, ImproveArgs } from '@obelism/improve-sdk/types';
1
+ import * as __types from './types.ts';
2
+ import { EnvironmentOption, Configuration, ImproveArgs } from './types.ts';
3
3
 
4
4
  declare class BaseImproveSDK {
5
5
  #private;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@obelism/improve-sdk",
3
3
  "description": "Obelism Improve SDK",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "keywords": [
6
6
  "ab-tests",
7
7
  "feature-flags",