⏱ Estimated Time To Completion: 3 minutes

Step 1: Sign in to Decipher

Sign in to Decipher using your work email address and a customer_id will be automatically created for you, which you’ll use in the next step.

Step 2: Integrate the SDK

Install the SDK

pip install decipher-sdk

Instrumenting your Flask app

Simply import decipher_sdk and initialize it as below.

from flask import Flask, request, jsonify
import decipher_sdk

app = Flask(__name__)

    # A codebase name of your choice to identify errors in Decipher.
    # This comes from https://www.app.getdecipher.com/settings; see Step 1.

@app.route("/submit", methods=['POST'])
def submit_data():
    data = request.json
    return jsonify({"status": "success", "received_data": data})

That’s it! Decipher will now monitor and surface all your errors and exceptions on the dashboard.

Capturing error details on handled exceptions

If you want to capture error details like the stack trace for handled exceptions (e.g. in a try/catch) you can use Decipher.capture_error(error) like below:

// ...other imports
import decipher_sdk

@app.route('/handled_example', methods=['GET'])
def example_endpoint():
        raise ValueError("This is a handled error")
    except Exception as e:
    return jsonify({"status": "success"}), 200

Boom! Decipher will now include the stack trace and other context to help you and Decipher’s AI debug.

Add user information as context for your errors

If you want to add user details to errors make sure to call decipher_sdk.set_user() near the beginning of the request.

You can include any subset of the following: id, email, username

// ...other imports
import decipher_sdk

@app.route('/handled_example', methods=['GET'])
def example_endpoint():
    decipher_sdk.set_user({"id": "2958292", "email": "john@example.com", "username:": "John Smith"})
    // other code here
    return jsonify({"status": "success"}), 200