@nextlua/khaos.js
v0.3.5
Published
Javascript SDK for Khaos.
Downloads
1
Readme
Khaos.js
Javascript SDK for Khaos.
Usage
With NPM/Yarn
npm install --save khaosjs
oryarn add khaosjs
- Initialize library:
import Khaos from "khaosjs";
Khaos.init({
apiKey: "your-api-key",
networkOptions: {
baseApiUrl: "https://api.yourapp.com",
bodyKeysToRecord: ["isSucceed", "data", "message"],
headerKeysToRecord: [],
headersToRedact: [],
urlBlocklist: [],
tracingOrigins: [],
},
showButton: true,
appInfo: {},
});
With HTML <script>
tag
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
This is an example of a vanilla JS app.
<script src="dist/index.js"></script>
<script>
Khaos.default.init({
apiKey: "your-api-key",
networkOptions: {
baseApiUrl: "https://api.yourapp.com",
bodyKeysToRecord: ["isSucceed", "data", "message"],
headerKeysToRecord: [],
headersToRedact: [],
urlBlocklist: [],
tracingOrigins: [],
},
showButton: true,
appInfo: {},
});
</script>
</body>
</html>
API
Khaos.init(options: KhaosInitOptions): void
- Initializes library and starts monitoring for diagnostic data.
options
apiKey
:string
: (Required) API key provided in Khaos Dashboard.appInfo
:KhaosAppInfo
(Optional)buildVersion
:string
: (Optional)appVersion
:string
: (Optional)appVersionBuild
:string
: (Optional)appName
:string
: (Optional)appNameId
:string
: (Optional)appLanguage
:string
: (Optional)bundleId
:string
: (Optional)
networkOptions
:KhaosNetworkOptions
: (Optional) options for network monitoring.baseApiUrl
:string
: (Required) Your project's base Back-end API URL. Network monitoring won't work unless it is present.bodyKeysToRecord
:string[]
: (Optional) OverridesbodyKeysToRedact
List of HTTP Body keys to be recorded. Other keys will be redacted for security.bodyKeysToRedact
:string[]
: (Optional) List of HTTP Body keys to be redacted for security (for hiding keys that contain secret keys/tokens).headerKeysToRecord
:string[]
: (Optional) OverridesheadersToRedact
, List of only HTTP Headers to be recorded.headersToRedact
:string[]
: (Optional) List of HTTP Header keys containing secret keys/tokens.urlBlocklist
:string[]
: (Optional) List of URL's that is unwanted to be monitored.tracingOrigins
:string[]
: (Optional) List of URL's to be monitored other thanbaseApiUrl
.
showButton
:boolean
: (Optional, default:true
) show Khaos button for bug submit form.
Khaos.showForm(): void
Shows bug request form.
Khaos.hideForm(): void
Hides bug request form.
Khaos.toggleForm(): void
Toggles bug request form.