### Basic Inspektify Ktor Plugin Installation Source: https://context7.com/bvantur/inspektify/llms.txt Install the InspektifyKtor plugin into your Ktor HttpClient. This is the minimum required setup for network traffic interception. ```kotlin import io.ktor.client.HttpClient import sp.bvantur.inspektify.ktor.InspektifyKtor val client = HttpClient { install(InspektifyKtor) // All network calls through this client will now be captured. } ``` -------------------------------- ### Copy secrets.properties.example Source: https://github.com/bvantur/inspektify/blob/main/README.md Copy the example secrets file to a new file named secrets.properties in the project root. ```bash cp secrets.properties.example secrets.properties ``` -------------------------------- ### Complete Real-World Inspektify Ktor Setup Source: https://context7.com/bvantur/inspektify/llms.txt A production-ready configuration combining common Inspektify options. This setup enables auto-detection for multiple platforms, custom desktop shortcuts, header logging, data retention policies, header and body redaction, payload size limits, and endpoint ignore rules. The entire feature set is gated behind a debug build check. ```kotlin import io.ktor.client.HttpClient import io.ktor.client.plugins.contentnegotiation.ContentNegotiation import io.ktor.client.plugins.defaultRequest import io.ktor.client.request.header import io.ktor.serialization.kotlinx.json.json import kotlinx.serialization.json.Json import sp.bvantur.inspektify.ktor.* val httpClient = HttpClient { install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) } defaultRequest { url("https://api.example.com/v1/") header("x-api-key", BuildConfig.API_KEY) } if (BuildConfig.DEBUG) { install(InspektifyKtor) { // Auto-detect on all platforms; custom Desktop shortcut autoDetectEnabledFor = setOf( AutoDetectTarget.Android, AutoDetectTarget.Apple, AutoDetectTarget.Desktop( ShortcutCombination( mainModifier = setOf(MainModifier.CONTROL, MainModifier.SHIFT), mainKey = MainKey.I ) ) ) logLevel = LogLevel.Headers // log headers to console dataRetentionPolicy = DataRetentionPolicy.SessionCount(5) redactHeaders = listOf("x-api-key", "Authorization") redactBodyProperties = listOf("password", "token") payloadTooLargePolicy = PayloadTooLargePolicy.BodySizeLimit(500_000) ignoreEndpoints = listOf( IgnorePathData( method = MethodType.GET, matchingStrategy = EndpointMatchingStrategy.Contains("/ping") ) ) } } } ``` -------------------------------- ### Install InspektifyKtor Plugin Source: https://github.com/bvantur/inspektify/blob/main/README.md Configure the Inspektify library by installing the InspektifyKtor plugin when creating your Ktor client. ```kotlin HttpClient() { ... install(InspektifyKtor) } ``` -------------------------------- ### Custom Desktop Shortcut Configuration Source: https://github.com/bvantur/inspektify/blob/main/docs/AUTO_DETECT_CONFIGURATION.md Configure a custom desktop shortcut for triggering Inspektify's functionality. This example sets the shortcut to `SHIFT + I` by specifying the modifier and the main key. ```kotlin AutoDetectTarget.Desktop( shortcutCombination = ShortcutCombination( mainModifier = setOf(MainModifier.SHIFT), mainKey = MainKey.I ) ) ``` -------------------------------- ### Manually Start Inspektify Tool Window Source: https://github.com/bvantur/inspektify/blob/main/docs/AUTO_DETECT_CONFIGURATION.md Call this function to manually present the Inspektify tool window when auto-detection is disabled. This is necessary to access Inspektify's features if `autoDetectEnabledFor` is set to an empty set. ```kotlin InspektifyKtor.startInspektify() ``` -------------------------------- ### Conditionally Install Inspektify in Debug Builds Source: https://context7.com/bvantur/inspektify/llms.txt Guard the InspektifyKtor installation with a debug flag to prevent its inclusion in production builds. This example uses BuildConfig.DEBUG. ```kotlin HttpClient { install(ContentNegotiation) { json() } if (BuildConfig.DEBUG) { // or your own isDebug() helper install(InspektifyKtor) { logLevel = LogLevel.All } } } ``` -------------------------------- ### Configure Log Level in Ktor Client Source: https://github.com/bvantur/inspektify/blob/main/docs/LOG_LEVEL.md Set the desired log level when installing the InspektifyKtor plugin to control network communication logging. ```kotlin install(InspektifyKtor) { logLevel = LogLevel.All } ``` -------------------------------- ### Conditionally Install Inspektify in Ktor Client Source: https://github.com/bvantur/inspektify/blob/main/docs/EXCLUDING_INSPEKTIFY_FROM_RELEASE_BUILDS.md Install the InspektifyKtor plugin only when the application is in a debug state. This prevents the debug tool from being included in release builds. ```kotlin HttpClient() { ... if (isDebug()) { install(InspektifyKtor) } } ``` -------------------------------- ### Configure Ignored Endpoints in InspektifyKtor Source: https://github.com/bvantur/inspektify/blob/main/docs/IGNORE_ENDPOINTS_CONFIGURATION.md Use the `ignoreEndpoints` property within the `InspektifyKtor` plugin configuration to specify which endpoints should be excluded. This example demonstrates ignoring GET requests to an exact health check URL, POST requests containing '/login' in their URL, and all HTTP methods matching a regex pattern for a specific domain. ```kotlin install(InspektifyKtor) { ignoreEndpoints = listOf( IgnorePathData( method = MethodType.GET, matchingStrategy = EndpointMatchingStrategy.Exact("https://www.example.com/health-check") ), IgnorePathData( method = MethodType.POST, matchingStrategy = EndpointMatchingStrategy.Contains("/login") ), IgnorePathData( method = MethodType.ALL, matchingStrategy = EndpointMatchingStrategy.Regex("https://reqres\\.in/.*") ) ) } ``` -------------------------------- ### Create AppDelegate for iOS Project Source: https://github.com/bvantur/inspektify/blob/main/docs/SHORTCUT_FOR_MOBILE_CLIENTS.md If your iOS project does not have an `AppDelegate.swift` file, create one with the provided basic structure. ```swift import UIKit class AppDelegate: NSObject, UIApplicationDelegate { } ``` -------------------------------- ### Integrate Inspektify Scene Configuration in AppDelegate Source: https://github.com/bvantur/inspektify/blob/main/docs/SHORTCUT_FOR_MOBILE_CLIENTS.md Override the `application(_:configurationForConnecting:options:)` method in your `AppDelegate.swift` to return the Inspektify scene configuration. ```swift func application( _ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions ) -> UISceneConfiguration { return InspektifyShortcutHandlerKt.getInspektifyUISceneConfiguration(configurationForConnectingSceneSession: connectingSceneSession) } ``` -------------------------------- ### Enable iOS Quick Action / Android Shortcut Source: https://context7.com/bvantur/inspektify/llms.txt Enable the iOS Quick Action and Android shortcut for opening the inspector as an alternative to the shake gesture. This is useful when shake is already claimed by another library. ```kotlin // Step 1: Enable in Ktor plugin config HttpClient { install(InspektifyKtor) { shortcutEnabled = true } } ``` ```kotlin // Step 2 (Ktor 3): Export the library from the iOS framework in build.gradle.kts kotlin { listOf(iosArm64(), iosX64(), iosSimulatorArm64()).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "ComposeApp" isStatic = false export("io.github.bvantur:inspektify-ktor3:1.0.0") } } sourceSets { commonMain.dependencies { api("io.github.bvantur:inspektify-ktor3:1.0.0") // api, not implementation } } } ``` ```swift // Step 3: Wire the Quick Action in AppDelegate.swift import UIKit import ComposeApp class AppDelegate: NSObject, UIApplicationDelegate { func application( _ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions ) -> UISceneConfiguration { return InspektifyShortcutHandlerKt.getInspektifyUISceneConfiguration( configurationForConnectingSceneSession: connectingSceneSession ) } } ``` -------------------------------- ### iOS Dynamic Framework Linker Flags Source: https://github.com/bvantur/inspektify/blob/main/README.md Add this Gradle configuration for dynamic iOS frameworks to include the sqlite3 library. ```gradle iosTarget.binaries.all { linkerOpts("-lsqlite3") } ``` -------------------------------- ### Manually Open Inspector with startInspektify() Source: https://context7.com/bvantur/inspektify/llms.txt When auto-detection is disabled, call `startInspektify()` from a button, gesture, or debug menu to open the inspector window on demand. Ensure `autoDetectEnabledFor` is set to an empty set to disable automatic triggers. ```kotlin HttpClient { install(InspektifyKtor) { autoDetectEnabledFor = emptySet() // disable all automatic triggers logLevel = LogLevel.Info } } // In your debug UI — e.g., a floating debug button visible only in debug builds: Button(onClick = { InspektifyKtor.startInspektify() }) { Text("Open Network Inspector") } ``` -------------------------------- ### Configure Inspektify Auto-Detection and Shortcuts Source: https://context7.com/bvantur/inspektify/llms.txt Customize auto-detection behavior for Inspektify. You can restrict platforms or define custom desktop shortcuts. Pass an empty set to disable auto-detection entirely. ```kotlin import sp.bvantur.inspektify.ktor.AutoDetectTarget import sp.bvantur.inspektify.ktor.MainKey import sp.bvantur.inspektify.ktor.MainModifier import sp.bvantur.inspektify.ktor.ShortcutCombination HttpClient { install(InspektifyKtor) { // Enable auto-detect only on mobile; disable on Desktop autoDetectEnabledFor = setOf(AutoDetectTarget.Android, AutoDetectTarget.Apple) // Custom Desktop shortcut: Shift+I instead of the default Ctrl+Shift+D autoDetectEnabledFor = setOf( AutoDetectTarget.Desktop( shortcutCombination = ShortcutCombination( mainModifier = setOf(MainModifier.SHIFT), mainKey = MainKey.I ) ) ) // Disable ALL auto-detection — you must call startInspektify() yourself autoDetectEnabledFor = emptySet() } } // Open the inspector programmatically (e.g., from a debug menu button) InspektifyKtor.startInspektify() ``` -------------------------------- ### Add Inspektify for Ktor 3.x.x Source: https://github.com/bvantur/inspektify/blob/main/README.md Include the Inspektify Ktor 3.x.x dependency in your commonMain dependencies. ```gradle commonMain.dependencies { ... implementation("io.github.bvantur:inspektify-ktor3:{mavenVersion}") } ``` -------------------------------- ### Enable Inspektify Shortcut in Ktor Source: https://github.com/bvantur/inspektify/blob/main/docs/SHORTCUT_FOR_MOBILE_CLIENTS.md Set `shortcutEnabled` to `true` within the `InspektifyKtor` configuration block to enable the shortcut feature. ```kotlin install(InspektifyKtor) { shortcutEnabled = true } ``` -------------------------------- ### Configure Log Level for Ktor HttpClient Source: https://context7.com/bvantur/inspektify/llms.txt Controls the verbosity of captured traffic logs. Choose from All, Info, Headers, Body, or None. Default is None. ```kotlin import sp.bvantur.inspektify.ktor.LogLevel HttpClient { install(InspektifyKtor) { logLevel = LogLevel.All // logs URL + method + status + headers + body // logLevel = LogLevel.Info // URL, method, response code only // logLevel = LogLevel.Headers // Info + request & response headers // logLevel = LogLevel.Body // Info + request & response bodies // logLevel = LogLevel.None // silent (default) } } // Expected system-log output for LogLevel.All on a GET /users request: // --> GET https://reqres.in/api/users?page=1 // Accept: application/json // x-api-key: *** // --> END GET // <-- 200 OK (312ms) // Content-Type: application/json; charset=utf-8 // {"page":1,"per_page":6,"total":12,...} // <-- END HTTP ``` -------------------------------- ### Add Maven Repository Source: https://github.com/bvantur/inspektify/blob/main/README.md Ensure mavenCentral is added to your project's repositories if it's not already present. ```gradle repositories { ... mavenCentral() } ``` -------------------------------- ### Add Inspektify for Ktor 2.3.1 - 3.0.0 Source: https://github.com/bvantur/inspektify/blob/main/README.md Include the Inspektify Ktor 2.3.1 - 3.0.0 dependency in your commonMain dependencies. ```gradle commonMain.dependencies { ... implementation("io.github.bvantur:inspektify-ktor2:{mavenVersion}") } ``` -------------------------------- ### Configure Data Retention by Days Source: https://github.com/bvantur/inspektify/blob/main/docs/DATA_RETENTION_POLICY.md Set data retention to a specific number of days (1-14). Data older than the specified duration will be preserved. ```kotlin install(InspektifyKtor) { dataRetentionPolicy = DataRetentionPolicy.DayDuration(7) } ``` -------------------------------- ### Add Inspektify Ktor 2.x Dependency Source: https://context7.com/bvantur/inspektify/llms.txt Add the Inspektify Ktor 2.x dependency to your commonMain dependencies. ```kotlin commonMain.dependencies { implementation("io.github.bvantur:inspektify-ktor2:1.0.0") } ``` -------------------------------- ### Update API Key in secrets.properties Source: https://github.com/bvantur/inspektify/blob/main/README.md Replace the placeholder with your actual API key in the secrets.properties file. ```properties reqres.api.key=your_reqres_api_key_here ``` -------------------------------- ### iOS Static Framework Linker Flag Source: https://context7.com/bvantur/inspektify/llms.txt If using iOS static frameworks, add '-lsqlite3' to your 'Other Linker Flags' in Xcode. For dynamic frameworks, configure it in Gradle. ```kotlin iosTarget.binaries.all { linkerOpts("-lsqlite3") } ``` -------------------------------- ### Configure Data Retention by Session Count Source: https://github.com/bvantur/inspektify/blob/main/docs/DATA_RETENTION_POLICY.md Set data retention to a maximum number of sessions (1-20). When the session limit is exceeded, the oldest session's data is removed. ```kotlin install(InspektifyKtor) { dataRetentionPolicy = DataRetentionPolicy.SessionCount(10) } ``` -------------------------------- ### Export Inspektify Ktor Dependency for iOS Frameworks Source: https://github.com/bvantur/inspektify/blob/main/docs/SHORTCUT_FOR_MOBILE_CLIENTS.md Ensure the Inspektify Ktor library is exported for all defined iOS targets when building a framework. ```kotlin listOf( iosArm64(), iosX64(), iosSimulatorArm64() ).forEach { iosTarget -> iosTarget.binaries.framework { ... export("io.github.bvantur:inspektify-ktor3:{mavenVersion}") } } ``` -------------------------------- ### Configure Body Size Limit for Payloads Source: https://github.com/bvantur/inspektify/blob/main/docs/PAYLOAD_TOO_LARGE_POLICY.md Use `PayloadTooLargePolicy.BodySizeLimit` to store only the first N bytes of a payload. When truncated, a `[... truncated]` marker is appended. The default limit is 250,000 bytes. ```kotlin install(InspektifyKtor) { payloadTooLargePolicy = PayloadTooLargePolicy.BodySizeLimit() // default: 250 000 bytes payloadTooLargePolicy = PayloadTooLargePolicy.BodySizeLimit(500_000) // larger limit payloadTooLargePolicy = PayloadTooLargePolicy.BodySizeLimit(100_000) // stricter limit } ``` -------------------------------- ### Add Inspektify Ktor 3.x Dependency Source: https://context7.com/bvantur/inspektify/llms.txt Add the Inspektify Ktor 3.x dependency to your commonMain dependencies in Gradle. Ensure mavenCentral is listed in your repositories. ```kotlin dependencyResolutionManagement { repositories { mavenCentral() } } // shared/build.gradle.kts kotlin { sourceSets { commonMain.dependencies { implementation("io.github.bvantur:inspektify-ktor3:1.0.0") } } } ``` -------------------------------- ### Configure Data Retention Policy for Ktor HttpClient Source: https://context7.com/bvantur/inspektify/llms.txt Sets how long captured traffic is stored in the local SQLite database. Supports time-based (days) or session-based (count) retention. ```kotlin import sp.bvantur.inspektify.ktor.DataRetentionPolicy HttpClient { install(InspektifyKtor) { // Keep data for 7 days (1–14 allowed; default is 14) dataRetentionPolicy = DataRetentionPolicy.DayDuration(7) } } HttpClient { install(InspektifyKtor) { // Keep data for the last 10 sessions (1–20 allowed) // When the 11th session starts, the oldest session's data is deleted dataRetentionPolicy = DataRetentionPolicy.SessionCount(10) } } ``` -------------------------------- ### Update Gradle Dependency to API Source: https://github.com/bvantur/inspektify/blob/main/docs/SHORTCUT_FOR_MOBILE_CLIENTS.md Change the Inspektify Ktor dependency from `implementation` to `api` in your `commonMain` dependencies for iOS compatibility. ```kotlin commonMain.dependencies { ... api("io.github.bvantur:inspektify-ktor3:{mavenVersion}") } ``` -------------------------------- ### Enable Auto Detection for Specific Targets Source: https://github.com/bvantur/inspektify/blob/main/docs/AUTO_DETECT_CONFIGURATION.md Override the default auto-detection behavior to enable it only for Android and Apple platforms. This is useful when you want to limit the automatic detection of network transactions to specific environments. ```kotlin install(InspektifyKtor) { autoDetectEnabledFor = setOf(AutoDetectTarget.Android, AutoDetectTarget.Apple) } ``` -------------------------------- ### Configure Payload Too Large Policy for Ktor HttpClient Source: https://context7.com/bvantur/inspektify/llms.txt Limits the size of stored request/response bodies to prevent `SQLiteBlobTooBigException`. Choose between truncating the body or omitting it entirely. ```kotlin import sp.bvantur.inspektify.ktor.PayloadTooLargePolicy HttpClient { install(InspektifyKtor) { // Truncate body at 500 KB; stored text ends with "[... truncated]" payloadTooLargePolicy = PayloadTooLargePolicy.BodySizeLimit(500_000) } } HttpClient { install(InspektifyKtor) { // Drop the body entirely when it exceeds 100 KB; stored as "[body omitted]" payloadTooLargePolicy = PayloadTooLargePolicy.OmitBody(100_000) } } // The responsePayloadSize field always reflects the real transfer size from // the network, so the traffic list shows accurate sizes even for truncated entries. ``` -------------------------------- ### Configure Omit Body for Large Payloads Source: https://github.com/bvantur/inspektify/blob/main/docs/PAYLOAD_TOO_LARGE_POLICY.md Use `PayloadTooLargePolicy.OmitBody` to drop the entire body if its size exceeds a specified threshold. A `[body omitted]` marker indicates the body was intentionally skipped. This is useful for conserving database space. ```kotlin install(InspektifyKtor) { payloadTooLargePolicy = PayloadTooLargePolicy.OmitBody() // default: 250 000 bytes payloadTooLargePolicy = PayloadTooLargePolicy.OmitBody(500_000) // larger threshold payloadTooLargePolicy = PayloadTooLargePolicy.OmitBody(100_000) // stricter threshold } ``` -------------------------------- ### Redact Specific Headers in Inspektify Source: https://github.com/bvantur/inspektify/blob/main/docs/REDACT_DATA_FROM_INSPEKTIFY.md Configure Inspektify to redact specific HTTP headers by providing a list of header names. This is useful for sensitive information like API keys or authentication tokens. ```kotlin install(InspektifyKtor) { redactHeaders = listOf("x-api-key", "Auth-Token") } ``` -------------------------------- ### Ignore Specific Endpoints in Ktor HttpClient Source: https://context7.com/bvantur/inspektify/llms.txt Excludes specific endpoints from being intercepted. Supports exact URL, substring, and regex matching, optionally scoped to an HTTP method. ```kotlin import sp.bvantur.inspektify.ktor.EndpointMatchingStrategy import sp.bvantur.inspektify.ktor.IgnorePathData import sp.bvantur.inspektify.ktor.MethodType HttpClient { install(InspektifyKtor) { ignoreEndpoints = listOf( // Skip GET health-check pings (exact URL match) IgnorePathData( method = MethodType.GET, matchingStrategy = EndpointMatchingStrategy.Exact( "https://api.example.com/health-check" ) ), // Skip all POST requests whose URL contains "/login" IgnorePathData( method = MethodType.POST, matchingStrategy = EndpointMatchingStrategy.Contains("/login") ), // Skip every method hitting the analytics domain (regex) IgnorePathData( method = MethodType.ALL, matchingStrategy = EndpointMatchingStrategy.Regex( "https://analytics\.example\.com/.*" ) ) ) } } ``` -------------------------------- ### Disable All Auto Detection Source: https://github.com/bvantur/inspektify/blob/main/docs/AUTO_DETECT_CONFIGURATION.md Completely disable auto-detection for all targets by assigning an empty set to `autoDetectEnabledFor`. When auto-detection is disabled, you must manually present the Inspektify tool window. ```kotlin install(InspektifyKtor) { autoDetectEnabledFor = emptySet() } ``` -------------------------------- ### Redact Sensitive Data in Ktor HttpClient Source: https://context7.com/bvantur/inspektify/llms.txt Prevents sensitive values in headers and JSON body properties from being stored. Matched values are replaced with '*** REDACTED ***'. ```kotlin HttpClient { install(InspektifyKtor) { // Redact specific HTTP headers by name (case-insensitive match) redactHeaders = listOf("Authorization", "x-api-key", "Auth-Token") // Redact JSON body properties by key name redactBodyProperties = listOf("password", "ssn", "creditCardNumber") } } // Request with Authorization: Bearer secret123 // → stored as Authorization: *** REDACTED *** // Request body { "username": "alice", "password": "hunter2" } // → stored as { "username": "alice", "password": "*** REDACTED ***" } ``` -------------------------------- ### Redact Payload Properties in Inspektify Source: https://github.com/bvantur/inspektify/blob/main/docs/REDACT_DATA_FROM_INSPEKTIFY.md Configure Inspektify to redact specific properties from request and response payloads. This is useful for sensitive fields within JSON or other data structures. ```kotlin install(InspektifyKtor) { redactHeaders = listOf("firstName", "lastName") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.