AWS RUM integration in flutter webapp

WE ARE USING AWS FOR BACKEND . AND AWS RUM SPECIFIC FOR FRONTEND LOGGING. THIS CODE SNIPPET IS PROVIDED BY RUM TO CONNECT RUM TO FLUTTER.

HOW CAN WE PREVENT SECURITY MEASURES ,IF WE ADD THIS SCRIPT IN HTML.INDEX FILE FOR WEBAPP. FOR ‘RUM ID’ AND ‘IDENTITY POOL’ . IF WE ADD THEM IN .ENV FILE WE WILL LOSE LOADING LOGS OF RUM .
MAIN REASON IS HOW WE GONNA SECURE THESE TWO IDS. IN OUR WEBAPP SECURITY IS VERY CRUCIAL FOR US.

This is a pretty common concern, but the key point is that neither the RUM app ID nor the identity pool ID are meant to be treated as secrets in the first place. Anything that runs in a browser is always public by design, so hiding them in a .env or trying to “secure” them client-side doesn’t really add real protection.

What actually matters for security is what those identities are allowed to do in AWS. The identity pool should have very tightly scoped IAM roles, minimal permissions, and proper conditions (like domain restrictions, Cognito auth state if used, etc.). That’s where you enforce control, not in hiding the IDs.

For RUM specifically, you can also restrict data collection using allowed origins in the RUM app monitor settings, so only your domain can send events. That’s usually the real safeguard.

So in short: don’t try to hide public identifiers, instead lock down IAM roles and allowed sources. That’s the AWS model for frontend services like RUM.