Skip to content

Commit

Permalink
Update api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Nov 30, 2020
1 parent c196193 commit d268882
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsIncrementCounterOptions](./kibana-plugin-core-server.savedobjectsincrementcounteroptions.md) &gt; [initialize](./kibana-plugin-core-server.savedobjectsincrementcounteroptions.initialize.md)

## SavedObjectsIncrementCounterOptions.initialize property

Sets all the counter fields to 0 if they don't already exist

<b>Signature:</b>

```typescript
initialize?: boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface SavedObjectsIncrementCounterOptions extends SavedObjectsBaseOpt
| Property | Type | Description |
| --- | --- | --- |
| [initialize](./kibana-plugin-core-server.savedobjectsincrementcounteroptions.initialize.md) | <code>boolean</code> | Sets all the counter fields to 0 if they don't already exist |
| [migrationVersion](./kibana-plugin-core-server.savedobjectsincrementcounteroptions.migrationversion.md) | <code>SavedObjectsMigrationVersion</code> | |
| [refresh](./kibana-plugin-core-server.savedobjectsincrementcounteroptions.refresh.md) | <code>MutatingOperationRefreshSetting</code> | The Elasticsearch Refresh setting for this operation |
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@ incrementCounter(type: string, id: string, counterFieldNames: string[], options?

## Remarks

When supplying a field name like `stats.api.counter` the field name will be used as-is to create a document like: `{attributes: {'stats.api.counter': 1}}` It will not create a nested structure like: `{attributes: {stats: {api: {counter: 1}}}}`
\* When supplying a field name like `stats.api.counter` the field name will be used as-is to create a document like: `{attributes: {'stats.api.counter': 1}}` It will not create a nested structure like: `{attributes: {stats: {api: {counter: 1}}}}` When using incrementCounter for collecting usage data, you need to ensure that usage collection happens on a best-effort basis and doesn't negatively affect your plugin or users. See https://github.com/elastic/kibana/blob/master/src/plugins/usage\_collection/README.md\#tracking-interactions-with-incrementcounter)

## Example

Collecting usage data

```ts
const repository = coreStart.savedObjects.createInternalRepository();

// NOTE: Usage collection happens on a best-effort basis, so we don't
// `await` the promise returned by `incrementCounter` and we swallow any
// exceptions in production.
repository
.incrementCounter('test_counter_type', 'counter_2', [
'stats.api.count',
'stats.api.count2',
'stats.total',
.incrementCounter('dashboard_counter_type', 'counter_id', [
'stats.apiCalls',
'stats.sampleDataInstalled',
])
.catch((e) => (coreContext.env.cliArgs.dev ? logger.error(e) : e));

```

1 change: 1 addition & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,7 @@ export interface SavedObjectsImportUnsupportedTypeError {

// @public (undocumented)
export interface SavedObjectsIncrementCounterOptions extends SavedObjectsBaseOptions {
initialize?: boolean;
// (undocumented)
migrationVersion?: SavedObjectsMigrationVersion;
refresh?: MutatingOperationRefreshSetting;
Expand Down

0 comments on commit d268882

Please sign in to comment.