@adobe/spacecat-shared-rum-api-client 2.1.1 → 2.2.1

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [@adobe/spacecat-shared-rum-api-client-v2.2.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.2.0...@adobe/spacecat-shared-rum-api-client-v2.2.1) (2024-07-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Click count is artificially inflating the conversion rate ([#278](https://github.com/adobe/spacecat-shared/issues/278)) ([77a1c6a](https://github.com/adobe/spacecat-shared/commit/77a1c6a27103db4ce463959b882311cf1d3924a3))
7
+ * **deps:** update external fixes ([#284](https://github.com/adobe/spacecat-shared/issues/284)) ([f4fe169](https://github.com/adobe/spacecat-shared/commit/f4fe1699c432637f1217198ad7f4a1cde6deeb76))
8
+
9
+ # [@adobe/spacecat-shared-rum-api-client-v2.2.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.1.1...@adobe/spacecat-shared-rum-api-client-v2.2.0) (2024-06-28)
10
+
11
+
12
+ ### Features
13
+
14
+ * add helix config to site/candidates ([#277](https://github.com/adobe/spacecat-shared/issues/277)) ([5ed489d](https://github.com/adobe/spacecat-shared/commit/5ed489dc84cb594689092e1f0019dd83d3647039))
15
+
1
16
  # [@adobe/spacecat-shared-rum-api-client-v2.1.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v2.1.0...@adobe/spacecat-shared-rum-api-client-v2.1.1) (2024-06-27)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-rum-api-client",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "Shared modules of the Spacecat Services - Rum API client",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -44,6 +44,6 @@
44
44
  "nock": "13.5.4",
45
45
  "sinon": "18.0.0",
46
46
  "sinon-chai": "3.7.0",
47
- "typescript": "5.5.2"
47
+ "typescript": "5.5.3"
48
48
  }
49
49
  }
@@ -62,9 +62,25 @@ function handler(bundles) {
62
62
  const variantObject = getOrCreateVariantObject(experimentObject.variants, variantName);
63
63
  variantObject.views += weight;
64
64
 
65
+ const metrics = {};
66
+ for (const checkpoint of METRIC_CHECKPOINTS) {
67
+ metrics[checkpoint] = {};
68
+ }
65
69
  for (const event of bundle.events) {
66
70
  if (METRIC_CHECKPOINTS.includes(event.checkpoint)) {
67
71
  const { source, checkpoint } = event;
72
+ if (!metrics[checkpoint][source]) {
73
+ metrics[checkpoint][source] = weight;
74
+ } else {
75
+ metrics[checkpoint][source] += weight;
76
+ }
77
+ }
78
+ }
79
+ // combine metrics and variantObject, considering the interaction events
80
+ // only once during the session
81
+ for (const checkpoint of METRIC_CHECKPOINTS) {
82
+ // eslint-disable-next-line no-restricted-syntax
83
+ for (const source in metrics[checkpoint]) {
68
84
  if (!variantObject[checkpoint][source]) {
69
85
  variantObject[checkpoint][source] = weight;
70
86
  } else {
@@ -72,6 +88,25 @@ function handler(bundles) {
72
88
  }
73
89
  }
74
90
  }
91
+ // add each metric to the variantObject's * count by weight
92
+ for (const checkpoint of Object.keys(metrics)) {
93
+ if (Object.keys(metrics[checkpoint]).length > 0) {
94
+ if (!variantObject[checkpoint]['*']) {
95
+ variantObject[checkpoint]['*'] = weight;
96
+ } else {
97
+ variantObject[checkpoint]['*'] += weight;
98
+ }
99
+ }
100
+ }
101
+ // add global interactionsCount if there's any interaction
102
+ const hasInteraction = Object.values(metrics).some((m) => Object.keys(m).length > 0);
103
+ if (hasInteraction) {
104
+ if (!variantObject.interactionsCount) {
105
+ variantObject.interactionsCount = weight;
106
+ } else {
107
+ variantObject.interactionsCount += weight;
108
+ }
109
+ }
75
110
  }
76
111
  }
77
112
  return experimentInsights;