Step 1: Import Javascript CDN

Import the script in your index html file. Add the following script tag to the head section of your index.html file.

<script src="https://cdnjs.middleware.io/browser/libs/0.0.1/middleware-rum.min.js" type="text/javascript"></script>

Step 2: Initialize the SDK

Create your application from installation instruction (Doc link: https://[account].middleware.io/installation#rum/javascript), Place this method just below the initialize script tag in the head section of your index.html file. We have env and recording options available with the script.

<script>
    if (window.Middleware){
        Middleware.track({
            serviceName: "service_name",
            projectName: "project_name",
            accountKey: "account_key",
            target:"https://[account].middleware.io",
            env: “production”,
            recording:1})
    }
</script>

To add user related information in the RUM data you can pass that data with RUM configuration as below (Here name and email both are fixed parameters),


// Add below key and value pair in above RUM config
defaultAttributes: { 
    name: 'John Doe', 
    email: '[email protected]', 
    user_type: 'admin', // it can be key value pairs
}