PageSourceSearch

https://loja.correios.com.br/public-resources/js/lojaweb/dtmonitor.js

js correios.com.br collected 2026-09-24 07:27:09 UTC 1,894 bytes, 47 lines download raw bytes

1/**
2 * Tenta identificar o usuário no Dynatrace.
3 * Caso o objeto `dtrum` ainda não esteja disponível, aguarda e tenta novamente.
4 */
5function identifyAuthenticatedUser(userHash) {
6	
7  if (userHash === "undefined" || userHash == "" ){
8	console.warn("[Dynatrace] Id Correios não informado!");
9	return;
10  }
11	
12  // Verifica se estamos em ambiente de navegador (evita erros em SSR/Node.js).
13  if (typeof window === "undefined") {
14    console.warn("[Dynatrace] Ambiente não-browser detectado. Não é possível identificar o usuário.");
15    return;
16  }
17
18  // Verifica se o objeto global `dtrum` da API Dynatrace está disponível.
19  if (typeof window.dtrum !== "undefined" && typeof window.dtrum.identifyUser === "function") {
20    window.dtrum.identifyUser(userHash);
21    console.log("[Dynatrace] Usuário identificado com sucesso.");
22  } else {
23    // Se `dtrum` ainda não carregou, aguarda 500ms e tenta novamente (máximo de 10 tentativas).
24    const maxAttempts = 10;
25    let attempts = 0;
26
27    const retryInterval = setInterval(() => {
28      attempts += 1;
29
30      if (typeof window.dtrum !== "undefined" && typeof window.dtrum.identifyUser === "function") {
31        window.dtrum.identifyUser(userHash);
32        console.log("[Dynatrace] Usuário identificado com sucesso (tentativa " + attempts + ").");
33        clearInterval(retryInterval);
34      } else if (attempts >= maxAttempts) {
35        console.warn("[Dynatrace] Não foi possível identificar o usuário: API indisponível após " + maxAttempts + " tentativas.");
36        clearInterval(retryInterval);
37      }
38    }, 500);
39  }
40}
41
42// Executa a identificação do usuário autenticado.
43// Em aplicações reais, chame esta função após confirmar que o login foi bem-sucedido.
44identifyAuthenticatedUser(DT_IDENTIFY);
45
46// Também é possível exportar a função para uso em módulos ES/CJS:
47// export { identifyAuthenticatedUser };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.