TelemetryDeck / Issues

When something is wrong in TelemetryDeck-Land, or if you have a cool idea how to make things better, this is the place to create an Issue.
https://telemetrydeck.com
36 stars 0 forks source link

Allow Relative Intervals in Aggregation Filter #346

Closed ActuallyTaylor closed 2 months ago

ActuallyTaylor commented 7 months ago

Hi!

I am working on building Telemetry Deck out as an Analytics platform for an upcoming app. I have got most of my Analytics working, however I have been having trouble with DAU/WAU and WAU/MAU. From what I can tell, these will both require the use of Filtered Aggregations with relative date ranges for the past month, past week etc...

I have the following structure for a custom TQL Query that should allow me to get the Daily users over a certain period. However, relative intervals are not supported within Filtered aggregations. Is there a way around this or do I have to wait RelativeIntervals support within aggregation filters?

{
  "aggregations": [
    {
      "type": "filtered",
      "filter": {
        "type": "and",
        "fields": [
          {
            "type": "interval",
            "dimension": "__time",
            "relativeIntervals": [
              {
                "beginningDate": {
                  "component": "day",
                  "offset": -30,
                  "position": "beginning"
                },
                "endDate": {
                  "component": "day",
                  "offset": 0,
                  "position": "end"
                }
              }
            ]
          }
        ]
      },
      "aggregator": {
        "type": "thetaSketch",
        "name": "Daily Users",
        "fieldName": "clientUser"
      }
    }
  ],
  "granularity": "month",
  "queryType": "groupBy"
}
DivineDominion commented 2 months ago

Sorry for asking: I'm looking for a way to aggregate the previous 7 days for each day, so I get a graph with a 7-day-average trend. Not sure what the technical term for this is :) This issue sounds like that, so would that be it, and is it indeed not supported?

winsmith commented 2 months ago

I've had time to look at this properly and @ActuallyTaylor, the answer for this is way easier: you just need one aggregation that counts users. You then set the granularity to day to get the number for each day, with a custom relative interval:

{
  "aggregations": [
    {
      "fieldName": "clientUser",
      "name": "count",
      "type": "thetaSketch"
    }
  ],
  "granularity": "day",
  "queryType": "timeseries",
  "relativeIntervals": [
    {
      "beginningDate": {
        "component": "day",
        "offset": -30,
        "position": "beginning"
      },
      "endDate": {
        "component": "day",
        "offset": 0,
        "position": "end"
      }
    }
  ]
}
winsmith commented 2 months ago

@DivineDominion the term you're looking for is "moving average" and it's not supported right now. I'm closing this ticket now, but if you're into moving averages, you can totally open a new one in this very repository. :)