From 6bf42a0b760ac99ebb2191d83668f59b205697f0 Mon Sep 17 00:00:00 2001 From: Jacob Bare Date: Mon, 22 Mar 2021 16:13:13 -0500 Subject: [PATCH] Add support for deferring P1 Events library --- .../marko-web-p1-events/components/init.marko | 44 +++++++++---------- .../marko-web-p1-events/components/marko.json | 3 +- packages/marko-web-p1-events/package.json | 1 + 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/marko-web-p1-events/components/init.marko b/packages/marko-web-p1-events/components/init.marko index 65749cb52..d14aea13e 100644 --- a/packages/marko-web-p1-events/components/init.marko +++ b/packages/marko-web-p1-events/components/init.marko @@ -5,31 +5,29 @@ $ const { enabled, tenant, cookieDomain } = site.getAsObject("p1events"); $ const realm = core.website("id"); $ const { NODE_ENV } = process.env; +$ const { on } = input; $ const scriptSrc = defaultValue(input.scriptSrc, "https://cdn.parameter1.com/p1-events/1ed2a30f.js"); $ const uri = defaultValue(input.uri, "https://db0y8smio0.execute-api.us-east-2.amazonaws.com/default/p1-website-events-enqueue"); -$ const identityQueryBuilder = ` - identityQueryBuilder: function(query) { - ${input.identityQueryBuilder ? input.identityQueryBuilder : ''} - } -`; +$ const identityQueryBuilder = `identityQueryBuilder: function(query) { ${input.identityQueryBuilder ? input.identityQueryBuilder.split("\n").map((l) => l.trim()).join(" ") : ""} }`; - + + + + + + + diff --git a/packages/marko-web-p1-events/components/marko.json b/packages/marko-web-p1-events/components/marko.json index 7f3599a34..e411dc457 100644 --- a/packages/marko-web-p1-events/components/marko.json +++ b/packages/marko-web-p1-events/components/marko.json @@ -3,7 +3,8 @@ "template": "./init.marko", "@script-src": "string", "@uri": "string", - "@identity-query-builder": "string" + "@identity-query-builder": "string", + "@on": "string" }, "": { "template": "./track-content.marko", diff --git a/packages/marko-web-p1-events/package.json b/packages/marko-web-p1-events/package.json index 5b4299ce1..1270b8557 100644 --- a/packages/marko-web-p1-events/package.json +++ b/packages/marko-web-p1-events/package.json @@ -12,6 +12,7 @@ }, "dependencies": { "@parameter1/base-cms-inflector": "^2.0.0", + "@parameter1/base-cms-marko-web-deferred-script-loader": "^2.9.0", "@parameter1/base-cms-object-path": "^2.5.0" }, "peerDependencies": {