Send Meta Data with RUM for APM

I am testing out a few of the Agent API in RUM with Elasticsearch APM as shown in this documentation here: Agent API | APM RUM JavaScript agent

So far I got most things working like getting span information, traces, transactions, user interactions, errors etc…

There’s only one thing left I can’t figure out, and it is how to run the addLabels, setUserContext and setCustomContext. Here’s my code:

	<!DOCTYPE html>
	<html lang="en">
	  <head>
		<meta charset="utf-8" />
		<title>Meta Data</title>
		<script src="https://unpkg.com/@elastic/apm-rum@5.12.0/dist/bundles/elastic-apm-rum.umd.min.js"></script>
		<script>
	const apm = window.elasticApm.init({
	  serviceName: 'myapp',
	  serverUrl: 'http://192.168.0.21:8200',
	  serviceVersion: '0.90'
	});
	const clickSendMetaData = () => {
	  const msg = document.getElementById('message').value;
	  apm.addLabels({'MyLabel': msg})
	  apm.setUserContext({'id': msg, 'username': msg, 'email': msg + '@' + msg + '.com'})
	  apm.setCustomContext({'MyObject': {'MyCustomContextMessage': msg}})
	  console.log('sent meta data');

	};
		</script>
	  </head>
	  <body>
		<input type="text" id="message" placeHolder="Type A Message For Meta Data" value="" />
		<button id="send_meta_data" name="send_meta_data" onClick="clickSendMetaData();">Send Meta Data</button>
	  </body>
	</html>

When I click the Send Meta Data button, nothing happens. I look in my browser’s Network Tab and no http requests are made. There are no errors in my console, only the message sent meta data which shows all the code fired without issues.

Am I missing something from my code?