blogtutor / blog-tutor-support

Custom Support Plugin for NerdPress Clients
6 stars 3 forks source link

FEATURE: Add WordPress Dashboard widget to display cloudflare data Completes #340 #337

Closed 1337rout closed 3 months ago

1337rout commented 4 months ago

image Adds a dashboard widget that sends a request to relay for the Cloudflare pageviews html and renders it.

blogtutor commented 4 months ago

If the site isn't on our Cloudflare Enterprise setup, we should display a message in the box. Easy to tell, we just need to show this if the Firewall setting is on "Sucuri" or "None/Other":

It looks like your site isn't currently on our Cloudflare Enterprise service. Please contact us to discuss how this feature can help your site's performance and security.

blogtutor commented 4 months ago

@1337rout I installed on eatingrules.com, which is on Cloudflare Enterprise (DNS 3). It's not showing anything in the box. It's pointed to the production server.

image

1337rout commented 4 months ago

@blogtutor relay doesn’t have the API available yet. There’s still an open PR for it. https://github.com/blogtutor/np-dashboard/pull/483

I’ll bug Jon to get it reviewed for me so it’ll be easier to test this one.

blogtutor commented 4 months ago

Oh! Well that would explain it. 🤦‍♂️

jchristopher commented 4 months ago

Approved with one suggestion

1337rout commented 4 months ago

@blogtutor I have removed the disclaimer text in favor of letting Relay send it along with the graph. I'll let you know when the relay change is up on at least relaydev.nerdpress!

1337rout commented 4 months ago

&& now it's on relaydev!

blogtutor commented 3 months ago

Hey @1337rout - could you please change the text in the widget header to just "NerdPress Stats"? And we'd like to change the icon to be teal on dark blue -- using a circle not a rounded square. Let me know if you need a hand with converting the image format. Thanks!

blogtutor commented 3 months ago

I just noticed that we're not appending a versioned query string to this request:

https://eatingrules.com/wp-content/plugins/blog-tutor-support-feature-display-cloudflare-graph-from-relay/includes/css/html-admin-menu.css

Which means that if we don't clear the Cloudflare cache after updating the support plugin, the widget ain't gonna look so good. Can you please add a query string with the plugin version number? Pretty sure we already have that as a constant elsewhere, so don't reinvent any wheels.

1337rout commented 3 months ago

I just noticed that we're not appending a versioned query string to this request:

https://eatingrules.com/wp-content/plugins/blog-tutor-support-feature-display-cloudflare-graph-from-relay/includes/css/html-admin-menu.css

Which means that if we don't clear the Cloudflare cache after updating the support plugin, the widget ain't gonna look so good. Can you please add a query string with the plugin version number? Pretty sure we already have that as a constant elsewhere, so don't reinvent any wheels.

@blogtutor ~So we don't have that variable, or at least not using it when enqueuing js.~ We aren't properly enqueuing the styles. Are you okay with a hard-coded value now and a new issue to fix all of our enqueues and convert all uses of stylesheets to be properly enqueued?

Ignore me I found it, we're using it when registering the scripts, not enqueuing them.

blogtutor commented 3 months ago

Just put latest version of the branch on Eating Rules. Looking good!

✅ N icon looks good. (I agree it's a half-pixel off to the left but I'll [try to] accept that as wabi-sabi) ✅ Help Scout beacon opens, even if it hadn't been initialized already. ✅ Admin CSS now has a version number.

image

blogtutor commented 3 months ago

✅ And the stats widget now correctly does not show for contributor and editor users (those are the only two I tested - looks good.)

1337rout commented 3 months ago

@blogtutor did you check that changing the firewall setting sends a snapshot so you don't have to manually do this?

blogtutor commented 3 months ago

Ah! Thanks for reminding me.

I just tested on Eating Rules, which is sending to relaydev right now. It DID correctly try to send snapshots back on setting save, and also appears to be doing it only when I make a change to the settings. (This is desired/expected behavior, right?)

BUT both requests also timed out. Seems unrelated but maybe something we should look into elsewhere?

cURL error 28: Operation timed out after 5000 milliseconds with 0 out of -1 bytes received

1337rout commented 3 months ago

Ah! Thanks for reminding me.

I just tested on Eating Rules, which is sending to relaydev right now. It DID correctly try to send snapshots back on setting save, and also appears to be doing it only when I make a change to the settings. (This is desired/expected behavior, right?)

BUT both requests also timed out. Seems unrelated but maybe something we should look into elsewhere?

cURL error 28: Operation timed out after 5000 milliseconds with 0 out of -1 bytes received

Weird that I am not getting this on my local. This is worrisome as I don't think it actually sent. I'll look into it further.

blogtutor commented 3 months ago

It did send. I'm using Log HTTP requests.

image

1337rout commented 3 months ago

I see the issue. It's with relay. A response is never sent back to the requesting server (client plugin). I can work on getting this updated to send a response. I'll make an issue to get this fixed.

blogtutor commented 3 months ago

Ah, so it's saving the snapshot but then the client's not getting back a "Success" message. Got it.

1337rout commented 3 months ago

@blogtutor I solved this in https://github.com/blogtutor/np-dashboard/pull/526 and have put it on relaydev. Can you check again, please?

blogtutor commented 3 months ago

Still getting a timeout after 5 seconds.

image

1337rout commented 3 months ago

@blogtutor I just increased the timeout on the request to 20 seconds just to be safe, I guess my local is just too fast for this to happen. :shrug: at least the curl 28 isn't showing in my debug log.

blogtutor commented 3 months ago

Ok so I remember now that we ran into some issues with this kind of stuff a long time ago, and that's why we're not waiting for a response.

This should probably be moved to a separate issue and future PR -- because it's really a bigger thing to look into. (Perhaps this is also related to some sites not successfully sending snapshots back because of something slow at Relay, not because of cron issue son the client end).

Maybe for now we should revert these recent changes and have a convo with Jon, as he'll probably remember details better than I do.