This repository has been archived by the owner on Jan 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4237d0
commit 0c9c9cd
Showing
22 changed files
with
274 additions
and
168 deletions.
There are no files selected for viewing
This file contains 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 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,29 @@ | ||
import { strEqualsIgnoreCase } from "live-connect-common"; | ||
import { DurableCache, NoOpCache, StorageHandlerBackedCache } from "../cache"; | ||
import { WrappedStorageHandler } from "../handlers/storage-handler"; | ||
import { StorageStrategies, StorageStrategy } from "../model/storage-strategy"; | ||
import { Enricher } from "../types"; | ||
|
||
type Input = { domain: string, storageHandler: WrappedStorageHandler, storageStrategy: StorageStrategy } | ||
type Output = { cache: DurableCache } | ||
|
||
export const enrichCache: Enricher<Input, Output> = state => { | ||
let cache | ||
|
||
if (strEqualsIgnoreCase(state.storageStrategy, StorageStrategies.cookie) && strEqualsIgnoreCase(state.storageStrategy, StorageStrategies.none)) { | ||
cache = NoOpCache | ||
} else if (strEqualsIgnoreCase(state.storageStrategy, StorageStrategies.ls)) { | ||
cache = new StorageHandlerBackedCache({ | ||
strategy: 'ls', | ||
storageHandler: state.storageHandler, | ||
domain: state.domain, | ||
}) | ||
} else { | ||
cache = new StorageHandlerBackedCache({ | ||
strategy: 'cookie', | ||
storageHandler: state.storageHandler, | ||
domain: state.domain, | ||
}) | ||
} | ||
return { ...state, cache } | ||
} |
This file contains 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,11 @@ | ||
import { CallHandler, EventBus } from "live-connect-common" | ||
import { WrappedCallHandler } from "../handlers/call-handler" | ||
import { Enricher } from "../types" | ||
|
||
type Input = { callHandler: CallHandler, eventBus: EventBus } | ||
type Output = { callHandler: WrappedCallHandler } | ||
|
||
export const enrichCallHandler: Enricher<Input, Output> = state => { | ||
const callHandler = new WrappedCallHandler(state.callHandler, state.eventBus) | ||
return { ...state, callHandler } | ||
} |
This file contains 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 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,9 @@ | ||
import { WrappedStorageHandler } from "../handlers/storage-handler" | ||
import { Enricher } from "../types" | ||
import { determineHighestAccessibleDomain } from "../utils/domain" | ||
|
||
type Input = { storageHandler: WrappedStorageHandler } | ||
type Output = { domain: string } | ||
|
||
export const enrichDomain: Enricher<Input, Output> = state => | ||
({ ...state, domain: determineHighestAccessibleDomain(state.storageHandler) }) |
This file contains 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,10 @@ | ||
import { EventBus } from "live-connect-common"; | ||
import { Enricher } from "../types"; | ||
import { register } from "../events/error-pixel"; | ||
import { WrappedCallHandler } from "../handlers/call-handler"; | ||
|
||
type Input = { eventBus: EventBus, domain: string, callHandler: WrappedCallHandler } | ||
|
||
export const enrichErrorPixel: Enricher<Input, {}> = ({ eventBus, domain, callHandler }) => { | ||
register(eventBus, domain, callHandler) | ||
} |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,18 +1,15 @@ | ||
import { State } from '../types' | ||
import { Enricher } from '../types' | ||
import { getPage, getReferrer, getContextElements } from '../utils/page' | ||
|
||
let _currentPage: State | null = null | ||
type Input = { privacyMode: boolean, contextSelectors: string, contextElementsLength: number } | ||
type Output = { pageUrl?: string, referrer?: string, contextElements: string } | ||
|
||
export function enrich(state: State): State { | ||
if (_currentPage) { | ||
return _currentPage | ||
} else { | ||
const result = { | ||
pageUrl: getPage(), | ||
referrer: getReferrer(), | ||
contextElements: getContextElements(state.privacyMode, state.contextSelectors, state.contextElementsLength) | ||
} | ||
_currentPage = result | ||
return result | ||
export const enrichPage: Enricher<Input, Output> = state => { | ||
return { | ||
...state, | ||
pageUrl: getPage(), | ||
referrer: getReferrer(), | ||
contextElements: getContextElements(state.privacyMode, state.contextSelectors, state.contextElementsLength) | ||
} | ||
} | ||
|
This file contains 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,19 @@ | ||
import { PEOPLE_VERIFIED_LS_ENTRY } from '../utils/consts' | ||
import { Enricher, EventBus } from '../types' | ||
import { WrappedReadOnlyStorageHandler } from '../handlers/storage-handler' | ||
|
||
type Input = { peopleVerifiedId?: string, storageHandler: WrappedReadOnlyStorageHandler, eventBus: EventBus } | ||
type Output = { peopleVerifiedId?: string } | ||
|
||
export const enrichPeopleVerifiedId: Enricher<Input, Output> = state => { | ||
try { | ||
return { | ||
...state, | ||
peopleVerifiedId: state.peopleVerifiedId || state.storageHandler.getDataFromLocalStorage(PEOPLE_VERIFIED_LS_ENTRY) || undefined | ||
} | ||
} catch (e) { | ||
state.eventBus.emitError('PeopleVerifiedEnrich', e) | ||
return state | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { State } from '../types' | ||
import { isNonEmpty } from 'live-connect-common' | ||
import { Enricher } from '../types' | ||
|
||
export function enrich(state: State): State { | ||
if (isNonEmpty(state) && isNonEmpty(state.gdprApplies)) { | ||
const privacyMode = !!state.gdprApplies | ||
return { | ||
privacyMode | ||
} | ||
} else return {} | ||
} | ||
type Input = { gdprApplies?: boolean } | ||
type Output = { privacyMode: boolean } | ||
|
||
export const enrichPrivacyMode: Enricher<Input, Output> = state => | ||
({ ...state, privacyMode: !!state.gdprApplies }) |
This file contains 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,20 @@ | ||
import { EventBus, ReadOnlyStorageHandler, StorageHandler } from "live-connect-common"; | ||
import { StorageStrategy } from "../model/storage-strategy"; | ||
import { Enricher } from "../types"; | ||
import { WrappedReadOnlyStorageHandler, WrappedStorageHandler } from "../handlers/storage-handler"; | ||
|
||
type InputReadOnly = { storageStrategy: StorageStrategy, storageHandler: ReadOnlyStorageHandler, eventBus: EventBus } | ||
type OutputReadOnly = { storageHandler: WrappedReadOnlyStorageHandler } | ||
|
||
export const enrichReadOnlyStorageHandler: Enricher<InputReadOnly, OutputReadOnly> = state => { | ||
const storageHandler = WrappedReadOnlyStorageHandler.make(state.storageStrategy, state.storageHandler, state.eventBus) | ||
return { ...state, storageHandler } | ||
} | ||
|
||
type Input = { storageStrategy: StorageStrategy, storageHandler: StorageHandler, eventBus: EventBus } | ||
type Output = { storageHandler: WrappedStorageHandler } | ||
|
||
export const enrichStorageHandler: Enricher<Input, Output> = state => { | ||
const storageHandler = WrappedStorageHandler.make(state.storageStrategy, state.storageHandler, state.eventBus) | ||
return { ...state, storageHandler } | ||
} |
Oops, something went wrong.