@financial-times/custom-code-component 1.9.7 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,14 +7,14 @@ declare class Tracking {
7
7
  category: string;
8
8
  elements: string | string[];
9
9
  isInitialised: boolean;
10
- constructor({ id, name, subtype, teamName, shadowRoot, category, elements, }?: {
10
+ constructor({ id, name, subtype, teamName, shadowRoot, category, elements, }: {
11
11
  id?: string;
12
- name?: string;
13
- subtype?: string;
12
+ name: string;
13
+ subtype: string;
14
14
  teamName?: string;
15
- shadowRoot?: any;
15
+ shadowRoot: ShadowRoot | null;
16
16
  category?: string;
17
- elements?: string;
17
+ elements?: string | string[];
18
18
  });
19
19
  getEventProperties(event: any): {};
20
20
  handleClickEvent(eventData: any, root: any): (clickEvent: any, clickElement: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/custom-code-component",
3
- "version": "1.9.7",
3
+ "version": "1.9.9",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -26,11 +26,13 @@
26
26
  "vite-plugin-dts": "^3.6.0"
27
27
  },
28
28
  "dependencies": {
29
- "@financial-times/o-tracking": "^4.5.4",
30
29
  "ftdomdelegate": "^5.0.0",
31
30
  "react": "^18.2.0",
32
31
  "react-dom": "^18.2.0"
33
32
  },
33
+ "peerDependencies": {
34
+ "@financial-times/o-tracking": "4.x"
35
+ },
34
36
  "overrides": {
35
37
  "react-dom16": {
36
38
  "react": "react16"
@@ -44,14 +44,14 @@ class FTCustomCodeComponent extends HTMLElement {
44
44
  );
45
45
 
46
46
  // Clear old children
47
- this.shadowRoot?.replaceChildren();
47
+ // this.shadowRoot?.replaceChildren();
48
48
 
49
49
  // Create tracking instance
50
50
  this.tracking = new Tracking({
51
51
  name: `${this.getAttribute("path")}@${this.getAttribute("version")}`,
52
52
  subtype: "interactive",
53
53
  teamName: "djd",
54
- shadowRoot: this.shadowRoot as ShadowRoot,
54
+ shadowRoot: this.shadowRoot,
55
55
  });
56
56
 
57
57
  const { unmount, onmessage } =
package/src/tracking.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import Delegate from "ftdomdelegate";
2
- import oTracking from "@financial-times/o-tracking";
3
2
  import { getTrace } from "./get-trace";
4
3
  import {
5
4
  sanitise,
@@ -26,7 +25,15 @@ class Tracking {
26
25
  shadowRoot = null,
27
26
  category = "cta",
28
27
  elements = 'a, button, input, [role="button"]',
29
- } = {}) {
28
+ }: {
29
+ id?: string;
30
+ name: string;
31
+ subtype: string;
32
+ teamName?: string;
33
+ shadowRoot: ShadowRoot | null;
34
+ category?: string;
35
+ elements?: string | string[];
36
+ }) {
30
37
  this.cccId = id;
31
38
  this.cccName = name;
32
39
  this.subtype = subtype;
@@ -119,14 +126,12 @@ class Tracking {
119
126
  this.isInitialised = true;
120
127
  this.cccId = id ? id : this.cccId;
121
128
 
122
- oTracking.init({ queue: true });
123
-
124
129
  const eventData = {
125
130
  action: "click",
126
131
  category: this.category,
127
132
  };
128
133
 
129
- const root = this.shadowRoot?.querySelector("#component-root");
134
+ const root = this.shadowRoot?.querySelector("[data-component-root]");
130
135
 
131
136
  if (this.shadowRoot) {
132
137
  const shadowDelegate = new Delegate(root);