|
| 1 | +import posthog from "posthog-js"; |
| 2 | + |
| 3 | +import type { Team } from "../api/team"; |
| 4 | + |
| 5 | +// ---------------------------- |
| 6 | +// CONTRACTS |
| 7 | +// ---------------------------- |
| 8 | + |
| 9 | +/** |
| 10 | + * ### Why do we need to report this event? |
| 11 | + * - To track the number of contracts deployed |
| 12 | + * - To track the number of contracts deployed on each chain |
| 13 | + * |
| 14 | + * ### Who is responsible for this event? |
| 15 | + * @jnsdls |
| 16 | + * |
| 17 | + */ |
| 18 | +export function reportContractDeployed(properties: { |
| 19 | + address: string; |
| 20 | + chainId: number; |
| 21 | + publisher: string | undefined; |
| 22 | + contractName: string | undefined; |
| 23 | +}) { |
| 24 | + posthog.capture("contract deployed", properties); |
| 25 | +} |
| 26 | + |
| 27 | +/** |
| 28 | + * ### Why do we need to report this event? |
| 29 | + * - To track the number of contracts that failed to deploy |
| 30 | + * - To track the error message of the failed contract deployment (so we can fix it / add workarounds) |
| 31 | + * |
| 32 | + * ### Who is responsible for this event? |
| 33 | + * @jnsdls |
| 34 | + * |
| 35 | + */ |
| 36 | +export function reportContractDeployFailed(properties: { |
| 37 | + errorMessage: string; |
| 38 | +}) { |
| 39 | + posthog.capture("contract deploy failed", properties); |
| 40 | +} |
| 41 | + |
| 42 | +// ---------------------------- |
| 43 | +// ONBOARDING (TEAM) |
| 44 | +// ---------------------------- |
| 45 | + |
| 46 | +/** |
| 47 | + * ### Why do we need to report this event? |
| 48 | + * - To track the number of teams that enter the onboarding flow |
| 49 | + * |
| 50 | + * ### Who is responsible for this event? |
| 51 | + * @jnsdls |
| 52 | + * |
| 53 | + */ |
| 54 | +export function reportOnboardingStarted() { |
| 55 | + posthog.capture("onboarding started"); |
| 56 | +} |
| 57 | + |
| 58 | +/** |
| 59 | + * ### Why do we need to report this event? |
| 60 | + * - To track the number of teams that select a paid plan during onboarding |
| 61 | + * - To know **which** plan was selected |
| 62 | + * |
| 63 | + * ### Who is responsible for this event? |
| 64 | + * @jnsdls |
| 65 | + * |
| 66 | + */ |
| 67 | +export function reportOnboardingPlanSelected(properties: { |
| 68 | + plan: Team["billingPlan"]; |
| 69 | +}) { |
| 70 | + posthog.capture("onboarding plan selected", properties); |
| 71 | +} |
| 72 | + |
| 73 | +/** |
| 74 | + * ### Why do we need to report this event? |
| 75 | + * - To track the number of teams that skip the plan-selection step during onboarding |
| 76 | + * |
| 77 | + * ### Who is responsible for this event? |
| 78 | + * @jnsdls |
| 79 | + * |
| 80 | + */ |
| 81 | +export function reportOnboardingPlanSelectionSkipped() { |
| 82 | + posthog.capture("onboarding plan selection skipped"); |
| 83 | +} |
| 84 | + |
| 85 | +/** |
| 86 | + * ### Why do we need to report this event? |
| 87 | + * - To track the number of teams that invite members during onboarding |
| 88 | + * - To track **how many** members were invited |
| 89 | + * |
| 90 | + * ### Who is responsible for this event? |
| 91 | + * @jnsdls |
| 92 | + * |
| 93 | + */ |
| 94 | +export function reportOnboardingMembersInvited(properties: { |
| 95 | + count: number; |
| 96 | +}) { |
| 97 | + posthog.capture("onboarding members invited", { |
| 98 | + count: properties.count, |
| 99 | + }); |
| 100 | +} |
| 101 | + |
| 102 | +/** |
| 103 | + * ### Why do we need to report this event? |
| 104 | + * - To track the number of teams that skip inviting members during onboarding |
| 105 | + * |
| 106 | + * ### Who is responsible for this event? |
| 107 | + * @jnsdls |
| 108 | + * |
| 109 | + */ |
| 110 | +export function reportOnboardingMembersSkipped() { |
| 111 | + posthog.capture("onboarding members skipped"); |
| 112 | +} |
| 113 | + |
| 114 | +/** |
| 115 | + * ### Why do we need to report this event? |
| 116 | + * - To track how many teams click the upsell (upgrade) button on the member-invite step during onboarding |
| 117 | + * |
| 118 | + * ### Who is responsible for this event? |
| 119 | + * @jnsdls |
| 120 | + * |
| 121 | + */ |
| 122 | +export function reportOnboardingMembersUpsellButtonClicked() { |
| 123 | + posthog.capture("onboarding members upsell clicked"); |
| 124 | +} |
| 125 | + |
| 126 | +/** |
| 127 | + * ### Why do we need to report this event? |
| 128 | + * - To track which plan is selected from the members-step upsell during onboarding |
| 129 | + * |
| 130 | + * ### Who is responsible for this event? |
| 131 | + * @jnsdls |
| 132 | + * |
| 133 | + */ |
| 134 | +export function reportOnboardingMembersUpsellPlanSelected(properties: { |
| 135 | + plan: Team["billingPlan"]; |
| 136 | +}) { |
| 137 | + posthog.capture("onboarding members upsell plan selected", properties); |
| 138 | +} |
| 139 | + |
| 140 | +/** |
| 141 | + * ### Why do we need to report this event? |
| 142 | + * - To track the number of teams that completed onboarding |
| 143 | + * |
| 144 | + * ### Who is responsible for this event? |
| 145 | + * @jnsdls |
| 146 | + * |
| 147 | + */ |
| 148 | +export function reportOnboardingCompleted() { |
| 149 | + posthog.capture("onboarding completed"); |
| 150 | +} |
0 commit comments