DataDog / browser-sdk

Datadog Browser SDK
Apache License 2.0
303 stars 132 forks source link

Sending Logs to Backend Before Forwarding to Datadog (Without Exposing clientToken) #3104

Open maoryadin opened 5 days ago

maoryadin commented 5 days ago

I would like to implement a method to send logs to my backend first, rather than directly to Datadog.

This would allow my backend to perform checks or transformations on the payload before forwarding it to Datadog. Additionally, this setup would prevent the need to expose the clientToken on the frontend, which is essential for maintaining security.

Is this approach supported by Datadog, or are there any recommended best practices for achieving this?

Thank you!

amortemousque commented 1 day ago

Hello @maoryadin, You can configure a proxy URL to send the Logs / RUM events to you backend. Here is the guide. This guide focuses on the RUM SDK but the same capability exists for the Logs SDK.

rodgarcialima commented 13 hours ago

@maoryadin @amortemousque This is exactly what I was trying to achieve, and the proxy works fine, but my "proxy" backend requires authentication (Bearer Token), and this is not possible with the current proxy implementation. I'd love to see a way of injecting headers before the proxy call.