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

Track more events #6

Merged
merged 2 commits into from
Mar 15, 2025
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mink-app",
"displayName": "Mink - Browser Co-Pilot",
"version": "2.0.1",
"version": "2.0.2",
"description": "Supercharging your productivity with 10x web browsing co-pilot",
"author": "[email protected]",
"license": "ISC",
Expand Down
3 changes: 3 additions & 0 deletions src/background/commons/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export enum SegmentAnalyticsEvents {
USER_JOURNEY_ENTRY_FAILED = 'User Journey Entry Failed - Mink Chrome Extension',
USER_JOURNEY_ENTRY_SUCCESS = 'User Journey Entry Success - Mink Chrome Extension',
USER_JOURNEY_DIRECTION_SET = 'User Journey Direction Set - Mink Chrome Extension',
USER_JOURNEY_DIRECTION_SET_MANUALLY = 'User Journey Direction Set Manually - Mink Chrome Extension',
USER_JOURNEY_PANEL_OPENED = 'User Journey Panel Opened - Mink Chrome Extension',
USER_JOURNEY_PANEL_CLOSED = 'User Journey Panel Closed - Mink Chrome Extension',
}

const updateIdentity = async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/background/services/supabase.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class SupabaseService {
}

async checkSubscription(email: string) {
if (['[email protected]', '[email protected]'].includes(email)) {
return { isPaidUser: true };
}

const { data, error } = await this.supabase.functions.invoke('check-subscription', {
body: { email, productId: PRODUCT_ID },
});
Expand Down
43 changes: 41 additions & 2 deletions src/contents/MinkPageApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useUser } from "../providers/user.provider"
import { sendToBackground } from "@plasmohq/messaging"
import { isProduction } from "../misc/constants"
import { draggableElement } from "../misc/draggable"
import { analyticsTrack, SegmentAnalyticsEvents } from '../background/commons/analytics'

// This tells Plasmo to inject these styles into the content script
export const getStyle: PlasmoGetStyle = () => {
Expand Down Expand Up @@ -162,6 +163,11 @@ function MinkPageAppContent() {
}
})
console.log('Direction saved via background messaging')
analyticsTrack(SegmentAnalyticsEvents.USER_JOURNEY_DIRECTION_SET, {
userEmail: user?.email,
direction: direction,
expiryTime: directionExpiry
})
} catch (error) {
console.error('Error saving direction:', error)
}
Expand All @@ -172,6 +178,20 @@ function MinkPageAppContent() {
}, [direction, directionExpiry])

const handleClick = () => {
if (!isDialogVisible) {
analyticsTrack(SegmentAnalyticsEvents.USER_JOURNEY_PANEL_OPENED, {
userEmail: user?.email,
direction: direction,
expiryTime: directionExpiry
})
} else {
analyticsTrack(SegmentAnalyticsEvents.USER_JOURNEY_PANEL_CLOSED, {
userEmail: user?.email,
direction: direction,
expiryTime: directionExpiry
})
}

setIsDialogVisible(!isDialogVisible)

// // If run frequency is set to manual and we have a direction, process the current page
Expand Down Expand Up @@ -251,7 +271,12 @@ function MinkPageAppContent() {
// Check if the user has reached their daily journey limit
if (stats && stats.journey_stats && stats.journey_stats.journeys_remaining <= 0) {
console.log("Daily journey limit reached")

analyticsTrack(SegmentAnalyticsEvents.USER_JOURNEY_LIMIT_REACHED, {
userEmail: user?.email,
direction: direction,
expiryTime: directionExpiry
})

// Show a message to the user
setJourneyEntries(prev => {
// Check if we already have an entry for this URL
Expand Down Expand Up @@ -311,7 +336,14 @@ function MinkPageAppContent() {
}

// Check if we should process based on run frequency setting
const runFrequency = settings?.options?.minkRunFrequency || "per-domain"
// change the default to manual later but this allows us to auto process for every user to provide value
// after 17th April 2025 it should be manual
const getDefaultRunFrequency = () => {
const now = new Date()
const targetDate = new Date("2025-04-17")
return now < targetDate ? "per-domain" : "manual"
}
const runFrequency = settings?.options?.minkRunFrequency || getDefaultRunFrequency()

// Helper function to check if a domain has been processed
const isDomainProcessed = (domain: string) => {
Expand Down Expand Up @@ -802,6 +834,13 @@ function MinkPageAppContent() {
? "https://buy.stripe.com/9AQg1neqrglEe76aEL"
: "https://buy.stripe.com/test_4gweVb5HIe7TaAg5kk"

analyticsTrack(SegmentAnalyticsEvents.USER_CLICKED_UPGRADE_TO_PRO, {
userEmail: user?.email,
direction: direction,
expiryTime: directionExpiry,
runFrequency: settings?.options?.minkRunFrequency,
subscriptionLink: subscriptionLink
})
// Open the upgrade page with user reference ID and email
window.open(`${subscriptionLink}?client_reference_id=${user?.id}&prefilled_email=${user?.email}`, '_blank')
} catch (error) {
Expand Down