Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: add api to retrieve the latest data for the server and client sdks #275

Merged
merged 3 commits into from
Mar 21, 2023

Conversation

deleteLater
Copy link
Contributor

@deleteLater deleteLater commented Mar 16, 2023

get latest feature flags & segments for server-side sdk

request with

curl -H "Authorization: the-env-secret" http://localhost:5100/api/public/sdk/server/latest-all

example output

{
   "messageType":"data-sync",
   "data":{
      "eventType":"full",
      "featureFlags":[
         {
            "envId":"1331554d-98c4-41fe-ade4-68e6f5eeb54a",
            "name":"hello world",
            "key":"hello-world",
            "variationType":"boolean",
            "variations":[
               {
                  "id":"bbe8f444-090e-4a3b-99fa-b487bab424aa",
                  "value":"true"
               },
               {
                  "id":"cf8f9626-0d6f-4d05-a98f-8c3a50c85d0f",
                  "value":"false"
               }
            ],
            "targetUsers":[
               
            ],
            "rules":[
               
            ],
            "isEnabled":true,
            "disabledVariationId":"cf8f9626-0d6f-4d05-a98f-8c3a50c85d0f",
            "fallthrough":{
               "dispatchKey":null,
               "includedInExpt":true,
               "variations":[
                  {
                     "id":"bbe8f444-090e-4a3b-99fa-b487bab424aa",
                     "rollout":[
                        0,
                        1
                     ],
                     "exptRollout":1
                  }
               ]
            },
            "exptIncludeAllTargets":true,
            "tags":[
               
            ],
            "isArchived":false,
            "disabledVariation":{
               "id":"cf8f9626-0d6f-4d05-a98f-8c3a50c85d0f",
               "value":"false"
            },
            "creatorId":"b58fa8fd-eca2-460a-ab0f-e7758dbcec6a",
            "updatorId":"b58fa8fd-eca2-460a-ab0f-e7758dbcec6a",
            "createdAt":"2023-03-16T09:11:23.739Z",
            "updatedAt":"2023-03-16T09:11:26.0465535Z",
            "id":"4daca70f-86ae-4468-aee8-afc700977202"
         }
      ],
      "segments":[
         {
            "envId":"1331554d-98c4-41fe-ade4-68e6f5eeb54a",
            "name":"beta users",
            "description":"this is a segment for beta users",
            "included":[
               
            ],
            "excluded":[
               
            ],
            "rules":[
               
            ],
            "isArchived":false,
            "createdAt":"2023-03-16T09:18:21.1317917Z",
            "updatedAt":"2023-03-16T09:18:21.1317248Z",
            "id":"b2b91bbe-5d54-4d8a-882f-afc700995b23"
         }
      ]
   }
}

get latest variations for client-side sdk

request with

curl -X POST http://localhost:5100/api/public/sdk/client/latest-all \
-H 'Content-Type: application/json' \
-H 'Authorization: the-env-secret' \
-d '{
    "keyId": "bot-id",
    "name": "bot",
    "customizedProperties": [
        {
            "name": "level",
            "value": "high"
        },
        {
            "name": "localtion",
            "value": "us"
        }
    ]
}'

example output

[
    {
       "id":"hello-world",
       "variation":"true",
       "variationType":"boolean"
    }
]

@cosmos-explorer
Copy link
Contributor

cosmos-explorer commented Mar 16, 2023

The endpoint for client side sdk is POST, why would you add the params to the URL as query string, it's really unreadable.
You can make a post requst with curl

@deleteLater
Copy link
Contributor Author

Because I think it's really a GET operation, not a POST operation. It's safe and idempotent.

@cosmos-explorer
Copy link
Contributor

Because I think it's really a GET operation, not a POST operation. It's safe and idempotent.

But a GET request makes it really difficult to create this url

@cosmos-explorer cosmos-explorer deleted the feat/get-latest-data branch March 17, 2023 06:21
@deleteLater deleteLater restored the feat/get-latest-data branch March 17, 2023 06:34
@deleteLater deleteLater reopened this Mar 17, 2023
@cosmos-explorer
Copy link
Contributor

LGTM

@deleteLater deleteLater merged commit d431153 into main Mar 21, 2023
@deleteLater deleteLater deleted the feat/get-latest-data branch March 21, 2023 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants