# devunus Documentation (Full Content) This file contains the full content of all documentation for LLM processing. Generated on: 2025-04-27T20:45:32.133Z ## source sdk/unit-testing.md # Unit Testing All SDKs come with overrides to ease unit testing. ```javascript title="javascript example" // Arrange devunusClient.local_mode = true; // sdk will not make any api calls devunusClient.setConfig('flag-test1', true); // accepts boolean or string // Act const result = devunusClient.getFeatureStatus('flag-test1') // will return value set by setConfig // Assert expect(devunusClient.getFeatureStatus('flag-test1')).toBe(true); ``` --- ## source sdk/intro.md # Introduction devunus SDKs allow your applications to interact with the devunus platform to get feature flag config and log events for your users. **Server-side SDKs must be initialized with a server-side environment key. These should be considered secret.** ## Client-side SDK - For web/mobile client facing applications - SDKs designed to run against a single user - Flag Evaluations are computed in advance and delivered to your client applications with obfuscated names - Supports User Session tracing for capture of errors, network requests, logs, etc. - In the event of failure, the SDK will fallback to last loaded config (using local storage) ## Server-side SDK - SDKs designed to run against multiple users - Config loaded at application start-up and cached for the duration of the application - All Flag evaluations are done on your own server - Will pull new config from the devunus platform at regular intervals All SDKs come with overrides to ease [unit testing](/docs/sdk/unit-testing). --- ## source sdk/server/getting-started.md # Getting Started with JS Server (node, etc) Coming soon... --- ## source sdk/client/track.md # Track Custom Events Track events are used to track user behavior and drive analytics. Simply call the logEvent to track custom events or see new feature adoption. you can provide optional metadata to be logged with the event. ```javascript devunusClient.logEvent('add_to_cart', { product_id: '1234', quantity: 2 }) ``` metadata may be of type boolean, number, or string. Please see limits below - Event names have a maximum of 60 characters. - A maximum of 1KB of metadata is supported ## Events with reliability and performance metrics Measure how long tasks are taking to complete or how often tasks are succeeding. All functions accept optional metadata that can be recorded against the event. These will be shown in the reliability Performance screen ```javascript const task = devunusClient.getMeasure('event-name'); // will create and start the timer try { // processing task.done(); } catch (err) { task.fail({ error: err }); } ``` --- ## source sdk/client/privacy.md # Privacy Additional optional settings to restrict the data that is sent to the devunus servers ## Redact URLs or ignore requests optional ``` urlSanitizer : (url: string) => string ``` Function to update the URL stored against the request or pass null to ignore the request completely ```javascript import { devunusClient } from "@devunus/js-client-sdk"; const context: Options = { ... urlSanitizer: (url: string) => { if (url.includes('/cdn-cgi/rum')) { return null; // do not log any requests to this URL } if (url.includes('/users/')) { return url.replace(/\/users\/\d+/, '/users/:id'); // strip user_ids } return url; }, }; devunusClient.init(env_key, context); ``` ## IP Address IP addresses for your users are not captured by default. optional (default false) ``` enable_ip_capture : bool ``` ```javascript import { devunusClient } from "@devunus/js-client-sdk"; const context: Options = { ... enable_ip_capture: true, // IP addresses for your users will be captured }; devunusClient.init(env_key, context); ``` --- ## source sdk/client/getting-started.md # Getting Started with Web SDK Client SDK enables you to run experiments for user experience improvements in applications running on end-user devices. These applications include web and mobile apps. ## Install ```bash npm install @devunus/js-client-sdk ``` ## Initialize SDK - devunusClient.init Obtain an environment key from the [getting started | SDK keys](./Initializing.md). In addition to the environment key, you should also pass in a user context for feature targeting and user grouping, all of which are optional. ### Each environment key is unique to each environment ```javascript import { devunusClient } from "@devunus/js-client-sdk"; const context: Context = { user_id: 'your users id', // optional if added will allow flag targeting and generate user analytics user_name: 'your users name', // optional, provides more meaningfully analytics }; devunusClient.init(env_key, context); ``` ## Get Feature Flag Feature flags can be used to create logic branches in your code that can be rolled out to users. By default will return false unless enabled in the admin console. ```javascript devunusClient.getFeatureStatus('new_invoice_feature') ``` ## Get Config Config allows you to store values that can be used to drive logic in your application. By default will return the default value unless set in the admin console. Get config can use the same targeting rules as feature flags. ```javascript devunusClient.getConfig('flag_name','default value') ``` ## Get Notified when Feature Flag Changes The SDK will automatically update when a feature flag or config is updated in the configuration screen, due to the global distribution of the flag configuration, updates can take up to 1 minute to be deployed. If you need to get notified of these changes, you can use the `on` method. ```javascript if (devunusClient.on('flags_update', () => { if (devunusClient.getFeatureStatus('flag_name')) { // do something } }); ``` If you want to disable the automatic updates, you can set the `live_config_updates` property to false. The value is true by default. ```javascript // disable live config updates devunusClient.live_config_updates = false; ``` --- ## source sdk/client/Initializing.md # Initialize options First step is to initialize the async devunusClient.init() ## User Context Use the `user_id` and `user_name` to target features and generate analytics at the user level. environment key is unique to each environment ```javascript import { devunusClient } from "@devunus/js-client-sdk"; const context: Context = { user_id: 'your users id', // optional if added will allow flag targeting and generate user analytics user_name: 'your users name', // optional, allows easier user searches user_email: 'your users email', // optional, useful for user targeting }; devunusClient.init(env_key, context); ``` ## B2B/Saas Options Use the `company_id` and `company_name` to target features and generate analytics at the organization level. ```javascript import { devunusClient } from "@devunus/js-client-sdk"; const context: Context = { ... company_id: 'users organization/account id', // optional if added will allow flag targeting and generate organization analytics company_name: 'company name' // optional, used to make searchable in analytics }; devunusClient.init(env_key, context); ``` ## Release Analytics Use the `git_commit` or `app_name` to generate release analytics. ```javascript import { devunusClient } from "@devunus/js-client-sdk"; const context: Context = { ... app_name 'app or service name' // optional if added will drive release dashboard app_version: '1.0.0' // optional if added will drive release dashboard git_commit: 'GIT_SHA' // optional if added will generate release data }; devunusClient.init(env_key, context); ``` ## User Traits Use the `user_traits` to provide additional user information. ```javascript const context: Context = { ... user_traits: { plan: 'pro', company_size: '1-10', }; devunusClient.init(env_key, context); ``` ## Advanced Options ### Http Path grouping To enable url path grouping by default Ids are replaced with an `*` in the path. The default implementation will replace UIDs with an `*`. If you use other id formats you can override this behavior by providing a `removeIds` function. ```javascript devunusClient.init('key', { ..., urlRemoveIds: removeIds }); /* this function will replace account ID in admin routes with * and project ID with * */ function removeIds(path: string): string { return path // Replace account ID in admin routes with * .replace(/\/admin\/[a-zA-Z0-9]+(?=\/|$)/g, '/admin/*') // Replace project ID (number only) with * .replace(/\/project\/\d+(?=\/|$)/g, '/project/*'); } describe('remove IDs from paths to allow api call grouping', () => { test('should replace account ID and project ID in routes with *', () => { expect(removeIds('/admin/abc1236/project/1/metrics/')).toBe('/admin/*/project/*/metrics/'); }); }); ``` --- ## source guides/session-replay.md # Session Replay Session Replay enables you to capture and review how users interact with your website or application. By watching recorded user sessions, you can: - Gain deep insights into user behavior and navigation patterns - Identify and troubleshoot user experience issues - Understand friction points in your conversion funnel - Make data-driven decisions to enhance your product This powerful feature helps teams improve their application's usability and overall user experience through direct observation of real user interactions. ## Getting Started ### 1. Enable Session Replay Navigate to the Feature Flags section and enable the `session_replay` flag. You can configure this flag to target: - Specific environments - Individual companies - Selected user groups - A percentage of random users ![Enable Session Replay](/img/enable-replay.png) ### 2. Watch Recorded Sessions Access recorded sessions through the Sessions view and click the "replay" button to start playback. ![Watch Session](/img/session-card.png) ## Privacy Settings ### Input Field Handling By default, all form inputs are masked for privacy. To enable input recording: ```javascript devunusClient.init(key, { record_form_inputs: true, }); ``` **Note:** Password fields are always masked regardless of settings. ### Element Privacy Controls Add these CSS classes to control recording behavior: - `.rr-block` - Prevents recording of the element completely - `.rr-mask` - Masks the text content of the element and its children ### Data Retention All session recordings are automatically deleted after 30 days. --- ## source guides/release-flags.md # Release Flags Use Feature Flags to control the rollout of new features to your users or companies. devunus supports 3 different types of flags: - **Release Flags** (Roll out a feature to a subset of users, normally 10% of users and then increase the percentage if the feature is working as expected) - **Experiments** (A/B testing) - **Kill Switches** (Disable a feature, such as a 3rd party dependency, or maintenance window) Below we will go over the process of releasing a new feature using a **Release Flag**. ## Step 1 - Create a Release flag Go to Feature Flags from the menu and click Add Release Flag ![Flags](./img/flags.png) Enter a name and description for the flag. For our example we will add a new client onboarding flag for a CRM product. ![Add Release Flag](./img/addFlag.png) ## Step 2 - Add targeting rules Assign a default value for each environment, or set up more complex targeting rules for example targeting a small section of your users. ![Add Rules](./img/addRules.png) ## Step 3 - Use the new flag using the devunus SDK Now that you have created a new flag, you can use it in your application. see [getting started](/docs/sdk/client/getting-started) for more information on how to install the SDK. Javascript example below: ```javascript if (devunusClient.getFeatureStatus('new_client_onboarding')) { // show new onboarding experience } else { // show old onboarding experience } ``` ## Step 4 - Update Rules to slowly rollout the change to all users Monitor the feature to ensure it is working as expected. Use analytics to identify any issues. Gradually increase the number of users receiving the new feature by updating the targeting rules. If issues arise, roll back the distribution. In the example below we will roll out the new onboarding experience to 60% of our users. ![Flag Split](./img/FlagUserSplit.png) ## Step 5 - Feature Rolled out Once the feature is fully rolled out, remove the flag from your code. --- ## source guides/product-analytics.md # Product Analytics Product analytics is a crucial aspect of understanding how users interact with your product/application. By analyzing user behavior, you can make informed decisions to improve user experience, increase engagement, and drive growth. ## Events Use the SDK to track events for your users, for example this could be when they used an important feature. In the exmaple below we will track when an invoice is generated. ```javascript title="js client-sdk example" devunusClient.logEvent('invoice_created', { property: 'value' }) ``` See the SDK guides for [JavaScript](/docs/sdk/client/track), for more information. ### Best Practices for event naming 1. **Use Clear and Descriptive Names**: Event names should clearly describe the action being tracked. Avoid abbreviations and ambiguous terms. - **Good**: `user_signed_up` - **Bad**: `signup` 2. **Follow a Consistent Naming Convention**: Use a consistent format for all event names. A common convention is to use lowercase letters and underscores to separate words. - **Example**: `button_clicked`, `page_viewed` 3. **Include Context**: Provide context to the event to make it more meaningful. This can include the object or feature being interacted with. - **Example**: `invoice_generated`, `profile_updated` 4. **Use Past Tense**: Name events in the past tense to indicate that the action has already occurred. - **Example**: `email_sent`, `file_uploaded` ## Metrics devunus will automatically generate metrics for your events to track daily counts, unique users and companies (SaaS only). ![Metrics](./img/metrics.png) From which you can then view the data by period, event, user or company. ![Metrics](./img/count_metric.png) --- ## source guides/intro.md # Getting Started Guides Welcome to the comprehensive guide for Devunus Multi-Tool - your all-in-one solution for feature management, user analytics, and application monitoring. ## Explore our main features through these detailed guides: - **[Release Flags](./release-flags.md)** - Implement feature flags to manage and safely roll out changes to your production environment - **[Product Analytics](./product-analytics.md)** - Track, analyze, and understand user behavior with powerful analytics tools - **[Session Replay](./session-replay.md)** - Gain deep insights into user interactions through detailed session recordings These guides provide step-by-step instructions to help you leverage the full potential of the Devunus Multi-Tool platform for your application. ## Why Choose Devunus? - 🚀 Safe and controlled feature releases - 📊 Real-time user behavior analytics - 🔍 Detailed session replay capabilities - 🛠️ Easy integration and setup ---