@rh-support/utils 2.1.37 → 2.1.39

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.
@@ -11,6 +11,7 @@ type AddToDate = {
11
11
  date?: string;
12
12
  };
13
13
  export declare const addDaysToDate: (params: AddToDate) => moment.Moment;
14
+ export declare const isValidDate: (dateString: string) => boolean;
14
15
  export declare const trafficSplit: (testVariationWeight: number, dateString: string) => "A" | "B";
15
16
  export {};
16
17
  //# sourceMappingURL=dateUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAQF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
1
+ {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAEF,eAAO,MAAM,WAAW,eAAgB,MAAM,YAI7C,CAAC;AAQF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { isValid, parseISO } from 'date-fns';
1
2
  import moment from 'moment-timezone';
2
3
  export const formatDate = (date, locale = 'en-us', format = { month: 'short', day: 'numeric', year: 'numeric' }) => {
3
4
  if (!date) {
@@ -40,6 +41,10 @@ export const addDaysToDate = (params) => {
40
41
  const { days, date = new Date() } = params;
41
42
  return moment(date).add(days, 'days');
42
43
  };
44
+ export const isValidDate = (dateString) => {
45
+ const parsedDate = parseISO(dateString);
46
+ return isValid(parsedDate);
47
+ };
43
48
  // split traffic based on time and weight
44
49
  // for example, if testVariationWeight is 2 and the current time in seconds modulo 10 is less than 2,
45
50
  // redirect to test version (20% of the time), else redirect to control version (80% of the time)
@@ -4,6 +4,8 @@ export interface IPendoTrackEventProperty {
4
4
  }
5
5
  declare function haltEvent(event: React.SyntheticEvent<{}>): void;
6
6
  declare function pendoTrackEvent(name: any, properties?: IPendoTrackEventProperty): void;
7
- declare function dtmTrackEvent(eventName: string, caseNumber?: string, product?: string): void;
8
- export { haltEvent, pendoTrackEvent, dtmTrackEvent };
7
+ declare function dtmTrackEvent(eventName: string, stepName: string, caseNumber?: string, product?: string): void;
8
+ declare function dtmTrackEventCaseStartStopped(stepName: string, caseNumber?: string, product?: string): void;
9
+ declare function dtmTrackEventCaseDetailsSolutionDocs(stepName: string, caseNumber?: string, product?: string): void;
10
+ export { haltEvent, pendoTrackEvent, dtmTrackEvent, dtmTrackEventCaseStartStopped, dtmTrackEventCaseDetailsSolutionDocs, };
9
11
  //# sourceMappingURL=eventUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eventUtils.d.ts","sourceRoot":"","sources":["../../src/eventUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,QAKjD;AAKD,iBAAS,eAAe,CAAC,IAAI,KAAA,EAAE,UAAU,GAAE,wBAA6B,QAMvE;AAED,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAU9E;AAED,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"eventUtils.d.ts","sourceRoot":"","sources":["../../src/eventUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,QAKjD;AAKD,iBAAS,eAAe,CAAC,IAAI,KAAA,EAAE,UAAU,GAAE,wBAA6B,QAMvE;AAED,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAUhG;AAED,iBAAS,6BAA6B,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAE7F;AAED,iBAAS,oCAAoC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,QAEpG;AAED,OAAO,EACH,SAAS,EACT,eAAe,EACf,aAAa,EACb,6BAA6B,EAC7B,oCAAoC,GACvC,CAAC"}
@@ -16,15 +16,21 @@ function pendoTrackEvent(name, properties = {}) {
16
16
  pendo.track(name, properties);
17
17
  }
18
18
  }
19
- function dtmTrackEvent(eventName, caseNumber, product) {
19
+ function dtmTrackEvent(eventName, stepName, caseNumber, product) {
20
20
  (window.appEventData || []).push({
21
- event: 'Case Step Encountered',
21
+ event: eventName,
22
22
  case: {
23
23
  type: 'cp-support',
24
- stepName: eventName, //submit, close, comment, follow, review, search, recommendation click
24
+ stepName, //submit, close, comment, follow, review, search, recommendation click
25
25
  caseNumber,
26
26
  caseProduct: product,
27
27
  },
28
28
  });
29
29
  }
30
- export { haltEvent, pendoTrackEvent, dtmTrackEvent };
30
+ function dtmTrackEventCaseStartStopped(stepName, caseNumber, product) {
31
+ dtmTrackEvent('Case Step Encountered', stepName, caseNumber, product);
32
+ }
33
+ function dtmTrackEventCaseDetailsSolutionDocs(stepName, caseNumber, product) {
34
+ dtmTrackEvent('Case details solution docs', stepName, caseNumber, product);
35
+ }
36
+ export { haltEvent, pendoTrackEvent, dtmTrackEvent, dtmTrackEventCaseStartStopped, dtmTrackEventCaseDetailsSolutionDocs, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "2.1.37",
3
+ "version": "2.1.39",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -41,7 +41,7 @@
41
41
  "prepublishOnly": "npm run build"
42
42
  },
43
43
  "peerDependencies": {
44
- "@cee-eng/hydrajs": "4.17.21",
44
+ "@cee-eng/hydrajs": "4.17.24",
45
45
  "@cee-eng/ui-toolkit": "1.1.8",
46
46
  "dompurify": "^2.2.6",
47
47
  "i18next": "^22.5.1",
@@ -55,9 +55,10 @@
55
55
  "solr-query-builder": "1.0.1"
56
56
  },
57
57
  "dependencies": {
58
- "@cee-eng/hydrajs": "4.17.21",
58
+ "@cee-eng/hydrajs": "4.17.24",
59
59
  "@cee-eng/ui-toolkit": "1.1.8",
60
60
  "@rh-support/types": "2.0.4",
61
+ "date-fns": "3.6.0",
61
62
  "dompurify": "^2.2.6",
62
63
  "dot": "^1.1.3",
63
64
  "i18next": "^22.5.1",
@@ -93,5 +94,5 @@
93
94
  "defaults and supports es6-module",
94
95
  "maintained node versions"
95
96
  ],
96
- "gitHead": "fe9dac0d0d3517281da0692cf84070b998b22f78"
97
+ "gitHead": "c195673bed3013aac9cc45a1a7db4d9d28b218e7"
97
98
  }