@cuemath/web-utils 1.0.4 → 1.0.5-beta.0
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/dist/e-cna/index.d.ts +4 -0
- package/dist/e-cna/index.js +22 -0
- package/dist/e-cna/index.js.map +1 -0
- package/dist/growth-source/index.d.ts +1 -1
- package/dist/growth-source/index.js +3 -1
- package/dist/growth-source/index.js.map +1 -1
- package/dist/growth-source/types.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package-lock.json +3274 -0
- package/package.json +3 -2
- package/src/e-cna/index.ts +23 -0
- package/src/growth-source/index.ts +3 -0
- package/src/growth-source/types.ts +2 -0
- package/src/index.ts +1 -0
- package/dist/date-time-helper/e-cna/index.d.ts +0 -4
- package/dist/date-time-helper/e-cna/index.js +0 -40
- package/dist/date-time-helper/e-cna/index.js.map +0 -1
- package/src/date-time-helper/e-cna/index.ts +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuemath/web-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5-beta.0",
|
|
4
4
|
"description": "Shared web utils package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@types/node": "^18.11.18",
|
|
44
|
-
"dayjs": "^1.11.7"
|
|
44
|
+
"dayjs": "^1.11.7",
|
|
45
|
+
"yarn": "^1.22.19"
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TWENTY_FOUR_HOURS_IN_SECONDS } from '../constants/date-time';
|
|
2
|
+
import { getCurrentDatebyTimezone } from '../date-time-helper/index';
|
|
3
|
+
|
|
4
|
+
// if adding any change in this function, then need update at all the places where we are using this function in website and astro
|
|
5
|
+
export const getDates = (
|
|
6
|
+
timezone: string,
|
|
7
|
+
): Array<{ futureDate: number; disabled: boolean }> => {
|
|
8
|
+
const currentDate = Date.parse(getCurrentDatebyTimezone(timezone)) / 1000;
|
|
9
|
+
const dates = [];
|
|
10
|
+
|
|
11
|
+
const days = 10;
|
|
12
|
+
const buffer = 2;
|
|
13
|
+
|
|
14
|
+
// getting dates by adding 86400 seconds(24 hours)
|
|
15
|
+
for (let i = 0; i < days; i += 1) {
|
|
16
|
+
dates.push({
|
|
17
|
+
futureDate: currentDate + TWENTY_FOUR_HOURS_IN_SECONDS * i,
|
|
18
|
+
disabled: !(i > buffer),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return dates;
|
|
23
|
+
};
|
|
@@ -160,6 +160,7 @@ export const initSourceDetails = async ({
|
|
|
160
160
|
organicChannel,
|
|
161
161
|
performanceChannel,
|
|
162
162
|
revenueChannel,
|
|
163
|
+
guestId
|
|
163
164
|
}: SourceDetails): Promise<void> => {
|
|
164
165
|
const utmParams: Partial<UTMParams> = getUTMParams();
|
|
165
166
|
const { utm_source: utmSource } = utmParams;
|
|
@@ -196,6 +197,7 @@ export const initSourceDetails = async ({
|
|
|
196
197
|
performance_channel: performanceChannel,
|
|
197
198
|
revenue_channel: revenueChannel,
|
|
198
199
|
first_page: getFirstPage(),
|
|
200
|
+
guest_id: guestId
|
|
199
201
|
};
|
|
200
202
|
|
|
201
203
|
writeSourceCookie(sourceDetails);
|
|
@@ -203,6 +205,7 @@ export const initSourceDetails = async ({
|
|
|
203
205
|
let updatedSource: Partial<SourceDetailsCookie> = {
|
|
204
206
|
experiment_dict: experiments,
|
|
205
207
|
flow: flow || getFlow(platform, experiments),
|
|
208
|
+
guest_id: guestId,
|
|
206
209
|
};
|
|
207
210
|
|
|
208
211
|
if (utmSource) {
|
|
@@ -30,6 +30,7 @@ export type SourceDetailsCookie = {
|
|
|
30
30
|
flow_entry?: string;
|
|
31
31
|
first_page?: string;
|
|
32
32
|
last_page?: string;
|
|
33
|
+
guest_id?: string;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export type SourceDetails = {
|
|
@@ -45,4 +46,5 @@ export type SourceDetails = {
|
|
|
45
46
|
flowEntry?: string;
|
|
46
47
|
firstPage?: string;
|
|
47
48
|
lastPage?: string;
|
|
49
|
+
guestId?: string;
|
|
48
50
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDates = void 0;
|
|
4
|
-
const index_1 = require("../../constants/country/index");
|
|
5
|
-
const date_time_1 = require("../../constants/date-time");
|
|
6
|
-
const index_2 = require("../index");
|
|
7
|
-
const getDates = (timezone, platform, country) => {
|
|
8
|
-
const currentDate = Date.parse((0, index_2.getCurrentDatebyTimezone)(timezone)) / 1000;
|
|
9
|
-
const dates = [];
|
|
10
|
-
let days = 7;
|
|
11
|
-
let buffer = 1;
|
|
12
|
-
switch (platform) {
|
|
13
|
-
case 'astro':
|
|
14
|
-
if (country === index_1.ISO_COUNTRY_CODE.INDIA) {
|
|
15
|
-
days = 10;
|
|
16
|
-
buffer = 2;
|
|
17
|
-
}
|
|
18
|
-
break;
|
|
19
|
-
case 'website':
|
|
20
|
-
if (country === index_1.ISO_COUNTRY_CODE.INDIA) {
|
|
21
|
-
days = 10;
|
|
22
|
-
buffer = 2;
|
|
23
|
-
}
|
|
24
|
-
break;
|
|
25
|
-
default:
|
|
26
|
-
days = 7;
|
|
27
|
-
buffer = 1;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
// getting dates by adding 86400 seconds(24 hours)
|
|
31
|
-
for (let i = 0; i < days; i += 1) {
|
|
32
|
-
dates.push({
|
|
33
|
-
futureDate: currentDate + date_time_1.TWENTY_FOUR_HOURS_IN_SECONDS * i,
|
|
34
|
-
disabled: !(i > buffer),
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return dates;
|
|
38
|
-
};
|
|
39
|
-
exports.getDates = getDates;
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-time-helper/e-cna/index.ts"],"names":[],"mappings":";;;AAAA,yDAAiE;AACjE,yDAAyE;AACzE,oCAAoD;AAE7C,MAAM,QAAQ,GAAG,CACtB,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACmC,EAAE;IACpD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,gCAAwB,EAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1E,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,QAAQ,QAAQ,EAAE;QAChB,KAAK,OAAO;YACV,IAAI,OAAO,KAAK,wBAAgB,CAAC,KAAK,EAAE;gBACtC,IAAI,GAAG,EAAE,CAAC;gBACV,MAAM,GAAG,CAAC,CAAC;aACZ;YACD,MAAM;QACR,KAAK,SAAS;YACZ,IAAI,OAAO,KAAK,wBAAgB,CAAC,KAAK,EAAE;gBACtC,IAAI,GAAG,EAAE,CAAC;gBACV,MAAM,GAAG,CAAC,CAAC;aACZ;YACD,MAAM;QACR;YACE,IAAI,GAAG,CAAC,CAAC;YACT,MAAM,GAAG,CAAC,CAAC;YACX,MAAM;KACT;IAED,kDAAkD;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE;QAChC,KAAK,CAAC,IAAI,CAAC;YACT,UAAU,EAAE,WAAW,GAAG,wCAA4B,GAAG,CAAC;YAC1D,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;SACxB,CAAC,CAAC;KACJ;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAvCW,QAAA,QAAQ,YAuCnB"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ISO_COUNTRY_CODE } from '../../constants/country/index';
|
|
2
|
-
import { TWENTY_FOUR_HOURS_IN_SECONDS } from '../../constants/date-time';
|
|
3
|
-
import { getCurrentDatebyTimezone } from '../index';
|
|
4
|
-
|
|
5
|
-
export const getDates = (
|
|
6
|
-
timezone: string,
|
|
7
|
-
platform: string,
|
|
8
|
-
country: string,
|
|
9
|
-
): Array<{ futureDate: number; disabled: boolean }> => {
|
|
10
|
-
const currentDate = Date.parse(getCurrentDatebyTimezone(timezone)) / 1000;
|
|
11
|
-
const dates = [];
|
|
12
|
-
|
|
13
|
-
let days = 7;
|
|
14
|
-
let buffer = 1;
|
|
15
|
-
|
|
16
|
-
switch (platform) {
|
|
17
|
-
case 'astro':
|
|
18
|
-
if (country === ISO_COUNTRY_CODE.INDIA) {
|
|
19
|
-
days = 10;
|
|
20
|
-
buffer = 2;
|
|
21
|
-
}
|
|
22
|
-
break;
|
|
23
|
-
case 'website':
|
|
24
|
-
if (country === ISO_COUNTRY_CODE.INDIA) {
|
|
25
|
-
days = 10;
|
|
26
|
-
buffer = 2;
|
|
27
|
-
}
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
days = 7;
|
|
31
|
-
buffer = 1;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// getting dates by adding 86400 seconds(24 hours)
|
|
36
|
-
for (let i = 0; i < days; i += 1) {
|
|
37
|
-
dates.push({
|
|
38
|
-
futureDate: currentDate + TWENTY_FOUR_HOURS_IN_SECONDS * i,
|
|
39
|
-
disabled: !(i > buffer),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return dates;
|
|
44
|
-
};
|