Skip to content

Commit

Permalink
Merge pull request #1755 from aziontech/dev
Browse files Browse the repository at this point in the history
DEPLOY 2024.09.25
  • Loading branch information
vinigfer authored Sep 25, 2024
2 parents ef8e4bc + 7a73928 commit 5f4bbe2
Show file tree
Hide file tree
Showing 33 changed files with 570 additions and 262 deletions.
19 changes: 0 additions & 19 deletions azion.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,6 @@ const backRules = [
rewrite: '/billing/graphql'
}
},
{
name: 'Route List Client Ids to Github',
description: 'this route will get the client ids of the accounts released to the console',
match: '^/api/allowed-accounts',
behavior: {
forwardCookies: true,
setOrigin: {
name: 'origin-github-allowed-accounts',
type: 'single_origin'
},
rewrite: '/aziontech/console-client-list/main/clids.json'
}
},
{
name: 'Route Send Feedback',
description: 'this route will send user feedback to jira',
Expand Down Expand Up @@ -310,12 +297,6 @@ const AzionConfig = {
addresses: [`api.azion.com`]
},
]),
{
name: 'origin-github-allowed-accounts',
type: 'single_origin',
hostHeader: `raw.githubusercontent.com`,
addresses: [`raw.githubusercontent.com`]
},
{
name: 'origin-console-feedback',
type: 'single_origin',
Expand Down
10 changes: 0 additions & 10 deletions azion/production/azion.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@
"origin-key": "4c361d2f-dbb5-42c0-a6b6-28b0e6e50d91",
"name": "console_kit_31-07-2024_single"
},
{
"origin-id": 153663,
"origin-key": "6ec17c87-d2fb-4c28-a3b7-588b1ae61bf2",
"name": "origin-github-allowed-accounts"
},
{
"origin-id": 154233,
"origin-key": "8c16e835-20af-41d5-a688-cac8e6aefa94",
Expand Down Expand Up @@ -153,11 +148,6 @@
"name": "Secure Headers",
"phase": "response"
},
{
"id": 296352,
"name": "Route List Client Ids to Github",
"phase": "request"
},
{
"id": 297983,
"name": "Route Send Feedback",
Expand Down
10 changes: 0 additions & 10 deletions azion/stage/azion.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@
"origin-key": "c92f57e1-79d6-4bcc-9493-2af4ad9f4dd5",
"name": "origin-cities"
},
{
"origin-id": 153113,
"origin-key": "ab771dc5-8ee9-4f9f-bb5d-3fa6fe9483c5",
"name": "origin-github-allowed-accounts"
},
{
"origin-id": 153761,
"origin-key": "f1f976fb-0558-4592-a930-dcad70ab2e7c",
Expand Down Expand Up @@ -153,11 +148,6 @@
"name": "Secure Headers",
"phase": "response"
},
{
"id": 294965,
"name": "Route List Client Ids to Github",
"phase": "request"
},
{
"id": 296641,
"name": "Route Send Feedback",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azion-console-kit",
"version": "1.22.2",
"version": "1.22.3",
"private": false,
"type": "module",
"repository": {
Expand Down
27 changes: 24 additions & 3 deletions src/helpers/convert-gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ const getGraphQLType = (value) => {
return 'String'
}

if (!isNaN(Date.parse(value))) {
if (isValidDate(value)) {
return 'DateTime'
}

return 'String'
}
}

function isValidDate(dateString) {
const dateRegexes = /^\d{2,4}[-/]\d{2}[-/]\d{2,4}?.*$/
const isValidFormat = dateRegexes.test(dateString)
if (!isValidFormat) {
return false
}

return !isNaN(Date.parse(dateString))
}

/**
* Builds a GraphQL query based on the provided parameters.
*
Expand All @@ -49,6 +59,15 @@ function buildGraphQLQuery({ filterParameter, dataset, limit, orderBy, filterQue
].join('\n')
}

const formatValueContainOperator = (variable) => {
for (const key in variable) {
if (variable[key] && key.includes('Like')) {
variable[key] = `%${variable[key]}%`
}
}
return variable
}

/**
* Convert filter and table to gql body
*
Expand All @@ -59,11 +78,11 @@ function buildGraphQLQuery({ filterParameter, dataset, limit, orderBy, filterQue
const convertGQL = (filter, table) => {
if (!table) throw new Error('Table parameter is required')

const variables = {}
let variables = {}
const filterQuery = buildFilterQuery(filter, variables)

const fieldsFormat = table.fields.map((field) => `\t\t${field}`).join('\n')
const filterParameter = formatFilterParameter(variables)
variables = formatValueContainOperator(variables)

const queryConfig = {
filterParameter,
Expand All @@ -73,6 +92,7 @@ const convertGQL = (filter, table) => {
filterQuery,
fields: fieldsFormat
}

const query = buildGraphQLQuery(queryConfig)

return {
Expand Down Expand Up @@ -138,6 +158,7 @@ const separateFieldsByType = (fields) => {
const mergeFieldsIntoFilter = (fields, filter) => {
fields.forEach(({ operator, valueField, value }) => {
const filterKey = operator === 'In' ? 'in' : 'and'

filter[filterKey] = {
...filter[filterKey],
[`${valueField}${operator}`]: value
Expand Down
16 changes: 15 additions & 1 deletion src/modules/real-time-metrics/constants/help-center-urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,21 @@ const HELP_CENTER_URLS = {
sqlInjectionThreats: '/real-time-metrics/waf/threats/sql-injection-threats',
threatsVsRequests: '/real-time-metrics/waf/threats/threats-vs-requests'
}
}
},
botManager: {
botManagerSummary: {
badBotHits: '/real-time-metrics/bot-manager-advanced/overview/bad-bot-hits',
goodBotHits: '/real-time-metrics/bot-manager-advanced/overview/good-bot-hits',
botHits: '/real-time-metrics/bot-manager-advanced/overview/bot-hits',
transactions: '/real-time-metrics/bot-manager-advanced/overview/transactions',
botTraffic: '/real-time-metrics/bot-manager-advanced/overview/bot-traffic',
topBotAction: '/real-time-metrics/bot-manager-advanced/overview/top-bot-action',
botCaptchaLine: '/real-time-metrics/bot-manager-advanced/overview/bot-captcha-line-graph',
topBotCaptchaPie: '/real-time-metrics/bot-manager-advanced/overview/top-bot-captcha-pie-graph',
topBotClassification: '/real-time-metrics/bot-manager-advanced/overview/top-bot-classifications',
botActivityMap: '/real-time-metrics/bot-manager-advanced/overview/bot-activity-map'
}
},
}

export default HELP_CENTER_URLS
6 changes: 4 additions & 2 deletions src/modules/real-time-metrics/constants/reports-texts.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ const REPORTS_TEXTS = {
description: 'Number of requests evaluated by Azion Bot Manager.'
},
botTraffic: {
description: 'Sum of requests grouped by classification.'
description:
'Sum of requests grouped by identifying traffic as Legitimate, Bad Bot, Good Bot, and Under Evaluation.'
},
botCaptcha: {
description: 'Sum of CAPTCHA challenge results returned for requests classified as bots.'
Expand All @@ -199,7 +200,8 @@ const REPORTS_TEXTS = {
'Actions taken by Azion Bot Manager for requests identified as bots, displayed in both absolute values and percentages.'
},
botClassification: {
description: 'Number of requests by bot categories.'
description:
'Sum of requests classified according to the tactics used and the purpose of the bots.'
},
botActivityMap: {
description: 'Sum of requests identified as bots, presented by the country of origin.'
Expand Down
26 changes: 13 additions & 13 deletions src/modules/real-time-metrics/constants/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ const REPORTS = [
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'inverse',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.badBotHits
},
{
id: '934654293238823255',
Expand Down Expand Up @@ -892,7 +892,7 @@ const REPORTS = [
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'neutral',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.goodBotHits
},
{
id: '259047966206560862',
Expand Down Expand Up @@ -922,7 +922,7 @@ const REPORTS = [
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'inverse',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.botHits
},
{
id: '541669034905662013',
Expand All @@ -949,7 +949,7 @@ const REPORTS = [
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'neutral',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.transactions
},
{
id: '329891149133127508',
Expand All @@ -975,12 +975,12 @@ const REPORTS = [
orderDirection: 'ASC',
dashboardId: '371360344901061482',
variationType: 'regular',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.botTraffic
},
{
id: '577704475532819772',
chartOwner: 'azion',
label: 'Bot Action',
label: 'Top Bot Action',
description: REPORTS_TEXTS.botManager.botManagerSummary.botAction.description,
aggregationType: 'sum',
columns: 6,
Expand All @@ -1007,7 +1007,7 @@ const REPORTS = [
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'regular',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.topBotAction
},
{
id: '071851224118431167',
Expand Down Expand Up @@ -1036,12 +1036,12 @@ const REPORTS = [
orderDirection: 'ASC',
dashboardId: '371360344901061482',
variationType: 'regular',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.botCaptchaLine
},
{
id: '455330743572401794',
chartOwner: 'azion',
label: 'Bot CAPTCHA',
label: 'Top Bot CAPTCHA',
description: REPORTS_TEXTS.botManager.botManagerSummary.botCaptcha.description,
aggregationType: 'sum',
columns: 6,
Expand All @@ -1066,12 +1066,12 @@ const REPORTS = [
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'regular',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.topBotCaptchaPie
},
{
id: '424388331488145485',
chartOwner: 'azion',
label: 'Bot Classifications',
label: 'Top Bot Classifications',
description: REPORTS_TEXTS.botManager.botManagerSummary.botClassification.description,
aggregationType: 'sum',
columns: 6,
Expand All @@ -1098,7 +1098,7 @@ const REPORTS = [
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'regular',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.topBotClassification
},
{
id: '190246009413028885',
Expand Down Expand Up @@ -1128,7 +1128,7 @@ const REPORTS = [
orderDirection: 'ASC',
dashboardId: '371360344901061482',
variationType: 'regular',
helpCenterPath: ''
helpCenterPath: HELP_CENTER_URLS.botManager.botManagerSummary.botActivityMap
},
/**
* OBSERVE
Expand Down
18 changes: 17 additions & 1 deletion src/plugins/analytics/AnalyticsTrackerAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { SignUpTracker, SignInTracker, CreateTracker, ProductTracker } from './trackers'
import {
SignUpTracker,
SignInTracker,
CreateTracker,
ProductTracker,
WafRulesTracker
} from './trackers'

/**
* @typedef {Object} TrackerEvent
Expand Down Expand Up @@ -27,6 +33,8 @@ export class AnalyticsTrackerAdapter {
#createTracker = null
/** @type {ProductTracker} */
#productTracker = null
/** @type {WafTracker} */
#wafRulesTracker = null

/**
* Creates an instance of AnalyticsTrackerAdapter.
Expand All @@ -40,6 +48,7 @@ export class AnalyticsTrackerAdapter {
this.#signInTracker = new SignInTracker(this)
this.#createTracker = new CreateTracker(this)
this.#productTracker = new ProductTracker(this)
this.#wafRulesTracker = new WafRulesTracker(this)
}

/**
Expand Down Expand Up @@ -119,4 +128,11 @@ export class AnalyticsTrackerAdapter {
get product() {
return this.#productTracker
}

/**
* @return {ProductTracker}
*/
get wafRules() {
return this.#wafRulesTracker
}
}
13 changes: 13 additions & 0 deletions src/plugins/analytics/trackers/ProductTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,17 @@ export class ProductTracker {
})
return this.#trackerAdapter
}

/**
* @param {Object} payload
* @param {String} payload.target
* @returns {AnalyticsTrackerAdapter}
*/
clickedOn(payload) {
this.#trackerAdapter.addEvent({
eventName: `Clicked on ${payload.target}`,
props: {}
})
return this.#trackerAdapter
}
}
Loading

0 comments on commit 5f4bbe2

Please sign in to comment.