Skip to content

Moesif/events-across-apps-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Moesif Multi-App Aggregation Script

Fetch aggregated event cardinalities per app (one auth token per app) over a date range, with optional cumulative sums.

Background

In Moesif, Management API keys (tokens) are scoped per app for security. Even within the same organization, to fetch data across multiple apps for comparison you must obtain a separate Management API key for each app. Thus we created this script to fetch from different app and combine them into a single result.

Requirements

  • Node.js 18 or newer. Uses native HTTPS; no external dependencies required.
  • One Management API key per app, each with at least the READ EVENTS permission.

Usage

node index.js \
  --tokens TOKEN_FOR_APP1,TOKEN_FOR_APP2 \
  --from 2025-10-28T21:35:47.000Z \
  --to 2025-11-28T22:35:47.000Z \
  --interval 1d \
  --timeZone America/Los_Angeles \
  --cumulative true

Optional: --baseUrl override (defaults to https://api.moesif.com/v1/search/~/count/events).

Output

JSON printed to stdout:

{
  "from": "2025-10-28T21:35:47.000",
  "to": "2025-11-28T22:35:47.000",
  "interval": "1d",
  "timeZone": "America/Los_Angeles",
  "cumulative": true,
  "apps": [
    {
      "app": "appNameFromJwt",
      "status": "ok",
      "total_cardinality": 123,
      "points": [
        {
          "key": "2025-11-01T00:00:00.000Z",
          "cardinality": 5,
          "cumulative": 5
        }
      ]
    }
  ]
}

Notes

  • App name derived from JWT payload field app, fallback to app_id or application.
  • Cumulative values only present when --cumulative true.
  • Errors per token included with { app, error } entries.
  • status values: ok (parsed), no-data (no aggregations but hits present), empty-response, unrecognized-format.

About

a script to fetch events across apps in Moesif

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors