⁜ Obelism Improve

Datafile

The datafile contains the complete configuration of an environment for one organization. It contains all flags and tests that are active and links the audiences required for those entries.

Url

http://improve.obelism.studio/config/:organizationId/:environment

  • Method: GET
  • organizationId - Unique identifier of the organization; org_XXX
  • environment - environment to load; 'develop | 'staging' | 'production'

Caching

Loading the datafile is one of the metrics on Improve that could increase costs. If you'd run an test on the server and want to post analytics from the client, this could mean two requests to the datafile per visitor. To make sure you don't rapidly chew through your usage plan you can cache this file in a few ways;

Add a caching layer

Instead of requesting the file from Improve for every visitor you could place it in your own key/value storage (like Redis). Here you can configure a time-to-live, ttl for short, and load it once every 5 minutes or per hour. This can be a great solution if you're not making changes on the fly. However keep in mind that disabling all traffic from a flag back to the original will have the caching time as a delay.

Statically generate

If you hardly make any changes in your config but you have one AB test running for a few weeks, or you're a solo developer that can easily deploy when you make a change, it could be an idea to grab the file on deploy and host it yourself in your project. A way of doing this is with pre-deploy scripts. For example if you host using Github actions you could add a task to grab it then. For hosting providers like Vercel and Netlify you utilize a prebuild script to download the latest datafile at that point.

Type

type AudienceParamKey = 'pointer' | 'device' | 'browser' | 'os'
 
export type Configuration = {
	name: string
	version: number
	flags: {
		[flagSlug in string]: {
			id: string
			name: string
			audience: string
			options: {
				name: string
				slug: string
				value: string | undefined
				split: number
			}[]
		}
	}
	tests: {
		[testSlug in string]: {
			id: string
			name: string
			defaultValue: string
			audience: string
			allocation: number
			options: {
				name: string
				slug: string
				value: string | undefined
				split: number
			}[]
			events: Events
		}
	}
	audience: {
		[audienceSlug in string]: {
			[Key in AudienceParamKey]: string
		}
	}
}

Example

{
  "name": "obelism",
  "version": 1,
  "flags": {
    "feature-test": {
      "id": "feat_VGEFKIJEXBLBRB5KUCZJSTNMD7",
      "name": "Feature test",
      "audience": "cooler-users",
      "options": [
        {
          "name": "Original",
          "slug": "original",
          "value": "a",
          "split": 80
        },
        {
          "name": "Alteration",
          "slug": "alteration",
          "value": "b",
          "split": 20
        }
      ]
    }
  },
  "tests": {
    "duo-test": {
      "id": "test_AM1TCFPYQW08EQFNWHL5ZSP8VB",
      "name": "Duo test",
      "defaultValue": "control",
      "allocation": 100,
      "audience": "",
      "options": [
        {
          "name": "Control",
          "slug": "control",
          "value": "a",
          "split": 50
        },
        {
          "name": "Variation",
          "slug": "variation",
          "value": "b",
          "split": 50
        }
      ],
      "events": {
        "start": "pageView",
        "metrics": [],
        "conversion": "signUp"
      }
    }
  },
  "audience": {
    "cooler-users": {
      "device": "tablet",
      "os": "ios"
    }
  }
}

On this page