-
Notifications
You must be signed in to change notification settings - Fork 12
feat(analytics): add click extension link event tracking for banner and offerwall #683
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
Open
kjmitchelljr
wants to merge
44
commits into
main
Choose a base branch
from
feat/682-cdn-analytics-events
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
6579ea8
feat(analytics): add tools event tracking and shared event constants
kjmitchelljr 118e943
Merge branch 'main' into feat/663-tools-analytics-events
kjmitchelljr 3dd8b6a
Resolve pnpm lockfile
kjmitchelljr 95649ef
Merge branch 'main' into feat/663-tools-analytics-events
kjmitchelljr f5b43de
removed shared analytics and made TrackFn constrained to ToolsEventMap
kjmitchelljr 613f985
resolve pnpm lockfile
kjmitchelljr 5b8bc1c
use id instead of authServer for wallet provider capture
kjmitchelljr 51274ac
Add simple tracking for fields changed
kjmitchelljr db4fd66
Merge branch 'main' into feat/663-tools-analytics-events
kjmitchelljr 100df55
Revert "Add simple tracking for fields changed"
kjmitchelljr 28ae2bc
Remove tools prefix
kjmitchelljr 4613aa0
Merge branch 'main' into feat/663-tools-analytics-events
kjmitchelljr 598f8e9
Remove tool settings and update link tag tracking
kjmitchelljr 5dcc993
Tool name added to event
kjmitchelljr 5890bda
Merge branch 'main' into feat/663-tools-analytics-events
kjmitchelljr 9621e4a
Add analytic tracking for extension link clicks on banner and offerwall
kjmitchelljr 8e74ad4
prettier fix
kjmitchelljr 6a750ba
lint fix
kjmitchelljr 6827127
Clean up code - don't need to match frontend as much
kjmitchelljr 81753d0
Merge branch 'main' into feat/663-tools-analytics-events
kjmitchelljr 5f1532b
Simplify logic for analytic events being tracked in umami
kjmitchelljr 6cbdcec
Merge branch 'main' into feat/663-tools-analytics-events
kjmitchelljr c473b26
Merge branch 'feat/663-tools-analytics-events' into feat/682-cdn-anal…
kjmitchelljr 1d9ee2d
Merge branch 'main' into feat/682-cdn-analytics-events
kjmitchelljr e0c0f6a
feat(analytics): proxy CDN extension-link clicks to Umami via API
kjmitchelljr 132294d
Merge branch 'main' into feat/682-cdn-analytics-events
kjmitchelljr 6858838
feat(analytics): proxy Umami payload andinclude url and extension lin…
kjmitchelljr 9db44cd
Resolve prettier issue
kjmitchelljr 8e215c8
set prettier path for pnpm
kjmitchelljr 918c997
Merge branch 'main' into feat/682-cdn-analytics-events
kjmitchelljr f671e58
Resolve issue where zValidator wasn't accepting text/plain and fix nit
kjmitchelljr a1b024a
Use build time variables for API and hostname from CDN
kjmitchelljr 903bfe1
Added event detail in controller
kjmitchelljr 1d22a5a
introduce trackEventFactory and rename events
kjmitchelljr 19ba347
Merge branch 'main' into feat/682-cdn-analytics-events
kjmitchelljr 2ce05a5
Remove bubbles and composed flags on click-extension-link
kjmitchelljr b8b5162
Fix prettier error
kjmitchelljr 0aad2d9
Forward Cloudflare geo headers to Umami
kjmitchelljr 9fc349e
Add a few mock tests if anything to catch any future changes
kjmitchelljr 87b0a5c
Remove API_HOST variable
kjmitchelljr a6063d1
add comments for schema object and afterEach for each test
kjmitchelljr 2876510
Export of EventsData and more ergonomic function handling
kjmitchelljr 2354170
Nit - clean up event url
kjmitchelljr af0ff16
Merge branch 'main' into feat/682-cdn-analytics-events
kjmitchelljr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { UMAMI_HOST, UMAMI_WEBSITE_ID } from '@shared/defines' | ||
|
|
||
| type ExtensionLinkSource = 'banner' | 'offerwall' | ||
| type ClickLinkEvent = `click_link_${ExtensionLinkSource}` | ||
|
|
||
| export type CdnEventMap = { | ||
| [K in ClickLinkEvent]: undefined | ||
| } | ||
|
|
||
| type TrackArgs<E extends keyof CdnEventMap> = CdnEventMap[E] extends undefined | ||
| ? [eventName: E] | ||
| : [eventName: E, data: CdnEventMap[E]] | ||
|
|
||
| let umamiInjected = false | ||
|
|
||
| /** | ||
| * Appended the Umami tracker script so it's loaded before any | ||
| * trackEvent() call fires (avoids a race on the first user interaction). | ||
| */ | ||
| export function injectUmami() { | ||
| if (!UMAMI_HOST || !UMAMI_WEBSITE_ID) return | ||
| if (typeof window === 'undefined' || typeof document === 'undefined') return | ||
| if (window.umami || umamiInjected) return | ||
|
|
||
| umamiInjected = true | ||
| const script = document.createElement('script') | ||
| script.defer = true | ||
| script.src = `${UMAMI_HOST}/script.js` | ||
| script.setAttribute('data-website-id', UMAMI_WEBSITE_ID) | ||
|
kjmitchelljr marked this conversation as resolved.
Outdated
|
||
| document.head.appendChild(script) | ||
| } | ||
|
|
||
| export function trackEvent<E extends keyof CdnEventMap>( | ||
| ...args: TrackArgs<E> | ||
| ): void { | ||
| const [eventName, data] = args as [E, CdnEventMap[E] | undefined] | ||
| injectUmami() | ||
| window.umami?.track(eventName, data) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { Tool } from '@shared/types' | ||
|
|
||
| type ProfileSavedEvent = `${Tool}_profile_saved` | ||
| type ScriptGeneratedEvent = `${Tool}_script_generated` | ||
|
|
||
| export type ToolsEventMap = { | ||
| click_card_tool: { link: string } | ||
| wallet_connected: { wallet_provider: string } | ||
| wallet_disconnected: undefined | ||
| link_tag_generated: { wallet_provider: string } | ||
| } & { | ||
| [K in ProfileSavedEvent | ScriptGeneratedEvent]: undefined | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.