{"id":26063258,"url":"https://github.com/edgio/experimentation","last_synced_at":"2025-10-12T05:32:24.281Z","repository":{"id":183589623,"uuid":"670390916","full_name":"Edgio/Experimentation","owner":"Edgio","description":"Provides access to Edgio Experimentation data in your application","archived":false,"fork":false,"pushed_at":"2023-09-26T13:41:17.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-08-08T15:49:06.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Edgio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-25T00:38:24.000Z","updated_at":"2024-02-14T16:05:53.000Z","dependencies_parsed_at":"2023-07-25T03:29:09.716Z","dependency_job_id":"dcae2cf3-662a-45f0-b89a-2f9156b0ffab","html_url":"https://github.com/Edgio/Experimentation","commit_stats":null,"previous_names":["edgio/experimentation","edgio/experimentation.js"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Edgio/Experimentation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2FExperimentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2FExperimentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2FExperimentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2FExperimentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Edgio","download_url":"https://codeload.github.com/Edgio/Experimentation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edgio%2FExperimentation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269748230,"owners_count":24469107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-08T16:34:25.983Z","updated_at":"2025-10-12T05:32:24.169Z","avatar_url":"https://github.com/Edgio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Edgio Experimentation\n\n## Overview\n\nThe `@edgio/experimentation` package provides utilities to extract experiment and variant information from both the `x-edg-experiments-info` origin header and server timing response headers. This allows customers to easily access and utilize the experiment and variant information in their applications.\n\n## Installation\n\nTo use this package in your project, you can install it via npm or yarn:\n\n```bash\nnpm install @edgio/experimentation\n\n# or\n\nyarn add @edgio/experimentation\n```\n\n## Accessing Information in Frontend through Server-Timing Header\n\nEach response with experiments information will have a `Server-Timing` header that has a value similar to this:\n\n```\nServer-Timing: edgio_cache;desc=TCP_MISS,edgio_pop;desc=dcd,edgio_country;desc=UA,experiments;desc=%7B%22Testing_new_page_1238476236%22%3A%22New_page_816213%22%2C%22New_Banner_Test_8123712%22%3A%22Old_banner_712312%22%7D\n```\n\nThe Experimentation information in this header (encoded in the `experiments` description field) can be access like so:\n\n```javascript\nimport { getInfoForPath } from '@edgio/experimentation';\n\nconst relativeUrl = '/path/to/resource';\ngetInfoForPath(relativeUrl).then((info) =\u003e {\n    if (info) {\n        console.log(info);\n    } else {\n        console.log('No experimentation info found for the given path.');\n    }\n});\n\n/*\n{\n    \"Testing_new_page_1238476236\": \"New_page_816213\",\n    \"New_Banner_Test_8123712\": \"Old_banner_712312\"\n}\n */\n```\n\nThis can be parsed as JSON in your application, giving you a map of Experiment IDs (keys) and their corresponding Variant IDs (values).\n\nYou can also use our open-source Experiments library to parse this information as shown below.\n\n## Accessing Information in Backend through x-edg-experiments-info Header\n\nFor the request in the example above, when it is received in your backend, it will have the following `x-edg-experiments-info` header:\n\n```\nx-edg-experiments-info: %7B%22Testing_new_page_1238476236%22%3A%22New_page_816213%22%2C%22New_Banner_Test_8123712%22%3A%22Old_banner_712312%22%7D\n```\n\nSimilar to the frontend, this header value can be parsed like so:\n\n```javascript\nimport { parseInfoFromValue } from '@edgio/experimentation';\nconst experimentationInfo = parseInfoFromValue(headers.get('x-edg-experiments-info'));\n\nconsole.log(experimentationInfo);\n/*\n{\n    \"Testing_new_page_1238476236\": \"New_page_816213\",\n    \"New_Banner_Test_8123712\": \"Old_banner_712312\"\n}\n*/\n```\n\nThe `experimentationInfo` provides a JSON object that can be used in your application, giving you a map of Experiment IDs (keys) and their corresponding Variant IDs (values).\n\n## Error Handling\n- If the provided header value is not a string or empty, the `parseInfoFromValue` function will return an empty JSON object.\n- If no experimentation info is found for the given path using `getInfoForPath`, it will resolve with `undefined`.\n\n## Contribution\n\nWe welcome contributions from the community! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on our GitHub repository.\n\n## License\n\nThis package is open-source and available under the [MIT License](/LICENSE). Please refer to the LICENSE file for more details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgio%2Fexperimentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedgio%2Fexperimentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedgio%2Fexperimentation/lists"}