Client Tokens Management¶
A Client Token is the core authentication credential for the TrueWatch Real User Monitoring (RUM) feature. It is used to securely send data from user devices (Web, Mobile, Mini Programs, etc.) to the TrueWatch server.
When users interact with a website or application, the Client Token is sent along with performance data so that the server can validate and accept the data, ensuring its security and accuracy. This token mechanism not only simplifies the authentication process but also enables efficient cross-domain data transmission, providing TrueWatch with a simple and effective way to collect and analyze real user usage.
Use Cases¶
Client Tokens are mainly used for Public DataWay access. With this method, you do not need to install the DataKit collector. Simply configure the site and clientToken parameters to quickly integrate RUM data.
Create a Client Token¶
Prerequisites¶
- You have Admin or Owner permissions in the TrueWatch workspace;
-
The RUM feature has been enabled.
-
Enter a name for the Client Token;
- Click Confirm;
- Copy the Client Token automatically generated by TrueWatch as needed.
Note
The full Client Token is displayed only when it is created. You cannot view the full token again later. If you lose it, create a new one.
Use a Client Token in RUM Applications¶
Public DataWay Access Configuration¶
When using Public DataWay access, you must specify the site (DataWay address) and clientToken parameters in the SDK initialization configuration.
Web Application Access Example¶
1. NPM Integration
import { datafluxRum } from "@truewatchtech/browser-rum"
datafluxRum.init({
applicationId: "<Application ID>",
site: "http://172.16.212.186:9529",
clientToken: "a993f53a8ea04bc6b9350e5e670a3a3b",
env: "production",
version: "1.0.0",
service: "browser",
sessionSampleRate: 100,
sessionReplaySampleRate: 70,
compressIntakeRequests: true,
trackInteractions: true,
traceType: "ddtrace", // Optional. Defaults to ddtrace. Currently supports 6 types: ddtrace, zipkin, skywalking_v3, jaeger, zipkin_single_header, and w3c_traceparent
allowedTracingOrigins: ["https://api.example.com", /https:\/\/.*\.my-api-domain\.com/], // Optional. List of all requests allowed to inject the headers required by the trace collector. Can be a request origin or a regular expression.
})
datafluxRum.startSessionReplayRecording()
2. CDN Synchronous Loading
<script
src="https://static.truewatch.com/browser-sdk/v3/dataflux-rum.js"
type="text/javascript"
></script>
<script>
window.DATAFLUX_RUM &&
window.DATAFLUX_RUM.init({
applicationId: "<Application ID>",
site: "http://172.16.212.186:9529",
clientToken: "a993f53a8ea04bc6b9350e5e670a3a3b",
env: "production",
version: "1.0.0",
service: "browser",
sessionSampleRate: 100,
sessionReplaySampleRate: 70,
compressIntakeRequests: true,
trackInteractions: true,
traceType: "ddtrace", // Optional. Defaults to ddtrace. Currently supports 6 types: ddtrace, zipkin, skywalking_v3, jaeger, zipkin_single_header, and w3c_traceparent
allowedTracingOrigins: ["https://api.example.com", /https:\/\/.*\.my-api-domain\.com/], // Optional. List of all requests allowed to inject the headers required by the trace collector. Can be a request origin or a regular expression.
})
window.DATAFLUX_RUM && window.DATAFLUX_RUM.startSessionReplayRecording()
</script>
For more access configuration instructions and examples, refer to Web Application Access.
Manage Client Tokens¶
All created Client Tokens are listed in the list. You can directly view the Client Token name, token value, creator, and creation time from the list.
Delete a Token¶
Click the delete button to delete the current Token. After deletion, if any agent is currently using this Token, data reporting will stop immediately.
Note
If an application is deleted, the corresponding Client Token in the Client Tokens management list is deleted at the same time.
Automatic Cleanup Mechanism¶
When a RUM application is deleted, the system automatically deletes the associated Client Token at the same time. We recommend cleaning up Tokens that are no longer in use on a regular basis to reduce security risks.
FAQ¶
What is the difference between a Client Token and a DataKit Token?
A Client Token is used for RUM Public DataWay access and only allows data reporting. A DataKit Token (starting with tkn_) is used for DataKit collector authentication and has broader permissions. The two cannot be used interchangeably.
Do I need to install DataKit to use Public DataWay?
No. Public DataWay is a managed service provided by TrueWatch. You do not need to install or maintain DataKit, making it suitable for quick integration scenarios.
What should I do if my Client Token is leaked?
The risk of a Client Token leak is relatively low (it only allows data reporting and cannot query or modify data), but we still recommend:
- Delete the Token immediately in the console;
- Create a new Token and update the application configuration;
- Check for any anomalous reported data.
Why is my application integrated but no data is being received?
Check the following:
- Whether the Client Token is correct (note that it is case-sensitive);
- Whether the site address is correct (it may differ by region);
- Whether the network allows access to the Public DataWay;
- Whether the sample rate configuration (sessionSampleRate) is too low.
Can one Token be used for multiple applications?
Technically yes, but it is not recommended. Sharing one Token across multiple applications causes data to be mixed, making it difficult to distinguish the source, and you cannot independently control data reporting for a specific application.
Can local deployment and Public DataWay be used together?
No. An application can only choose one access method:
- Choose Public DataWay → a Client Token is required, DataKit is not required
- Choose local deployment → a Client Token is not required, DataKit is required
