Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add Plausible/Analytics to MVP to track page view/stats #287

Closed
6 tasks done
nelsonic opened this issue Feb 6, 2023 · 35 comments · Fixed by #290
Closed
6 tasks done

Feat: Add Plausible/Analytics to MVP to track page view/stats #287

nelsonic opened this issue Feb 6, 2023 · 35 comments · Fixed by #290
Assignees
Labels
enhancement New feature or enhancement of existing functionality good first issue Good for newcomers help wanted If you can help make progress with this issue, please comment! priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Feb 6, 2023

Story

As a team of people building an App
we want to track the stats of who is viewing the App and trying it out
so that we know if our efforts are producing fruits.

We are currently exploring using Plausible.io/analytics for tracking our stats, see: dwyl/technology-stack#127

Todo

  • Add mvp.fly.dev to plausible

    Note: if that doesn't work, we may need to create a subdomain mvp.dwyl.com and redirect it. 💭

  • Add the JS snippet to the root template for the mvp
  • Create PR
  • Assign PR for quick review
  • Deploy the JS snippet
  • Track analytics in Plausible dashboard.

Going to work on this now with @seaneady on the call. 👌

@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality help wanted If you can help make progress with this issue, please comment! good first issue Good for newcomers technical A technical issue that requires understanding of the code, infrastructure or dependencies priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1h Time Estimate 1 Hour labels Feb 6, 2023
@nelsonic nelsonic self-assigned this Feb 6, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Direct link: https://plausible.io/mvp.fly.dev

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

PR: #288

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Going to add documentation for this once it's shipped because want to include some relevant screenshots of the dashboard and graphs. 📈

SimonLab added a commit that referenced this issue Feb 6, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Merge CI in progress: https://github.com/dwyl/mvp/actions/runs/4102786893
image

Waiting patiently for this to deploy. ⏳

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Deployed: https://github.com/dwyl/mvp/actions/runs/4102786893
image

Now for the moment of truth! 🤞

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Yep: the JS snippet is there: view-source:https://mvp.fly.dev/

image

Now to check in Plausible.io!

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Waiting ... https://plausible.io/mvp.fly.dev
image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

The snippet is definitely there and we've refreshed the https://mvp.fly.dev page a few times but still "waiting" ... ⏳

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Looks like we're just going to have to be patient on this ... ⏳

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

You should all have access to the stats at: https://plausible.io/mvp.fly.dev

@SimonLab
Copy link
Member

SimonLab commented Feb 6, 2023

Plausible script blocked:
image

image

Reading https://plausible.io/docs/troubleshoot-integration#keep-seeing-a-blinking-green-dot

Does your site use a Content Security Policy (CSP)? If it does, you need to add plausible.io specifically to the allowed domains. More info here.

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

@SimonLab good catch. that's what I was afraid of. Looks like we're going to have to go down the sub-domain route ...
unless this is an issue that other people have faced using Plausible/analytics ... 💭

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

This is what I see: https://mvp.fly.dev/

image

Refused to load the script 'https://plausible.io/js/script.js' 
because it violates the following Content Security Policy directive: 
"script-src 'self' https://cdnjs.cloudflare.com 'unsafe-eval' 'unsafe-inline'". 
Note that 'script-src-elem' was not explicitly set, 
so 'script-src' is used as a fallback.

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Reading: https://web.dev/csp

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Follow-up PR to add the Content Security Policy: #289

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Patiently waiting for deploy: https://github.com/dwyl/mvp/actions/runs/4103255349
image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Deployed. 🚀
Checking now .... 🔍

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

https://mvp.fly.dev/
image

Looks like I made it worse ... 🤦‍♂️ 🤷‍♂️

Refused to load the script 
'https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.10.2/cdn.js' 
because it violates the following Content Security Policy directive: 
"script-src-elem 'self' 'unsafe-inline' 'unsafe-eval' https://plausible.io".

mvp.fly.dev/:1 Refused to load the script 'https://plausible.io/js/script.js' 
because it violates the following Content Security Policy directive: 
"script-src-elem 'self' 'unsafe-inline' 'unsafe-eval' http://cdnjs.cloudflare.com".

mvp.fly.dev/:1 Refused to load the script 'https://plausible.io/js/script.js' 
because it violates the following Content Security Policy directive: 
"script-src 'self' https://cdnjs.cloudflare.com 'unsafe-eval' 'unsafe-inline'". 
Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

Going to look at how to add multiple domains to the same CSP ... 🧑‍💻

@SimonLab
Copy link
Member

SimonLab commented Feb 6, 2023

We can try with only the plausible CSP maybe?

SimonLab added a commit that referenced this issue Feb 6, 2023
Remove csp for cloudflare to attempt to fix #287 (comment)
@SimonLab SimonLab mentioned this issue Feb 6, 2023
@nelsonic nelsonic reopened this Feb 6, 2023
@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Re-opening. Happy to close once this is fully working. 🤞🏼

@SimonLab
Copy link
Member

SimonLab commented Feb 6, 2023

Still failing to load the script:
image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Hmm ... are we at the point where we should open an issue on: https://github.com/plausible/analytics/issues ?

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

https://stackoverflow.com/questions/17789426/whitelist-multiple-domains-in-content-security-policy
Gonna try and list all domains in a single CSP directive. 🧑‍💻

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Next attempt: #291

SimonLab added a commit that referenced this issue Feb 6, 2023
PR: inline both plausible and cloudflare in CSP #287
@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Is this better? https://mvp.fly.dev/
image

Refused to load the script 'https://plausible.io/js/script.js' 
because it violates the following Content Security Policy directive: 
"script-src 'self' https://cdnjs.cloudflare.com 'unsafe-eval' 'unsafe-inline'". 
Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Issue opened: plausible/analytics#2648 🤞

@SimonLab
Copy link
Member

SimonLab commented Feb 6, 2023

Not a lot better unfortunately:
image

I'll try to understand a bit more the CSP syntax

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Nope. this broke the whole site! 🤦‍♂️
image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

@SimonLab thanks for looking into this. 🤞

@SimonLab
Copy link
Member

SimonLab commented Feb 6, 2023

Fixed with #293

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2023

Thanks @SimonLab 👌

@nelsonic
Copy link
Member Author

nelsonic commented Feb 7, 2023

@nelsonic
Copy link
Member Author

nelsonic commented Feb 7, 2023

you should all have access to the dashboard. please confirm. 🙏

Don't know how useful this data is going to be ... 🤷‍♂️
we aren't publicising the MVP for now. 💭

@nelsonic nelsonic closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing functionality good first issue Good for newcomers help wanted If you can help make progress with this issue, please comment! priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished T1h Time Estimate 1 Hour technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants