Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin-hubtype-analytics: change events to use new endpoint v2 #2827

Merged
merged 15 commits into from
Jun 11, 2024

Conversation

Iru89
Copy link
Contributor

@Iru89 Iru89 commented May 17, 2024

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

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

@Iru89 Iru89 force-pushed the plugin-hubtype-analytics/feedback-event branch from c62f8b7 to 49104cd Compare May 17, 2024 16:49
@Iru89 Iru89 changed the title Plugin hubtype analytics/feedback event plugin-hubtype-analytics: feedback event May 22, 2024
@Iru89 Iru89 requested a review from vanbasten17 May 23, 2024 10:19
@Iru89 Iru89 marked this pull request as ready for review May 23, 2024 13:22
@Iru89 Iru89 changed the title plugin-hubtype-analytics: feedback event plugin-hubtype-analytics: change events to use new endpoint v2 May 23, 2024
@Iru89 Iru89 force-pushed the plugin-hubtype-analytics/feedback-event branch from c027dd9 to cc41c1f Compare May 23, 2024 14:27
Iru89 and others added 8 commits May 28, 2024 18:28
…ent (#2834)

## Description

Review commit by commit
Add events to plugin flow builder:
- fallback event
- keyword event
- intent
- intent smart
## Description

Refactor custom event to have only one custom event and to always go
through the public API
## Description
* Removing data field from events

---------

Co-authored-by: Oriol Raventos <o.raventos.89@gmail.com>
@Iru89 Iru89 merged commit 2bd349b into master-lts Jun 11, 2024
5 checks passed
@Iru89 Iru89 deleted the plugin-hubtype-analytics/feedback-event branch June 11, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants