mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-04-19 19:01:19 +00:00
tracking events for new signups, course, resource, and subscription payments
This commit is contained in:
parent
aab1d5c6ce
commit
d23e98f535
@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { LightningAddress } from '@getalby/lightning-tools';
|
||||
import { track } from '@vercel/analytics';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { ProgressSpinner } from 'primereact/progressspinner';
|
||||
@ -76,6 +77,7 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
|
||||
const result = await axios.post('/api/purchase/course', purchaseData);
|
||||
|
||||
if (result.status === 200) {
|
||||
track('Course Payment', { courseId: courseId });
|
||||
if (onSuccess) onSuccess(response);
|
||||
} else {
|
||||
throw new Error('Failed to update user purchases');
|
||||
|
@ -1,6 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { track } from '@vercel/analytics';
|
||||
import { LightningAddress } from '@getalby/lightning-tools';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { useSession } from 'next-auth/react';
|
||||
@ -73,6 +74,7 @@ const ResourcePaymentButton = ({ lnAddress, amount, onSuccess, onError, resource
|
||||
const result = await axios.post('/api/purchase/resource', purchaseData);
|
||||
|
||||
if (result.status === 200) {
|
||||
track('Resource Payment', { resourceId: resourceId });
|
||||
if (onSuccess) onSuccess(response);
|
||||
} else {
|
||||
throw new Error('Failed to update user purchases');
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Button } from 'primereact/button';
|
||||
import { ProgressSpinner } from 'primereact/progressspinner';
|
||||
import { track } from '@vercel/analytics';
|
||||
import { initializeBitcoinConnect } from './BitcoinConnect';
|
||||
import { LightningAddress } from '@getalby/lightning-tools';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
@ -74,6 +73,7 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio
|
||||
|
||||
const handlePaymentSuccess = async (response) => {
|
||||
console.log('Payment successful', response);
|
||||
track('Subscription Payment', { method: "pay_as_you_go" });
|
||||
showToast('success', 'Payment Successful', 'Your payment has been processed successfully.');
|
||||
if (onSuccess) onSuccess(response);
|
||||
};
|
||||
@ -131,6 +131,7 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio
|
||||
});
|
||||
|
||||
if (subscriptionResponse.status === 200) {
|
||||
track('Subscription Payment', { method: "recurring" });
|
||||
showToast('success', 'Subscription Setup', 'Recurring subscription setup successful!');
|
||||
if (onRecurringSubscriptionSuccess) onRecurringSubscriptionSuccess();
|
||||
} else {
|
||||
@ -184,6 +185,7 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio
|
||||
});
|
||||
|
||||
if (subscriptionResponse.status === 200) {
|
||||
track('Subscription Payment', { method: "recurring-manual" });
|
||||
showToast('success', 'NWC', 'Subscription setup successful!');
|
||||
if (onRecurringSubscriptionSuccess) onRecurringSubscriptionSuccess();
|
||||
} else {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import NextAuth from "next-auth";
|
||||
import { track } from '@vercel/analytics/server';
|
||||
import CredentialsProvider from "next-auth/providers/credentials";
|
||||
import EmailProvider from "next-auth/providers/email";
|
||||
import NDK from "@nostr-dev-kit/ndk";
|
||||
@ -47,6 +48,7 @@ const authorize = async (pubkey) => {
|
||||
} else {
|
||||
// Create user
|
||||
if (profile) {
|
||||
track('Nostr Signup', { pubkey: pubkey, method: "nostr" });
|
||||
const fields = await findKind0Fields(profile);
|
||||
const payload = { pubkey, username: fields.username, avatar: fields.avatar };
|
||||
|
||||
@ -110,7 +112,14 @@ export const authOptions = {
|
||||
pass: process.env.EMAIL_SERVER_PASSWORD
|
||||
}
|
||||
},
|
||||
from: process.env.EMAIL_FROM
|
||||
from: process.env.EMAIL_FROM,
|
||||
sendVerificationRequest: async ({ identifier, url, provider }) => {
|
||||
track('Email Signup', { email: identifier });
|
||||
|
||||
// Use the default sendVerificationRequest function or customize it
|
||||
const { sendVerificationRequest } = require("next-auth/providers/email");
|
||||
await sendVerificationRequest({ identifier, url, provider });
|
||||
}
|
||||
}),
|
||||
],
|
||||
callbacks: {
|
||||
|
@ -8,8 +8,6 @@ import { InputText } from 'primereact/inputtext';
|
||||
export default function SignIn() {
|
||||
const [email, setEmail] = useState("")
|
||||
const [showEmailInput, setShowEmailInput] = useState(false)
|
||||
const [nostrPubkey, setNostrPubkey] = useState("")
|
||||
const [nostrPrivkey, setNostrPrivkey] = useState("")
|
||||
const {ndk, addSigner} = useNDKContext();
|
||||
const { data: session, status } = useSession(); // Get the current session's data and status
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user