@schibsted/niche-tracking
Advanced tools
Comparing version 4.6.9 to 4.7.0
@@ -8,4 +8,5 @@ export declare const originToEngagementFormat: (data: { | ||
'@type': string; | ||
terms: string | undefined; | ||
url: string; | ||
}; | ||
export declare const withReferrer: (fn: any) => (options: any, trackerOptions?: any) => any; |
@@ -1,8 +0,12 @@ | ||
import { get } from '../utils'; | ||
import { get, getSearchParam } from '../utils'; | ||
import state from './state'; | ||
export const originToEngagementFormat = (data) => ({ | ||
'@id': data.id, | ||
'@type': data.type, | ||
url: data.url, | ||
}); | ||
export const originToEngagementFormat = (data) => { | ||
const terms = getSearchParam('utm_term'); | ||
return { | ||
'@id': data.id, | ||
'@type': data.type, | ||
terms, | ||
url: data.url, | ||
}; | ||
}; | ||
export const withReferrer = (fn) => (options, trackerOptions) => { | ||
@@ -9,0 +13,0 @@ if (!options.object) { |
@@ -6,1 +6,2 @@ export function isWeb(): boolean; | ||
export function isPromise(obj: any): boolean; | ||
export function getSearchParam(key: any): string | undefined; |
@@ -8,1 +8,12 @@ export const isWeb = () => typeof window !== 'undefined'; | ||
export const isPromise = (obj) => !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; | ||
export const getSearchParam = (key) => { | ||
try { | ||
const params = new URL(document.location).searchParams; | ||
const value = params.get(key); | ||
return value !== null && value !== void 0 ? value : undefined; | ||
} | ||
catch (error) { | ||
// | ||
} | ||
return undefined; | ||
}; |
{ | ||
"name": "@schibsted/niche-tracking", | ||
"version": "4.6.9", | ||
"version": "4.7.0", | ||
"description": "Package containing tracking logic reused between multiple Schibsted niche sites", | ||
@@ -26,3 +26,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "3ec7a2376961132c7bca25adaa397e72a3f8cc32" | ||
"gitHead": "f64531781d6455ef3d5f27f9883eb7f7b86bc493" | ||
} |
@@ -1,10 +0,15 @@ | ||
import { get } from '../utils'; | ||
import { get, getSearchParam } from '../utils'; | ||
import state from './state'; | ||
export const originToEngagementFormat = (data: { id: string; type: string; url: string }) => ({ | ||
'@id': data.id, | ||
'@type': data.type, | ||
url: data.url, | ||
}); | ||
export const originToEngagementFormat = (data: { id: string; type: string; url: string }) => { | ||
const terms = getSearchParam('utm_term'); | ||
return { | ||
'@id': data.id, | ||
'@type': data.type, | ||
terms, | ||
url: data.url, | ||
}; | ||
}; | ||
export const withReferrer = (fn: any) => (options: any, trackerOptions?: any) => { | ||
@@ -11,0 +16,0 @@ if (!options.object) { |
@@ -16,1 +16,13 @@ export const isWeb = () => typeof window !== 'undefined'; | ||
!!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; | ||
export const getSearchParam = (key) => { | ||
try { | ||
const params = new URL(document.location).searchParams; | ||
const value = params.get(key); | ||
return value ?? undefined; | ||
} catch (error) { | ||
// | ||
} | ||
return undefined; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70092
1458