From d760af321f7844bdced6d2a05f6355e92a66e125 Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:56:19 +0200 Subject: [PATCH] feat(onboarding): add comments to snippets (#8361) Add warning about plaintext API key and increased metrics interval --- frontend/src/component/onboarding/dialog/snippets/dotnet.md | 4 ++-- .../src/component/onboarding/dialog/snippets/flutter.md | 2 +- frontend/src/component/onboarding/dialog/snippets/go.md | 4 ++-- frontend/src/component/onboarding/dialog/snippets/java.md | 4 ++-- .../src/component/onboarding/dialog/snippets/javascript.md | 4 ++-- frontend/src/component/onboarding/dialog/snippets/nodejs.md | 6 ++++-- frontend/src/component/onboarding/dialog/snippets/php.md | 4 ++-- frontend/src/component/onboarding/dialog/snippets/python.md | 4 ++-- frontend/src/component/onboarding/dialog/snippets/react.md | 2 +- frontend/src/component/onboarding/dialog/snippets/ruby.md | 2 +- frontend/src/component/onboarding/dialog/snippets/rust.md | 4 ++-- frontend/src/component/onboarding/dialog/snippets/svelte.md | 4 ++-- frontend/src/component/onboarding/dialog/snippets/swift.md | 4 ++-- frontend/src/component/onboarding/dialog/snippets/vue.md | 4 ++-- 14 files changed, 27 insertions(+), 25 deletions(-) diff --git a/frontend/src/component/onboarding/dialog/snippets/dotnet.md b/frontend/src/component/onboarding/dialog/snippets/dotnet.md index 1e82582056..e35bf4287b 100644 --- a/frontend/src/component/onboarding/dialog/snippets/dotnet.md +++ b/frontend/src/component/onboarding/dialog/snippets/dotnet.md @@ -18,10 +18,10 @@ public class Program { AppName = "unleash-onboarding-dotnet", UnleashApi = new Uri(""), - SendMetricsInterval = TimeSpan.FromSeconds(1), + SendMetricsInterval = TimeSpan.FromSeconds(1), // in production remove this or increase to >=15s CustomHttpHeaders = new Dictionary() { - {"Authorization",""} + {"Authorization",""} // in production use environment variable } }; diff --git a/frontend/src/component/onboarding/dialog/snippets/flutter.md b/frontend/src/component/onboarding/dialog/snippets/flutter.md index 76ab182e9c..6a5a6ea24f 100644 --- a/frontend/src/component/onboarding/dialog/snippets/flutter.md +++ b/frontend/src/component/onboarding/dialog/snippets/flutter.md @@ -10,7 +10,7 @@ import 'dart:async'; final unleash = UnleashClient( url: Uri.parse(''), - clientKey: '', + clientKey: '', // in production use environment variable appName: 'unleash-onboarding-flutter'); unleash.start(); diff --git a/frontend/src/component/onboarding/dialog/snippets/go.md b/frontend/src/component/onboarding/dialog/snippets/go.md index 19cf5039c7..b79841f646 100644 --- a/frontend/src/component/onboarding/dialog/snippets/go.md +++ b/frontend/src/component/onboarding/dialog/snippets/go.md @@ -18,8 +18,8 @@ func init() { unleash.WithListener(&unleash.DebugListener{}), unleash.WithAppName("unleash-onboarding-golang"), unleash.WithUrl(""), - unleash.WithCustomHeaders(http.Header{"Authorization": {""}}), - unleash.WithMetricsInterval(1*time.Second), + unleash.WithCustomHeaders(http.Header{"Authorization": {""}}), // in production use environment variable + unleash.WithMetricsInterval(1*time.Second), // in production remove this or increase to >=15s ) } diff --git a/frontend/src/component/onboarding/dialog/snippets/java.md b/frontend/src/component/onboarding/dialog/snippets/java.md index a12297f7eb..3c8033e028 100644 --- a/frontend/src/component/onboarding/dialog/snippets/java.md +++ b/frontend/src/component/onboarding/dialog/snippets/java.md @@ -13,8 +13,8 @@ UnleashConfig config = UnleashConfig.builder() .appName("unleash-onboarding-java") .instanceId("unleash-onboarding-instance") .unleashAPI("") - .apiKey("") - .sendMetricsInterval(1) + .apiKey("") // in production use environment variable + .sendMetricsInterval(1) // in production remove this or increase to >=15 .build(); Unleash unleash = new DefaultUnleash(config); diff --git a/frontend/src/component/onboarding/dialog/snippets/javascript.md b/frontend/src/component/onboarding/dialog/snippets/javascript.md index 4f8234c327..9f84489f01 100644 --- a/frontend/src/component/onboarding/dialog/snippets/javascript.md +++ b/frontend/src/component/onboarding/dialog/snippets/javascript.md @@ -9,9 +9,9 @@ const { UnleashClient } = require('unleash-proxy-client'); const unleash = new UnleashClient({ url: '', - clientKey: '', + clientKey: '', // in production use environment variable appName: 'unleash-onboarding-javascript', - metricsInterval: 1000, + metricsInterval: 1000, // in production remove this or increase to >=15000 }); unleash.start(); diff --git a/frontend/src/component/onboarding/dialog/snippets/nodejs.md b/frontend/src/component/onboarding/dialog/snippets/nodejs.md index 5686602130..c8e6fdb24e 100644 --- a/frontend/src/component/onboarding/dialog/snippets/nodejs.md +++ b/frontend/src/component/onboarding/dialog/snippets/nodejs.md @@ -10,8 +10,10 @@ const { initialize } = require('unleash-client'); const unleash = initialize({ url: '', appName: 'unleash-onboarding-node', - customHeaders: { Authorization: '' }, - metricsInterval: 1000, + customHeaders: { + Authorization: '' // in production use environment variable + }, + metricsInterval: 1000, // in production remove this or increase to >=15000 }); setInterval(() => { diff --git a/frontend/src/component/onboarding/dialog/snippets/php.md b/frontend/src/component/onboarding/dialog/snippets/php.md index d03644c942..b3b47ba02a 100644 --- a/frontend/src/component/onboarding/dialog/snippets/php.md +++ b/frontend/src/component/onboarding/dialog/snippets/php.md @@ -14,9 +14,9 @@ require 'vendor/autoload.php'; $unleash = UnleashBuilder::create() ->withAppName('unleash-onboarding-php') ->withAppUrl('') - ->withHeader('Authorization', '') + ->withHeader('Authorization', '') // in production use environment variable ->withInstanceId('unleash-onboarding-instance') - ->withMetricsInterval(1000) + ->withMetricsInterval(1000) // in production remove this or increase to >=15000 ->build(); while (true) { diff --git a/frontend/src/component/onboarding/dialog/snippets/python.md b/frontend/src/component/onboarding/dialog/snippets/python.md index 92a0788d44..06b14998e8 100644 --- a/frontend/src/component/onboarding/dialog/snippets/python.md +++ b/frontend/src/component/onboarding/dialog/snippets/python.md @@ -11,8 +11,8 @@ import asyncio client = UnleashClient( url="", app_name="unleash-onboarding-python", - metrics_interval=1, - custom_headers={'Authorization': ''}) + metrics_interval=1, # in production remove this or increase to >=15 + custom_headers={'Authorization': ''}) # in production use environment variable client.initialize_client() diff --git a/frontend/src/component/onboarding/dialog/snippets/react.md b/frontend/src/component/onboarding/dialog/snippets/react.md index d8aa4cfd41..3a2ef3c746 100644 --- a/frontend/src/component/onboarding/dialog/snippets/react.md +++ b/frontend/src/component/onboarding/dialog/snippets/react.md @@ -10,7 +10,7 @@ import { FlagProvider } from '@unleash/proxy-client-react'; const config = { url: '', - clientKey: '', + clientKey: '', // in production use environment variable metricsInterval: 1, // In production use interval of >15s appName: 'unleash-onboarding-react', }; diff --git a/frontend/src/component/onboarding/dialog/snippets/ruby.md b/frontend/src/component/onboarding/dialog/snippets/ruby.md index 54d4d3d8e9..4e0e44d3c9 100644 --- a/frontend/src/component/onboarding/dialog/snippets/ruby.md +++ b/frontend/src/component/onboarding/dialog/snippets/ruby.md @@ -9,7 +9,7 @@ require 'unleash' @unleash = Unleash::Client.new( url: "", - custom_http_headers: { 'Authorization': "" }, + custom_http_headers: { 'Authorization': "" }, # in production use environment variable app_name: 'unleash-onboarding-ruby', instance_id: 'unleash-onboarding-ruby', metrics_interval: 3, # In production use interval of >15s diff --git a/frontend/src/component/onboarding/dialog/snippets/rust.md b/frontend/src/component/onboarding/dialog/snippets/rust.md index f7389bef38..f518db8f73 100644 --- a/frontend/src/component/onboarding/dialog/snippets/rust.md +++ b/frontend/src/component/onboarding/dialog/snippets/rust.md @@ -26,12 +26,12 @@ enum Flags { #[tokio::main] async fn main() -> Result<(), Box> { let client: Client = ClientBuilder::default() - .interval(1000) // Polling & metrics interval - default 15000 (ms) + .interval(1000) // in production remove this or increase to >=15000 .into_client( "", "unleash-onboarding-rust", "unleash-onboarding-instance", - Some("".to_owned()), + Some("".to_owned()), // in production use environment variable )?; client.register().await?; diff --git a/frontend/src/component/onboarding/dialog/snippets/svelte.md b/frontend/src/component/onboarding/dialog/snippets/svelte.md index f5357a62a3..fd76029871 100644 --- a/frontend/src/component/onboarding/dialog/snippets/svelte.md +++ b/frontend/src/component/onboarding/dialog/snippets/svelte.md @@ -10,9 +10,9 @@ npm install @unleash/proxy-client-svelte const config = { url: '', - clientKey: '', + clientKey: '', // in production use environment variable appName: 'unleash-onboarding-svelte', - metricsInterval: 1, + metricsInterval: 1, // in production remove this or increase to >=15 }; diff --git a/frontend/src/component/onboarding/dialog/snippets/swift.md b/frontend/src/component/onboarding/dialog/snippets/swift.md index 33457403b1..79824a296f 100644 --- a/frontend/src/component/onboarding/dialog/snippets/swift.md +++ b/frontend/src/component/onboarding/dialog/snippets/swift.md @@ -11,8 +11,8 @@ import UnleashProxyClientSwift var unleash = UnleashProxyClientSwift.UnleashClient( unleashUrl: "", - clientKey: "", - refreshInterval: 5, + clientKey: "", // in production use environment variable + refreshInterval: 5, // in production remove this or increase to >=5 appName: "unleash-onboarding-swift", context: [:]) diff --git a/frontend/src/component/onboarding/dialog/snippets/vue.md b/frontend/src/component/onboarding/dialog/snippets/vue.md index f7bd96446f..13813ecd62 100644 --- a/frontend/src/component/onboarding/dialog/snippets/vue.md +++ b/frontend/src/component/onboarding/dialog/snippets/vue.md @@ -10,9 +10,9 @@ npm install @unleash/proxy-client-vue const config = { url: '', - clientKey: '', + clientKey: '', // in production use environment variable appName: 'unleash-onboarding-vue', - metricsInterval: 1, + metricsInterval: 1, // in production remove this or increase to >=15 }