This SDK instruments express app to capture http requests for auto-generating accurate postman live collections.
At the top of your app.js file, before app is initialized add this.
-
collectionId: Postman collectionId where requests will be added. This is the id for your live collection.
-
apiKey: Postman api key needed for authentication.
-
receiverBaseUrl: Where the data should be shipped to receiver's http endpoint.
-
bufferIntervalInMilliseconds: The interval in milliseconds that the SDK waits before sending data to Postman. The default interval is 5000 milliseconds. This interval can be tweaked for lower or higher throughput systems.
- type: number
- default: 5000
-
enable: enable or disable the SDK. Disabled SDK does not capture any new traces, nor does it use up system resources.
- type: boolean
- Can be set by using an environment variable 'POSTMAN_SDK_ENABLE' , which will over-ride any other config
-
debug: Enable/Disable debug logs.
-
truncateData: Truncate the request and response body so that no PII data is sent to Postman. This is enabled by default. Disabling it sends actual request and response payloads.
-
type: boolean
-
default: true
-
Example:
Sample payload or non-truncated payload:
{
"first_name": "John",
"age": 30
}
Truncated payload:
{
"first_name": {
"type": "String"
},
"age": {
"type": "Number"
}
}
-
redactSensitiveData: Redact sensitive data such as api_keys and auth tokens, before they leave the sdk. When this is enabled, below redaction rules are applied by default (they are not case-sensitive):
{
"pmPostmanAPIKey": "PMAK-[a-f0-9]{24}-[a-f0-9]{34}",
"pmPostmanAccessKey": "PMAT-[0-9a-z]{26}",
"pmBasicAuth": "Basic [a-zA-Z0-9]{3,1000}(?![a-z0-9+({})!@#$%^&|*])[=]{0,2}",
"pmBearerToken": "Bearer [a-z0-9A-Z\-\._~\+\/]{15,1000}"
}
- type: Object
{enable: true/false, rules: {ruleName: '<regexPattern>'}}
Example
initialize(
collectionId: '<postmanCollectionId>'
apiKey: '<apiKey>',
redactSensitiveData: {
enable: true,
rules: {
apiToken: 'PMAK-[a-f0-9]'
}
}
)
-
ignoreIncomingRequests: Return true/false to ignore incoming request from Live Collection
Example
initialize({
...otherParams,
ignoreIncomingRequests: (request) => {
return request.url.includes('knockknock');
}
});
-
ignoreOutgoingingRequests: Return true/false to ignore outgoing request from Live Collection
Example
initialize({
...otherParams,
ignoreOutgoingRequests: (request) => {
return request.headers['User-Agent'].includes('ignoreme');
}
});