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

adds some usage analytics #67

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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