Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: testing target hiding snippet #142

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ branches:
# - solrtest
- qa
- production
- adobe-target-test
env:
global:
- AWS_DEFAULT_REGION=us-east-1
Expand All @@ -20,9 +21,9 @@ env:
jobs:
include:
- stage: deploy QA
if: "(branch = qa) AND (type != pull_request)"
if: "(branch = adobe-target-test)"
env:
- ECR_URL=685731035297.dkr.ecr.us-east-1.amazonaws.com/dc-frontend:$TRAVIS_BRANCH-latest
- ECR_URL=685731035297.dkr.ecr.us-east-1.amazonaws.com/dc-frontend:solrtest-latest
- AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_QA
- AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_QA
- CLUSTER_NAME=dc-frontend-qa
Expand Down
5 changes: 4 additions & 1 deletion src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ export const ADOBE_ANALYTICS_PAGE_NAMES = {
};

export const DC_URL = appConfig.DC_URL[appConfig.environment];
export const ADOBE_EMBED_URL = appConfig.adobeEmbedUrl[appConfig.environment];
// export const ADOBE_EMBED_URL = appConfig.adobeEmbedUrl[appConfig.environment];
// Hardcoded just to test for now.
export const ADOBE_EMBED_URL =
"https://assets.adobedtm.com/1a9376472d37/0eae8b2db428/launch-73f21f6dbd57-development.min.js";
15 changes: 8 additions & 7 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React from "react";
import { useEffect } from "react";
import { useRouter } from "next/router";
import Script from "next/script";

import { trackVirtualPageView } from "../utils/utils";
import appConfig from "../../appConfig";
import { ADOBE_EMBED_URL, DC_URL } from "../config/constants";
Expand Down Expand Up @@ -66,13 +67,13 @@ export default function App({ Component, pageProps }: AppProps) {
<Script async src={ADOBE_EMBED_URL} />
<Script id="adobeDataLayerDefinition">
{`
// First define the global variable for the entire data layer array
window.adobeDataLayer = window.adobeDataLayer || [];
// Then push in the variables required in the Initial Data Layer Definition
window.adobeDataLayer.push({
disable_page_view: true
});
`}
// First define the global variable for the entire data layer array
window.adobeDataLayer = window.adobeDataLayer || [];
// Then push in the variables required in the Initial Data Layer Definition
window.adobeDataLayer.push({
disable_page_view: true
});
`}
</Script>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand Down
35 changes: 35 additions & 0 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,41 @@ export default function Document() {
<body>
<Main />
<NextScript />
<Script id="target-snippet" strategy="beforeInteractive">
{`
// prehiding snippet for Adobe Target with asynchronous
// tags deployment
;(function(win, doc, style, timeout) {
var STYLE_ID = 'at-body-style';
function getParent() {
return doc.getElementsByTagName('head')[0];
}
function addStyle(parent, id, def) {
if (!parent) {
return;
}
var style = doc.createElement('style');
style.id = id;
style.innerHTML = def;
parent.appendChild(style);
}
function removeStyle(parent, id) {
if (!parent) {
return;
}
var style = doc.getElementById(id);
if (!style) {
return;
}
parent.removeChild(style);
}
addStyle(getParent(), STYLE_ID, style);
setTimeout(function() {
removeStyle(getParent(), STYLE_ID);
}, timeout);
}(window, document, "body {opacity: 0 !important}", 2500));
`}
</Script>
<div id="nypl-footer"></div>
<Script
src="https://ds-header.nypl.org/footer.min.js?containerId=nypl-footer"
Expand Down
Loading