Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
gangb-tech committed Apr 14, 2023
2 parents 88f7dca + 3518066 commit 940d1c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
24 changes: 12 additions & 12 deletions docs/docs/reference/sdk-contributor.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Example response protocol:
}
```

- This API requires setting the Authorization HTTP request header to ${sdk_key} to authenticate when polling the API. ${sdk_key} is the Server SDK key passed by the client application to FeatureProbe configuration.
- This API requires setting the Authorization HTTP request header to `sdk_key` to authenticate when polling the API. `sdk_key` is the Server SDK key passed by the client application to FeatureProbe configuration.

- To implement asynchronous polling, a timer or polling library can be used to periodically send HTTP requests to retrieve the latest feature flag rules. The recommended default frequency is 5 seconds.

Expand All @@ -129,7 +129,7 @@ When there is a higher requirement for the latency of feature flags changes, opt

- First, it is necessary to implement the asynchronous polling mechanism as an alternative solution for streaming api updates.

- To implement the streaming api mechanism, you will need to add the [socket-io](https://github.com/socketio) client dependency to your SDK and establish a long connection with the FeatureProbe Server during SDK initialization. You can send a "register" event with a parameter named key and a value of ${sdk_key} to verify the SDK's identity during the authentication process. Here, ${sdk_key} is the Server SDK key passed by the client application to the FeatureProbe configuration.
- To implement the streaming api mechanism, you will need to add the [socket.io-client](https://github.com/socketio/socket.io-client) client dependency to your SDK and establish a long connection with the FeatureProbe Server during SDK initialization. You can send a "register" event with a parameter named key and a value of `sdk_key` to verify the SDK's identity during the authentication process. Here, `sdk_key` is the Server SDK key passed by the client application to the FeatureProbe configuration.

- Listen to the "update" event so that when the feature flags configuration changes, the client is immediately notified to proactively pull the latest switch rule through the polling API.

Expand All @@ -139,7 +139,7 @@ When there is a higher requirement for the latency of feature flags changes, opt

### Client SDK receives feature flags change

When we make changes to the feature flags configuration or add new page_view or click event metric through the FeatureProbe platform or Open API, the client SDK needs to update the results and event sets of the corresponding feature flags in memory. Currently, the following two implementations need to be provided:
When we make changes to the feature flags configuration through the FeatureProbe platform or Open API, the client SDK needs to update the results of the corresponding feature flags in memory. Currently, the following two implementations need to be provided:

1、**Getting feature flag result through asynchronous polling**
Protocol for the API used by the server to retrieve feature flag result:
Expand All @@ -162,9 +162,9 @@ Example response protocol:
}
```

- This API requires setting the Authorization HTTP request header to ${sdk_key} for authentication during polling API. ${sdk_key} is the Client SDK key passed by the client application to FeatureProbe configuration.
- This API requires setting the Authorization HTTP request header to `sdk_key` for authentication during polling API. `sdk_key` is the Client SDK key passed by the client application to FeatureProbe configuration.

- Additionally, the API requires setting the user parameter in the HTTP request as ${FPUser}, with its value being the Base64-encoded string obtained from serializing the FPUser object to a JSON format.
- Additionally, the API requires setting the user parameter in the HTTP request as `FPUser`, with its value being the Base64-encoded string obtained from serializing the FPUser object to a JSON format.

- To implement the asynchronous polling mechanism, you can use a timer or a polling library to periodically send HTTP requests to obtain the latest feature flags result. It is recommended to set the default frequency to 5 seconds.

Expand All @@ -179,7 +179,7 @@ Here are the steps to implement streaming api for updating feature flag changes

- First, implement asynchronous polling mechanism as an alternative solution for streaming api updates

- To implement the streaming api mechanism, you will need to add the [socket-io](https://github.com/socketio) client dependency to your SDK and establish a long connection with the FeatureProbe Server during SDK initialization. You can send a "register" event with a parameter named key and a value of ${sdk_key} to verify the SDK's identity during the authentication process. Here, ${sdk_key} is the Server SDK key passed by the client application to the FeatureProbe configuration.
- To implement the streaming api mechanism, you will need to add the [socket.io-client](https://github.com/socketio/socket.io-client) client dependency to your SDK and establish a long connection with the FeatureProbe Server during SDK initialization. You can send a "register" event with a parameter named key and a value of `sdk_key` to verify the SDK's identity during the authentication process. Here, `sdk_key` is the Server SDK key passed by the client application to the FeatureProbe configuration.

- Listen to the "update" event so that when the feature flags configuration changes, the client is immediately notified to proactively pull the latest switch rule through the polling API.

Expand All @@ -204,11 +204,11 @@ The client-side SDK does not need to implement the logic of feature flag rule ca
Currently, FeatureProbe provides 4 types of events for reporting:

- **custom**: Events sent when the application calls the SDK's track method.
- **event**: Feature flag evaluation information。
- **page_view**: Records page access events for the JavaScript SDK.
- **access**: Feature flag evaluation information。
- **pageview**: Records page access events for the JavaScript SDK.
- **click**: Records page click events for the JavaScript SDK.

And it is necessary to report the access statistics of each group's feature flag within a certain period of tim
And it is necessary to report the access statistics of each group's feature flag within a certain period of time.

All SDKs must send events in batches to the FeatureProbe server asynchronously for a period of time. The SDKs need to enable a timer task, which is executed every 5 seconds by default, to send all events generated during this period to the server.

Expand Down Expand Up @@ -278,11 +278,11 @@ curl --location --request POST 'https://featureprobe.io/server/api/events' \

This API must include the following request headers:

***Authorization***:The value is ${sdk_key}, where ${sdk_key} is the Server(Client) SDK key passed by the client application to FeatureProbe configuration.
***Authorization***:The value is `sdk_key`, where `sdk_key` is the Server(Client) SDK key passed by the client application to FeatureProbe configuration.

***user-agent***:The value is ${sdk_language_kind}/${sdk_version}, where ${sdk_language_kind} is the language name of the SDK implementation, and ${sdk_version} is the version number of the current SDK.
***UA***:The value is `sdk_language_kind/sdk_version`, where `sdk_language_kind` is the language name of the SDK implementation, and `sdk_version` is the version number of the current SDK.

## Reference Materials.

- Reference implementation of the server-side SDK: [Java SDK](https://github.com/FeatureProbe/server-sdk-java) and [API Docs](https://featureprobe.github.io/server-sdk-java/)
- Reference implementation of the client-side SDK: [Javascript SDK](https://github.com/FeatureProbe/client-sdk-js) and [API Docs](https://featureprobe.github.io/client-sdk-js/)
- Reference implementation of the client-side SDK: [Javascript SDK](https://github.com/FeatureProbe/client-sdk-js) and [API Docs](https://featureprobe.github.io/client-sdk-js/)
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ curl --location --request GET 'https://featureprobe.io/server/api/server-sdk/tog
}
```

- 该 API 需要使用 HTTP 请求头将 Authorization 设置为 ${sdk_key},以便在轮询API时进行身份验证。其中 ${sdk_key} 是客户端应用程序传递给 FeatureProbe 配置的 Server SDK 密钥。
- 该 API 需要使用 HTTP 请求头将 Authorization 设置为 `sdk_key`,以便在轮询API时进行身份验证。其中 `sdk_key` 是客户端应用程序传递给 FeatureProbe 配置的 Server SDK 密钥。

- 实现异步轮询机制,可以使用定时器或轮询库来定期发送HTTP请求以获取最新的开关规则,建议默认频率为5s。

Expand All @@ -130,7 +130,7 @@ curl --location --request GET 'https://featureprobe.io/server/api/server-sdk/tog

- 首先需要实现异步轮询机制,以便作为长连接更新的备选方案。

- 需要引入 [socket-io](https://github.com/socketio) 客户端依赖到您的 SDK 中,并在 SDK 初始化时与 FeatureProbe Server 建立长连接。您可以在建立连接时发送一个 “register” 事件,并携带一个名为 key, 值为${sdk_key}的参数,以便在后续的身份验证过程中进行验证。其中${sdk_key}是客户端应用程序传递给 FeatureProbe 配置的 Server SDK 密钥。
- 需要引入 [socket-io](https://github.com/socketio) 客户端依赖到您的 SDK 中,并在 SDK 初始化时与 FeatureProbe Server 建立长连接。您可以在建立连接时发送一个 “register” 事件,并携带一个名为 key, 值为`sdk_key`的参数,以便在后续的身份验证过程中进行验证。其中`sdk_key`是客户端应用程序传递给 FeatureProbe 配置的 Server SDK 密钥。

- 监听名为 “update” 的事件,以便在开关配置发生更改时立即通知客户端主动通过轮询API拉取最新开关规则。

Expand All @@ -140,7 +140,7 @@ curl --location --request GET 'https://featureprobe.io/server/api/server-sdk/tog

### 客户端SDK接收开关变更

当我们通过 FeatureProbe 平台或者 Open API 对开关的配置做出变更或添加新的 page_view 或 click 事件指标时, 客户端SDK 需要更新内存中的开关对于的结果和事件集。目前需提供如下两种实现:
当我们通过 FeatureProbe 平台或者 Open API 对开关的配置做出变更, 客户端SDK 需要更新内存中的开关对应的结果。目前需提供如下两种实现:

1、**通过异步轮询获取开关配置**
Server 获取开关结果API协议:
Expand All @@ -163,9 +163,9 @@ curl --location --request GET 'https://featureprobe.io/server/api/client-sdk/tog
}
```

- 该 API 需要使用 HTTP 请求头将 Authorization 设置为 ${sdk_key},以便在轮询 API 时进行身份验证。其中 ${sdk_key} 是客户端应用程序传递给 FeatureProbe 配置的 Client SDK 密钥。
- 该 API 需要使用 HTTP 请求头将 Authorization 设置为 `sdk_key`,以便在轮询 API 时进行身份验证。其中 `sdk_key` 是客户端应用程序传递给 FeatureProbe 配置的 Client SDK 密钥。

- 还需要使用 HTTP 请求参数将 user 设置为 ${FPUser},参数值为将 FPUser 对象Json序列化后进行Base64编码的字符串。
- 还需要使用 HTTP 请求参数将 user 设置为 `FPUser`,参数值为将 FPUser 对象Json序列化后进行Base64编码的字符串。

- 实现异步轮询机制,可以使用定时器或轮询库来定期发送 HTTP 请求以获取最新的开关规则,建议默认频率为5s。

Expand All @@ -180,34 +180,34 @@ curl --location --request GET 'https://featureprobe.io/server/api/client-sdk/tog

- 首先需要实现异步轮询机制,以便作为长连接更新的备选方案。

- 需要引入[socket-io](https://github.com/socketio)客户端依赖到您的SDK中,并在 SDK 初始化时与 FeatureProbe Server 建立长连接。您可以在建立连接时发送一个 “register” 事件,并携带一个名为 key 值为 ${sdk_key} 的参数,以便在后续的身份验证过程中进行验证。其中 ${sdk_key} 是客户端应用程序传递给 FeatureProbe 配置的 Client SDK 密钥。
- 需要引入[socket.io-client](https://github.com/socketio/socket.io-client)客户端依赖到您的SDK中,并在 SDK 初始化时与 FeatureProbe Server 建立长连接。您可以在建立连接时发送一个 “register” 事件,并携带一个名为 key 值为 `sdk_key` 的参数,以便在后续的身份验证过程中进行验证。其中 `sdk_key` 是客户端应用程序传递给 FeatureProbe 配置的 Client SDK 密钥。

- 监听名为 “update” 的事件,以便在开关配置发生更改时立即通知客户端主动通过轮询API拉取最新开关规则。

- 最后需要将长连接的地址(realtimeUri)通过 FPConfig 暴露给用户,以方便自定义配置。
- 最后需要将长连接的地址(realtimeUrl)通过 FPConfig 暴露给用户,以方便自定义配置。

***可供参考的代码[长链接Javascript实现#](https://github.com/FeatureProbe/client-sdk-js/blob/main/src/FeatureProbe.ts#)中的connectSocket()方法***
***可供参考的代码[长链接Javascript实现 ](https://github.com/FeatureProbe/client-sdk-js/blob/main/src/FeatureProbe.ts#)中的connectSocket()方法***

## 评估开关的结果

服务端和客户端SDK 在开关结果评估的方式上不一致。
服务端SDK和客户端SDK 在开关结果评估的方式上不一致。

### 服务端SDK评估开关结果

服务端SDK 需要在本地内存实现对开关的规则计算,具体计算方法请阅读[开关规则评估](./evaluation-rules)

### 客户端SDK评估开关结果

客户端SDK不用实现开关规则计算的逻辑,由 FeatureProbe 服务负责开关规则计算。所以对于客户端SDK 在实现上述获取开关结果的
客户端SDK不用实现开关规则计算的逻辑,由 FeatureProbe 服务负责开关规则计算。所以对于客户端SDK 在实现上只需获取开关的结果。

## 上报事件

目前 FeatureProbe 提供4事件类型的上报:

- **custom**: 当应用程序调用 SDK 的 track 方法时发送的事件。
- **event**: 开关评估信息
- **page_view**: 对于Javascript SDK端记录页面访问事件。
- **click**: 对于Javascript SDK端记录页面点击事件。
- **access**: 开关评估事件
- **pageview**: 对于Javascript SDK或React SDK端记录页面访问事件。
- **click**: 对于Javascript SDK或React SDK端记录页面点击事件。

以及需要上报一段时间内开关各分组访问统计。

Expand Down Expand Up @@ -280,11 +280,11 @@ curl --location --request POST 'https://featureprobe.io/server/api/events' \

此 API 必须包含以下请求头:

***Authorization***:值为 ${sdk_key},其中 ${sdk_key} 是客户端应用程序传递给 FeatureProbe 配置的 Server(Client) SDK 密钥。
***Authorization***:值为 `sdk_key`,其中 `sdk_key` 是客户端应用程序传递给 FeatureProbe 配置的 Server(Client) SDK 密钥。

***user-agent***:值为 ${sdk_language_kind}/${sdk_version},其中 ${sdk_language_kind} 是 SDK 实现的语言名称,${sdk_version} 是当前 SDK 的版本号。
***UA***:值为 `sdk_language_kind/sdk_version`,其中 `sdk_language_kind` 是 SDK 实现的语言名称,`sdk_version` 是当前 SDK 的版本号。

## 参考资料

- 可供参考的服务端SDK 实现: [Java SDK](https://github.com/FeatureProbe/server-sdk-java)[接口文档](https://featureprobe.github.io/server-sdk-java/)
- 可供参考的客户端SDK 实现: [Javascript SDK](https://github.com/FeatureProbe/client-sdk-js)[接口文档](https://featureprobe.github.io/client-sdk-js/)
- 可供参考的客户端SDK 实现: [Javascript SDK](https://github.com/FeatureProbe/client-sdk-js)[接口文档](https://featureprobe.github.io/client-sdk-js/)
Binary file modified pictures/Wechat0715.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 940d1c5

Please sign in to comment.