Skip to content

Commit

Permalink
feat: added analytics events
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdavis committed Jul 12, 2024
1 parent 8805d5e commit 5d8f401
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/registry/app/[username]/letter/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSearchParams } from 'next/navigation';
import ReactMarkdown from 'react-markdown';
import Hero from '../../../src/ui/Hero';
import Loading from '../../components/Loading';
import { track } from '@vercel/analytics/server';

export default function Letter({ params }) {
const searchParams = useSearchParams();
Expand All @@ -29,6 +30,7 @@ export default function Letter({ params }) {

useEffect(() => {
if (submitting) {
track('ResumeLetter', { username });
const fetchData = async () => {
try {
const response = await axios.post('/api/letter', {
Expand Down
2 changes: 2 additions & 0 deletions apps/registry/app/[username]/suggestions/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect, useState } from 'react';
import Hero from '../../../src/ui/Hero';
import ReactMarkdown from 'react-markdown';
import Loading from '../../components/Loading';
import { track } from '@vercel/analytics/server';

export default function Suggestions({ params }) {
const { username } = params;
Expand All @@ -15,6 +16,7 @@ export default function Suggestions({ params }) {

useEffect(() => {
if (submitting) {
track('ResumeSuggestions', { username });
const fetchData = async () => {
try {
const response = await axios.post('/api/suggestions', {
Expand Down
4 changes: 3 additions & 1 deletion apps/registry/app/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { find } from 'lodash';
import axios from 'axios';
import ResumeEditor from './ResumeEditor';
import CreateResume from './CreateResume';
import { track } from '@vercel/analytics/server';
// @todo - add json schema to editor
//codesandbox.io/p/sandbox/monaco-editor-json-validation-example-gue0q?file=%2Fsrc%2FApp.js

Expand Down Expand Up @@ -203,7 +204,7 @@ export default async function Page() {
async function updateGist(resume) {
'use server';
const octokit = new Octokit({ auth: session.accessToken });

track('ResumeUpdate', { username: login });
if (gistId) {
await octokit.rest.gists.update({
gist_id: gistId,
Expand All @@ -219,6 +220,7 @@ export default async function Page() {

async function createGist() {
'use server';
track('ResumeCreate', { username: login });
const octokit = new Octokit({ auth: session.accessToken });

const response = await octokit.rest.gists.create({
Expand Down
3 changes: 2 additions & 1 deletion apps/registry/app/components/SignIn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Github } from 'lucide-react';
import { signIn } from '../../auth';

import { track } from '@vercel/analytics/server';
export default function SignIn() {
return (
<div className="text-lg m-8 w-[400px] mx-auto p-8 bg-white rounded-lg shadow-md">
Expand All @@ -21,6 +21,7 @@ export default function SignIn() {
<form
action={async () => {
'use server';
track('Signin');
await signIn('github');
}}
>
Expand Down

0 comments on commit 5d8f401

Please sign in to comment.