An open API service indexing awesome lists of open source software.

https://github.com/commercelayer/commercelayer-cli-plugin-metrics


https://github.com/commercelayer/commercelayer-cli-plugin-metrics

commercelayer

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

          

# @commercelayer/cli-plugin-metrics

Commerce Layer CLI Metrics plugin

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@commercelayer/cli-plugin-metrics.svg)](https://npmjs.org/package/@commercelayer/cli-plugin-metrics)
[![Downloads/week](https://img.shields.io/npm/dw/@commercelayer/cli-plugin-metrics.svg)](https://npmjs.org/package/@commercelayer/cli-plugin-metrics)
[![License](https://img.shields.io/npm/l/@commercelayer/cli-plugin-metrics.svg)](https://github.com/@commercelayer/cli-plugin-metrics/blob/master/package.json)

* [Usage](#usage)
* [Commands](#commands)

## Usage

```sh-session
commercelayer COMMAND

commercelayer [COMMAND] (--help | -h) for detailed information about plugin commands.
```

## Commands

* [`commercelayer metrics:breakdown RESOURCE`](#commercelayer-metricsbreakdown-resource)
* [`commercelayer metrics:date_breakdown RESOURCE`](#commercelayer-metricsdate_breakdown-resource)
* [`commercelayer metrics:fbt`](#commercelayer-metricsfbt)
* [`commercelayer metrics:search RESOURCE`](#commercelayer-metricssearch-resource)
* [`commercelayer metrics:stats RESOURCE`](#commercelayer-metricsstats-resource)

### `commercelayer metrics:breakdown RESOURCE`

Perform a breakdown query on the Metrics API endpoint.

```sh-session
USAGE
$ commercelayer metrics:breakdown RESOURCE -b -f -O
avg|cardinality|max|min|percentiles|stats|sum|value_count [-F ] [-B ] [-c ] [-s asc|desc] [-l
]

FLAGS
-B, --breakdown= the optional nested breakdown
-F, --filter= the filter to apply to the query in JSON format (enclosed in single quotes)
-O, --operator= (required) the computing operator

-b, --by= (required) the field you want the results of the query aggragated by
-c, --condition= an additional constraint to fine-tune the set of records
-f, --field= (required) the field you want the metrics or statistics computed on
-l, --limit= the maximum number of records shown in the response
-s, --sort= the way you want the results of the query to be sorted

DESCRIPTION
perform a breakdown query on the Metrics API endpoint

ALIASES
$ commercelayer metrics:break
$ commercelayer breakdown

EXAMPLES
$ commercelayer metrics:breakdown orders -b order.country_code -f order.id -O value_count -s desc -l 20

cl breakdown orders -b order.country_code -f order.id -O value_count -s desc -l 20 -B '{"by": "line_items.name","field": "line_items.id","operator": "value_count","sort": "desc","limit": 20}'

FLAG DESCRIPTIONS
-B, --breakdown= the optional nested breakdown

a JSON object (enclosed in single quotes) containing the nested breakdown

-O, --operator=avg|cardinality|max|min|percentiles|stats|sum|value_count the computing operator

the list of valid operators depends on the value of the field key

-c, --condition= an additional constraint to fine-tune the set of records

the condition is applied to the computed results of the query and it is available for operators that return single
numeric (float or integer) values.
```

_See code: [src/commands/metrics/breakdown.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/breakdown.ts)_

### `commercelayer metrics:date_breakdown RESOURCE`

Perform a date breakdown query on the Metrics API endpoint.

```sh-session
USAGE
$ commercelayer metrics:date_breakdown RESOURCE -b -f -O
avg|cardinality|max|min|percentiles|stats|sum|value_count [-F ] [-B ] [-i hour|day|week|month|year]

FLAGS
-B, --breakdown= the optional nested breakdown
-F, --filter= the filter to apply to the query in JSON format (enclosed in single quotes)
-O, --operator= (required) the computing operator

-b, --by= (required) the field you want the results of the query aggragated by
-f, --field= (required) the field you want the metrics or statistics computed on
-i, --interval= the time interval over which the metrics are computed

DESCRIPTION
perform a date breakdown query on the Metrics API endpoint

ALIASES
$ commercelayer metrics:breakdate
$ commercelayer metrics:date
$ commercelayer breakdate
$ commercelayer date_breakdown

EXAMPLES
$ commercelayer metrics:date_breakdown orders -b order.placed_at -f order.total_amount_with_taxes -O stats -i month

FLAG DESCRIPTIONS
-B, --breakdown= the optional nested breakdown

a JSON object (enclosed in single quotes) containing the nested breakdown

-O, --operator=avg|cardinality|max|min|percentiles|stats|sum|value_count the computing operator

the list of valid operators depends on the value of the field key
```

_See code: [src/commands/metrics/date_breakdown.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/date_breakdown.ts)_

### `commercelayer metrics:fbt`

Perform a Frequently Bought Together query on the Metrics API analysis endpoint.

```sh-session
USAGE
$ commercelayer metrics:fbt [-F ] [-i ...]

FLAGS
-F, --filter= the filter to apply to the query in JSON format (enclosed in single quotes)
-i, --in=... a list of SKU or bundle IDs associated as line items to one or more orders

DESCRIPTION
perform a Frequently Bought Together query on the Metrics API analysis endpoint

ALIASES
$ commercelayer fbt

EXAMPLES
$ commercelayer metrics:fbt --in xYZkjABcde,yzXKjYzaCx
```

_See code: [src/commands/metrics/fbt.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/fbt.ts)_

### `commercelayer metrics:search RESOURCE`

Perform a search query on the Metrics API endpoint.

```sh-session
USAGE
$ commercelayer metrics:search RESOURCE -f ... [-F ] [-l ] [-s asc|desc -b ] [-c
]

FLAGS
-F, --filter= the filter to apply to the query in JSON format (enclosed in single quotes)
-b, --sort_by= the date field you want the results of the query sorted by
-c, --cursor= the cursor pointing to a specific page in the paginated search results
-f, --fields=... (required) comma-separated list of fields you want to be returned for each record in the
response
-l, --limit= the maximum number of records shown in the response
-s, --sort= the way you want the results of the query to be sorted

DESCRIPTION
perform a search query on the Metrics API endpoint

ALIASES
$ commercelayer search

EXAMPLES
$ commercelayer metrics:search orders -l 5 -s asc -b order.placed_at -f order.id,order.number,order.placed_at,customer.email
```

_See code: [src/commands/metrics/search.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/search.ts)_

### `commercelayer metrics:stats RESOURCE`

Perform a stats query on the Metrics API endpoint.

```sh-session
USAGE
$ commercelayer metrics:stats RESOURCE -f -O avg|cardinality|max|min|percentiles|stats|sum|value_count
[-F ]

FLAGS
-F, --filter= the filter to apply to the query in JSON format (enclosed in single quotes)
-O, --operator= (required) the computing operator

-f, --field= (required) the field you want the metrics or statistics computed on

DESCRIPTION
perform a stats query on the Metrics API endpoint

ALIASES
$ commercelayer stats

EXAMPLES
$ commercelayer metrics:stats orders -f order.total_amount_with_taxes --op avg

cl stats orders -f order.total_amount_with_taxes -O stats
```

_See code: [src/commands/metrics/stats.ts](https://github.com/commercelayer/commercelayer-cli-plugin-metrics/blob/main/src/commands/metrics/stats.ts)_