Skip to content

Commit 9c2bff7

Browse files
committed
stop tracking iframe pageviews
1 parent 9222288 commit 9c2bff7

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

web/app/lib/constants/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ export const REFERRAL_DISCOUNT_CODE = 'REFERRAL_DISCOUNT'
369369

370370
export const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined'
371371

372+
export const isIframe = isBrowser && window.self !== window.top
373+
372374
export type ThemeType = 'dark' | 'light'
373375
export const SUPPORTED_THEMES = ['light', 'dark']
374376

web/app/utils/analytics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _includes from 'lodash/includes'
22
import * as Swetrix from 'swetrix'
33

4-
import { isBrowser, isDevelopment, isSelfhosted } from '~/lib/constants'
4+
import { isBrowser, isDevelopment, isIframe, isSelfhosted } from '~/lib/constants'
55

66
const SWETRIX_PID = 'STEzHcB1rALV'
77

@@ -108,7 +108,7 @@ Swetrix.init(SWETRIX_PID, {
108108
const BLOG_PAGE_REGEX = /^\/blog\/.+$/
109109

110110
export const trackViews = () => {
111-
if (isSelfhosted || !isBrowser) {
111+
if (isSelfhosted || !isBrowser || isIframe) {
112112
return
113113
}
114114

0 commit comments

Comments
 (0)