Skip to content

Commit

Permalink
[F] Survey Sparrow script
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake Mason committed Nov 14, 2023
1 parent 3b8be9d commit 0378363
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import GlobalStyles from "@/styles/globalStyles";
import styles from "@/styles/styles.scss";

const PLAUSIBLE_DOMAIN = process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN;
const SURVEY_SPARROW = process.env.NEXT_PUBLIC_SURVEY_SPARROW;

function Client({ Component, pageProps }) {
const authData = useAuthentication({
Expand All @@ -30,6 +31,66 @@ function Client({ Component, pageProps }) {
strategy="afterInteractive"
/>
)}
{SURVEY_SPARROW && (
<>
<div id="ss_survey_widget"></div>
<Script
id="SS_SCRIPT"
dangerouslySetInnerHTML={{
__html: `
function sparrowLaunch(opts) {
// eslint-disable-next-line no-var, one-var
var e = "ss-widget",
t = "script",
a = document,
r = window,
l = localStorage;
// eslint-disable-next-line no-var, one-var
var s,
n,
c,
rm = a.getElementById("SS_SCRIPT");
r.SS_WIDGET_TOKEN = "tt-jCJ9T1UiXP2bVPQ1K3sF3g";
r.SS_ACCOUNT = "rockmanetal.surveysparrow.com";
r.SS_SURVEY_NAME = "rubin-pop-up---chat-survey";
if (
!a.getElementById(e) &&
!l.getItem("removed-ss-widget-tt-jCJ9T1UiXP2bVPQ1K3sF3g")
) {
// eslint-disable-next-line no-var
var S = function () {
S.update(arguments);
};
S.args = [];
S.update = function (e) {
S.args.push(e);
};
r.SparrowLauncher = S;
s = a.getElementsByTagName(t);
c = s[s.length - 1];
n = a.createElement(t);
n.type = "text/javascript";
n.async = !0;
n.id = e;
n.src = [
"https://",
"rockmanetal.surveysparrow.com/widget/",
r.SS_WIDGET_TOKEN,
"?",
"customParams=",
JSON.stringify(opts),
].join("");
c.parentNode.insertBefore(n, c);
r.SS_VARIABLES = opts;
rm.parentNode.removeChild(rm);
}
}
sparrowLaunch({/*add custom params here*/});
`,
}}
/>
</>
)}
<GlobalStyles />
<Component {...pageProps} />
</AuthenticationContextProvider>
Expand Down

0 comments on commit 0378363

Please sign in to comment.