This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Report Summary via E-Mail #920
Comments
The problem is that there is no way to do automations with the app. It would have to be done on the server. |
so there needs to be some cron-like connection? This could either be done serverside by letting actual system cron trigger some action periodically, or |
I didn't see this problem when starting this thread, so action-umami-report may be an answer (or improved to fit your need as contribution are welcome). |
@boly38 nice! Right now I'm using pyppeteer to take a screenshot of the page and email it. Do you have a way to change the default time from 24hrs to the last 7 days? |
@christopherpickering it's planned (boly38/action-umami-report#11), but not implemented right now speaking. your feedback with pyppeteer is intersting ! 👍 |
Yeah, sorry to hijack this thread, here's a script I use. Help yourself :) It snapshots a few places and sends an email so I can verify medias are online w/out need to visit each page. It is also just doing 24hrs. Wish a url param could set the default time period ;) Maybe I'll put a feature request for it. import asyncio
from pyppeteer import launch
import email
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
import os
from dotenv import load_dotenv
from PIL import Image
from pathlib import Path
load_dotenv()
async def screenshot(url: str,size:dict,filename:str,timeout:int) -> None:
print(url)
browser = await launch()
page = await browser.newPage()
await page.setViewport({'width': size['width'],'height':size['height']})
await page.setJavaScriptEnabled(enabled=True)
await page.goto(url, {'timeout': 10000})
await page.waitFor(selectorOrFunctionOrTimeout=timeout)
await page.screenshot({'path': filename})
await browser.close()
sites = [
#[facebook],
#[yt,..etc..]
['https://analytics.example.org/share/mz8VMkyv/example', {"height":2400,"width":1200}, "analytics.png",7000]
]
for site in sites:
asyncio.get_event_loop().run_until_complete(screenshot(*site))
for png in Path(__file__).parent.glob('*.png'):
picture = Image.open(png)
picture = picture.resize((int(picture.size[0] * .9), int(picture.size[1] * .9)), Image.Resampling.LANCZOS)
picture.save(png,
optimize = True,
quality = 55)
api_key = os.environ.get('MAILJET_API_KEY',"")
api_secret = os.environ.get('MAILJET_API_SECRET',"")
SMTP_SENDER_NAME = 'me'
SMTP_SENDER_EMAIL = 'me@example.com'
SMTP_SERVER = 'in-v3.mailjet.com'
SMTP_PORT = 25
subject = "Daily Snapshot"
mailto = ['em@example.com']
html = """\
<html>
<head></head>
<body>
<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0" style='text-align:center'>
<tr>
<td align='center' style='text-align:center'>
<h1 style="font-size:25px;">Daily Snapshot</h1>
<p>
Current snapshot of the medias.
</p>
<h4 style="font-size:15px;">Facebook</h4>
<div style="margin: 0 auto; text-align: center;">
<img src="cid:facebook" alt="Logo" style="width:70%;" align="center"><br>
</div>
<h4 style="font-size:15px;">Youtube</h4>
<div style="margin: 0 auto; text-align: center;">
<img src="cid:youtube" alt="Logo" style="width:70%;" align="center"><br>
</div>
<h4 style="font-size:15px;">Gettr</h4>
<div style="margin: 0 auto; text-align: center;">
<img src="cid:gettr" alt="Logo" style="width:70%;" align="center"><br>
</div>
<h4 style="font-size:15px;">Rumble</h4>
<div style="margin: 0 auto; text-align: center;">
<img src="cid:rumble" alt="Logo" style="width:70%;" align="center"><br>
</div>
<h4 style="font-size:15px;">Website Analytics (24hrs)</h4>
<div style="margin: 0 auto; text-align: center;">
<img src="cid:analytics" alt="Logo" style="width:70%;" align="center"><br>
</div>
</td>
</tr>
</table>
</body>
</html>
"""
msg = MIMEMultipart()
msg["From"] = email.utils.formataddr( # type: ignore[attr-defined]
(
email.header.Header(SMTP_SENDER_NAME, "utf-8").encode(
"utf-8"
),
SMTP_SENDER_EMAIL,
)
)
# subject only needed for html mail
msg["Subject"] = subject
msg["To"] = ",".join(mailto)
msg.attach(MIMEText(html, "html"))
with open('facebook.png', 'rb') as fp:
facebookImage = MIMEImage(fp.read())
facebookImage.add_header('Content-ID', '<facebook>')
msg.attach(facebookImage)
with open('youtube.png', 'rb') as fp:
youtubeImage = MIMEImage(fp.read())
youtubeImage.add_header('Content-ID', '<youtube>')
msg.attach(youtubeImage)
with open('rumble.png', 'rb') as fp:
rumbleImage = MIMEImage(fp.read())
rumbleImage.add_header('Content-ID', '<rumble>')
msg.attach(rumbleImage)
with open('analytics.png', 'rb') as fp:
analyticsImage = MIMEImage(fp.read())
analyticsImage.add_header('Content-ID', '<analytics>')
msg.attach(analyticsImage)
with open('gettr.png', 'rb') as fp:
gettrImage = MIMEImage(fp.read())
gettrImage.add_header('Content-ID', '<gettr>')
msg.attach(gettrImage)
mail_server = smtplib.SMTP(
SMTP_SERVER, SMTP_PORT, timeout=180
)
mail_server.ehlo()
mail_server.login(api_key,api_secret)
mail_server.sendmail(
SMTP_SENDER_EMAIL, mailto, msg.as_string()
)
mail_server.quit() |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
would it be possible to implement summary reports periodically via E-Mail? Additionally, spike reports could also be beneficial.
I thought about writing a tiny service for that, that interacts with the API, but it would generally make much more sense to have this indirectly within umami.
The text was updated successfully, but these errors were encountered: