@adobe/spacecat-shared-rum-api-client 1.6.2 → 1.6.4

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,17 @@
1
+ # [@adobe/spacecat-shared-rum-api-client-v1.6.4](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v1.6.3...@adobe/spacecat-shared-rum-api-client-v1.6.4) (2024-02-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * create404Backlink and createRUMBacklink documentation ([#165](https://github.com/adobe/spacecat-shared/issues/165)) ([418ec68](https://github.com/adobe/spacecat-shared/commit/418ec68a1cabf22054688342438dcf2ea60acf38))
7
+
8
+ # [@adobe/spacecat-shared-rum-api-client-v1.6.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v1.6.2...@adobe/spacecat-shared-rum-api-client-v1.6.3) (2024-02-27)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add backlink params ([cbf715d](https://github.com/adobe/spacecat-shared/commit/cbf715d2e04762a8e8fb40bb7daca7f6f9df193a))
14
+
1
15
  # [@adobe/spacecat-shared-rum-api-client-v1.6.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-rum-api-client-v1.6.1...@adobe/spacecat-shared-rum-api-client-v1.6.2) (2024-02-21)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-rum-api-client",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Shared modules of the Spacecat Services - Rum API client",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.d.ts CHANGED
@@ -14,11 +14,23 @@ import { UniversalContext } from '@adobe/helix-universal';
14
14
 
15
15
  export interface RUMAPIOptions {
16
16
  interval?: number;
17
+ startdate?: string,
18
+ enddate?: string,
17
19
  offset?: number;
18
20
  limit?: number;
19
21
  url?: string;
20
22
  }
21
23
 
24
+ export interface RUMDashboardOptions {
25
+ interval?: number;
26
+ startdate?: string,
27
+ enddate?: string,
28
+ offset?: number;
29
+ limit?: number;
30
+ domainkey?: string,
31
+ url?: string;
32
+ }
33
+
22
34
  export default class RUMAPIClient {
23
35
  /**
24
36
  * Static factory method to create an instance of RUMAPIClient.
@@ -42,21 +54,23 @@ export default class RUMAPIClient {
42
54
  * Asynchronous method to create a RUM backlink.
43
55
  * @param {string} url - A string representing the URL for the backlink.
44
56
  * @param {number} expiry - An integer representing the expiry value for the backlink.
57
+ * @param {RUMDashboardOptions} params - An object representing the parameters to be included
45
58
  * @returns A Promise resolving to a string representing url of the created backlink.
46
59
  * @remarks This method creates a backlink to the RUM dashboard, allowing users
47
60
  * to view their reports and monitor real user activities.
48
61
  */
49
- createRUMBacklink(url: string, expiry: number): Promise<string>;
62
+ createRUMBacklink(url: string, expiry: number, params?: RUMDashboardOptions): Promise<string>;
50
63
 
51
64
  /**
52
65
  * Asynchronous method to create a 404 backlink.
53
66
  * @param {string} url - A string representing the URL for the backlink.
54
67
  * @param {number} expiry - An integer representing the expiry value for the backlink.
68
+ * @param {RUMDashboardOptions} params - An object representing the parameters to be included
55
69
  * @returns A Promise resolving to a string representing url of the created backlink.
56
70
  * @remarks This method creates a backlink to the 404 report, allowing users
57
71
  * to view their 404 pages.
58
72
  */
59
- create404Backlink(url: string, expiry: number): Promise<string>;
73
+ create404Backlink(url: string, expiry: number, params?: RUMDashboardOptions): Promise<string>;
60
74
 
61
75
  /**
62
76
  * Asynchronous method to return the RUM dashboard API call response data.
package/src/index.js CHANGED
@@ -88,9 +88,16 @@ async function generateDomainKey(domainkey, url, expiry) {
88
88
  return data[0].key;
89
89
  }
90
90
 
91
- async function createBacklink(dashboardUrl, domainKey, domainUrl, expiry) {
91
+ async function createBacklink(dashboardUrl, domainKey, domainUrl, expiry, params) {
92
92
  const scopedDomainKey = await generateDomainKey(domainKey, domainUrl, expiry);
93
- return `${dashboardUrl}?interval=${expiry}&offset=0&limit=100&url=${domainUrl}&domainkey=${scopedDomainKey}`;
93
+ return createUrl(dashboardUrl, {
94
+ offset: 0,
95
+ limit: 100,
96
+ url: domainUrl,
97
+ domainkey: scopedDomainKey,
98
+ interval: expiry,
99
+ ...params,
100
+ });
94
101
  }
95
102
 
96
103
  export default class RUMAPIClient {
@@ -160,11 +167,23 @@ export default class RUMAPIClient {
160
167
  return data.map((row) => row.hostname);
161
168
  }
162
169
 
163
- async createRUMBacklink(url, expiry) {
164
- return createBacklink(APIS.RUM_DASHBOARD_UI, this.domainkey, url, expiry);
170
+ async createRUMBacklink(url, expiry, params) {
171
+ return createBacklink(
172
+ APIS.RUM_DASHBOARD_UI,
173
+ this.domainkey,
174
+ url,
175
+ expiry,
176
+ params,
177
+ );
165
178
  }
166
179
 
167
- async create404Backlink(url, expiry) {
168
- return createBacklink(APIS.NOT_FOUND_DASHBOARD_UI, this.domainkey, url, expiry);
180
+ async create404Backlink(url, expiry, params) {
181
+ return createBacklink(
182
+ APIS.NOT_FOUND_DASHBOARD_UI,
183
+ this.domainkey,
184
+ url,
185
+ expiry,
186
+ params,
187
+ );
169
188
  }
170
189
  }