Skip to content

Latest commit

 

History

History
158 lines (109 loc) · 12.3 KB

README.md

File metadata and controls

158 lines (109 loc) · 12.3 KB

Stats

(notifications.stats)

Overview

Available Operations

  • retrieve - Get notification statistics
  • graph - Get notification graph statistics

retrieve

Get notification statistics

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.notifications.stats.retrieve();

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { notificationsStatsRetrieve } from "@novu/api/funcs/notificationsStatsRetrieve.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await notificationsStatsRetrieve(novu);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
idempotencyKey string A header for idempotency purposes
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.NotificationsControllerGetActivityStatsResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 400, 404, 409 application/json
errors.ValidationErrorDto 422 application/json
errors.SDKError 4XX, 5XX */*

graph

Get notification graph statistics

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.notifications.stats.graph();

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { notificationsStatsGraph } from "@novu/api/funcs/notificationsStatsGraph.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await notificationsStatsGraph(novu);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
idempotencyKey string A header for idempotency purposes
days number N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.NotificationsControllerGetActivityGraphStatsResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 400, 404, 409 application/json
errors.ValidationErrorDto 422 application/json
errors.SDKError 4XX, 5XX */*