hajeonghun / electron-google-analytics4

electron-google-analytics4
17 stars 2 forks source link

Uncaught ReferenceError: process is not defined #4

Open korbinzhao opened 1 year ago

korbinzhao commented 1 year ago

I am using in electron renderer, error as below:

image
hajeonghun commented 1 year ago

The default value for clientID is node machine id. Any thoughts on using it in the main process?

korbinzhao commented 1 year ago

The default value for clientID is node machine id. Any thoughts on using it in the main process?

Thx for your response. I did use electron-google-analytics4 in a wrong place. It works now when I using it in the main process. Thx a lot.

But now I encountered a new problem as below.

(node:33013) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT 172.217.163.36:443

I pinged the google-analytics.com in my local terminal, and reproduced this problem as below.

PING google-analytics.com (172.217.163.36): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2 Request timeout for icmp_seq 3

I can request google-analytics.com success in my local browser.

image

Do you encountered this problem? It will be a large help for me if you can give me some suggestions.

Waiting for you response. Thx a lot again.

korbinzhao commented 1 year ago

In another way, I can request google-analytics.com successful in renderer, but timeout in main process. It bothered me a lot. I have tried many ways to solve it, but just useless.

hajeonghun commented 1 year ago

It could be a firewall or DNS configuration issue. There are several approaches you can try, and I hope they prove helpful.

  1. There might be an issue with your current DNS server, so I suggest trying Google Public DNS instead.
  2. Try clearing the DNS cache and give it another attempt.
    sudo dscacheutil -flushcache
  3. Please verify if the host file is configured correctly. (cat /etc/hosts)

I'll attach an issue that seems similar to yours. I hope it proves helpful. Web server is working, but ping returns a request timeout

korbinzhao commented 1 year ago

@hajeonghun Thanks a lot for you response. I was able to fix the request problem in an unexpected way. At first I tried request GA API using axios, but it always timeout, looked like network blocked. Now I switched from using axios as my request tool to using fetch and disabled the webSecurity parameter in BrowserWindow. This enabled me to request the google-analytics.com API in the renderer process. It might also work for the main process, but I haven't tested it yet. I believe that there might have been some internal logic in axios that caused this issue.

hajeonghun commented 1 year ago

@korbinzhao Congratulations, and thank you for sharing your situation. It will surely be helpful to others.

dw-acc commented 9 months ago

@korbinzhao sorry how did you solve the process is not defined issue? I am using electron and vite