Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ export class ActionExecutor {
}

// start genai extension
if (result.status === 'ok' && shouldTrackGenAiToken(actionTypeId)) {
if (
result.status === 'ok' &&
shouldTrackGenAiToken(actionTypeId, `${validatedParams.subAction}`)
) {
getGenAiTokenTracking({
actionTypeId,
logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,8 @@ describe('getGenAiTokenTracking', () => {
it('should be false with any other action', () => {
expect(shouldTrackGenAiToken('.jira')).toEqual(false);
});
it('should be false with OpenAI action and getDashboard', () => {
expect(shouldTrackGenAiToken('.gen-ai', 'getDashboard')).toEqual(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,12 @@ export const getGenAiTokenTracking = async ({
return null;
};

export const shouldTrackGenAiToken = (actionTypeId: string) =>
actionTypeId === '.gen-ai' ||
actionTypeId === '.bedrock' ||
actionTypeId === '.gemini' ||
actionTypeId === '.inference';
export const shouldTrackGenAiToken = (actionTypeId: string, subAction?: string) =>
(actionTypeId === '.gen-ai' ||
actionTypeId === '.bedrock' ||
actionTypeId === '.gemini' ||
actionTypeId === '.inference') &&
subAction !== 'getDashboard';

function hasTelemetryMetadata(obj: unknown): obj is { telemetryMetadata: TelemetryMetadata } {
return obj !== null && typeof obj === 'object' && 'telemetryMetadata' in obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { useCallback } from 'react';
import { EuiLink } from '@elastic/eui';
import { EuiLink, EuiSpacer } from '@elastic/eui';
import { useKibana } from '@kbn/triggers-actions-ui-plugin/public';
import * as i18n from './translations';
import { useGetDashboard } from '../lib/gen_ai/use_get_dashboard';
Expand Down Expand Up @@ -40,10 +40,13 @@ export const DashboardLink: React.FC<Props> = ({
return dashboardUrl != null ? (
// href gives us right click -> open in new tab
// onclick prevents page reload
// eslint-disable-next-line @elastic/eui/href-or-on-click
<EuiLink data-test-subj="link-gen-ai-token-dashboard" onClick={onClick} href={dashboardUrl}>
{i18n.USAGE_DASHBOARD_LINK(selectedProvider, connectorName)}
</EuiLink>

<>
<EuiSpacer size="s" />
<EuiLink data-test-subj="link-gen-ai-token-dashboard" onClick={onClick} href={dashboardUrl}>
{i18n.USAGE_DASHBOARD_LINK(selectedProvider, connectorName)}
</EuiLink>
</>
) : null;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { QueryClientProvider } from '@tanstack/react-query';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { ActionsPublicPluginSetup } from '@kbn/actions-plugin/public';
import { DashboardStart } from '@kbn/dashboard-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';
import { suspendedComponentWithProps } from './lib/suspended_component_with_props';
import { ActionTypeRegistryContract, RuleTypeRegistryContract } from '../types';

Expand Down Expand Up @@ -57,6 +58,7 @@ export interface TriggersAndActionsUiServices extends CoreStart {
element: HTMLElement;
theme$: Observable<CoreTheme>;
unifiedSearch: UnifiedSearchPublicPluginStart;
share: SharePluginStart;
}

export const renderApp = (deps: TriggersAndActionsUiServices) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/publ
import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
import { ALERT_RULE_TRIGGER } from '@kbn/ui-actions-browser/src/triggers';
import { CONTEXT_MENU_TRIGGER } from '@kbn/embeddable-plugin/public';
import type { SharePluginStart } from '@kbn/share-plugin/public';
import type { Rule, RuleUiAction } from './types';
import type { AlertsSearchBarProps } from './application/sections/alerts_search_bar';

Expand Down Expand Up @@ -171,6 +172,7 @@ interface PluginsStart {
lens: LensPublicStart;
fieldsMetadata: FieldsMetadataPublicStart;
uiActions: UiActionsStart;
share: SharePluginStart;
}

export class Plugin
Expand Down Expand Up @@ -310,6 +312,7 @@ export class Plugin
fieldFormats: pluginsStart.fieldFormats,
lens: pluginsStart.lens,
fieldsMetadata: pluginsStart.fieldsMetadata,
share: pluginsStart.share,
});
},
});
Expand Down Expand Up @@ -357,6 +360,7 @@ export class Plugin
history: params.history,
actionTypeRegistry,
ruleTypeRegistry,
share: pluginsStart.share,
kibanaFeatures,
});
},
Expand Down