1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

feat(onboarding): add comments to snippets (#8361)

Add warning about plaintext API key and increased metrics interval
This commit is contained in:
Tymoteusz Czech 2024-10-04 10:56:19 +02:00 committed by GitHub
parent 52b7e235fd
commit d760af321f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 27 additions and 25 deletions

View File

@ -18,10 +18,10 @@ public class Program
{
AppName = "unleash-onboarding-dotnet",
UnleashApi = new Uri("<YOUR_API_URL>"),
SendMetricsInterval = TimeSpan.FromSeconds(1),
SendMetricsInterval = TimeSpan.FromSeconds(1), // in production remove this or increase to >=15s
CustomHttpHeaders = new Dictionary<string, string>()
{
{"Authorization","<YOUR_API_TOKEN>"}
{"Authorization","<YOUR_API_TOKEN>"} // in production use environment variable
}
};

View File

@ -10,7 +10,7 @@ import 'dart:async';
final unleash = UnleashClient(
url: Uri.parse('<YOUR_API_URL>'),
clientKey: '<YOUR_API_TOKEN>',
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
appName: 'unleash-onboarding-flutter');
unleash.start();

View File

@ -18,8 +18,8 @@ func init() {
unleash.WithListener(&unleash.DebugListener{}),
unleash.WithAppName("unleash-onboarding-golang"),
unleash.WithUrl("<YOUR_API_URL>"),
unleash.WithCustomHeaders(http.Header{"Authorization": {"<YOUR_API_TOKEN>"}}),
unleash.WithMetricsInterval(1*time.Second),
unleash.WithCustomHeaders(http.Header{"Authorization": {"<YOUR_API_TOKEN>"}}), // in production use environment variable
unleash.WithMetricsInterval(1*time.Second), // in production remove this or increase to >=15s
)
}

View File

@ -13,8 +13,8 @@ UnleashConfig config = UnleashConfig.builder()
.appName("unleash-onboarding-java")
.instanceId("unleash-onboarding-instance")
.unleashAPI("<YOUR_API_URL>")
.apiKey("<YOUR_API_TOKEN>")
.sendMetricsInterval(1)
.apiKey("<YOUR_API_TOKEN>") // in production use environment variable
.sendMetricsInterval(1) // in production remove this or increase to >=15
.build();
Unleash unleash = new DefaultUnleash(config);

View File

@ -9,9 +9,9 @@ const { UnleashClient } = require('unleash-proxy-client');
const unleash = new UnleashClient({
url: '<YOUR_API_URL>',
clientKey: '<YOUR_API_TOKEN>',
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
appName: 'unleash-onboarding-javascript',
metricsInterval: 1000,
metricsInterval: 1000, // in production remove this or increase to >=15000
});
unleash.start();

View File

@ -10,8 +10,10 @@ const { initialize } = require('unleash-client');
const unleash = initialize({
url: '<YOUR_API_URL>',
appName: 'unleash-onboarding-node',
customHeaders: { Authorization: '<YOUR_API_TOKEN>' },
metricsInterval: 1000,
customHeaders: {
Authorization: '<YOUR_API_TOKEN>' // in production use environment variable
},
metricsInterval: 1000, // in production remove this or increase to >=15000
});
setInterval(() => {

View File

@ -14,9 +14,9 @@ require 'vendor/autoload.php';
$unleash = UnleashBuilder::create()
->withAppName('unleash-onboarding-php')
->withAppUrl('<YOUR_API_URL>')
->withHeader('Authorization', '<YOUR_API_TOKEN>')
->withHeader('Authorization', '<YOUR_API_TOKEN>') // in production use environment variable
->withInstanceId('unleash-onboarding-instance')
->withMetricsInterval(1000)
->withMetricsInterval(1000) // in production remove this or increase to >=15000
->build();
while (true) {

View File

@ -11,8 +11,8 @@ import asyncio
client = UnleashClient(
url="<YOUR_API_URL>",
app_name="unleash-onboarding-python",
metrics_interval=1,
custom_headers={'Authorization': '<YOUR_API_TOKEN>'})
metrics_interval=1, # in production remove this or increase to >=15
custom_headers={'Authorization': '<YOUR_API_TOKEN>'}) # in production use environment variable
client.initialize_client()

View File

@ -10,7 +10,7 @@ import { FlagProvider } from '@unleash/proxy-client-react';
const config = {
url: '<YOUR_API_URL>',
clientKey: '<YOUR_API_TOKEN>',
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
metricsInterval: 1, // In production use interval of >15s
appName: 'unleash-onboarding-react',
};

View File

@ -9,7 +9,7 @@ require 'unleash'
@unleash = Unleash::Client.new(
url: "<YOUR_API_URL>",
custom_http_headers: { 'Authorization': "<YOUR_API_TOKEN>" },
custom_http_headers: { 'Authorization': "<YOUR_API_TOKEN>" }, # in production use environment variable
app_name: 'unleash-onboarding-ruby',
instance_id: 'unleash-onboarding-ruby',
metrics_interval: 3, # In production use interval of >15s

View File

@ -26,12 +26,12 @@ enum Flags {
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let client: Client<Flags, reqwest::Client> = ClientBuilder::default()
.interval(1000) // Polling & metrics interval - default 15000 (ms)
.interval(1000) // in production remove this or increase to >=15000
.into_client(
"<YOUR_API_URL>",
"unleash-onboarding-rust",
"unleash-onboarding-instance",
Some("<YOUR_API_TOKEN>".to_owned()),
Some("<YOUR_API_TOKEN>".to_owned()), // in production use environment variable
)?;
client.register().await?;

View File

@ -10,9 +10,9 @@ npm install @unleash/proxy-client-svelte
const config = {
url: '<YOUR_API_URL>',
clientKey: '<YOUR_API_TOKEN>',
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
appName: 'unleash-onboarding-svelte',
metricsInterval: 1,
metricsInterval: 1, // in production remove this or increase to >=15
};
</script>

View File

@ -11,8 +11,8 @@ import UnleashProxyClientSwift
var unleash = UnleashProxyClientSwift.UnleashClient(
unleashUrl: "<YOUR_API_URL>",
clientKey: "<YOUR_API_TOKEN>",
refreshInterval: 5,
clientKey: "<YOUR_API_TOKEN>", // in production use environment variable
refreshInterval: 5, // in production remove this or increase to >=5
appName: "unleash-onboarding-swift",
context: [:])

View File

@ -10,9 +10,9 @@ npm install @unleash/proxy-client-vue
const config = {
url: '<YOUR_API_URL>',
clientKey: '<YOUR_API_TOKEN>',
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
appName: 'unleash-onboarding-vue',
metricsInterval: 1,
metricsInterval: 1, // in production remove this or increase to >=15
}
</script>