Skip to content

Commit

Permalink
code review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
zikaari committed Aug 28, 2023
1 parent 8333307 commit bc7e8f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
21 changes: 5 additions & 16 deletions packages/browser/src/plugins/page-enrichment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function utm(query: string): Campaign {
const [k, v = ''] = str.split('=')
if (k.includes('utm_') && k.length > 4) {
let utmParam = k.substr(4) as keyof Campaign
if ((utmParam as string) === 'campaign') {
if (utmParam === 'campaign') {
utmParam = 'name'
}
acc[utmParam] = gracefulDecodeURIComponent(v)
Expand All @@ -158,9 +158,8 @@ function referrerId(
}>(disablePersistance ? [] : [new CookieStorage(getCookieOptions())])

const stored = storage.get('s:context.referrer')
let ad: Ad | undefined | null = ads(query)

ad = ad ?? stored
const ad = ads(query) ?? stored

if (!ad) {
return
Expand Down Expand Up @@ -222,19 +221,9 @@ class PageEnrichmentPlugin implements Plugin {
evtCtx.locale = locale
}

if (!evtCtx.library) {
const type = getVersionType()
if (type === 'web') {
evtCtx.library = {
name: 'analytics.js',
version: `next-${version}`,
}
} else {
evtCtx.library = {
name: 'analytics.js',
version: `npm:next-${version}`,
}
}
evtCtx.library ??= {
name: 'analytics.js',
version: `${getVersionType() === 'web' ? 'next' : 'npm:next'}-${version}`,
}

if (query && !evtCtx.campaign) {
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/events/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ export type Traits = UserTraits | GroupTraits

export type Campaign = {
name: string
term: string
source: string
medium: string
content: string
[key: string]: string
}

0 comments on commit bc7e8f1

Please sign in to comment.