{"id":398303,"date":"2024-06-29T13:59:46","date_gmt":"2024-06-29T13:59:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=398303"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T13:59:46","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=398303","title":{"rendered":"<span>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f Google Analytics \u0441 Telegram<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442 \u043a\u0430\u043a \u0432\u0430\u0436\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430. \u041e\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u043e \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0444\u0438\u0447\u0438 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0430\u0439\u0442\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u043f\u0440\u043e\u0442\u044b\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u044d\u0432\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u0443\u0442\u0438\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u044f \u043d\u0430\u0431\u0440\u043e\u0441\u0430\u043b python \u0441\u0435\u0440\u0432\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438 \u0437\u0430\u0431\u0438\u0440\u0430\u043b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0431\u044b \u0432 \u0447\u0430\u0442. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043e\u043f\u0438\u0448\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0435\u0439 \u0441 \u0432\u0430\u0448\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0435\u0441\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f id \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u043d\u0430\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>Custom definition<\/strong> \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0440\u043e\u043b\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0447\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/support.google.com\/analytics\/answer\/10075209?hl=en\" rel=\"noopener noreferrer nofollow\">Custom dimensions and metrics<\/a>.<\/p>\n<p>\u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0434\u0435\u043c \u0432 \u043f\u0430\u043d\u0435\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 property.<\/p>\n<\/li>\n<li>\n<p>\u0416\u043c\u0435\u043c \u043d\u0430 <strong>Custom definitions.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c definition \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0442\u043e\u0440\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <code>credentials.json<\/code> \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Cloud Platform \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0435 \u0435\u0433\u043e \u043d\u0435\u0442 \u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c Google Analytics Data API v1 \u0432 \u043d\u0435\u043c. \u0427\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/developers.google.com\/analytics\/devguides\/reporting\/data\/v1\/quickstart-client-libraries\" rel=\"noopener noreferrer nofollow\">Google Analytics Data API (GA4)<\/a>.<\/p>\n<p>\u041a\u0430\u043a \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0431\u0440\u0430\u0442\u044c email \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e json-\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0435. Viewer \u043f\u0440\u0430\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>\u0421 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043e\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0449\u0435. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0435 \u043d\u0435\u0442 \u0431\u043e\u0442\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c, \u0442\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0443 <a href=\"https:\/\/telegram.me\/BotFather\" rel=\"noopener noreferrer nofollow\">@BotFather<\/a> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0430\u0441\u0442 \u0442\u043e\u043a\u0435\u043d \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c id \u0447\u0430\u0442\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u0435\u0449\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u0442 \u0432 \u0447\u0430\u0442 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u043c\u0443 \u0447\u0442\u043e \u043b\u0438\u0431\u043e, \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0430\u043f\u0434\u0435\u0439\u0442\u044b \u0443 API \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c<\/p>\n<pre><code class=\"bash\">curl https:\/\/api.telegram.org\/&lt;\u0432\u0430\u0448_\u0442\u043e\u043a\u0435\u043d>\/getUpdates<\/code><\/pre>\n<h2>\u0421\u0435\u0440\u0432\u0435\u0440<\/h2>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 python \u0438 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>google-analytics-data<\/p>\n<\/li>\n<li>\n<p>python-telegram-bot<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">pip install google-analytics-data python-telegram-bot<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430 \u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c REST-\u043e\u043c, \u043d\u043e \u0432 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043f\u043e\u0441\u0435\u043c\u0443 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u0442 \u043a\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <code>data<\/code> \u043a\u0443\u0434\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043d\u0430\u0448 <code>credentials.json<\/code>  \u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h3>Google \u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435<\/p>\n<pre><code class=\"python\">from google.analytics.data_v1beta import BetaAnalyticsDataClient from google.analytics.data_v1beta.types import (     DateRange,     Dimension,     Metric,     RunReportRequest, )  def sample_run_report(property_id=\"YOUR-GA4-PROPERTY-ID\"):     \"\"\"Runs a simple report on a Google Analytics 4 property.\"\"\"     client = BetaAnalyticsDataClient()      request = RunReportRequest(         property=f\"properties\/{property_id}\",         dimensions=[Dimension(name=\"city\")],         metrics=[Metric(name=\"activeUsers\")],         date_ranges=[DateRange(start_date=\"2020-03-31\", end_date=\"today\")],     )     response = client.run_report(request)      print(\"Report result:\")     for row in response.rows:         print(row.dimension_values[0].value, row.metric_values[0].value)<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0435 dimension. \u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043d\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443<\/p>\n<pre><code class=\"python\">dimensions=[Dimension(name=\"customEvent:&lt;\u0432\u044b\u0448_\u0441ustom_definition>\")],<\/code><\/pre>\n<p>\u0414\u0438\u0430\u043f\u043e\u0437\u043e\u043d \u0434\u0430\u0442 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u0439. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0437\u0430 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0435 7 \u0434\u043d\u0435\u0439<\/p>\n<pre><code class=\"python\">date_format = \"%Y-%m-%d\" week_ago = (date.today() - timedelta(days = 7)).strftime(date_format)<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0441. \u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u044f \u043d\u0435 \u0442\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0438\u043c\u0435\u044e \u0434\u0435\u043b\u043e \u0441 python \u0438 \u043d\u0435 \u0437\u043d\u0430\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a, \u043d\u043e \u0447\u0442\u043e \u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 property_id \u0438 \u043d\u0435 \u0445\u043e\u0447\u0443 \u0442\u0430\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u0442\u043e\u043b\u043a\u0430\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">class Analytics:     def __init__(self, config):         self.property_id = config['property_id']      def run_report(self, event_name, limit):         \"\"\"Runs a simple report on a Google Analytics 4 property.\"\"\"         client = BetaAnalyticsDataClient()         date_format = \"%Y-%m-%d\"         week_ago = (date.today() - timedelta(days = 7)).strftime(date_format)                  request = RunReportRequest(             property=f\"properties\/{self.property_id}\",             dimensions=[Dimension(name=\"customEvent:\" + event_name)],             metrics=[Metric(name=\"activeUsers\")],             date_ranges=[DateRange(start_date=week_ago, end_date=\"today\")],              limit=limit,         )         response = client.run_report(request)         result = []         for row in response.rows:             demension = row.dimension_values[0].value             value = row.metric_values[0].value             if demension == \"(not set)\":                  continue             result.append((demension, value))         return result<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e) \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043e. \u0418\u0445 \u0431\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438 \u043e\u043d\u043e \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.<\/p>\n<h3>Telegram<\/h3>\n<p>\u0423 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c id \u0447\u0430\u0442\u0430, \u0442\u043e\u043a\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u0442\u0430 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0445 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u0421\u043f\u0435\u0440\u0432\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">def format_report(title, data):      message = f'*{title}:*\\n'     index = 1     for row in data:         message += f'{str(index)}. {row[0]} - _{row[1]}_\\n'         index += 1     return message<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430<\/p>\n<pre><code class=\"python\">from telegram.constants import ParseMode from telegram.ext import ApplicationBuilder, Defaults  application = (     ApplicationBuilder()     .token(\"&lt;\u0432\u0430\u0448_\u0442\u043e\u043a\u0435\u043d>\")     .defaults(Defaults(parse_mode=ParseMode.MARKDOWN))     .build() )  await application.bot.send_message(     chat_id=\"&lt;id_\u0447\u0430\u0442\u0430>\",     text=format_report(\"&lt;\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a>\", report) ) <\/code><\/pre>\n<p>\u0418 \u0442\u0430\u043a \u0436\u0435 \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0441<\/p>\n<pre><code class=\"python\">import logging from telegram.constants import ParseMode from telegram.ext import ApplicationBuilder, Defaults  logging.basicConfig(     format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',     level=logging.INFO )  class TelegramBot:     def __init__(self, config):         self.chat_id = config['chat_id']         self.application = (             ApplicationBuilder()             .token(config['token'])             .defaults(Defaults(parse_mode=ParseMode.MARKDOWN))             .build()         )      def format_report(self, title, data):          message = f'*{title}:*\\n'         index = 1         for row in data:             message += f'{str(index)}. {row[0]} - _{row[1]}_\\n'             index += 1         return message      async def send_report(self, report, title):         message = self.format_report(title, report)         await self.application.bot.send_message(             chat_id=self.chat_id,             text=message         ) <\/code><\/pre>\n<h3>HTTP \u0421\u0435\u0440\u0432\u0435\u0440<\/h3>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440. \u0415\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0434\u0435\u0440\u0433\u0430\u0442\u044c cron-\u043e\u043c \u0447\u0435\u0440\u0435\u0437 curl \u0434\u0430 \u0438 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u0441\u0442\u0430\u0442\u0443\u0441, \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u0438\u0445 \u0442\u043e \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0441\u0431\u043e\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u043d\u043e\u043c\u0443 \u0441\u043b\u0443\u0447\u0430\u044e.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 HTTP \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d <strong>AIOHTTP<\/strong><\/p>\n<pre><code class=\"bash\">pip install aiohttp<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0438\u043c \u0437\u0432\u0435\u043d\u043e\u043c \u043e\u0431\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u0431\u043e\u0442\u0430, \u043f\u043e\u0441\u0435\u043c\u0443 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u0441\u0435\u0431\u0435. \u0410 \u0442\u0430\u043a \u0436\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 \u0434\u043b\u044f \u0432\u044b\u0434\u0430\u0447\u0438.<\/p>\n<pre><code class=\"python\">class AnalyticsProperty:     def __init__(self, config):         self.title = config['title']         self.dimension = config['dimension']         self.limit = config['limit']         self.endpoint = config['endpoint']  class Server:      def __init__(self, config, telegram: TelegramBot, analytics: Analytics):         self.telegram = telegram         self.analytics = analytics         self.host = config['host']         self.port = config['port']         self.app = web.Application()         self.app.add_routes([             web.get('\/analytics\/{property}', self.handle_analytics)         ])         self.properties = {}          def add_routes(self, properties):         for property in properties:             item = AnalyticsProperty(property)             self.properties[item.endpoint] = item              async def handle_analytics(self, request):         property_id = request.match_info['property']         if property_id in self.properties:             property = self.properties[property_id]             report = self.analytics.run_report(property.dimension, property.limit)             await self.telegram.send_report(report, title=property.title)             return web.Response(text='ok')         else:             raise web.HTTPNotFound()              def run(self):         web.run_app(self.app, host=self.host, port=self.port)<\/code><\/pre>\n<p>\u041f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u0437\u0436\u0435. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c, \u044d\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0437\u0430\u0431\u043e\u0440 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u0438\u0445 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439.<\/p>\n<ol>\n<li>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 Server \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0431\u043e\u0442\u0430 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u044b \u043f\u0443\u0442\u0438 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0431\u0443\u0434\u0435\u0442 \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435<\/p>\n<pre><code class=\"python\">bot = TelegramBot(config['telegram']) analytics = Analytics(config['analytics']) server = Server(config['server'], bot, analytics) server.add_routes(config['properties']) server.run()<\/code><\/pre>\n<h2>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u044f \u0432\u044b\u0431\u0440\u0430\u043b yaml-\u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"bash\">pip install pyyaml<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 4 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>telegram &#8212; \u0442\u043e\u043a\u0435\u043d \u0438 id \u0447\u0430\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>analytics &#8212; id \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>server &#8212; host \u0438 post \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>properties &#8212; \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>title &#8212; \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>dimension &#8212; \u043d\u0430\u0448 custom difinition;<\/p>\n<\/li>\n<li>\n<p>limit &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>endpoint &#8212; \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0443\u0442\u0438 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 <code>config.yaml<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 <code>data<\/code>:<\/p>\n<pre><code class=\"yaml\">server:   host: 0.0.0.0 # Server host   port: 8080 # Server port analytics:   property_id: &lt;your_google_analytics_view_id> telegram:   token: &lt;your_telegram_bot_token>   chat_id: &lt;your_telegram_chat_id> properties:   -      title: 'Popular categories'     dimension: 'category_name'     limit: 15     endpoint: 'top_categories'<\/code><\/pre>\n<h2>Docker<\/h2>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u043e\u043a\u0435\u0440\u0435 \u0438 \u0434\u0435\u0440\u0433\u0430\u0442\u044c \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 endpoint \u043a\u0440\u043e\u043d\u043e\u043c \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0432\u043f\u043e\u043b\u043d\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 Dockerfile:<\/p>\n<pre><code class=\"yaml\">FROM python:3.9-alpine  WORKDIR \/app COPY requirements.txt . RUN pip install -r requirements.txt COPY [\"app.py\", \"analytics.py\", \"server.py\", \"telegram_bot.py\", \".\/\"] ENV GOOGLE_APPLICATION_CREDENTIALS=\"\/app\/data\/credentials.json\"  EXPOSE 8080 ENTRYPOINT [\"python\", \"app.py\"]<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u043f\u043a\u0438 data \u0432 \/app\/data \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a Google \u0430\u043d\u0430\u043b\u0438\u0442\u043a\u0435 \u0438 \u043d\u0430\u0448 \u043a\u043e\u043d\u0444\u0438\u0433.<\/p>\n<p>\u0425\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u0430\u043a\u043e\u0439 \u043b\u0438\u0431\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0443 \u0438\u043b\u0438 \u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c cron \u043d\u0435 \u0441\u043d\u0430\u0440\u0443\u0436\u0438, \u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438 \u043d\u0435 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u0442\u044b \u043d\u0430\u0440\u0443\u0436\u0443.<\/p>\n<h2>Cron<\/h2>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0432 \u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043f\u0440\u043e \u0437\u0430\u043f\u0443\u0441\u043a. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 cron \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435<\/p>\n<pre><code class=\"bash\">crontab -e<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438 \u0432 00:00 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f GET \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code class=\"yaml\">0 0 * * * curl localhost:8060\/analytics\/top_categories >\/dev\/null 2>&amp;1<\/code><\/pre>\n<p>\u041f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/crontab.guru\/\" rel=\"noopener noreferrer nofollow\">https:\/\/crontab.guru\/<\/a> \u0438 \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u043b\u044f \u0441\u0435\u0431\u044f<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/ftp27\/google-analytics-telegram\" rel=\"noopener noreferrer nofollow\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/u><\/a>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0441\u0435\u0431\u044f \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043e\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u0432\u044b\u0434\u0430\u0447\u0438 \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041d\u043e \u043a\u0430\u043a \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0431\u044f \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/716538\/\"> https:\/\/habr.com\/ru\/articles\/716538\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442 \u043a\u0430\u043a \u0432\u0430\u0436\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430. \u041e\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u043e \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0444\u0438\u0447\u0438 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0430\u0439\u0442\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u043f\u0440\u043e\u0442\u044b\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u044d\u0432\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u0443\u0442\u0438\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u044f \u043d\u0430\u0431\u0440\u043e\u0441\u0430\u043b python \u0441\u0435\u0440\u0432\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438 \u0437\u0430\u0431\u0438\u0440\u0430\u043b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0431\u044b \u0432 \u0447\u0430\u0442. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043e\u043f\u0438\u0448\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0435\u0439 \u0441 \u0432\u0430\u0448\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0435\u0441\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f id \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u041f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h2>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u043d\u0430\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>Custom definition<\/strong> \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0440\u043e\u043b\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0438 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0447\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c <a href=\"https:\/\/support.google.com\/analytics\/answer\/10075209?hl=en\" rel=\"noopener noreferrer nofollow\">Custom dimensions and metrics<\/a>.<\/p>\n<p>\u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0434\u0435\u043c \u0432 \u043f\u0430\u043d\u0435\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 property.<\/p>\n<\/li>\n<li>\n<p>\u0416\u043c\u0435\u043c \u043d\u0430 <strong>Custom definitions.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c definition \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0442\u043e\u0440\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <code>credentials.json<\/code> \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Cloud Platform \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0435 \u0435\u0433\u043e \u043d\u0435\u0442 \u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c Google Analytics Data API v1 \u0432 \u043d\u0435\u043c. \u0427\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <a href=\"https:\/\/developers.google.com\/analytics\/devguides\/reporting\/data\/v1\/quickstart-client-libraries\" rel=\"noopener noreferrer nofollow\">Google Analytics Data API (GA4)<\/a>.<\/p>\n<p>\u041a\u0430\u043a \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0431\u0440\u0430\u0442\u044c email \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e json-\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 \u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0435. Viewer \u043f\u0440\u0430\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>\u0421 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043e\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0449\u0435. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0435 \u043d\u0435\u0442 \u0431\u043e\u0442\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c, \u0442\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0443 <a href=\"https:\/\/telegram.me\/BotFather\" rel=\"noopener noreferrer nofollow\">@BotFather<\/a> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0430\u0441\u0442 \u0442\u043e\u043a\u0435\u043d \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c id \u0447\u0430\u0442\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u0435\u0449\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u0442 \u0432 \u0447\u0430\u0442 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u043c\u0443 \u0447\u0442\u043e \u043b\u0438\u0431\u043e, \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0430\u043f\u0434\u0435\u0439\u0442\u044b \u0443 API \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c<\/p>\n<pre><code class=\"bash\">curl https:\/\/api.telegram.org\/&lt;\u0432\u0430\u0448_\u0442\u043e\u043a\u0435\u043d>\/getUpdates<\/code><\/pre>\n<h2>\u0421\u0435\u0440\u0432\u0435\u0440<\/h2>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 python \u0438 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>google-analytics-data<\/p>\n<\/li>\n<li>\n<p>python-telegram-bot<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">pip install google-analytics-data python-telegram-bot<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0430 \u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c REST-\u043e\u043c, \u043d\u043e \u0432 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043f\u043e\u0441\u0435\u043c\u0443 \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u0442 \u043a\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <code>data<\/code> \u043a\u0443\u0434\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043d\u0430\u0448 <code>credentials.json<\/code>  \u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h3>Google \u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435<\/p>\n<pre><code class=\"python\">from google.analytics.data_v1beta import BetaAnalyticsDataClient from google.analytics.data_v1beta.types import (     DateRange,     Dimension,     Metric,     RunReportRequest, )  def sample_run_report(property_id=\"YOUR-GA4-PROPERTY-ID\"):     \"\"\"Runs a simple report on a Google Analytics 4 property.\"\"\"     client = BetaAnalyticsDataClient()      request = RunReportRequest(         property=f\"properties\/{property_id}\",         dimensions=[Dimension(name=\"city\")],         metrics=[Metric(name=\"activeUsers\")],         date_ranges=[DateRange(start_date=\"2020-03-31\", end_date=\"today\")],     )     response = client.run_report(request)      print(\"Report result:\")     for row in response.rows:         print(row.dimension_values[0].value, row.metric_values[0].value)<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0435 dimension. \u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043d\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443<\/p>\n<pre><code class=\"python\">dimensions=[Dimension(name=\"customEvent:&lt;\u0432\u044b\u0448_\u0441ustom_definition>\")],<\/code><\/pre>\n<p>\u0414\u0438\u0430\u043f\u043e\u0437\u043e\u043d \u0434\u0430\u0442 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u0439. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0437\u0430 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0435 7 \u0434\u043d\u0435\u0439<\/p>\n<pre><code class=\"python\">date_format = \"%Y-%m-%d\" week_ago = (date.today() - timedelta(days = 7)).strftime(date_format)<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0441. \u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u044f \u043d\u0435 \u0442\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0438\u043c\u0435\u044e \u0434\u0435\u043b\u043e \u0441 python \u0438 \u043d\u0435 \u0437\u043d\u0430\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a, \u043d\u043e \u0447\u0442\u043e \u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 property_id \u0438 \u043d\u0435 \u0445\u043e\u0447\u0443 \u0442\u0430\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u0442\u043e\u043b\u043a\u0430\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">class Analytics:     def __init__(self, config):         self.property_id = config['property_id']      def run_report(self, event_name, limit):         \"\"\"Runs a simple report on a Google Analytics 4 property.\"\"\"         client = BetaAnalyticsDataClient()         date_format = \"%Y-%m-%d\"         week_ago = (date.today() - timedelta(days = 7)).strftime(date_format)                  request = RunReportRequest(             property=f\"properties\/{self.property_id}\",             dimensions=[Dimension(name=\"customEvent:\" + event_name)],             metrics=[Metric(name=\"activeUsers\")],             date_ranges=[DateRange(start_date=week_ago, end_date=\"today\")],              limit=limit,         )         response = client.run_report(request)         result = []         for row in response.rows:             demension = row.dimension_values[0].value             value = row.metric_values[0].value             if demension == \"(not set)\":                  continue             result.append((demension, value))         return result<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e) \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043e. \u0418\u0445 \u0431\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438 \u043e\u043d\u043e \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e.<\/p>\n<h3>Telegram<\/h3>\n<p>\u0423 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c id \u0447\u0430\u0442\u0430, \u0442\u043e\u043a\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u0442\u0430 \u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0445 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c. \u0421\u043f\u0435\u0440\u0432\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">def format_report(title, data):      message = f'*{title}:*\\n'     index = 1     for row in data:         message += f'{str(index)}. {row[0]} - _{row[1]}_\\n'         index += 1     return message<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430<\/p>\n<pre><code class=\"python\">from telegram.constants import ParseMode from telegram.ext import ApplicationBuilder, Defaults  application = (     ApplicationBuilder()     .token(\"&lt;\u0432\u0430\u0448_\u0442\u043e\u043a\u0435\u043d>\")     .defaults(Defaults(parse_mode=ParseMode.MARKDOWN))     .build() )  await application.bot.send_message(     chat_id=\"&lt;id_\u0447\u0430\u0442\u0430>\",     text=format_report(\"&lt;\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a>\", report) ) <\/code><\/pre>\n<p>\u0418 \u0442\u0430\u043a \u0436\u0435 \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0441<\/p>\n<pre><code class=\"python\">import logging from telegram.constants import ParseMode from telegram.ext import ApplicationBuilder, Defaults  logging.basicConfig(     format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',     level=logging.INFO )  class TelegramBot:     def __init__(self, config):         self.chat_id = config['chat_id']         self.application = (             ApplicationBuilder()             .token(config['token'])             .defaults(Defaults(parse_mode=ParseMode.MARKDOWN))             .build()         )      def format_report(self, title, data):          message = f'*{title}:*\\n'         index = 1         for row in data:             message += f'{str(index)}. {row[0]} - _{row[1]}_\\n'             index += 1         return message      async def send_report(self, report, title):         message = self.format_report(title, report)         await self.application.bot.send_message(             chat_id=self.chat_id,             text=message         ) <\/code><\/pre>\n<h3>HTTP \u0421\u0435\u0440\u0432\u0435\u0440<\/h3>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP \u0441\u0435\u0440\u0432\u0435\u0440. \u0415\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0434\u0435\u0440\u0433\u0430\u0442\u044c cron-\u043e\u043c \u0447\u0435\u0440\u0435\u0437 curl \u0434\u0430 \u0438 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u043e \u0441\u0442\u0430\u0442\u0443\u0441, \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u0438\u0445 \u0442\u043e \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0441\u0431\u043e\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u043d\u043e\u043c\u0443 \u0441\u043b\u0443\u0447\u0430\u044e.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 HTTP \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d <strong>AIOHTTP<\/strong><\/p>\n<pre><code class=\"bash\">pip install aiohttp<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0438\u043c \u0437\u0432\u0435\u043d\u043e\u043c \u043e\u0431\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u0431\u043e\u0442\u0430, \u043f\u043e\u0441\u0435\u043c\u0443 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0431\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u0441\u0435\u0431\u0435. \u0410 \u0442\u0430\u043a \u0436\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438 \u0434\u043b\u044f \u0432\u044b\u0434\u0430\u0447\u0438.<\/p>\n<pre><code class=\"python\">class AnalyticsProperty:     def __init__(self, config):         self.title = config['title']         self.dimension = config['dimension']         self.limit = config['limit']         self.endpoint = config['endpoint']  class Server:      def __init__(self, config, telegram: TelegramBot, analytics: Analytics):         self.telegram = telegram         self.analytics = analytics         self.host = config['host']         self.port = config['port']         self.app = web.Application()         self.app.add_routes([             web.get('\/analytics\/{property}', self.handle_analytics)         ])         self.properties = {}          def add_routes(self, properties):         for property in properties:             item = AnalyticsProperty(property)             self.properties[item.endpoint] = item              async def handle_analytics(self, request):         property_id = request.match_info['property']         if property_id in self.properties:             property = self.properties[property_id]             report = self.analytics.run_report(property.dimension, property.limit)             await self.telegram.send_report(report, title=property.title)             return web.Response(text='ok')         else:             raise web.HTTPNotFound()              def run(self):         web.run_app(self.app, host=self.host, port=self.port)<\/code><\/pre>\n<p>\u041f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u0437\u0436\u0435. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c, \u044d\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0437\u0430\u0431\u043e\u0440 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u0438\u0445 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439.<\/p>\n<ol>\n<li>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 Server \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0431\u043e\u0442\u0430 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u044b \u043f\u0443\u0442\u0438 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0431\u0443\u0434\u0435\u0442 \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435<\/p>\n<pre><code class=\"python\">bot = TelegramBot(config['telegram']) analytics = Analytics(config['analytics']) server = Server(config['server'], bot, analytics) server.add_routes(config['properties']) server.run()<\/code><\/pre>\n<h2>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u044f \u0432\u044b\u0431\u0440\u0430\u043b yaml-\u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"bash\">pip install pyyaml<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 4 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>telegram &#8212; \u0442\u043e\u043a\u0435\u043d \u0438 id \u0447\u0430\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>analytics &#8212; id \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>server &#8212; host \u0438 post \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>properties &#8212; \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p>title &#8212; \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>dimension &#8212;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-398303","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/398303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=398303"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/398303\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=398303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=398303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=398303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}