Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion public/libs/amplitude-analytics-browser-2.0.0-min.js

This file was deleted.

6 changes: 6 additions & 0 deletions public/libs/amplitude-script-eu-min.js

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions scripts/inject-amplitude.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from 'url';

const AMPLITUDE_API_KEY = process.env.AMPLITUDE_API_KEY;
const AMPLITUDE_SERVER_URL = process.env.AMPLITUDE_SERVER_URL;
const AMPLITUDE_SERVER_ZONE = process.env.AMPLITUDE_SERVER_ZONE || "US";
const AMPLITUDE_SERVER_ZONE = process.env.AMPLITUDE_SERVER_ZONE || 'US';

const currentPath = fileURLToPath(import.meta.url);
const projectRoot = path.dirname(currentPath);
Expand All @@ -14,7 +14,7 @@ if (AMPLITUDE_API_KEY) {
const files = await fs.readdir('entry-points');
for (const file of files) {
inject(file);
};
}
} catch (err) {
console.error('Error injecting Amplitude scripts:', err);
}
Expand All @@ -24,22 +24,21 @@ async function inject(fileName) {
const htmlFilePath = path.resolve(projectRoot, `../dist/entry-points/${fileName}`);
const html = await fs.readFile(htmlFilePath, 'utf-8');

const amplitudeCdnScript = `<script type="text/javascript">
!function(){"use strict";!function(e,t){var n=e.amplitude||{_q:[],_iq:{}};if(n.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var r=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,n){return function(r){e._q.push({name:t,args:Array.prototype.slice.call(n,0),resolve:r})}},o=function(e,t,n){e[t]=function(){if(n)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))}}},i=function(e){for(var t=0;t<m.length;t++)o(e,m[t],!1);for(var n=0;n<g.length;n++)o(e,g[n],!0)};n.invoked=!0;var u=t.createElement("script");u.type="text/javascript",u.integrity="sha384-BVo5ZjsjH373rWbcjz9Qjb2L6BgLwLADcZtZZPu3nMl8+7LPDhi1NcUEf0Ate41Y",u.crossOrigin="anonymous",u.async=!0,u.src="/libs/amplitude-analytics-browser-2.0.0-min.js",u.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var a=t.getElementsByTagName("script")[0];a.parentNode.insertBefore(u,a);for(var c=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],l=0;l<p.length;l++)r(c,p[l]);n.Identify=c;for(var d=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],v=0;v<f.length;v++)r(d,f[v]);n.Revenue=d;var m=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];i(n),n.createInstance=function(e){return n._iq[e]={_q:[]},i(n._iq[e]),n._iq[e]},e.amplitude=n}}(window,document)}();
</script>
`;
const amplitudeCdnScript = `<script type="text/javascript" src="/libs/amplitude-script-eu.js"></script>`;

const amplitudeListenerScript = `<script type="module">
!(function () {
var e = "${AMPLITUDE_API_KEY}";
e &&
(globalThis.amplitude.init(e${AMPLITUDE_SERVER_URL
? `, undefined, {
var key = "${AMPLITUDE_API_KEY}";
key &&
(globalThis.amplitude.init(key${
AMPLITUDE_SERVER_URL
? `, undefined, {
autoCapture: true,
serverUrl: "${AMPLITUDE_SERVER_URL}",
serverZone: "${AMPLITUDE_SERVER_ZONE}"
}`
: ''
}),
: ''
}),
globalThis.amplitude.setOptOut(!1),
globalThis.addEventListener("dydx:track", function (e) {
var t = e.detail.eventType,
Expand Down Expand Up @@ -67,4 +66,4 @@ async function inject(fileName) {
await fs.writeFile(htmlFilePath, injectedHtml, 'utf-8');

console.log(`Amplitude scripts successfully injected (${fileName}).`);
}
}
1 change: 0 additions & 1 deletion src/hooks/tradingView/useTradingViewLaunchable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const useTradingViewLaunchable = ({
symbol: marketId,
saved_data: !isEmpty(savedTvChartConfig) ? savedTvChartConfig : undefined,
auto_save_delay: 1,
disabled_features: [...(widgetOptions.disabled_features ?? []), 'chart_scroll'],
};

const tvChartWidget = new Widget(options);
Expand Down
Loading