[{
  "name": "TrafficAnalytics",
  "description": "Traffic analytics for your Bubble",
  "url": "https://getbubblenow.com/apps/analytics",
  "template": true,
  "enabled": true,
  "priority": 100,
  "canPrime": false,
  "dataConfig": {
    "dataDriver": "bubble.app.analytics.TrafficAnalyticsAppDataDriver",
    "presentation": "app",
    "fields": [
      {"name": "ctime", "customFormat": true, "when": "view !== \"recent\""},
      {"name": "requestTime", "customFormat": true, "when": "view === \"recent\""},
      {"name": "accountName", "when": "view === \"recent\""},
      {"name": "deviceName", "when": "view === \"recent\""},
      {"name": "ip", "when": "view === \"recent\""},
      {"name": "fqdn"},
      {"name": "uri", "when": "view === \"recent\""},
      {"name": "userAgent", "when": "view === \"recent\""},
      {"name": "referer", "when": "view === \"recent\""},
      {"name": "device", "when": "view !== \"recent\""},
      {"name": "data", "when": "view !== \"recent\""}
    ],
    "params": [
      {"name": "device", "required": false, "index": 10, "when": "view !== \"recent\""},
      {"name": "meta2", "required": false, "operator": "like", "index": 20, "when": "view !== \"recent\""}
    ],
    "actions": [
      {
        "name": "filterHost",
        "when": "view === \"recent\"",
        "route": "/app/BubbleBlock/config/manageRules/local?action=createRule&rule={{fqdn}}"
      }, {
        "name": "filterUrl",
        "when": "view === \"recent\"",
        "route": "/app/BubbleBlock/config/manageRules/local?action=createRule&rule={{ encodeURIComponent( fqdn + (uri.startsWith('/') ? uri : '/'+uri) ) }}"
      }
    ],
    "views": [
      {"name": "recent", "layout": "tiles"},
      {"name": "last_24_hours"},
      {"name": "last_7_days"},
      {"name": "last_30_days"}
    ],
    "configDriver": "bubble.app.analytics.TrafficAnalyticsAppConfigDriver",
    "configFields": [
      {"name": "analyticsFilter", "truncate": false}
    ],
    "configViews": [{
      "name": "manageFilters",
      "scope": "app",
      "root": "true",
      "fields": ["analyticsFilter"],
      "actions": [
        {"name": "removeFilter", "index": 10},
        {
          "name": "addFilter", "scope": "app", "index": 10,
          "params": ["analyticsFilter"],
          "button": "addFilter"
        }
      ]
    }]
  },
  "children": {
    "AppSite": [{
      "name": "All_Sites",
      "url": "*",
      "description": "All websites",
      "template": true
    }],
    "AppRule": [{
      "name": "traffic_analytics",
      "template": true,
      "driver": "TrafficAnalyticsRuleDriver",
      "config": {
        "filterPatterns": [
          "\\.stripe\\.com",
          "\\.stripe\\.network"
        ]
      }
    }],
    "AppMessage": [{
      "locale": "en_US",
      "messages": [
        {"name": "name", "value": "Snitcher"},
        {"name": "icon", "value": "classpath:models/apps/analytics/snitcher-icon.svg"},
        {"name": "summary", "value": "Traffic Analytics"},
        {"name": "description", "value": "Review recent traffic for your devices. Block stuff that you don't like."},
        {"name": "field.ctime", "value": "When"},
        {"name": "field.requestTime", "value": "When"},
        {"name": "field.accountName", "value": "Account"},
        {"name": "field.fqdn", "value": "Host"},
        {"name": "field.device", "value": "Device"},
        {"name": "field.deviceName", "value": "Device"},
        {"name": "field.ip", "value": "From IP"},
        {"name": "field.uri", "value": "Path"},
        {"name": "field.userAgent", "value": "User Agent"},
        {"name": "field.referer", "value": "Referer"},
        {"name": "field.data", "value": "Count"},
        {"name": "param.meta2", "value": "Site"},
        {"name": "param.device", "value": "Device"},
        {"name": "action.filterHost", "value": "Block Host"},
        {"name": "action.filterUrl", "value": "Block URL"},
        {"name": "view.recent", "value": "Recent Traffic"},
        {"name": "view.recent.requestTime.format", "value": "{{MMM}} {{d}} @ {{h}}:{{m}}:{{s}}{{a}}"},
        {"name": "view.last_24_hours", "value": "Last 24 Hours"},
        {"name": "view.last_24_hours.ctime.format", "value": "{{MMM}} {{d}} @ {{h}}{{a}}"},
        {"name": "view.last_7_days", "value": "Last 7 Days"},
        {"name": "view.last_7_days.ctime.format", "value": "{{MMM}} {{d}}, {{YYYY}}"},
        {"name": "view.last_30_days", "value": "Last 30 Days"},
        {"name": "view.last_30_days.ctime.format", "value": "{{MMM}} {{d}}, {{YYYY}}"},

        {"name": "config.view.manageFilters", "value": "Manage Filters"},
        {"name": "config.field.analyticsFilter", "value": "Filter Pattern"},
        {"name": "config.field.analyticsFilter.description", "value": "Skip logging for URLs that match this pattern"},
        {"name": "config.action.addFilter", "value": "Add New Filter"},
        {"name": "config.button.addFilter", "value": "Add"},
        {"name": "config.action.removeFilter", "value": "Remove"}
      ]
    }]
  }
}]