-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Golang Local Evaluation V2 (#18)
* feat: update to local evaluation v2 * fix: build action * fix: formatting * fix: lint * test: add local client tests * feat: add details to assignment event
- Loading branch information
Showing
37 changed files
with
2,554 additions
and
1,038 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,14 @@ The `xpmt` command-line interface tool allows you to make Experiment SDK calls f | |
|
||
### Build | ||
|
||
**Makefile currently only builds for macos (amd64 & x64), add a line to the `Makefile` to support your OS and Architecture.** | ||
|
||
``` | ||
make xpmt | ||
``` | ||
|
||
### Run | ||
|
||
!!!warning Setting the deployment key | ||
All examples below assume the `EXPERIMENT_KEY` environment variable has been set. Alternatively, use the `-k` | ||
flag to set the key in the command. | ||
> **Warning** All examples below assume the `EXPERIMENT_KEY` environment variable has been set. Alternatively, use the `-k` | ||
flag to set the key in the command. | ||
|
||
#### Subcommands | ||
* `fetch`: fetch variants for a user from the server | ||
|
@@ -112,4 +109,4 @@ Fetch variants for a user given an experiment user JSON object | |
./xpmt evaluate -u '{"user_id":"[email protected]","user_properties":{"premium":true}}' | ||
``` | ||
|
||
> Note: must use single quotes around JSON object string | ||
> Note: must use single quotes around JSON object string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package evaluation | ||
|
||
import "github.com/amplitude/experiment-go-server/pkg/experiment" | ||
|
||
func UserToContext(user *experiment.User) map[string]interface{} { | ||
if user == nil { | ||
return nil | ||
} | ||
context := make(map[string]interface{}) | ||
userMap := make(map[string]interface{}) | ||
if len(user.UserId) != 0 { | ||
userMap["user_id"] = user.UserId | ||
} | ||
if len(user.DeviceId) != 0 { | ||
userMap["device_id"] = user.DeviceId | ||
} | ||
if len(user.Country) != 0 { | ||
userMap["country"] = user.Country | ||
} | ||
if len(user.Region) != 0 { | ||
userMap["region"] = user.Region | ||
} | ||
if len(user.Dma) != 0 { | ||
userMap["dma"] = user.Dma | ||
} | ||
if len(user.City) != 0 { | ||
userMap["city"] = user.City | ||
} | ||
if len(user.Language) != 0 { | ||
userMap["language"] = user.Language | ||
} | ||
if len(user.Platform) != 0 { | ||
userMap["platform"] = user.Platform | ||
} | ||
if len(user.Version) != 0 { | ||
userMap["version"] = user.Version | ||
} | ||
if len(user.Os) != 0 { | ||
userMap["os"] = user.Os | ||
} | ||
if len(user.DeviceManufacturer) != 0 { | ||
userMap["device_manufacturer"] = user.DeviceManufacturer | ||
} | ||
if len(user.DeviceBrand) != 0 { | ||
userMap["device_brand"] = user.DeviceBrand | ||
} | ||
if len(user.DeviceModel) != 0 { | ||
userMap["device_model"] = user.DeviceModel | ||
} | ||
if len(user.Carrier) != 0 { | ||
userMap["carrier"] = user.Carrier | ||
} | ||
if len(user.Library) != 0 { | ||
userMap["library"] = user.Library | ||
} | ||
if len(user.UserProperties) != 0 { | ||
userMap["user_properties"] = user.UserProperties | ||
} | ||
context["user"] = userMap | ||
return context | ||
} |
Oops, something went wrong.