1import { fetchPlaceholders } from '../lib-franklin.js'; 2import Helpers from '../helpers.js'; 3 4class AnalyticsService { 5 implementation = 'worker'; 6 7 version = 'legacy'; 8 9 constructor(options = {}) { 10 this.version = options.version ?? 'legacy'; 11 this.implementation = options.default ?? 'worker'; 12 } 13 14 async setVersion() { 15 try { 16 const helpers = new Helpers(); 17 const placeholders = await fetchPlaceholders(''); 18 if (helpers.get(placeholders, 'analyticsVersion') === 'SDK') { 19 this.version = 'SDK'; 20 } 21 } catch (e) { 22 console.log('error in setVersion'); 23 } 24 } 25 26 // eslint-disable-next-line class-methods-use-this 27 async setImplementation() { 28 try { 29 const helpers = new Helpers(); 30 const placeholders = await fetchPlaceholders(''); 31 if (helpers.get(placeholders, 'analyticsStrategy') === 'worker') { 32 this.implementation = 'worker'; 33 } 34 } catch (e) { 35 console.log('error in setImplementation'); 36 } 37 } 38 39 async getImplementation() { 40 await this.setVersion(); 41 const version = this.version.toLowerCase(); 42 console.log(`analytics-version: ${version}`); 43 44 await this.setImplementation(); 45 console.log(`data-layer: ${this.implementation}`); 46 47 const { default: analytics } = await import(`./${version}/analytics-${this.implementation}.js`); 48 49 return analytics; 50 } 51} 52 53export default AnalyticsService;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.