Skip to content

feat: add custom metric functionality - #39

Merged
zzbrar merged 1 commit into
masterfrom
bots_metrics
Aug 11, 2026
Merged

zzbrar merged 1 commit into
masterfrom
bots_metrics

Conversation

@zzbrar

@zzbrar zzbrar commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available: https://taskei.amazon.dev/tasks/Wickr-25457

Description of changes:
Add custom bot metric functionality. Three functions for bot integrations to publish their own metrics to the bot engine.

Comment thread src/wickrio_addon.js
async cmdIncrementMetric(name, value = 1) {
if (this.debug) console.log('in cmdIncrementMetric')

if (typeof name !== 'string' || name.length == 0) {

@dunnmtt dunnmtt Aug 11, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the duplicated statements in these methods to a validation method? Should this also be > 0? We should use should use strict equality checks for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't much duplication that we can get rid of here especially since we would have to pass in these strings and values that are different across all of these. > 0 would be for a positive check, this is a negative check so == 0 is correct

Comment thread src/wickrio_addon.js
if (this.debug) console.log('in cmdIncrementMetric')

if (typeof name !== 'string' || name.length == 0) {
throw 'IncrementMetric: metric name must be set!';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use Error('message') to preserve stack trace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid. My only hesitation with this is that there is 105 other occurrences throughout in the file that should also change to match the pattern

Comment thread src/wickrio_addon.js

// Send command to the engine
const result = await this.queueCommands.sendMessage(command);
if (result.success)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this throw here so the caller can handle the errors for all these? Otherwise it requires explicit check of this string which might be missed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explicit check already exists with the callers of all other functions in the file that have this pattern. If we change that for these functions we'll have 2 different patterns

@zzbrar
zzbrar merged commit 8610b9f into master Aug 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants