Skip to content

Commit

Permalink
fix: fixed cohesion snippet loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ayesha-waris committed Nov 13, 2024
1 parent b18caa2 commit 791a60a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 88 deletions.
64 changes: 62 additions & 2 deletions src/MainApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AppProvider } from '@edx/frontend-platform/react';
import { Helmet } from 'react-helmet';
import { Navigate, Route, Routes } from 'react-router-dom';

import Cohesion from './cohesion';
import {
EmbeddedRegistrationRoute, NotFoundPage, registerIcons, UnAuthOnlyRoute,
} from './common-components';
Expand Down Expand Up @@ -36,8 +35,69 @@ registerIcons();

const MainApp = () => (
<AppProvider store={configureStore()}>
<Cohesion />
<Helmet>
{/* Cohesion Snippet */}
<script>
{`!function (co, h, e, s, i, o, n) {
var d = 'documentElement'; var a = 'className'; h[d][a] += ' preampjs fusejs';
n.k = e; co._Cohesion = n; co._Preamp = { k: s, start: new Date }; co._Fuse = { k: i }; co._Tagular = { k: o };
[e, s, i, o].map(function (x) { co[x] = co[x] || function () { (co[x].q = co[x].q || []).push([].slice.call(arguments)) } });
var b = function () { var u = h[d][a]; h[d][a] = u.replace(/ ?preampjs| ?fusejs/g, '') };
h.addEventListener('DOMContentLoaded', function () {
co.setTimeout(b, 3e3);
co._Preamp.docReady = co._Fuse.docReady = !0
}); var z = h.createElement('script');
z.async = 1; z.src = 'https://beam.edx.org/cohesion/cohesion-latest.min.js';
z.onerror = function () { var ce = 'error',f = 'function'; for (var o of co[e].q || []) o[0] === ce && typeof o[1] == f && o[1](); co[e] = function (n, cb) { n === ce && typeof cb == f && cb() }; b() };
h.head.appendChild(z);
}
(window, document, 'cohesion', 'preamp', 'fuse', 'tagular', {
tagular: {
apiHost: 'https://beam.edx.org/v2/t',
writeKey: "${process.env.COHESION_WRITE_KEY}",
sourceKey: "${process.env.COHESION_SOURCE_KEY}",
cookieDomain: 'edx.org',
domainWhitelist: ["edx.org"],
apiVersion: 'v2/t',
multiparty: true,
taggy: {
enabled: true
}
}
});`}
</script>

{/* Stitch Cohesion and Segment IDs */}
<script>
{`cohesion("tagular:ready", function () {
window.analytics.ready(function () {
const cohesionAnonymId = window.tagular("getAliasSet")["anonymousId"];
const segmentAnonymId = window.analytics.user().anonymousId();
const segmentUserId = window.analytics.user().id();
window.analytics.identify(segmentUserId, {
cohesion_anonymous_id: cohesionAnonymId,
});
window.tagular("beam", {
"@type": "core.Identify.v1",
traits: {},
externalIds: [
{
id: segmentAnonymId,
type: "segment_anonymous_id",
collection: "users",
encoding: "none",
},
{
id: cohesionAnonymId,
type: "cohesion_anonymous_id",
collection: "users",
encoding: "none",
},
],
});
});
});`}
</script>
<link rel="shortcut icon" href={getConfig().FAVICON_URL} type="image/x-icon" />
</Helmet>
<Routes>
Expand Down
86 changes: 0 additions & 86 deletions src/cohesion/index.js

This file was deleted.

0 comments on commit 791a60a

Please sign in to comment.