⏱ 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

Terminal
pip install decipher-sdk

Instrumenting your Flask app

Simply import decipher_sdk and initialize it as below.

app.py
from flask import Flask, request, jsonify
import decipher_sdk

app = Flask(__name__)

decipher_sdk.init(
    # A codebase name of your choice to identify errors in Decipher.
    codebase_id="CODEBASE_NAME_OF_MY_CHOICE",
    # This comes from https://www.app.getdecipher.com/settings; see Step 1.
    customer_id="MY_CUSTOMER_ID_FROM_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:

app.py
// ...other imports
import decipher_sdk

@app.route('/handled_example', methods=['GET'])
def example_endpoint():
    try:
        raise ValueError("This is a handled error")
    except Exception as e:
        decipher_sdk.capture_error(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

app.py
// ...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