{"id":19411483,"url":"https://github.com/volcengine/datatester-go-sdk","last_synced_at":"2025-04-24T10:33:38.549Z","repository":{"id":65184115,"uuid":"532686592","full_name":"volcengine/datatester-go-sdk","owner":"volcengine","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-22T07:30:24.000Z","size":74,"stargazers_count":3,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-22T08:44:09.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/volcengine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-04T23:50:41.000Z","updated_at":"2024-08-22T07:29:40.000Z","dependencies_parsed_at":"2024-06-03T10:33:33.146Z","dependency_job_id":"5240415f-9b8f-45b9-8c33-197cb0002ef8","html_url":"https://github.com/volcengine/datatester-go-sdk","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"b96c3c3d37f98511f335a972a11a81249be58557"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fdatatester-go-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fdatatester-go-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fdatatester-go-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volcengine%2Fdatatester-go-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/volcengine","download_url":"https://codeload.github.com/volcengine/datatester-go-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223950340,"owners_count":17230457,"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","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":"2024-11-10T12:21:38.430Z","updated_at":"2024-11-10T12:21:39.072Z","avatar_url":"https://github.com/volcengine.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"DataTester GO SDK\n==================\n\n## Limitation\n\u003eThis SDK is only supported on **Go v1.15** and later versions.\n\n## Prerequisite\nObtain your project's App Key:\n1. Go to the [BytePlus console](https://console.byteplus.com/) and sign in to your account.\n2. Under the **Products** section, click **BytePlus Data Intelligence**.\n3. On the **Project List** page, for the project you want to integrate the SDK with, under the **Actions** column, click **Details**.\n4. On the **Social Media Details** pop-up window, copy the **App Key**.\n\n## Install the SDK\n```\ngo get github.com/volcengine/datatester-go-sdk@v1.0.4\n```\n\n## Using the SDK\nThe following is a code example of using the Go SDK.\n```\npackage main\n\nimport (\n\t\"github.com/volcengine/datatester-go-sdk/client\"\n\t\"github.com/volcengine/datatester-go-sdk/config\"\n)\n\nfunc main() {\n\t// Find your app key by clicking \"details\" on the project list page on the BytePlus console\n\tabClient := client.NewClient(\"${app_key}\")\n\n    /*\n\t   client.NewClient(\"2b47a1f318d78fd718548153901addde\",\n\t   config.WithMetaHost(config.MetaHostSG), // Change it to \"https://datarangers.com\"\n\t   config.WithTrackHost(config.TrackHostSG), // Change it to \"https://mcs.tobsnssdk.com\"\n\t   config.WithWorkerNumOnce(20)) // The number of worker threads. 20 by default. Only supports one-time configuration\n\t   config.WithFetchInterval(60 * time.Second), // meta update interval, N * time.Second is recommended\n       config.WithAnonymousConfig(true, true), // anonymous user event reporting configuration(enable/disable, saas/onpremise)\n       config.WithLogger(log.NewLogrusAdapt(logrus.New()))) // customize the log interface\n\t*/\n\n\t// attributes: User properties. Only used for allocating the traffic\n\tattributes := map[string]interface{}{\n\t}\n\t// decisionId: The local user identifier. Not used for event tracking. You need to replace it with the actual user ID\n\t// trackId(uuid): The user identifier for event tracking. You need to replace it with the actual user ID\n\tvalue, err := abClient.Activate(\"${experiment_key}\", \"decisionId\", \"trackId\", true, attributes)\n\tif err != nil {\n\t\treturn\n\t}\n\tif value.(bool) {\n\n\t} else {\n\n\t}\n}\n```\n\n## API reference\n\u003eInterfaces with **WithImpression** automatically track events. Meanwhile, make sure you fill in the **trackId** field in the **activate** interface if you want to track events.\n\n### AbClient\nA class for traffic allocation during initialization.\n```\nNewClient(token string, configs ...config.Func) *AbClient\n```\n#### Parameter description\n\n| Parameter                                            | Description                                                                       | Value                            |\n|:-----------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------|\n| token                                                | Your project's App Key. You can obtain it in the Prerequisites section.           | 2b47*****8d78fd718548153901addde |\n| config.WithMetaHost(config.MetaHostSG)               | Default value is CN SAAS, set according to business needs                         |                                  |\n| config.WithFetchInterval(60 * time.Second)           | Meta update interval, N * time.Second is recommended or use default value         |                                  |\n| config.WithTrackHost(config.TrackHostSG)             | Default value is CN SAAS, set according to business needs                         |                                  |\n| config.WithWorkerNumOnce(20))                        | The number of worker threads. 20 by default. Only supports one-time configuration |                                  |\n| config.WithAnonymousConfig(true, true)               | Anonymous user event reporting configuration(enable/disable, saas/onpremise)      |                                  |\n| config.WithLogger(log.NewLogrusAdapt(logrus.New()))) | The logger interface which has a default value but you can customize it.          |                                  |\n\n### NewClientWithUserAbInfo\nA class for traffic allocation during initialization.\n```\nNewClientWithUserAbInfo(token string, userAbInfoHandler handler.UserAbInfoHandler, configs ...config.Func) *AbClient\n```\n#### Parameter description\n\n| Parameter         | Description                                                                                                                                                                      | Value |\n|:------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------|\n| userAbInfoHandler | Ensure that incoming users' information about version ID remains unchanged. If you want to constantly store the information of incoming users, you must implement it by yourself |       |\n\n### SetCohortHandler\nSet a cohort handler used to obtain experiment/feature cohort ids\n```\nfunc (t *AbClient) SetCohortHandler(handler cohort.Client)\n```\n#### Parameter description\n\n| Parameter     | Description                                                                                                                           |\n|:--------------|:--------------------------------------------------------------------------------------------------------------------------------------|\n| handler       | handler to obtain cohort ids used in experiments or features. You can use the built-in cohort handlers, or customize your own handler | |\n\n### Activate\nObtain a specific experiment version's configuration after traffic allocation and automatically track the exposed events.\n```\nfunc (t *AbClient) Activate(variantKey, decisionId, trackId string, defaultValue interface{},\n\tattributes map[string]interface{}) (interface{}, error)\n```\n#### Parameter description\n\n| Parameter     | Description                                                                                                             |\n|:--------------|:------------------------------------------------------------------------------------------------------------------------|\n| variantKey    | The key of the experiment version                                                                                       |\n| decisionId    | The local user identifier for traffic allocating                                                                        |\n| trackId       | The user identifier for event tracking. You need to replace it with the actual user ID                                  |\n| defaultValue\t | When a user/device is not in this version, then the value of this parameter is returned. You can set its value as \"nil\" |\n| attributes    | User properties                                                                                                         |\n\n#### Returned value\nParameters of the version ID that a user enters or the default value when a user/device is not in this version.\n\n### getExperimentVariantName\nObtain the version's name of an experiment that a user enters.\n```\nfunc (t *AbClient) GetExperimentVariantName(experimentId, decisionId string,\n\tattributes map[string]interface{}) (string, error)\n```\n#### Parameter description\n| Parameter    | Description                                     |\n|:-------------|:------------------------------------------------|\n| experimentId | The experiment ID to which traffic is allocated |\n\n#### Returned value\nName of the version ID that a user enters or \"\" when a user/device is not in this version.\n\n### getExperimentConfigs\nObtain detailed information about the version that a user enters.\n```\nfunc (t *AbClient) GetExperimentConfigs(experimentId, decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### Parameter description\n\n#### Returned value\nThe detailed information about the version ID that a user enters or \"nil\" when a user/device is not in this version. The following is an example:\n```\n{\n    \"father_code\": {\n       \"val\": \"father_code_2\",\n       \"vid\": \"12345\"\n    }\n}\n```\n\n### getAllExperimentConfigs\nObtain detailed information about all the versions in all experiments.\n```\nfunc (t *AbClient) GetAllExperimentConfigs(decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### Parameter description\n\n#### Returned value\nThe detailed information about version IDs that a user enters or \"nil\" when a user/device is not in this version. The following is an example:\n```\n{\n    \"father_code\": {\n       \"val\": \"father_code_2\",\n       \"vid\": \"12345\"\n    },\n    \"grey_rollout\": {\n        \"val\": false,\n        \"vid\": \"45678\"\n    }\n}\n```\n\n### getFeatureConfigs\nObtain detailed information about a feature that a user joins.\n```\nfunc (t *AbClient) GetFeatureConfigs(featureId, decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### Parameter description\n| Parameter | Description              |\n|:----------|:-------------------------|\n| featureId | The feature's identifier |\n\n#### Returned value\nAn array object of detailed information about a feature's variant that a user joins. \"nil\" when a user/device is not in this feature or the feature is disabled. The following is an example:\n```\n{\n   \"feature_key\":{\n        \"val\" : \"prod\",\n        \"vid\" : \"20006421\"\n    }\n}\n```\n\n### getAllFeatureConfigs\nObtain detailed information about all features that a user joins.\n```\nfunc (t *AbClient) GetAllFeatureConfigs(decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### Parameter description\n\n#### Returned value\nThe detailed information about all feature variants that a user joins. The following is an example:\n```\n{\n   \"feature_key\":{\n       \"val\" : \"prod\",\n       \"vid\" : \"20006421\"\n    }\n    \"feature_key_color\":{\n       \"val\" : \"true\",\n       \"vid\" : \"20006423\"\n    }\n}\n```\n\n### getExperimentVariantNameWithImpression\nObtain the version's name of the experiment that a user enters.\n```\nfunc (t *AbClient) GetExperimentVariantNameWithImpression(experimentId, decisionId, trackId string,\n\tattributes map[string]interface{}) (string, error)\n```\n#### Parameter description\n\n#### Returned value\nName of the version ID that a user enters or \"\" when a user/device is not in this version.\n\n### getExperimentConfigsWithImpression\nObtain detailed information about the version that a user enters.\n```\nfunc (t *AbClient) GetExperimentConfigsWithImpression(experimentId, decisionId, trackId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### Parameter description\n\n#### Returned value\nThe detailed information about the version ID that a user enters or \"nil\" when a user/device is not in this version. The following is an example:\n```\n{\n    \"father_code\": {\n       \"val\": \"father_code_2\",\n       \"vid\": \"12345\"\n    }\n}\n```\n\n### getAllExperimentConfigsWithImpression\nObtain detailed information about all the versions in all experiments.\n```\nfunc (t *AbClient) GetAllExperimentConfigsWithImpression(decisionId string, trackId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### Parameter description\n\n#### Returned value\nThe detailed information about version IDs that a user enters or \"nil\" when a user/device is not in this version. The following is an example:\n```\n{\n    \"father_code\": {\n       \"val\": \"father_code_2\",\n       \"vid\": \"12345\"\n    },\n    \"grey_rollout\": {\n        \"val\": false,\n        \"vid\": \"45678\"\n    }\n}\n```\n\n### getFeatureConfigsWithImpression\nObtain detailed information about a feature that a user joins.\n```\nfunc (t *AbClient) GetFeatureConfigsWithImpression(featureId, decisionId, trackId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### Parameter description\n\n#### Returned value\nThe detailed information about a feature's variant that a user joins. \"nil\" when a user/device is not in this feature or the feature is disabled. The following is an example:\n```\n{\n   \"feature_key\":{\n        \"val\" : \"prod\",\n        \"vid\" : \"20006421\"\n    }\n}\n```\n\n## Others\nIn order to better use the sdk, some suggestions are provided.\n\n### UserAbInfoHandler\n\u003eMaintain user historical decision information; If you need to use the function of '**freezing experiment**' or '**Traffic changes will not affect exposed users**', you can customize the implementation class processing, and use it in when instantiating AbClient(NewClientWithUserAbInfo).\n#### Suggestion\n\u003eIt is recommended to use redis to cache decision information.\n\nThe following is an example:\n```\nclient.NewClientWithUserAbInfo(\"appKey\", NewRedisUserAbInfoHandler())\n\ntype RedisAbInfoHandler struct{}\n\nfunc (u *RedisAbInfoHandler) Query(decisionID string) string {\n\t// need to implement it yourself\n    return redis.get(decisionID);\n}\n\nfunc (u *RedisAbInfoHandler) CreateOrUpdate(decisionID, experiment2Variant string) bool {\n    // need to implement it yourself\n\treturn redis.set(decisionID, experiment2Variant);\n}\n\nfunc (u *RedisAbInfoHandler) NeedPersistData() bool {\n    // return true if customize this interface\n\treturn true\n}\n\nfunc NewRedisUserAbInfoHandler() *RedisAbInfoHandler {\n\treturn \u0026RedisAbInfoHandler{}\n}\n```\n\n### Cohort Handler\n\u003eHandler to obtain cohort ids if your experiment / feature uses cohorts as traffic filter. You can either use the built-in cohort handler listed below, or implement your own handler\n\n1. cdp cohort handler (built-in)\n\u003efunc NewCdpClient(cdpApi *cdpCli.APIClient, tenantId int64) *CdpClient\n\nfor more detail in cdp api, see https://github.com/volcengine/cdp-openapi-sdk-go\n\n2. customize cohort handler\n\nyou can customize your own cohort handler by implementing ```cohort.Client``` interface\n\n```\ntype Client interface {\n    UseCohort(decisionId string, cohortIds []string) []string\n}\n```\n\nhere shows a simple example, obtain cohort from redis\n```\ntype redisCohortClient struct {\n}\n\nfunc (c *redisCohortClient) UseCohort(decisionId string, cohortIds []string) []string {\n\treturn redis.get(decisionID);\n}\n```\n\n### Anonymously tracking\n\u003eIf there is no uuid as trackId, you can use device_id, web_id, bddid(only onpremise) for anonymous tracking.\n1. init anonymous config\n```\nenable anonymously tracking\nclient.NewClient(\"appKey\", config.WithAnonymousConfig(true, true))\n```\n2. append device_id, web_id, bddid to attributes when trackId is empty string\n```\ntrackId = \"\";\nattributes[\"device_id\"] = 1234; int64\nattributes[\"web_id\"] = 5678; int64\nattributes[\"bddid\"] = \"91011\"; string\n```\n3. call activate or 'WithImpression' interfaces\n\n\nDataTester GO SDK\n==================\n\n## 版本需求\n\u003e**Go v1.15**及更高版本\n\n## 准备工作\n获取应用的App Key（即SDK使用的token）:\n1. 访问[火山引擎](https://www.volcengine.com/)并登录您的账号\n2. 进入集团设置页面，找到应用列表-应用ID列\n3. 鼠标悬停在应用ID后的感叹号上获取App Key\n\n## 安装SDK\n```\ngo get github.com/volcengine/datatester-go-sdk@v1.0.4\n```\n\n## 代码示例\n```\npackage main\n\nimport (\n\t\"github.com/volcengine/datatester-go-sdk/client\"\n\t\"github.com/volcengine/datatester-go-sdk/config\"\n)\n\nfunc main() {\n\tabClient := client.NewClient(\"${app_key}\")\n\n    /*\n\t   client.NewClient(\"2b47a1f318d78fd718548153901addde\",\n\t   config.WithMetaHost(config.MetaHostCN), // 默认使用国内SAAS域名，私有化需要自行传入产品域名\n\t   config.WithTrackHost(config.TrackHostCN), // 默认使用国内SAAS域名，私有化需要自行传入上报域名\n\t   config.WithWorkerNumOnce(20)) // 事件上报协程数，一般不需要设置\n\t   config.WithFetchInterval(60 * time.Second), // meta更新间隔，默认为60s，一般不需要设置\n       config.WithAnonymousConfig(true, true), // 匿名上报配置，第一个参数为开启关闭，第二个参数区分saas和私有化\n       config.WithLogger(log.NewLogrusAdapt(logrus.New()))) // 自定义日志接口，提供默认实现\n\t*/\n\n\t// attributes: 用户属性\n\tattributes := map[string]interface{}{\n\t}\n\t// decisionId: 本地分流用户标识，不用于事件上报，请替换为客户的真实用户标识\n\t// trackId(uuid): 事件上报用户标识，用于事件上报，请替换为客户的真实用户标识\n\tvalue, err := abClient.Activate(\"${experiment_key}\", \"decisionId\", \"trackId\", true, attributes)\n\tif err != nil {\n\t\treturn\n\t}\n\tif value.(bool) {\n\n\t} else {\n\n\t}\n}\n```\n\n## 接口描述\n\n### AbClient\n初始化ABTest分流类\n```\nNewClient(token string, configs ...config.Func) *AbClient\n```\n#### 参数\n\n| 参数                                                    | 描述                                         | 值                          |\n|:------------------------------------------------------|:-------------------------------------------|:---------------------------|\n| token                                                 | 获取到的App Key                                | 2b47*****8d78fd71854815390 |\n| config.WithMetaHost                                   | 默认使用国内SAAS的域名，根据业务需要设置                     |                            |\n| config.WithFetchInterval(60 * time.Second)            | meta更新间隔，默认为60s，一般不需要设置                    |                            |\n| config.WithTrackHost                                  | 默认使用国内SAAS的域名，根据业务需要设置                     |                            |\n| config.WithWorkerNumOnce(20))                         | 事件上报协程数，一般不需要设置                            |                            |\n| config.WithAnonymousConfig(true, true)                | 匿名上报配置，第一个参数为开启关闭，第二个参数区分saas和私有化          |                            |\n| config.WithLogger(log.NewLogrusAdapt(logrus.New())))  | 自定义日志接口，提供默认实现                             |                            |\n\n### NewClientWithUserAbInfo\n初始化ABTest分流类，传入自定义的userAbInfoHandler\n```\nNewClientWithUserAbInfo(token string, userAbInfoHandler handler.UserAbInfoHandler, configs ...config.Func) *AbClient\n```\n#### 参数\n\n| 参数                | 描述                                   | 值   |\n|:------------------|:-------------------------------------|:----|\n| userAbInfoHandler | 用户进组信息管理接口，提供默认实现，实验冻结和进组不出组场景下需自行实现 |     |\n\n### SetCohortHandler\n设置用户分群handler\n```\nfunc (t *AbClient) SetCohortHandler(handler cohort.Client)\n```\n#### 参数\n\n| 参数      | 描述                                   |\n|:--------|:-------------------------------------|\n| handler | 用户分群handler。可以用sdk内置的cdp分群接口，也可以自行实现 | |\n\n### Activate\n获取特定key的分流结果，并上报曝光事件\n```\nfunc (t *AbClient) Activate(variantKey, decisionId, trackId string, defaultValue interface{},\n\tattributes map[string]interface{}) (interface{}, error)\n```\n#### 参数\n\n| 参数            | 描述       |\n|:--------------|:---------|\n| variantKey    | 变体的key   |\n| decisionId    | 本地分流用户标识 |\n| trackId       | 事件上报用户标识 |\n| defaultValue\t | 变体默认值    |\n| attributes    | 用户属性     |\n\n#### 返回值\n该函数返回命中版本的参数值，未命中时返回默认值\n\n### getExperimentVariantName\n获取用户命中的特定实验的变体名称\n```\nfunc (t *AbClient) GetExperimentVariantName(experimentId, decisionId string,\n\tattributes map[string]interface{}) (string, error)\n```\n#### 参数\n| 参数           | 描述        |\n|:-------------|:----------|\n| experimentId | 指定分流的实验Id |\n\n#### 返回值\n该函数返回用户命中的特定实验的变体名称\n\n### getExperimentConfigs\n获取用户命中的特定实验的变体详情\n```\nfunc (t *AbClient) GetExperimentConfigs(experimentId, decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### 参数\n\n#### 返回值\n该函数返回用户命中某个实验的变体详情，通常仅能命中一个变体\n```\n{\n    \"father_code\": {\n       \"val\": \"father_code_2\",\n       \"vid\": \"12345\"\n    }\n}\n```\n\n### getAllExperimentConfigs\n获取用户命中的所有实验的变体详情\n```\nfunc (t *AbClient) GetAllExperimentConfigs(decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### 参数\n\n#### 返回值\n该函数返回用户命中所有实验的变体详情，通常命中多个变体\n```\n{\n    \"father_code\": {\n       \"val\": \"father_code_2\",\n       \"vid\": \"12345\"\n    },\n    \"grey_rollout\": {\n        \"val\": false,\n        \"vid\": \"45678\"\n    }\n}\n```\n\n### getFeatureConfigs\n获取用户命中的特定feature的变体详情\n```\nfunc (t *AbClient) GetFeatureConfigs(featureId, decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### 参数\n| 参数        | 描述         |\n|:----------|:-----------|\n| featureId | feature Id |\n\n#### 返回值\n该函数返回用户命中某个feature的变体详情，通常仅能命中一个变体\n```\n{\n   \"feature_key\":{\n        \"val\" : \"prod\",\n        \"vid\" : \"20006421\"\n    }\n}\n```\n\n### getAllFeatureConfigs\n获取用户命中的所有feature的变体详情\n```\nfunc (t *AbClient) GetAllFeatureConfigs(decisionId string,\n\tattributes map[string]interface{}) (map[string]map[string]interface{}, error)\n```\n#### 参数\n\n#### 返回值\n该函数返回用户命中所有feature的变体详情，通常命中多个变体\n```\n{\n   \"feature_key\":{\n       \"val\" : \"prod\",\n       \"vid\" : \"20006421\"\n    }\n    \"feature_key_color\":{\n       \"val\" : \"true\",\n       \"vid\" : \"20006423\"\n    }\n}\n```\n\n\u003e1、含有“WithImpression”字样的接口均会自动上报曝光事件\n\u003e\n\u003e2、请务必填写trackId字段，否则会导致上报失效\n\u003e\n### getExperimentVariantNameWithImpression\n同接口“getExperimentVariantName”\n\n### getExperimentConfigsWithImpression\n同接口“getExperimentConfigs”\n\n### getAllExperimentConfigsWithImpression\n同接口“getAllExperimentConfigs”\n\n### getFeatureConfigsWithImpression\n同接口“getFeatureConfigs”\n\n## 其他\n\n### UserAbInfoHandler\n用户信息处理接口，冻结实验、进组不出组场景下使用\n\u003e1. 使用NewClient初始化AbClient时默认使用空实现，不启用“进组不出组”功能\n\u003e2. 继承UserAbInfoHandler接口，自行实现持久化存储；使用NewClientWithUserAbInfo初始化AbClient，并传入自行实现的UserAbInfoHandler类，则可启用“进组不出组”功能\n\n使用Redis缓存示例（仅供参考）\n```\nclient.NewClientWithUserAbInfo(\"appKey\", NewRedisUserAbInfoHandler())\n\ntype RedisAbInfoHandler struct{}\n\nfunc (u *RedisAbInfoHandler) Query(decisionID string) string {\n\t// need to implement it yourself\n    return redis.get(decisionID);\n}\n\nfunc (u *RedisAbInfoHandler) CreateOrUpdate(decisionID, experiment2Variant string) bool {\n    // need to implement it yourself\n\treturn redis.set(decisionID, experiment2Variant);\n}\n\nfunc (u *RedisAbInfoHandler) NeedPersistData() bool {\n    // return true if customize this interface\n\treturn true\n}\n\nfunc NewRedisUserAbInfoHandler() *RedisAbInfoHandler {\n\treturn \u0026RedisAbInfoHandler{}\n}\n```\n\n### Cohort Handler\n\u003e获取分群id，用于判断实验/feature的用户分群过滤条件\n\n1. cdp cohort handler (内置)\n\u003efunc NewCdpClient(cdpApi *cdpCli.APIClient, tenantId int64) *CdpClient\n\ncdp api的使用可以参考 https://github.com/volcengine/cdp-openapi-sdk-go\n\n2. 自定义cohort handler\n\n可以通过实现```cohort.Client```接口来自定义cohort handler的实现\n\n```\ntype Client interface {\n    UseCohort(decisionId string, cohortIds []string) []string\n}\n```\n\n通过redis获取分群的示例（仅供参考）\n```\ntype redisCohortClient struct {\n}\n\nfunc (c *redisCohortClient) UseCohort(decisionId string, cohortIds []string) []string {\n\treturn redis.get(decisionID);\n}\n```\n\n### 匿名上报\n\u003e获取不到uuid的用户，可以通过填充device_id或者web_id进行事件上报（私有化场景下也支持bddid）\n1. NewClient时设置匿名上报配置，第一个参数（true/开启，false/关闭）匿名上报，第二个参数（true/saas，false/私有化）\n```\nclient.NewClient(\"appKey\", config.WithAnonymousConfig(true, true))\n```\n2. 添加device_id, web_id, bddid到用户属性attributes，trackId固定传入空字符串\"\"\n```\ntrackId = \"\";\nattributes[\"device_id\"] = 1234; int64\nattributes[\"web_id\"] = 5678; int64\nattributes[\"bddid\"] = \"91011\"; string\n```\n3. 请求activate或其他'WithImpression'接口即可匿名上报","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolcengine%2Fdatatester-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvolcengine%2Fdatatester-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolcengine%2Fdatatester-go-sdk/lists"}