Skip to content

RUM applications with Terraform

fusescope_rum_application creates a Real User Monitoring application, the same object as Create application in Set up a web application, and its first public key.

Use this page when you want one RUM application per environment, created by the same pipeline that deploys the site.

rum.tf
resource "fusescope_rum_application" "shop" {
name = "shop-web"
platform = "web"
environment = "production"
allowed_origins = ["https://shop.example.com"]
trace_propagation_urls = ["https://api.example.com"]
sample_rate = 0.5
pii_policy = {
query_allowlist = ["page", "sort"]
require_consent = true
}
}
output "shop_rum_application_id" {
value = fusescope_rum_application.shop.id
}
output "shop_rum_key" {
value = fusescope_rum_application.shop.key
sensitive = true
}

For an Android app, set platform = "android" and list allowed_package_names instead of allowed_origins; source_maps.retention then also applies to R8 mappings. Changing platform replaces the application.

The attributes map to the form fields in Set up a web application:

Attribute Form field Applied by
allowed_origins, allowed_package_names Allowed origins Server
pii_policy.drop_query, pii_policy.query_allowlist Drop query strings, Keep these query parameters Server
trace_propagation_urls Link requests to backend traces SDK
sample_rate Session sample rate SDK
pii_policy.require_consent Wait for consent SDK
pii_policy.hash_user_id Hash user IDs SDK

Server settings take effect on terraform apply. SDK settings must also be in the init() options of your app, as below.

The public key is write-only and safe to ship in your bundle, but FuseScope returns it only when the application is created. Terraform keeps it in state; read it from the outputs when you build the site:

Terminal window
export VITE_FUSESCOPE_RUM_APP_ID=$(terraform output -raw shop_rum_application_id)
export VITE_FUSESCOPE_RUM_KEY=$(terraform output -raw shop_rum_key)
npm run build
src/main.ts
import { init } from '@fusescope/browser';
init({
applicationId: import.meta.env.VITE_FUSESCOPE_RUM_APP_ID,
publicKey: import.meta.env.VITE_FUSESCOPE_RUM_KEY,
endpoint: 'https://fusescope.example.com',
service: 'shop-web',
environment: 'production',
version: import.meta.env.VITE_APP_VERSION,
sessionSampleRate: 0.5,
requireConsent: true,
propagateTraceHeaderCorsUrls: ['https://api.example.com'],
privacy: { queryAllowlist: ['page', 'sort'] },
});

The variable names are an example for Vite; use your bundler’s convention. The other options are in the browser SDK reference.