Socket
Socket
Sign inDemoInstall

@maddevs/mad-radiator

Package Overview
Dependencies
315
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @maddevs/mad-radiator

Script for collect data from analytics and send to slack(webhook) and telegram


Version published
Weekly downloads
37
increased by94.74%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

MAD RADIATOR


Mad radiator is a simple script to collect a part of data from analytics, lighthouse, reddit, quora, glassdoor, and send it in the pretty format as message to slack and/or telegram

How to run

Running as function

To run radiator for your own project you need to do the following steps:

  • Install radiator as a dependency for your project(or for a new project, that's not important)
$ npm install @maddevs/mad-radiator
  • Create a file for running:
$ touch radiator.js

*In the file, you need to import the radiator and pass the configs optionally for each module (see the configuration section):

const { radiator } = require('@maddevs/mad-radiator')

const radiator = new Radiator(baseConfig)
radiator.useAnalytics(analyticsConfig)
radiator.useRedditCountPosts(redditConfig)
radiator.useQuoraService(quora, fireStore)
radiator.useGlassdoorService(glassdoor, fireStore)
radiator.useNewPagesInSite(lighthouseConfig, fireStore)
radiator.usePageAnalytics(pageAnalyticsConfig, fireStore)
radiator.useSlack(slackConfig)
  • Just run the file via nodeJS:
$ node radiator
  • Congrats! Now you just running radiator and it will send messages to your slack/telegram according to provided config
Running as CLI script

Sorry! Running the radiator by CLI script isn't available for now

Technologies stack

Core

It is a list of core technologies that we used to make a business logic

  • node.js
  • axios
  • googleapis
  • node-emoji
  • node-schedule
  • chalk
  • cheerio
  • firebase-admin
  • moment
  • reddit
  • sitemap-stream-parser
Additional

Additional tools for development

  • typescript
  • jest
  • prettier
  • eslint

Configuration

This is a most important part of the documentation. For running radiator you need to create the correct config (* required configs). In this section you can find all available options of the radiator:

Base config *
nametypedescription
authTypestringAuthentication type
analyticsProjectIdstringID of your project (it’s available after project creation)
analyticsPrivateKeyIdstringPrivate key ID
analyticsPrivateKeystringPrivate key
analyticsClientEmailstringClient email
analyticsClientIdstringClient ID
analyticsAuthUrlstringAuth URL
analyticsTokenUristringToken URI
analyticsProviderCertUrlstringProvider cert URL
analyticsClientCertUrlstringClient cert URL
googleapisKeystringGoogle apis key
expiryDatenumberExpiry date
tokenTypestringToken type
idTokenstringID token
websiteUrlstringWebsite URL
rangestringRange
retryAttemptsnumberRetry attempts (Number of radiator restarts)
nodeEnvstringNode env
Analytics config
nametypedescription
totalUsersToEnji{ url: string }After create a business goal in the enji - we
get endpoint urls to send data from radiator
analyticsViewIdstringAnalytics auth type
pagesPathForViewsAnalyticsarrayList with page paths for analyzing user traffic
analyticsConversionsarrayList of analytics conversions
Pages path for views analytics

PagesPathForViewsAnalytics array needed to get statistics of views on these page paths

const analyticsConfig = {
  // ...
  "pagesPathForViewsAnalytics": [
    "/customer-university/",
    "/blog/"
  ],
  // ...
};
Analytics Conversions

Analytics conversion array need to collect data from your analytics goals and calculate it. For example, you want to separate your goals by 3 categories: Leads, Contacts and Careers. You can do it using this configuration parameter.

nametypedescription
namestringThe name of your conversion group
emojiEmojiEmoji to display your group
goalsArrayAn array of your goals ids

Example. If you want to collect data for careers from goals 1,2,3 and for leads from 4,5,11 goals:

const analyticsConfig = {
  //...
  analyticsConversions: [
    {
      name: 'Careers',
      emoji: 'zap',
      goals: [1, 2, 3],
    },
    {
      name: 'Leads',
      emoji: 'briefcase',
      goals: [4, 5, 11],
    },
  ]
  //...
}
Lighthouse Config
nametypedescription
urlTestRegexpstringRegular for excluding some pages
topCountnumberNumber of top pages to display
worstCountnumberNumber of worst pages to display

Example

const lighthouseConfig = {
  "urlTestRegexp": "(\\/blog\\/)|(\\/customer-university\\/)|(\\/ru\\/)[a-zA-Z0-9]{1}",
  "topCount": 3,
  "worstCount": 3
}
Glassdoor config
nametypedescription
glassdoorUrlstringThe URL of your account

Example

// ...
"glassdoor": {
  "glassdoorUrl": "https://www.glassdoor.com/Overview/account-url"
},
// ...
Reddit config

The reddit library is used for easy interaction with the API. Data about the number of posts is requested from Reddit.

nametypedescription
redditClientIdstringReddit client ID from Reddit APP
redditClientSecretstringReddit client secret from Reddit APP
redditUserNamestringReddit username account
redditPasswordstringReddit password account

Example

// ...
"redditConfig": {
  "redditClientId": "clientid",
  "redditClientSecret": "clientsecret",
  "redditUsername": "username",
  "redditPassword": "password"
},
// ...
Firestore auth config
nametypedescription
authTypestring
firestoreProjectIdstring
firestorePrivateKeyIdstring
firestoreClientEmailstring
firestoreClientIdstringFrom Firestore auth JSON file
firestoreAuthUristring
firestoreTokenUristring
firestoreAuthProviderCertUrlstring
firestoreClientCertUrlstring

Example

// ...
"fireStoreAuthConfig": {
  "authType": "service_account",
  "firestoreProjectId": "project-id",
  "firestorePrivateKeyId": "private-key-id",
  "firestoreClientEmail": "client-email",
  "firestoreClientId": "1111111111111111",
  "firestoreAuthUri": "https://accounts.google.com/o/oauth2/auth",
  "firestoreTokenUri": "https://oauth2.googleapis.com/token",
  "firestoreAuthProviderCertUrl": "https://www.googleapis.com/oauth2/v1/certs",
  "firestoreClientCertUrl": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-2dolj%client-cert-url"
},
// ...
Slack Config
nametypedescription
slackWebhookUrlstringslack webhook url
slackChannelIdstringname of your slack channel
Schedule *

Schedule options is used for set up custom scheduler for your radiator.

If you want to run your radiator manually(when run the script) you don't need to provide the schedule configuration

nametypedescription
periodday/week/monthPeriod for your schedule
cronstringA custom cron string(all other arguments will skip)
timenumberTime to send a message(0-23)
weekDaynumberWeekday to send a message(0-7, 0 and 7 is Sunday) - only for period=week
monthDaynumberMonthday to send a message(0-31) - only for period=month

Example. You want to run your radiator script each day at 10AM. For this you need to use the following configuration:

// ...
"scheduleConfig: {
  "period": "day",
  "cron": '12 15 * * *',
}
// ...

Git commit format

The commit contains the following structural elements, to communicate intent to the consumers of your library:

fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
types other than fix: and feat: are allowed, for example @commitlint/config-conventional (based on the the Angular convention) recommends build:, chore:, ci:, docs:, style:, refactor:, perf:, test:, and others.
footers other than BREAKING CHANGE: <description> may be provided and follow a convention similar to git trailer format.

Keywords

FAQs

Last updated on 04 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc