Index of every page on this site: llms.txt
All skills
datadog-labs avatar

/dd-instrument-product-analytics

@618fae3 official
Run it yourself

Switches on Datadog Product Analytics (funnels, retention, pathways, user journeys) for a browser app that runs the Datadog RUM Browser SDK. Turns the product on for the app's RUM application, ties sessions to signed-in users with setUser, and checks that events arrive. Use when asked to add, set up, enable or verify Product Analytics or user-behavior analytics in a web frontend. Not for adding RUM itself, which dd-instrument-rum does first, or for mobile apps.

Use this Skill: https://skilld.dev/gh/datadog-labs/agent-skills/dd-instrument-product-analytics

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesapi-switch.md

≈790 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Switch Product Analytics on through the API

Open this in step 3 when DD_API_KEY and DD_APP_KEY are both set. The application key needs rum_apps_read for the initial lookup, plus rum_apps_write and product_analytics_apps_write for the update.

  1. Read the application with the Get a RUM application endpoint (the first curl below). Record two fields of data.attributes:
    • product_scales.product_analytics_retention_scale.state: MAX means Product Analytics was already on, so stop here.
    • product_analytics_preview_disabled: absent while the application is in preview. A new application starts in preview, and the API reports its state as NONE. Setting MAX ends the preview, and the public API documents no way back to it, so when this field is absent, say in the summary that turning Product Analytics on ended the preview.
  2. Otherwise, send only product_analytics_retention_state with the Update a RUM application endpoint (the PATCH below). Leave out rum_event_processing_state: sending a lower value, such as NONE, stops RUM and Error Tracking processing for the app.

The keys reach curl through a pipe, so they never appear in the process list. Resolve the site to one API host before either request. Any other value, including a lookalike domain, leaves the host empty and sends no keys. The commands run in any POSIX shell:

SITE=<site from step 1> APP_ID=<application id from step 1>
case "$SITE" in
  datadoghq.com) API_HOST=api.datadoghq.com ;;
  datadoghq.eu) API_HOST=api.datadoghq.eu ;;
  us3.datadoghq.com) API_HOST=api.us3.datadoghq.com ;;
  us5.datadoghq.com) API_HOST=api.us5.datadoghq.com ;;
  ap1.datadoghq.com) API_HOST=api.ap1.datadoghq.com ;;
  ap2.datadoghq.com) API_HOST=api.ap2.datadoghq.com ;;
  uk1.datadoghq.com) API_HOST=api.uk1.datadoghq.com ;;
  *) API_HOST= ;;
esac
if [ -n "$API_HOST" ]; then
  URL="https://$API_HOST/api/v2/rum/applications/$APP_ID"
  keys() { echo "DD-API-KEY: $DD_API_KEY"; echo "DD-APPLICATION-KEY: $DD_APP_KEY"; }
  keys | curl -sS -w ' HTTP %{http_code}' -H @- "$URL"
  BODY=$(printf '{"data":{"id":"%s","type":"rum_application_update","attributes":{"product_analytics_retention_state":"MAX"}}}' "$APP_ID")
  keys | curl -sS -w ' HTTP %{http_code}' -H @- -H 'Content-Type: application/json' -X PATCH -d "$BODY" "$URL"
else
  echo "unsupported site, not sending keys" >&2
fi

Each call prints its HTTP status after the body:

Status Meaning
200 The update's response shows MAX in the same field
401 or 403 A key is invalid, or the application key lacks one of the three permissions
404 The application belongs to another org, or the site is wrong

On any failure, fall back to the settings step in SKILL.md.

Undo. Use the same API_HOST. Send the update with "NONE" only when that host was set. When step 1 found the application in preview, also tell the user that its preview ended when Product Analytics was turned on, and that undoing does not bring the preview back.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts11d3 checks · Risk SAFE
  • Gen Agent Trust Hub11d

    The skill is safe and authored by Datadog Labs. It automates the setup of Datadog Product Analytics by discovering existing RUM configurations, updating the project code, and enabling the feature via the Datadog API. It follows security best practices, such as masking secrets in shell commands and whitelisting official domains for network requests.

  • Socket11d

    No alerts

  • Snyk11d

    Risk: LOW · No issues

Signed by skilld at 618fae3. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 2 weeks ago
Other metadata
metadata
{
  "version": "0.1.0",
  "author": "datadog-labs",
  "repository": "https://github.com/datadog-labs/agent-skills",
  "tags": "datadog,product-analytics,rum,browser-rum,instrumentation,funnels,retention,pathways",
  "alwaysApply": "false"
}

README badge

README badge for datadog-labs/agent-skills/dd-instrument-product-analytics