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ACAC,EACA+B,GAEA,GAAID,GAAiB/B,EAAa,CAChC,IAAMiC,EAAsC,CAAC,aAAcF,EAAe/B,GAEtEC,GAAWgC,EAAe3B,KAAKL,GAC/B+B,GAAYC,EAAe3B,KAAK0B,GAEpCpE,KAAKc,KAAK4B,KAAK2B,EACjB,CACF,M,iBAhHWtE,C,CAAN,GCJPG,OAAOoE,iBAAmB,CACxBC,OAAQ,IAAIxE,E","sources":["webpack://design-prototype/./src/js/mybeckhoff/mybeckhoff.ts","webpack://design-prototype/./src/js/mybeckhoff/types.ts","webpack://design-prototype/./src/js/tracking/matomo.ts","webpack://design-prototype/./src/js/tracking/index.ts"],"sourcesContent":["import { IMyBeckhoffService } from './types';\n\nexport const getMyBeckhoffService = (): IMyBeckhoffService => {\n if (window.myBeckhoff) {\n return window.myBeckhoff;\n } else {\n throw new Error('MyBeckhoffService not present!');\n }\n};\n","export type Nullable = T | null | undefined;\n\nexport type MyBeckhoffRequestOptions = {\n action: string;\n cmsLanguage: Nullable;\n cmsId: Nullable;\n cmsTemplatename: Nullable;\n cookie: Nullable;\n};\n\nexport type BookmarkRequestOptions = Pick<\n MyBeckhoffRequestOptions,\n 'cmsLanguage' | 'cmsId' | 'cmsTemplatename'\n>;\n\nexport type BookmarkStatusResponse = {\n status: boolean;\n bookmarkStatus: boolean;\n message: string;\n};\n\nexport type SetExportControlResponse = {\n status: boolean;\n loginStatus: boolean;\n exportControl: boolean;\n};\n\nexport interface LoginResponse extends LoginState {\n status: string;\n message: string;\n}\n\nexport type LoginState = {\n email: Nullable;\n exportControl: boolean;\n loginStatus: boolean;\n userid: Nullable;\n username: Nullable;\n userType: Nullable;\n};\n\nexport enum MyBeckhoffEventType {\n SESSION_UPDATE = 'SESSION_UPDATE',\n MANUAL_LOGIN = 'MANUAL_LOGIN',\n MANUAL_LOGOUT = 'MANUAL_LOGOUT',\n}\n\nexport type MyBeckhoffEventPayload = {\n [MyBeckhoffEventType.SESSION_UPDATE]: LoginState;\n [MyBeckhoffEventType.MANUAL_LOGIN]: LoginState & { message: string };\n [MyBeckhoffEventType.MANUAL_LOGOUT]: LoginState;\n};\n\nexport type MyBeckhoffEventByType = {\n type: T;\n payload: MyBeckhoffEventPayload[T];\n};\n\nexport type MyBeckhoffEvent = {\n [K in MyBeckhoffEventType]: {\n type: K;\n payload: MyBeckhoffEventPayload[K];\n };\n}[MyBeckhoffEventType];\n\nexport enum MyBeckhoffUserType {\n UNKNOWN = 'unknown',\n EMPLOYEE = 'employee',\n}\n\nexport interface IMyBeckhoffService {\n readonly options: MyBeckhoffRequestOptions;\n login(username: string, password: string, remeber: boolean, cmsLanguage?: string): Promise;\n logout(): Promise;\n addPlugin(plugin: unknown): void;\n plugins: unknown[];\n loginState: LoginState;\n updateLoginState: (values: Partial) => void;\n isLoggedIn: boolean;\n request(options: Partial): Promise;\n subscribe(callbackFn: (event: MyBeckhoffEvent) => void): void;\n unsubscribe(callbackFn: (event: MyBeckhoffEvent) => void): void;\n}\n","import { getMyBeckhoffService } from '../mybeckhoff/mybeckhoff';\nimport { MyBeckhoffEvent, MyBeckhoffEventType, MyBeckhoffUserType } from '../mybeckhoff/types';\n\nconst MIN_SCROLL_DEPTH = 0.25;\nconst MIN_INTERACTION_DELAY_MS = 200;\n\nexport class MatomoService {\n private myBeckhoffService = getMyBeckhoffService();\n\n private get _paq() {\n return (window._paq = window._paq || []);\n }\n\n constructor() {\n this.initMatomo();\n this.myBeckhoffService.subscribe((e) => this.onMyBeckhoffEvent(e));\n if (matomoVars.enableUserInteractionTracking === true) {\n this.initInteractionTracking();\n }\n }\n\n private initInteractionTracking() {\n const initialScrollY = window.scrollY;\n\n const onScroll = (event: Event) => {\n if (!this.isUserGenerated(event) || window.scrollY === initialScrollY) return;\n\n const scrollableHeight = document.documentElement.scrollHeight - window.innerHeight;\n if (scrollableHeight > 0 && window.scrollY / scrollableHeight > MIN_SCROLL_DEPTH) {\n window.removeEventListener('scroll', onScroll);\n this.trackInteraction(`scroll >${MIN_SCROLL_DEPTH * 100}%`);\n }\n };\n\n const onPointerMove = (event: PointerEvent) => {\n if (!this.isUserGenerated(event)) return;\n\n window.removeEventListener('pointermove', onPointerMove);\n this.trackInteraction('pointermove', event.pointerType);\n };\n\n window.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('pointermove', onPointerMove, { passive: true });\n }\n\n private isUserGenerated(event: Event) {\n return event.isTrusted && performance.now() > MIN_INTERACTION_DELAY_MS;\n }\n\n private trackInteraction(eventAction: string, eventName?: string) {\n if (matomoVars.customDimensionInteractionId) {\n this.setCustomDimension(matomoVars.customDimensionInteractionId, 'true');\n }\n this.trackEvent('Interaction', eventAction, eventName);\n }\n\n private initMatomo() {\n this._paq.push(['disableCookies']);\n\n this._paq.push(['enableJSErrorTracking']);\n this._paq.push(['enableHeartBeatTimer', 5]);\n\n this._paq.push(['trackPageView']);\n this._paq.push(['enableLinkTracking']);\n\n const u = matomoVars.url;\n this._paq.push(['setTrackerUrl', u + 'matomo.php']);\n this._paq.push(['setSiteId', matomoVars.siteId]);\n const d = document,\n g = d.createElement('script'),\n s = d.getElementsByTagName('script')[0];\n g.async = true;\n g.src = u + 'matomo.js';\n s.parentNode?.insertBefore(g, s);\n }\n\n private setCustomDimension(id: number, value: string) {\n this._paq.push(['setCustomDimension', id, value]);\n }\n\n private onMyBeckhoffEvent(event: MyBeckhoffEvent) {\n const loginState = event.payload.loginStatus.toString() || 'false';\n const userType = event.payload.userType || MyBeckhoffUserType.UNKNOWN;\n\n switch (event.type) {\n case MyBeckhoffEventType.MANUAL_LOGIN:\n if (event.payload.loginStatus === true) {\n if (matomoVars.customDimensionLoginStateId) {\n this.setCustomDimension(matomoVars.customDimensionLoginStateId, loginState);\n }\n\n if (matomoVars.customDimensionUserTypeId) {\n this.setCustomDimension(matomoVars.customDimensionUserTypeId, userType);\n }\n\n this.trackEvent('Session update', 'login', userType);\n }\n break;\n case MyBeckhoffEventType.MANUAL_LOGOUT:\n this.trackEvent('Session update', 'logout');\n break;\n }\n }\n\n public trackEvent(\n eventCategory: string,\n eventAction: string,\n eventName?: string,\n eventValue?: number,\n ) {\n if (eventCategory && eventAction) {\n const trackEventData: (string | number)[] = ['trackEvent', eventCategory, eventAction];\n\n if (eventName) trackEventData.push(eventName);\n if (eventValue) trackEventData.push(eventValue);\n\n this._paq.push(trackEventData);\n }\n }\n}\n","import { MatomoService } from './matomo';\n\nwindow.trackingServices = {\n matomo: new MatomoService(),\n};\n"],"names":["MyBeckhoffEventType","MyBeckhoffUserType","MatomoService","this","myBeckhoffService","window","myBeckhoff","Error","getMyBeckhoffService","initMatomo","subscribe","e","_this","onMyBeckhoffEvent","matomoVars","enableUserInteractionTracking","initInteractionTracking","_paq","initialScrollY","scrollY","onScroll","event","isUserGenerated","scrollableHeight","document","documentElement","scrollHeight","innerHeight","removeEventListener","trackInteraction","concat","MIN_SCROLL_DEPTH","onPointerMove","pointerType","addEventListener","passive","isTrusted","performance","now","eventAction","eventName","customDimensionInteractionId","setCustomDimension","trackEvent","s","push","u","url","siteId","d","g","createElement","getElementsByTagName","async","src","parentNode","insertBefore","id","value","loginState","payload","loginStatus","toString","userType","UNKNOWN","type","MANUAL_LOGIN","customDimensionLoginStateId","customDimensionUserTypeId","MANUAL_LOGOUT","eventCategory","eventValue","trackEventData","trackingServices","matomo"],"sourceRoot":""}