Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@yoctol/analytics

Package Overview
Dependencies
Maintainers
7
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yoctol/analytics

Analytics for Yoctol bots

npmnpm
Version
0.7.0-alpha.5
Version published
Weekly downloads
19
58.33%
Maintainers
7
Weekly downloads
 
Created
Source

yoctol-analytics

Module

Install

$ npm install @yoctol/analytics
$ npm install @yoctol/analytics-sdk

Usage

First install sdk and log data into bot db using monk or knex client. Then analytics can generate corresponding files based on report setting.

  • sdk default mongo collection name: interactionLogs
  • sdk default knex table name: interaction_logs

Sample Report Setting

  • switchToHumanPayloads only supported in messenger platform.
reporterSettings: [
      {
        title: '總覽',
        className: 'Statistics',
        config: {
          switchToHumanPayloads: {
            postback: ['__SWITCH_TO_HUMAN__'],
            quick_reply: ['__SWITCH_TO_HUMAN__', '__INTENT_轉接專人__'],
          },
        },
      },
      {
        title: '互動次數(每日)',
        className: 'Histogram',
        config: {
          switchToHumanPayloads: {
            postback: ['__SWITCH_TO_HUMAN__'],
            quick_reply: ['__SWITCH_TO_HUMAN__', '__INTENT_轉接專人__'],
          },
          periodMinutes: 24 * 60,
        },
      },
      {
        title: '互動次數(每小時)',
        className: 'Histogram',
        config: {
          switchToHumanPayloads: {
            postback: ['__SWITCH_TO_HUMAN__'],
            quick_reply: ['__SWITCH_TO_HUMAN__', '__INTENT_轉接專人__'],
          },
          periodMinutes: 60,
        },
      },
      {
        title: '按鈕觸發次數',
        className: 'Postback',
        config: {},
      },
      {
        title: '訊息記錄',
        className: 'Log',
        config: {},
      },
    ],
}

SDK

const logger = new AnalyticsLogger({ knexClient, monkClient, logDbName });

logger.insertLog({ id, platform, platformChannelId, direction, event, triggers })

AnaylticsLogger Input

  • id: request id
  • platform: line / messenger / universal
  • platformChannelId: bot binding channel/page id
  • direction
  • event
  • triggers
  • kuratorProjectId: optional (special case for Fubon)
{
  id,
  platform,
  platformChannelId,
  direction,
  event,
  triggers,
  kuratorProjectId
}

triggers:

triggers: trigger | [trigger] // single object or array of objects

trigger: {
   intentId: "NLU INTENT ID",
   intentName: "NLU INTENT NAME",
   entityId: "NLU ENTITY ID",
   entityName: "NLU ENTITY NAME",
   entityValueId: "NLU ENTITY VALUE ID",
   entityValueName: "NLU ENTITY VALUE NAME",
   regexp: "^REGEXP$/g",
   keywords: ["KEYWORD1", "KEYWORD2", "KEYWORD3"],
   displayName: "ACTION NAME WHEN TRIGGERED BY PAYLOAD OR UNKNOWN",
   actionId: "ACTION ID WHEN TRIGGERED BY PAYLOAD OR UNKNOWN"
   isFallback: Boolean // unknown or not
}

event:

rawEvent

direction:

  • incoming
  • outgoing

Generic Message

{
  id: STRING (uuid)
  direction: STRING ('incoming' | 'outgoing')
  type: STRING ('text' | 'quick_reply' | 'button' | ...)
  platform: STRING ('messenger' | 'line' | 'universal' | ...)
  text: STRING
  postback: STRING
  context: {
      trigger: JSON
      ... extendibleFields
  },
  raw: JSON
  ... extendibleFields
}

FAQs

Package last updated on 24 Feb 2020

Did you know?

Socket

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