MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / main

Function main

apps/worker/scripts/get-referrers.ts:66–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64}
65
66async function main() {
67 // Get document, or throw exception on error
68 try {
69 const data = await fetch(
70 'https://s3-eu-west-1.amazonaws.com/snowplow-hosted-assets/third-party/referer-parser/referers-latest.json',
71 ).then((res) => res.json());
72
73 fs.writeFileSync(
74 path.resolve(__dirname, '../../worker/src/referrers/index.ts'),
75 [
76 '// This file is generated by the script get-referrers.ts',
77 '',
78 '// The data is fetch from snowplow-referer-parser https://github.com/snowplow-referer-parser/referer-parser',
79 `// The orginal referers.yml is based on Piwik's SearchEngines.php and Socials.php, copyright 2012 Matthieu Aubry and available under the GNU General Public License v3.`,
80 '',
81 `const referrers: Record<string, { type: string, name: string }> = ${JSON.stringify(
82 {
83 ...transform(data),
84 ...extraReferrers,
85 },
86 )} as const;`,
87 'export default referrers;',
88 ].join('\n'),
89 'utf-8',
90 );
91 } catch (e) {
92 console.log(e);
93 }
94}
95
96main();

Callers 1

get-referrers.tsFile · 0.70

Calls 6

joinMethod · 0.80
transformFunction · 0.70
fetchFunction · 0.50
thenMethod · 0.45
stringifyMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected