custom: support promotekit affiliate
This commit is contained in:
parent
80763b4efb
commit
34b7c1c74f
10
env.example
10
env.example
@ -131,7 +131,15 @@ NEXT_PUBLIC_DISCORD_WIDGET_SERVER_ID=""
|
||||
NEXT_PUBLIC_DISCORD_WIDGET_CHANNEL_ID=""
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Affiliate (Affonso)
|
||||
# Affiliate
|
||||
# https://mksaas.com/docs/affiliate
|
||||
# -----------------------------------------------------------------------------
|
||||
# Affonso
|
||||
# https://affonso.com/
|
||||
# -----------------------------------------------------------------------------
|
||||
NEXT_PUBLIC_AFFILIATE_AFFONSO_ID=""
|
||||
# -----------------------------------------------------------------------------
|
||||
# PromoteKit
|
||||
# https://www.promotekit.com/
|
||||
# -----------------------------------------------------------------------------
|
||||
NEXT_PUBLIC_AFFILIATE_PROMOTEKIT_ID=""
|
||||
|
@ -5,7 +5,8 @@ import {
|
||||
fontNotoSansMono,
|
||||
fontNotoSerif,
|
||||
} from '@/assets/fonts';
|
||||
import { AffonsoScript } from '@/components/affiliate/affonso';
|
||||
import AffonsoScript from '@/components/affiliate/affonso';
|
||||
import PromotekitScript from '@/components/affiliate/promotekit';
|
||||
import { TailwindIndicator } from '@/components/layout/tailwind-indicator';
|
||||
import { routing } from '@/i18n/routing';
|
||||
import { cn } from '@/lib/utils';
|
||||
@ -44,6 +45,7 @@ export default async function LocaleLayout({
|
||||
<html suppressHydrationWarning lang={locale}>
|
||||
<head>
|
||||
<AffonsoScript />
|
||||
<PromotekitScript />
|
||||
</head>
|
||||
<body
|
||||
suppressHydrationWarning
|
||||
|
@ -8,7 +8,7 @@ import Script from 'next/script';
|
||||
*
|
||||
* https://affonso.com
|
||||
*/
|
||||
export function AffonsoScript() {
|
||||
export default function AffonsoScript() {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
return null;
|
||||
}
|
||||
|
34
src/components/affiliate/promotekit.tsx
Normal file
34
src/components/affiliate/promotekit.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
'use client';
|
||||
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import Script from 'next/script';
|
||||
|
||||
/**
|
||||
* PromoteKit
|
||||
*
|
||||
* https://www.promotekit.com
|
||||
*/
|
||||
export default function PromotekitScript() {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!websiteConfig.features.enablePromotekitAffiliate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const promotekitKey = process.env.NEXT_PUBLIC_AFFILIATE_PROMOTEKIT_ID;
|
||||
if (!promotekitKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Script
|
||||
src="https://cdn.promotekit.com/promotekit.js"
|
||||
data-promotekit={promotekitKey}
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
@ -53,6 +53,21 @@ export function CheckoutButton({
|
||||
|
||||
const mergedMetadata = metadata ? { ...metadata } : {};
|
||||
|
||||
// add promotekit_referral to metadata if enabled promotekit affiliate
|
||||
if (websiteConfig.features.enablePromotekitAffiliate) {
|
||||
const promotekitReferral =
|
||||
typeof window !== 'undefined'
|
||||
? (window as any).promotekit_referral
|
||||
: undefined;
|
||||
if (promotekitReferral) {
|
||||
console.log(
|
||||
'create checkout button, promotekitReferral:',
|
||||
promotekitReferral
|
||||
);
|
||||
mergedMetadata.promotekit_referral = promotekitReferral;
|
||||
}
|
||||
}
|
||||
|
||||
// add affonso_referral to metadata if enabled affonso affiliate
|
||||
if (websiteConfig.features.enableAffonsoAffiliate) {
|
||||
const affonsoReferral =
|
||||
|
@ -36,6 +36,7 @@ export const websiteConfig: WebsiteConfig = {
|
||||
enableDiscordWidget: true,
|
||||
enableUpgradeCard: true,
|
||||
enableAffonsoAffiliate: false,
|
||||
enablePromotekitAffiliate: false,
|
||||
},
|
||||
routes: {
|
||||
defaultLoginRedirect: '/dashboard',
|
||||
|
1
src/types/index.d.ts
vendored
1
src/types/index.d.ts
vendored
@ -68,6 +68,7 @@ export interface FeaturesConfig {
|
||||
enableDiscordWidget?: boolean; // Whether to enable the discord widget
|
||||
enableUpgradeCard?: boolean; // Whether to enable the upgrade card in the sidebar
|
||||
enableAffonsoAffiliate?: boolean; // Whether to enable affonso affiliate
|
||||
enablePromotekitAffiliate?: boolean; // Whether to enable promotekit affiliate
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user