Skip to content

Commit

Permalink
Release organization metrics API (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-stytch authored Apr 4, 2024
1 parent fe584af commit 681e8eb
Show file tree
Hide file tree
Showing 20 changed files with 206 additions and 6 deletions.
2 changes: 2 additions & 0 deletions dist/b2b/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dist/b2b/organizations.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/b2c/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions dist/b2c/project.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/b2b/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Organizations } from "./organizations";
import { OTPs } from "./otp";
import { Passwords } from "./passwords";
import { PolicyCache } from "./rbac_local";
import { Project } from "../b2c/project";
import { RBAC } from "./rbac";
import { RecoveryCodes } from "./recovery_codes";
import { SCIM } from "./scim";
Expand All @@ -25,6 +26,7 @@ export class B2BClient extends BaseClient {
otps: OTPs;
organizations: Organizations;
passwords: Passwords;
project: Project;
rbac: RBAC;
recoveryCodes: RecoveryCodes;
scim: SCIM;
Expand Down Expand Up @@ -56,6 +58,7 @@ export class B2BClient extends BaseClient {
this.otps = new OTPs(this.fetchConfig);
this.organizations = new Organizations(this.fetchConfig);
this.passwords = new Passwords(this.fetchConfig);
this.project = new Project(this.fetchConfig);
this.rbac = new RBAC(this.fetchConfig);
this.recoveryCodes = new RecoveryCodes(this.fetchConfig);
this.scim = new SCIM(this.fetchConfig);
Expand Down
2 changes: 2 additions & 0 deletions lib/b2b/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export type {
B2BOrganizationsDeleteResponse,
B2BOrganizationsGetRequest,
B2BOrganizationsGetResponse,
B2BOrganizationsMetricsRequest,
B2BOrganizationsMetricsResponse,
B2BOrganizationsSearchRequest,
B2BOrganizationsSearchResponse,
B2BOrganizationsUpdateRequest,
Expand Down
29 changes: 29 additions & 0 deletions lib/b2b/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,16 @@ export interface B2BOrganizationsGetResponse {
status_code: number;
}

export interface B2BOrganizationsMetricsRequest {
organization_id: string;
}

export interface B2BOrganizationsMetricsResponse {
request_id: string;
member_count: number;
status_code: number;
}

// Request type for `organizations.search`.
export interface B2BOrganizationsSearchRequest {
/**
Expand Down Expand Up @@ -1093,4 +1103,23 @@ export class Organizations {
data,
});
}

/**
* @param params {@link B2BOrganizationsMetricsRequest}
* @returns {@link B2BOrganizationsMetricsResponse}
* @async
* @throws A {@link StytchError} on a non-2xx response from the Stytch API
* @throws A {@link RequestError} when the Stytch API cannot be reached
*/
metrics(
params: B2BOrganizationsMetricsRequest
): Promise<B2BOrganizationsMetricsResponse> {
const headers: Record<string, string> = {};
return request<B2BOrganizationsMetricsResponse>(this.fetchConfig, {
method: "GET",
url: `/v1/b2b/organizations/${params.organization_id}/metrics`,
headers,
params: {},
});
}
}
11 changes: 10 additions & 1 deletion lib/b2b/scim_connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ export interface B2BSCIMConnectionsCreateRequest {
organization_id: string;
// A human-readable display name for the connection.
display_name?: string;
identity_provider?: "unknown" | "okta" | "microsoft-entra" | string;
identity_provider?:
| "unknown"
| "okta"
| "microsoft-entra"
| "cyberark"
| "jumpcloud"
| "onelogin"
| "pingfederate"
| "rippling"
| string;
}

// Response type for `scim.connections.create`.
Expand Down
3 changes: 3 additions & 0 deletions lib/b2c/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MagicLinks } from "./magic_links";
import { OAuth } from "./oauth";
import { OTPs } from "./otps";
import { Passwords } from "./passwords";
import { Project } from "./project";
import { Sessions } from "./sessions";
import { TOTPs } from "./totps";
import { Users } from "./users";
Expand All @@ -20,6 +21,7 @@ export class Client extends BaseClient {
oauth: OAuth;
otps: OTPs;
passwords: Passwords;
project: Project;
sessions: Sessions;
totps: TOTPs;
users: Users;
Expand All @@ -46,6 +48,7 @@ export class Client extends BaseClient {
this.oauth = new OAuth(this.fetchConfig);
this.otps = new OTPs(this.fetchConfig);
this.passwords = new Passwords(this.fetchConfig);
this.project = new Project(this.fetchConfig);
this.sessions = new Sessions(this.fetchConfig, this.jwtConfig);
this.totps = new TOTPs(this.fetchConfig);
this.users = new Users(this.fetchConfig);
Expand Down
2 changes: 2 additions & 0 deletions lib/b2c/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ export type {
OTPsEmailSendResponse,
} from "./otps_email";

export type { ProjectMetric, ProjectMetricsResponse } from "./project";

export type {
TOTPWithRecoveryCodes,
TOTPsAuthenticateRequest,
Expand Down
51 changes: 51 additions & 0 deletions lib/b2c/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

import {} from "../shared/method_options";
import { fetchConfig } from "../shared";
import { request } from "../shared";

export interface ProjectMetric {
count: number;
metric_type?:
| "UNKNOWN"
| "USER_COUNT"
| "ORGANIZATION_COUNT"
| "MEMBER_COUNT"
| "M2M_CLIENT_COUNT"
| string;
}

export interface ProjectMetricsResponse {
request_id: string;
project_id: string;
metrics: ProjectMetric[];
status_code: number;
}

export class Project {
private fetchConfig: fetchConfig;

constructor(fetchConfig: fetchConfig) {
this.fetchConfig = fetchConfig;
}

/**
* @param params {@link ProjectMetricsRequest}
* @returns {@link ProjectMetricsResponse}
* @async
* @throws A {@link StytchError} on a non-2xx response from the Stytch API
* @throws A {@link RequestError} when the Stytch API cannot be reached
*/
metrics(): Promise<ProjectMetricsResponse> {
const headers: Record<string, string> = {};
return request<ProjectMetricsResponse>(this.fetchConfig, {
method: "GET",
url: `/v1/projects/metrics`,
headers,
});
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stytch",
"version": "10.12.0",
"version": "10.13.0",
"description": "A wrapper for the Stytch API",
"types": "./types/lib/index.d.ts",
"main": "./dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions types/lib/b2b/client.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/b2b/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions types/lib/b2b/organizations.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/b2b/scim_connections.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions types/lib/b2c/client.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions types/lib/b2c/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 681e8eb

Please sign in to comment.