Your customers 
hate 
learning
 
your SDK.

Catch is a AI coding agent that install SDKs into user’s codebase.

Say goodbye to extensive documentation & back-and-forth emails.

Put this on your docs

Try this on my code
Install Amplitudeappend-at/catch
assistantassistant

This integration process should take approximately 2-3 hours for an experienced developer to implement and test thoroughly.

Overview

  • Install Amplitude Browser SDK using npm in the project directory.
  • Initialize Amplitude SDK in the root layout component (apps/www/app/layout.tsx).
  • Set up user properties (preferredLanguage and lastLoginDate) using a custom hook.
  • Implement custom events (SDK Integration Guide Generation, Code Suggestion Applied, View Artifact, Guide Exported) using another custom hook.
  • Integrate these events into relevant parts of the application (various components and pages).

Testing

  • Verify Amplitude SDK initialization in the browser console.
  • Check if user properties are correctly set upon application load.
  • Trigger each custom event and confirm they are tracked in Amplitude dashboard.
  • Test different user interactions to ensure all events are captured accurately.
  • Verify that sensitive information is not being tracked or logged.
useruser

In Chat Artifact, how can I send an analytics event when the "expand ... lines" button is clicked?

assistantassistant

Got it. I’ll add an Amplitude event for the "expand ... lines" button in the code diff section and update the apps/www/components/chat/right-artifact.tsx file as follows:

This update includes:

  • Importing the Amplitude SDK.
  • Adding handleExpand to send an event when the "expand ... lines" button is clicked.
  • Adding an onClick handler to the span from codeFoldMessageRenderer to call handleExpand.
  • Including session ID, project info, file name, expanded line count, and version in the event.

Now, clicking the button will trigger an 'Code Diff Expanded' event in Amplitude to analyze user behavior.

useruser

Could you change SDK token into 338862ce1d73453394fb1481f136e144?

assistantassistant

Sure, I’ll update the Amplitude SDK token to 338862ce1d73453394fb1481f136e144.

Amplitude Integration and Taxonomy Setupv3
apps/www/app/layout.tsx
1import * as amplitude from '@amplitude/analytics-browser';
2import { useEffect } from 'react';
3import { useAmplitudeUser } from '../hooks/useAmplitudeUser';
7 useEffect(() => {
8 amplitude.init('338862ce1d73453394fb1481f136e144', {
9 defaultTracking: {
10 sessions: true,
11 pageViews: true,
12 formInteractions: true,
13 fileDownloads: true,
14 },
15 });
16 }, []);
17
18 useAmplitudeUser();
19
47 useEffect(() => {

This code initializes Amplitude with default tracking options for sessions, page views, form interactions, and file downloads. It's important to note that these settings will apply globally to all pages in the application. Consider the potential impact on performance and data collection volume, especially for high-traffic applications.

apps/www/components/chat/right-artifact.tsx
1import * as amplitude from '@amplitude/analytics-browser';
10 const handleExpand = (totalFoldedLines: number, fileName: string) => {
11 amplitude.track('Code Diff Expanded', {
12 category: 'Artifact',
13 session_id: sessionId,
14 project_id: project?.id,
15 project_name: project?.productName,
16 project_type: project?.type,
17 file_name: fileName,
18 expanded_lines: totalFoldedLines,
19 version: version,
20 });
21 };
22
910 const handleExpand = (totalFoldedLines: number, fileName: string) => {
1011 amplitude.track('Code Diff Expanded', {
1112 category: 'Artifact',
1213 session_id: sessionId,
1314 project_id: project?.id,
1415 project_name: project?.productName,
1516 project_type: project?.type,
1617 file_name: fileName,
1718 expanded_lines: totalFoldedLines,
1819 version: version,
1920 });
2021 };
2122
2223 return (
2324 <div className='flex-grow overflow-y-auto h-full'>
2425 {exceptIdenticalPatchFiles.map((patchFile, idx) => (
2526 <div
2627 className={cn(
2728 'catch-code-diff w-full overflow-x-auto border border-solid border-slate-200 rounded-lg',
2829 '[&_pre]:!leading-[20px]',
2930 )}
3031 key={idx}
3132 >
3233 <MemoizedReactDiff
3334 oldValue={patchFile.originalContent}
apps/www/hooks/useAmplitudeUser.ts
1import { useEffect } from 'react';
2import * as amplitude from '@amplitude/analytics-browser';
3export function useAmplitudeUser() {
4 useEffect(() => {
5 const setUserProperties = async () => {
6 const preferredLanguage = navigator.language || 'en-US';
7 const lastLoginDate = new Date().toISOString();
8 amplitude.identify(new amplitude.Identify()
9 .set('preferredLanguage', preferredLanguage)
10 .set('lastLoginDate', lastLoginDate)
11 );
12 };
13 setUserProperties();
14 }, []);
15}

This custom hook sets user properties for Amplitude tracking. It's using the browser's language settings and the current timestamp for the last login date. Be aware that this will update the user properties on every mount of the component using this hook, which might not be the desired behavior for the 'lastLoginDate' property in all cases.

apps/www/package.json
4 "@amplitude/analytics-browser": "^2.3.8",

SDK 
setup
 makes your product 
slower to 
generate revenue
.

SDK setup is a time-consuming hassle for both user and the company.
It often takes a months with endless back-and-forth emails.

Let Catch Do It

Using Catch is like sending a solution engineer on-site.
Seamless setup in minutes. Empower customers, amplify growth.

Chat to Pull Request

Chat to Pull Request

Users can chat and get pull request. It will reduces customer support workloads.

“Try this on my code” Button

“Try this on my code” Button

Just put a button on your docs. Then users can install your SDK in minutes.

SDK Migration Copilot

SDK Migration Copilot

Take your competitors’ users in a minute. AI is good at code transformation.

Import Local Code with CLI

Import Local Code with CLI

Quickly add local files to your project with a CLI command.

How it works?

Connect your repo

Connect to GitHub and select a repo to work on.

You can also connect your local code with CLI.

Catch drastically cut down our time.
I loved how it magically inserted codes in the right places on our app’s codebase by reusing our existing logic.

Daehyun Yoon
Co-Founder of Standada

Secure by design.

E2E Encryption

Code uploads are E2E encrypted, and protected by AES-256 CDC and RSA-4096 encryption.

Local Upload

Connect your local project using CLI with a secure connection, even if you are not using GitHub. Learn More

Sandboxed Environment

Codes are separately stored on a E2E-encrypted sandbox, and deleted after a session.

Interested in?
We’ll get in touch in 24 hours.

Get a custom demo