mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
feat(onboarding): add comments to snippets (#8361)
Add warning about plaintext API key and increased metrics interval
This commit is contained in:
parent
52b7e235fd
commit
d760af321f
@ -18,10 +18,10 @@ public class Program
|
|||||||
{
|
{
|
||||||
AppName = "unleash-onboarding-dotnet",
|
AppName = "unleash-onboarding-dotnet",
|
||||||
UnleashApi = new Uri("<YOUR_API_URL>"),
|
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>()
|
CustomHttpHeaders = new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"Authorization","<YOUR_API_TOKEN>"}
|
{"Authorization","<YOUR_API_TOKEN>"} // in production use environment variable
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
final unleash = UnleashClient(
|
final unleash = UnleashClient(
|
||||||
url: Uri.parse('<YOUR_API_URL>'),
|
url: Uri.parse('<YOUR_API_URL>'),
|
||||||
clientKey: '<YOUR_API_TOKEN>',
|
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
|
||||||
appName: 'unleash-onboarding-flutter');
|
appName: 'unleash-onboarding-flutter');
|
||||||
|
|
||||||
unleash.start();
|
unleash.start();
|
||||||
|
@ -18,8 +18,8 @@ func init() {
|
|||||||
unleash.WithListener(&unleash.DebugListener{}),
|
unleash.WithListener(&unleash.DebugListener{}),
|
||||||
unleash.WithAppName("unleash-onboarding-golang"),
|
unleash.WithAppName("unleash-onboarding-golang"),
|
||||||
unleash.WithUrl("<YOUR_API_URL>"),
|
unleash.WithUrl("<YOUR_API_URL>"),
|
||||||
unleash.WithCustomHeaders(http.Header{"Authorization": {"<YOUR_API_TOKEN>"}}),
|
unleash.WithCustomHeaders(http.Header{"Authorization": {"<YOUR_API_TOKEN>"}}), // in production use environment variable
|
||||||
unleash.WithMetricsInterval(1*time.Second),
|
unleash.WithMetricsInterval(1*time.Second), // in production remove this or increase to >=15s
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ UnleashConfig config = UnleashConfig.builder()
|
|||||||
.appName("unleash-onboarding-java")
|
.appName("unleash-onboarding-java")
|
||||||
.instanceId("unleash-onboarding-instance")
|
.instanceId("unleash-onboarding-instance")
|
||||||
.unleashAPI("<YOUR_API_URL>")
|
.unleashAPI("<YOUR_API_URL>")
|
||||||
.apiKey("<YOUR_API_TOKEN>")
|
.apiKey("<YOUR_API_TOKEN>") // in production use environment variable
|
||||||
.sendMetricsInterval(1)
|
.sendMetricsInterval(1) // in production remove this or increase to >=15
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Unleash unleash = new DefaultUnleash(config);
|
Unleash unleash = new DefaultUnleash(config);
|
||||||
|
@ -9,9 +9,9 @@ const { UnleashClient } = require('unleash-proxy-client');
|
|||||||
|
|
||||||
const unleash = new UnleashClient({
|
const unleash = new UnleashClient({
|
||||||
url: '<YOUR_API_URL>',
|
url: '<YOUR_API_URL>',
|
||||||
clientKey: '<YOUR_API_TOKEN>',
|
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
|
||||||
appName: 'unleash-onboarding-javascript',
|
appName: 'unleash-onboarding-javascript',
|
||||||
metricsInterval: 1000,
|
metricsInterval: 1000, // in production remove this or increase to >=15000
|
||||||
});
|
});
|
||||||
|
|
||||||
unleash.start();
|
unleash.start();
|
||||||
|
@ -10,8 +10,10 @@ const { initialize } = require('unleash-client');
|
|||||||
const unleash = initialize({
|
const unleash = initialize({
|
||||||
url: '<YOUR_API_URL>',
|
url: '<YOUR_API_URL>',
|
||||||
appName: 'unleash-onboarding-node',
|
appName: 'unleash-onboarding-node',
|
||||||
customHeaders: { Authorization: '<YOUR_API_TOKEN>' },
|
customHeaders: {
|
||||||
metricsInterval: 1000,
|
Authorization: '<YOUR_API_TOKEN>' // in production use environment variable
|
||||||
|
},
|
||||||
|
metricsInterval: 1000, // in production remove this or increase to >=15000
|
||||||
});
|
});
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
@ -14,9 +14,9 @@ require 'vendor/autoload.php';
|
|||||||
$unleash = UnleashBuilder::create()
|
$unleash = UnleashBuilder::create()
|
||||||
->withAppName('unleash-onboarding-php')
|
->withAppName('unleash-onboarding-php')
|
||||||
->withAppUrl('<YOUR_API_URL>')
|
->withAppUrl('<YOUR_API_URL>')
|
||||||
->withHeader('Authorization', '<YOUR_API_TOKEN>')
|
->withHeader('Authorization', '<YOUR_API_TOKEN>') // in production use environment variable
|
||||||
->withInstanceId('unleash-onboarding-instance')
|
->withInstanceId('unleash-onboarding-instance')
|
||||||
->withMetricsInterval(1000)
|
->withMetricsInterval(1000) // in production remove this or increase to >=15000
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -11,8 +11,8 @@ import asyncio
|
|||||||
client = UnleashClient(
|
client = UnleashClient(
|
||||||
url="<YOUR_API_URL>",
|
url="<YOUR_API_URL>",
|
||||||
app_name="unleash-onboarding-python",
|
app_name="unleash-onboarding-python",
|
||||||
metrics_interval=1,
|
metrics_interval=1, # in production remove this or increase to >=15
|
||||||
custom_headers={'Authorization': '<YOUR_API_TOKEN>'})
|
custom_headers={'Authorization': '<YOUR_API_TOKEN>'}) # in production use environment variable
|
||||||
|
|
||||||
client.initialize_client()
|
client.initialize_client()
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import { FlagProvider } from '@unleash/proxy-client-react';
|
|||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
url: '<YOUR_API_URL>',
|
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
|
metricsInterval: 1, // In production use interval of >15s
|
||||||
appName: 'unleash-onboarding-react',
|
appName: 'unleash-onboarding-react',
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@ require 'unleash'
|
|||||||
|
|
||||||
@unleash = Unleash::Client.new(
|
@unleash = Unleash::Client.new(
|
||||||
url: "<YOUR_API_URL>",
|
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',
|
app_name: 'unleash-onboarding-ruby',
|
||||||
instance_id: 'unleash-onboarding-ruby',
|
instance_id: 'unleash-onboarding-ruby',
|
||||||
metrics_interval: 3, # In production use interval of >15s
|
metrics_interval: 3, # In production use interval of >15s
|
||||||
|
@ -26,12 +26,12 @@ enum Flags {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
let client: Client<Flags, reqwest::Client> = ClientBuilder::default()
|
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(
|
.into_client(
|
||||||
"<YOUR_API_URL>",
|
"<YOUR_API_URL>",
|
||||||
"unleash-onboarding-rust",
|
"unleash-onboarding-rust",
|
||||||
"unleash-onboarding-instance",
|
"unleash-onboarding-instance",
|
||||||
Some("<YOUR_API_TOKEN>".to_owned()),
|
Some("<YOUR_API_TOKEN>".to_owned()), // in production use environment variable
|
||||||
)?;
|
)?;
|
||||||
client.register().await?;
|
client.register().await?;
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ npm install @unleash/proxy-client-svelte
|
|||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
url: '<YOUR_API_URL>',
|
url: '<YOUR_API_URL>',
|
||||||
clientKey: '<YOUR_API_TOKEN>',
|
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
|
||||||
appName: 'unleash-onboarding-svelte',
|
appName: 'unleash-onboarding-svelte',
|
||||||
metricsInterval: 1,
|
metricsInterval: 1, // in production remove this or increase to >=15
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ import UnleashProxyClientSwift
|
|||||||
|
|
||||||
var unleash = UnleashProxyClientSwift.UnleashClient(
|
var unleash = UnleashProxyClientSwift.UnleashClient(
|
||||||
unleashUrl: "<YOUR_API_URL>",
|
unleashUrl: "<YOUR_API_URL>",
|
||||||
clientKey: "<YOUR_API_TOKEN>",
|
clientKey: "<YOUR_API_TOKEN>", // in production use environment variable
|
||||||
refreshInterval: 5,
|
refreshInterval: 5, // in production remove this or increase to >=5
|
||||||
appName: "unleash-onboarding-swift",
|
appName: "unleash-onboarding-swift",
|
||||||
context: [:])
|
context: [:])
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ npm install @unleash/proxy-client-vue
|
|||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
url: '<YOUR_API_URL>',
|
url: '<YOUR_API_URL>',
|
||||||
clientKey: '<YOUR_API_TOKEN>',
|
clientKey: '<YOUR_API_TOKEN>', // in production use environment variable
|
||||||
appName: 'unleash-onboarding-vue',
|
appName: 'unleash-onboarding-vue',
|
||||||
metricsInterval: 1,
|
metricsInterval: 1, // in production remove this or increase to >=15
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user