-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugin-hubtype-analytics: change events to use new endpoint v2 (#2827)
## Description **@botonic/plugin-hubtype-analytics** - Add Jest config - Add github action workflow to launch tests Accumulation of all PRs of new hubtype-analytics events with endpoint v2 Apply events within the **botonic-plugin-flow-builder** Update Session and Input types within **botonic-core** Add the withBotEvent option to the **botonic-core** HandoffBuilder to tell the backend to track the handoff-success ## Context There are two types of events: botevent and webevent - botevent: these are events that are always done in the bot's lambda and use an authenticated endpoint with token. - webevent: these events that can be sent from the bot's frontend (webchat, webviews) or from the bot's lambda, it uses an unauthenticated endpoint. ## Approach taken / Explain the design Different actions of the bot can be tracked, for now we have the following ones: - with botevent type: FlowNode, HandoffOption, HandoffSuccess, HandoffFail, Keyword, Intent, IntentSmart, Knowledgebase, and Fallback - with webevent type: FeedbackCase, FeedbackMessage, FeedbackConversation, FeedbackWebview, WebviewStep, WebviewEnd and Custom The **plugin-flow-builder** takes care of flow tracking and exports the function, trackFlowContent to facilitate the tracking of content displayed in the bot. Apart from tracking the content displayed by the bot, it tracks Keywords, IntentSmart, IntentKnowledge base and Fallback. It also uses the HandoffBuilder with the parameter with BotEvent for the backend to track the handoff-success. ## To document / Usage example In the bot code we can declare a function like this and then pass it through the flow builder constructor to make it work ```typescript type EventArgs = { [key: string]: any } export async function trackEvent( request: BotRequest, eventName: string, args?: EventArgs ): Promise<void> { if (Object.values(EventAction).includes(eventName as EventAction)) { const htEventProps = { action: eventName as EventAction, ...args, } as HtEventProps const hubtypeAnalyticsPlugin = request.plugins.hubtypeAnalytics await hubtypeAnalyticsPlugin.trackEvent(request, htEventProps) } return } ``` ## Testing - Add tests to check how each event is created --------- Co-authored-by: Adrià Sastre <[email protected]> Co-authored-by: Marc Rabat <[email protected]>
- Loading branch information
1 parent
0507eaf
commit 2bd349b
Showing
70 changed files
with
1,513 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
.github/workflows/botonic-plugin-hubtype-analytics-tests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Botonic plugin hubtype analytics tests | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'packages/botonic-plugin-hubtype-analytics/**' | ||
- '.github/workflows/botonic-plugin-hubtype-analytics-tests.yml' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
botonic-plugin-hubtype-analytics-tests: | ||
uses: ./.github/workflows/botonic-common-workflow.yml | ||
secrets: inherit #pragma: allowlist secret | ||
with: | ||
PACKAGE_NAME: Botonic plugin hubtype analytics tests | ||
PACKAGE: botonic-plugin-hubtype-analytics | ||
BUILD_COMMAND: 'cd ../botonic-core && npm run build && cd ../botonic-plugin-hubtype-analytics && npm run build' | ||
NEEDS_CODECOV_UPLOAD: 'yes' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.