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

Feat/grow 284.add amplitude to inkeep actions #176

Merged
merged 20 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
498b0ae
feat: GROW-284 - Add amplitude to inkeep event
hba-fingerprint Nov 14, 2024
157b6e7
feat: GROW-284 - Add location
hba-fingerprint Nov 18, 2024
75130b5
Merge remote-tracking branch 'origin/main' into feat/GROW-284.add_amp…
hba-fingerprint Nov 18, 2024
2835014
feat: GROW-284 - Refactor code and fix lint
hba-fingerprint Nov 18, 2024
760647e
feat: GROW-284 - Add generic type for inkeep event
hba-fingerprint Nov 18, 2024
6ec6faa
Merge branch 'main' into feat/GROW-284.add_amplitude_to_inkeep_actions
JuroUhlar Nov 20, 2024
1cf8ee3
feat: GROW-284 - PR remarks and reverting amplitude changes and keepi…
hba-fingerprint Nov 25, 2024
cc2e997
Merge remote-tracking branch 'origin/feat/GROW-284.add_amplitude_to_i…
hba-fingerprint Nov 25, 2024
24f0eb5
feat: GROW-284 - Fixing lint
hba-fingerprint Nov 25, 2024
8f3b464
Merge branch 'main' into feat/GROW-284.add_amplitude_to_inkeep_actions
JuroUhlar Nov 27, 2024
8bb6efd
feat: GROW-284 - PR Remarks
hba-fingerprint Nov 27, 2024
202fe87
Merge remote-tracking branch 'origin/feat/GROW-284.add_amplitude_to_i…
hba-fingerprint Nov 27, 2024
5488cd0
feat: GROW-284 - PR Remarks
hba-fingerprint Nov 27, 2024
77f4a9a
feat: GROW-284 - Remove debugger
hba-fingerprint Nov 28, 2024
b6de144
feat: GROW-284 - Remove settings validation
hba-fingerprint Nov 28, 2024
9a8ee0b
feat: GROW-284 - bring back eventName
hba-fingerprint Nov 28, 2024
639db7c
chore: clean up
JuroUhlar Nov 28, 2024
3bd4174
feat: GROW-284 - remove visitorId from event properties
hba-fingerprint Nov 28, 2024
bf9657a
Merge remote-tracking branch 'origin/feat/GROW-284.add_amplitude_to_i…
hba-fingerprint Nov 28, 2024
bb57d64
fix: remove `any` type
JuroUhlar Nov 28, 2024
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
19 changes: 16 additions & 3 deletions src/client/thirdParty/Amplitude.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { usePlaygroundSignals } from '../../app/playground/hooks/usePlaygroundSi
import { FunctionComponent } from 'react';

const AMPLITUDE_INGRESS_PROXY = 'https://demo.fingerprint.com/ampl-api/2/httpapi';
const EVENT_TYPE = 'Demo Page Viewed';
const AMPLITUDE_EVENT = {
DEMO_PAGE_VIEWED: 'Demo Page Viewed',
DEMO_ASK_AI_HELP_CHOSEN: 'Demo Ask AI Help Chosen',
JuroUhlar marked this conversation as resolved.
Show resolved Hide resolved
} as const;

/**
* This is an Amplitude plugin that renames the Page view event_properties according to our analytics needs
Expand All @@ -14,7 +17,7 @@ const demoPageViewedEventPropertiesEnrichment = (botDetected: 'True' | 'False'):
setup: async () => undefined,
execute: async (event) => {
// Only apply to Demo Page View events
if (event.event_type !== EVENT_TYPE) {
if (event.event_type !== AMPLITUDE_EVENT.DEMO_PAGE_VIEWED) {
return event;
}

Expand All @@ -36,6 +39,16 @@ type AmplitudeProps = {
apiKey: string;
};

type AskAIHelpChosenEventProperties = {
helpMethod: string;
'Demo Page Path': string;
'Demo Page Title': string;
};

export function trackAskAIHelpChosen(properties: AskAIHelpChosenEventProperties) {
amplitude.track(AMPLITUDE_EVENT.DEMO_ASK_AI_HELP_CHOSEN, properties);
}

export const Amplitude: FunctionComponent<AmplitudeProps> = ({ apiKey }) => {
usePlaygroundSignals({
onServerApiSuccess: (event) => {
Expand All @@ -46,7 +59,7 @@ export const Amplitude: FunctionComponent<AmplitudeProps> = ({ apiKey }) => {
amplitude.init(apiKey, {
defaultTracking: {
pageViews: {
eventType: EVENT_TYPE,
hba-fingerprint marked this conversation as resolved.
Show resolved Hide resolved
eventType: AMPLITUDE_EVENT.DEMO_PAGE_VIEWED,
},
attribution: false,
sessions: false,
Expand Down
23 changes: 12 additions & 11 deletions src/client/thirdParty/Inkeep.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';

import { InkeepChatButtonProps } from '@inkeep/uikit';
import type {
InkeepAIChatSettings,
InkeepSearchSettings,
Expand All @@ -9,6 +8,7 @@ import type {
} from '@inkeep/uikit';
import { env } from '../../env';
import dynamic from 'next/dynamic';
import { trackAskAIHelpChosen } from './Amplitude';

/**
* Inkeep (AI Help) chat button
Expand Down Expand Up @@ -36,7 +36,15 @@ const useInkeepSettings = (): InkeepSharedSettings => {
integrationId,
organizationId,
primaryBrandColor: '#F04405',
//logEventCallback: customAnalyticsCallback,
logEventCallback: (event) => {
if (event.eventName === 'get_help_option_clicked') {
trackAskAIHelpChosen({
helpMethod: event.properties.name,
'Demo Page Path': document.location.pathname,
'Demo Page Title': document.title,
});
}
},
};
const modalSettings: InkeepModalSettings = {};
const searchSettings: InkeepSearchSettings = {};
Expand Down Expand Up @@ -85,14 +93,7 @@ const useInkeepSettings = (): InkeepSharedSettings => {
};

export function InkeepChatButton() {
const { baseSettings, aiChatSettings, searchSettings, modalSettings } = useInkeepSettings();

const chatButtonProps: InkeepChatButtonProps = {
baseSettings,
aiChatSettings,
searchSettings,
modalSettings,
};
const settings = useInkeepSettings();

return <ChatButton {...chatButtonProps} />;
return <ChatButton {...settings} />;
}
Loading