widget.js 832 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. const DEFAULT_QUERIES = {
  2. discover: [
  3. {
  4. name: 'Known Users',
  5. fields: [],
  6. columns: [],
  7. aggregates: ['count()'],
  8. conditions: [['user.email', 'IS NOT NULL', null]],
  9. aggregations: [['uniq', 'user.email', 'Known Users']],
  10. limit: 1000,
  11. orderby: '-time',
  12. groupby: ['time'],
  13. rollup: 86400,
  14. },
  15. {
  16. name: 'Anonymous Users',
  17. fields: [],
  18. columns: [],
  19. aggregates: ['count()'],
  20. conditions: [['user.email', 'IS NULL', null]],
  21. aggregations: [['count()', null, 'Anonymous Users']],
  22. limit: 1000,
  23. orderby: '-time',
  24. groupby: ['time'],
  25. rollup: 86400,
  26. },
  27. ],
  28. };
  29. export function Widget(queries = {...DEFAULT_QUERIES}, options) {
  30. return {
  31. type: 'line',
  32. queries,
  33. title: 'Widget',
  34. ...options,
  35. };
  36. }