Skip to content

Commit

Permalink
Merge pull request #67 from ThatConference/cs/va
Browse files Browse the repository at this point in the history
adds some usage analytics
  • Loading branch information
theClarkSell committed Sep 18, 2023
2 parents 55bf2db + 9acd595 commit bfd8918
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/_components/newsletter/HubspotForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { superForm, superValidateSync } from 'sveltekit-superforms/client';
import Icon from 'svelte-awesome';
import * as flashModule from 'sveltekit-flash-message/client';
import va from '@vercel/analytics';
import { envelope } from '$components/svelte-awesome-icons';
import newsletterSchema from '$lib/formSchemas/newsletter';
Expand All @@ -28,6 +29,9 @@
syncFlashMessage: false,
flashMessage: {
module: flashModule
},
onResult: () => {
va.track('form:newsletter:submitted');
}
}
);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/cart/cartMachine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createMachine, assign } from 'xstate';
import lodash from 'lodash';
import dayjs from 'dayjs';
import isBetween from 'dayjs/plugin/isBetween.js';
import va from '@vercel/analytics';

import { log } from '../error';
import createConfig from './cartConfig';
Expand Down Expand Up @@ -148,6 +149,7 @@ function createServices() {
}

const { id, quantity = 1, price, name, description, productType } = event;
va.track('cart:add-item', { name, price, productType });

const currentCart = context.cart;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import * as flashModule from 'sveltekit-flash-message/client';
import { AlertOctagon } from 'lucide-svelte';
import Select from 'svelte-select';
import va from '@vercel/analytics';
import { DisabledShell, Shell } from '$elements/buttons';
Expand All @@ -20,6 +21,11 @@
taintedMessage: null, // todo - @csell phone number formatting taints the form.
flashMessage: {
module: flashModule
},
onUpdated: ({ form }) => {
if (form.valid) {
va.track('form:emergency-contact:submitted');
}
}
});
Expand Down
6 changes: 4 additions & 2 deletions src/routes/(admin my)/my/profiles/primary/profileForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import * as flashModule from 'sveltekit-flash-message/client';
import Checkbox from 'svelte-checkbox';
import { AlertOctagon } from 'lucide-svelte';
import va from '@vercel/analytics';
import { Shell, DisabledShell } from '$elements/buttons';
Expand All @@ -18,8 +19,9 @@
flashMessage: {
module: flashModule
},
onUpdated: ({ form }) => {
if (form.valid) {
onResult: ({ result }) => {
if (result.status === 303) {
va.track('form:system-profile:submitted');
invalidateAll();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import Checkbox from 'svelte-checkbox';
import lodash from 'lodash';
import { AlertOctagon } from 'lucide-svelte';
import va from '@vercel/analytics';
import config from '$lib/config.public';
import publicProfileSchema from '$lib/formSchemas/publicProfile';
Expand All @@ -33,6 +34,7 @@
onUpdated: ({ form }) => {
if (form.valid) {
invalidateAll();
va.track('form:public-profile:submitted');
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
export let sForm;
import { getContext } from 'svelte';
import { invalidateAll } from '$app/navigation';
import { superForm } from 'sveltekit-superforms/client';
import * as flashModule from 'sveltekit-flash-message/client';
import { AlertOctagon } from 'lucide-svelte';
import Select from 'svelte-select';
import va from '@vercel/analytics';
import { DisabledShell, Shell } from '$elements/buttons';
import sharedProfileFormSchema from '$lib/formSchemas/sharedProfile';
Expand All @@ -20,6 +22,12 @@
taintedMessage: null, // todo - @csell phone number formatting taints the form.
flashMessage: {
module: flashModule
},
onUpdated: ({ form }) => {
if (form.valid) {
invalidateAll();
va.track('form:public-profile:submitted');
}
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/routes/(root)/orders/_components/_Cart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import orderMutations from '$dataSources/api.that.tech/orders/mutations';
import CartItem from './_CartItem.svelte';
import { tagEvent } from '$lib/tagEvent';
import va from '@vercel/analytics';
const { state, send } = getContext('cart');
let apiErrorMessage = '';
Expand All @@ -23,6 +24,7 @@
level: 'info'
});
va.track('cart:handle-checkout');
Sentry.configureScope((scope) => scope.setTransactionName('Handle Checkout'));
const { eventId, cart } = $state.context;
Expand All @@ -47,6 +49,7 @@
);
if (checkoutSessionResults.success) {
va.track('cart:handle-checkout:redirect');
stripe.redirectToCheckout({ sessionId: checkoutSessionResults.stripeCheckoutId });
} else {
Sentry.captureException(checkoutSessionResults.message);
Expand Down

1 comment on commit bfd8918

@vercel
Copy link

@vercel vercel bot commented on bfd8918 Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.