Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #36 from zarathustra323/restructure-tracking
Browse files Browse the repository at this point in the history
Restructure click/link tracking within P1 Events and Leaders
  • Loading branch information
brandonbk authored Mar 3, 2021
2 parents 95be76d + c04d10e commit f9682c3
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 137 deletions.
50 changes: 0 additions & 50 deletions packages/marko-web-leaders/browser/click-emitter.vue

This file was deleted.

8 changes: 3 additions & 5 deletions packages/marko-web-leaders/browser/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const LeadersProgram = () => import(/* webpackChunkName: "leaders-program" */ '@parameter1/base-cms-leaders-program');
const LeadersClickEmitter = () => import(/* webpackChunkName: "leaders-click-emitter" */ './click-emitter.vue');
const LeadersCompanyWebsiteLink = () => import(/* webpackChunkName: "leaders-company-website-link" */ './company-website-link.vue');
const LeadersCompanySocialLink = () => import(/* webpackChunkName: "leaders-company-social-link" */ './company-social-link.vue');
const LeadersGTMTracker = () => import(/* webpackChunkName: "leaders-gtm-tracker" */ './gtm-tracker.vue');
const LeadersP1EventsTracker = () => import(/* webpackChunkName: "leaders-p1-event-tracker" */ './p1events-tracker.vue');


export default (Browser, { withGTM = true } = {}) => {
export default (Browser, { withGTM = true, withP1Events = true } = {}) => {
const { EventBus } = Browser;
if (withGTM) Browser.register('LeadersGTMTracker', LeadersGTMTracker, { provide: { EventBus } });
if (withP1Events) Browser.register('LeadersP1EventsTracker', LeadersP1EventsTracker, { provide: { EventBus } });
Browser.register('LeadersProgram', LeadersProgram, {
withApollo: true,
on: { action: (...args) => EventBus.$emit('leaders-action', ...args) },
Expand All @@ -18,7 +19,4 @@ export default (Browser, { withGTM = true } = {}) => {
Browser.register('LeadersCompanySocialLink', LeadersCompanySocialLink, {
on: { action: (...args) => EventBus.$emit('leaders-action', ...args) },
});
Browser.register('LeadersClickEmitter', LeadersClickEmitter, {
on: { action: (...args) => EventBus.$emit('leaders-action', ...args) },
});
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="p1-events-track-leaders" />
<div class="marko-web-leaders-p1events-tracker" style="display: none;" />
</template>

<script>
Expand Down Expand Up @@ -60,6 +60,7 @@ export default {
const matches = /^Company Social - (.+)$/.exec(label);
queue.push({
...baseEvent,
category: 'Company Profile Page',
...(matches && { label: 'Company Social Link' }),
action: 'Click',
entity: { id: payload.companyId, ns: this.ns('content-company') },
Expand Down
1 change: 0 additions & 1 deletion packages/marko-web-leaders/components/click-emitter.marko

This file was deleted.

6 changes: 3 additions & 3 deletions packages/marko-web-leaders/components/marko.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"<marko-web-leaders>": {
"template": "./index.marko"
},
"<marko-web-leaders-click-emitter>": {
"template": "./click-emitter.marko"
},
"<marko-web-leaders-company-social-link>": {
"template": "./company-social-link.marko",
"@company": "object",
Expand All @@ -19,5 +16,8 @@
},
"<marko-web-leaders-gtm-tracker>": {
"template": "./gtm-tracker.marko"
},
"<marko-web-leaders-p1events-tracker>": {
"template": "./p1events-tracker.marko"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<marko-web-browser-component name="LeadersP1EventsTracker" props={ baseTenantKey: process.env.TENANT_KEY } />
1 change: 0 additions & 1 deletion packages/marko-web-leaders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@parameter1/base-cms-leaders-program": "^2.5.0",
"@parameter1/base-cms-marko-web-icons": "^2.0.0",
"@parameter1/base-cms-object-path": "^2.5.0",
"dom-utils": "^0.9.0",
"graphql": "^14.7.0",
"graphql-tag": "^2.11.0",
"object-path": "^0.11.5"
Expand Down
8 changes: 0 additions & 8 deletions packages/marko-web-leaders/utils/event-attrs.js

This file was deleted.

16 changes: 0 additions & 16 deletions packages/marko-web-leaders/utils/event-link-attrs.js

This file was deleted.

21 changes: 0 additions & 21 deletions packages/marko-web-p1-events/browser/.eslintrc.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/marko-web-p1-events/browser/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/marko-web-p1-events/components/init.marko
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $ const { enabled, tenant, cookieDomain } = site.getAsObject("p1events");
$ const realm = core.website("id");
$ const { NODE_ENV } = process.env;

$ const scriptSrc = defaultValue(input.scriptSrc, "https://de3t5rrdmy18m.cloudfront.net/p1-events.b47b524e.js");
$ const scriptSrc = defaultValue(input.scriptSrc, "https://de3t5rrdmy18m.cloudfront.net/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) {
Expand Down
5 changes: 0 additions & 5 deletions packages/marko-web-p1-events/components/marko.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
"template": "./track-content.marko",
"@node": "object"
},
"<marko-web-p1-events-track-leaders>": {
"template": "./track-leaders.marko",
"@base-tenant-key": "string",
"@event-name": "string"
},
"<marko-web-p1-events-track-website-section>": {
"template": "./track-website-section.marko",
"@node": "object"
Expand Down
11 changes: 0 additions & 11 deletions packages/marko-web-p1-events/components/track-leaders.marko

This file was deleted.

1 change: 1 addition & 0 deletions packages/marko-web-p1-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test": "yarn compile && yarn lint"
},
"dependencies": {
"@parameter1/base-cms-inflector": "^2.0.0",
"@parameter1/base-cms-object-path": "^2.5.0"
},
"peerDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/marko-web-p1-events/utils/base-content-entity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { dasherize } = require('@parameter1/base-cms-inflector');
const entity = require('./base-entity');

module.exports = (id, type) => entity(id, `content-${dasherize(type)}`);
4 changes: 4 additions & 0 deletions packages/marko-web-p1-events/utils/base-entity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { dasherize } = require('@parameter1/base-cms-inflector');
const ns = require('./create-namespace');

module.exports = (id, type) => `${ns(dasherize(type))}*${id}`;
11 changes: 11 additions & 0 deletions packages/marko-web-p1-events/utils/link-attrs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const PREFIX = 'data-p1';

module.exports = (params = {}) => {
const keys = ['action', 'category', 'label', 'entity', 'context', 'props'];
return keys.reduce((o, key) => {
let value = key === 'props' ? JSON.stringify(params[key]) : params[key];
if (key === 'action' && !value) value = 'Click'; // assume click when not set
if (!value) return o;
return { ...o, [`${PREFIX}-${key}`]: value };
}, {});
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $ if (showEmail) fields.push("publicEmail");
$ const showFields = fields.some(k => content[k]);

$ const websiteLinkAttrs = getAsObject(input, "websiteLinkAttrs");
$ const socialLinkAttrs = getAsObject(input, "socialLinkAttrs");

<default-theme-page-contact-details|{ blockName }|
tag=input.tag
Expand Down Expand Up @@ -53,6 +54,7 @@ $ const websiteLinkAttrs = getAsObject(input, "websiteLinkAttrs");
provider=item.provider
href=item.url
modifiers=["dark", "lg"]
attrs=socialLinkAttrs
/>
</for>
</default-theme-content-contact-details-section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"@class": "string",
"@modifiers": "array",
"@attrs": "object",
"@website-link-attrs": "object"
"@website-link-attrs": "object",
"@social-link-attrs": "object"
},
"<default-theme-content-contact-details-section>": {
"template": "./section.marko",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ $ const name = label || provider;
$ const title = name ? `Visit us on ${name.charAt(0).toUpperCase()}${name.slice(1)}` : null;

<if(formatted && input.href)>
<marko-web-link class=classNames href=input.href target=input.target title=title>
<marko-web-link
class=classNames
href=input.href
target=input.target
title=title
attrs=input.attrs
>
<marko-web-icon name=provider modifiers=input.modifiers />
</marko-web-link>
</if>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"@href": "string",
"@target": "string",
"@modifiers": "array",
"@class": "string"
"@class": "string",
"@attrs": "object"
},
"<default-theme-social-icons>": {
"template": "./icons.marko"
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6733,11 +6733,6 @@ dom-serializer@^1.0.1, dom-serializer@~1.2.0:
domhandler "^4.0.0"
entities "^2.0.0"

dom-utils@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/dom-utils/-/dom-utils-0.9.0.tgz#e615a5af15ac4505e55ef612c72b5b5d176121f3"
integrity sha1-5hWlrxWsRQXlXvYSxytbXRdhIfM=

domain-browser@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda"
Expand Down

0 comments on commit f9682c3

Please sign in to comment.