@cuemath/web-utils 0.0.1-beta.6 → 0.0.2-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.
Files changed (215) hide show
  1. package/.husky/pre-commit +0 -1
  2. package/dist/index.js +1 -6
  3. package/package.json +8 -18
  4. package/src/cookie/index.ts +10 -4
  5. package/src/growth-source/index.ts +172 -0
  6. package/src/growth-source/types.ts +33 -0
  7. package/src/index.ts +1 -6
  8. package/.eslintignore +0 -2
  9. package/.huskyrc +0 -5
  10. package/.lintstagedrc.yml +0 -5
  11. package/dist/constants/country/index.d.ts +0 -2
  12. package/dist/constants/country/index.js +0 -7
  13. package/dist/constants/country/index.js.map +0 -1
  14. package/dist/constants/country/iso-country-code.d.ts +0 -248
  15. package/dist/constants/country/iso-country-code.js +0 -252
  16. package/dist/constants/country/iso-country-code.js.map +0 -1
  17. package/dist/constants/date-time/index.d.ts +0 -17
  18. package/dist/constants/date-time/index.js +0 -42
  19. package/dist/constants/date-time/index.js.map +0 -1
  20. package/dist/constants/date-time/international-timezones.d.ts +0 -7
  21. package/dist/constants/date-time/international-timezones.js +0 -155
  22. package/dist/constants/date-time/international-timezones.js.map +0 -1
  23. package/dist/constants/e-cna/index.d.ts +0 -35
  24. package/dist/constants/e-cna/index.js +0 -39
  25. package/dist/constants/e-cna/index.js.map +0 -1
  26. package/dist/constants/index.d.ts +0 -2
  27. package/dist/constants/index.js +0 -19
  28. package/dist/constants/index.js.map +0 -1
  29. package/dist/cookie/index.d.ts +0 -4
  30. package/dist/cookie/index.js +0 -46
  31. package/dist/cookie/index.js.map +0 -1
  32. package/dist/country/index.d.ts +0 -1
  33. package/dist/country/index.js +0 -13
  34. package/dist/country/index.js.map +0 -1
  35. package/dist/date-time-helper/e-cna.d.ts +0 -32
  36. package/dist/date-time-helper/e-cna.js +0 -153
  37. package/dist/date-time-helper/e-cna.js.map +0 -1
  38. package/dist/date-time-helper/index.d.ts +0 -51
  39. package/dist/date-time-helper/index.js +0 -233
  40. package/dist/date-time-helper/index.js.map +0 -1
  41. package/dist/e-cna/flow/aggregator.d.ts +0 -219
  42. package/dist/e-cna/flow/aggregator.js +0 -16
  43. package/dist/e-cna/flow/aggregator.js.map +0 -1
  44. package/dist/e-cna/flow/index.d.ts +0 -1
  45. package/dist/e-cna/flow/index.js +0 -18
  46. package/dist/e-cna/flow/index.js.map +0 -1
  47. package/dist/e-cna/flow/variants/default.d.ts +0 -219
  48. package/dist/e-cna/flow/variants/default.js +0 -28
  49. package/dist/e-cna/flow/variants/default.js.map +0 -1
  50. package/dist/e-cna/flow/variants/index.d.ts +0 -1
  51. package/dist/e-cna/flow/variants/index.js +0 -18
  52. package/dist/e-cna/flow/variants/index.js.map +0 -1
  53. package/dist/e-cna/index.d.ts +0 -43
  54. package/dist/e-cna/index.js +0 -221
  55. package/dist/e-cna/index.js.map +0 -1
  56. package/dist/e-cna/slides/child_hobbies/index.d.ts +0 -1
  57. package/dist/e-cna/slides/child_hobbies/index.js +0 -18
  58. package/dist/e-cna/slides/child_hobbies/index.js.map +0 -1
  59. package/dist/e-cna/slides/child_hobbies/variants.d.ts +0 -12
  60. package/dist/e-cna/slides/child_hobbies/variants.js +0 -16
  61. package/dist/e-cna/slides/child_hobbies/variants.js.map +0 -1
  62. package/dist/e-cna/slides/child_personality/index.d.ts +0 -1
  63. package/dist/e-cna/slides/child_personality/index.js +0 -18
  64. package/dist/e-cna/slides/child_personality/index.js.map +0 -1
  65. package/dist/e-cna/slides/child_personality/variants.d.ts +0 -12
  66. package/dist/e-cna/slides/child_personality/variants.js +0 -16
  67. package/dist/e-cna/slides/child_personality/variants.js.map +0 -1
  68. package/dist/e-cna/slides/curriculum/index.d.ts +0 -1
  69. package/dist/e-cna/slides/curriculum/index.js +0 -18
  70. package/dist/e-cna/slides/curriculum/index.js.map +0 -1
  71. package/dist/e-cna/slides/curriculum/variants.d.ts +0 -12
  72. package/dist/e-cna/slides/curriculum/variants.js +0 -17
  73. package/dist/e-cna/slides/curriculum/variants.js.map +0 -1
  74. package/dist/e-cna/slides/grade/index.d.ts +0 -1
  75. package/dist/e-cna/slides/grade/index.js +0 -18
  76. package/dist/e-cna/slides/grade/index.js.map +0 -1
  77. package/dist/e-cna/slides/grade/variants.d.ts +0 -18
  78. package/dist/e-cna/slides/grade/variants.js +0 -31
  79. package/dist/e-cna/slides/grade/variants.js.map +0 -1
  80. package/dist/e-cna/slides/index.d.ts +0 -17
  81. package/dist/e-cna/slides/index.js +0 -34
  82. package/dist/e-cna/slides/index.js.map +0 -1
  83. package/dist/e-cna/slides/intro/index.d.ts +0 -1
  84. package/dist/e-cna/slides/intro/index.js +0 -18
  85. package/dist/e-cna/slides/intro/index.js.map +0 -1
  86. package/dist/e-cna/slides/intro/variants.d.ts +0 -7
  87. package/dist/e-cna/slides/intro/variants.js +0 -11
  88. package/dist/e-cna/slides/intro/variants.js.map +0 -1
  89. package/dist/e-cna/slides/key_need_l1/index.d.ts +0 -1
  90. package/dist/e-cna/slides/key_need_l1/index.js +0 -18
  91. package/dist/e-cna/slides/key_need_l1/index.js.map +0 -1
  92. package/dist/e-cna/slides/key_need_l1/variants.d.ts +0 -14
  93. package/dist/e-cna/slides/key_need_l1/variants.js +0 -45
  94. package/dist/e-cna/slides/key_need_l1/variants.js.map +0 -1
  95. package/dist/e-cna/slides/key_need_l2/index.d.ts +0 -1
  96. package/dist/e-cna/slides/key_need_l2/index.js +0 -18
  97. package/dist/e-cna/slides/key_need_l2/index.js.map +0 -1
  98. package/dist/e-cna/slides/key_need_l2/variants.d.ts +0 -67
  99. package/dist/e-cna/slides/key_need_l2/variants.js +0 -139
  100. package/dist/e-cna/slides/key_need_l2/variants.js.map +0 -1
  101. package/dist/e-cna/slides/key_need_l3/index.d.ts +0 -1
  102. package/dist/e-cna/slides/key_need_l3/index.js +0 -18
  103. package/dist/e-cna/slides/key_need_l3/index.js.map +0 -1
  104. package/dist/e-cna/slides/key_need_l3/variants.d.ts +0 -11
  105. package/dist/e-cna/slides/key_need_l3/variants.js +0 -15
  106. package/dist/e-cna/slides/key_need_l3/variants.js.map +0 -1
  107. package/dist/e-cna/slides/math-perception/index.d.ts +0 -1
  108. package/dist/e-cna/slides/math-perception/index.js +0 -18
  109. package/dist/e-cna/slides/math-perception/index.js.map +0 -1
  110. package/dist/e-cna/slides/math-perception/variants.d.ts +0 -15
  111. package/dist/e-cna/slides/math-perception/variants.js +0 -32
  112. package/dist/e-cna/slides/math-perception/variants.js.map +0 -1
  113. package/dist/e-cna/slides/other_curriculum/index.d.ts +0 -1
  114. package/dist/e-cna/slides/other_curriculum/index.js +0 -18
  115. package/dist/e-cna/slides/other_curriculum/index.js.map +0 -1
  116. package/dist/e-cna/slides/other_curriculum/variants.d.ts +0 -12
  117. package/dist/e-cna/slides/other_curriculum/variants.js +0 -17
  118. package/dist/e-cna/slides/other_curriculum/variants.js.map +0 -1
  119. package/dist/e-cna/slides/school_performance_5_12/index.d.ts +0 -1
  120. package/dist/e-cna/slides/school_performance_5_12/index.js +0 -18
  121. package/dist/e-cna/slides/school_performance_5_12/index.js.map +0 -1
  122. package/dist/e-cna/slides/school_performance_5_12/variants.d.ts +0 -15
  123. package/dist/e-cna/slides/school_performance_5_12/variants.js +0 -26
  124. package/dist/e-cna/slides/school_performance_5_12/variants.js.map +0 -1
  125. package/dist/e-cna/slides/school_performance_kg_4/index.d.ts +0 -1
  126. package/dist/e-cna/slides/school_performance_kg_4/index.js +0 -18
  127. package/dist/e-cna/slides/school_performance_kg_4/index.js.map +0 -1
  128. package/dist/e-cna/slides/school_performance_kg_4/variants.d.ts +0 -14
  129. package/dist/e-cna/slides/school_performance_kg_4/variants.js +0 -28
  130. package/dist/e-cna/slides/school_performance_kg_4/variants.js.map +0 -1
  131. package/dist/e-cna/slides/secondary_needs/index.d.ts +0 -1
  132. package/dist/e-cna/slides/secondary_needs/index.js +0 -18
  133. package/dist/e-cna/slides/secondary_needs/index.js.map +0 -1
  134. package/dist/e-cna/slides/secondary_needs/variants.d.ts +0 -14
  135. package/dist/e-cna/slides/secondary_needs/variants.js +0 -28
  136. package/dist/e-cna/slides/secondary_needs/variants.js.map +0 -1
  137. package/dist/e-cna/slides/signup/index.d.ts +0 -1
  138. package/dist/e-cna/slides/signup/index.js +0 -18
  139. package/dist/e-cna/slides/signup/index.js.map +0 -1
  140. package/dist/e-cna/slides/signup/variants.d.ts +0 -7
  141. package/dist/e-cna/slides/signup/variants.js +0 -11
  142. package/dist/e-cna/slides/signup/variants.js.map +0 -1
  143. package/dist/e-cna/slides/signup_refer/index.d.ts +0 -1
  144. package/dist/e-cna/slides/signup_refer/index.js +0 -18
  145. package/dist/e-cna/slides/signup_refer/index.js.map +0 -1
  146. package/dist/e-cna/slides/signup_refer/variants.d.ts +0 -12
  147. package/dist/e-cna/slides/signup_refer/variants.js +0 -20
  148. package/dist/e-cna/slides/signup_refer/variants.js.map +0 -1
  149. package/dist/e-cna/slides/slot_pick/index.d.ts +0 -1
  150. package/dist/e-cna/slides/slot_pick/index.js +0 -18
  151. package/dist/e-cna/slides/slot_pick/index.js.map +0 -1
  152. package/dist/e-cna/slides/slot_pick/variants.d.ts +0 -7
  153. package/dist/e-cna/slides/slot_pick/variants.js +0 -11
  154. package/dist/e-cna/slides/slot_pick/variants.js.map +0 -1
  155. package/dist/e-cna/utils/index.d.ts +0 -4
  156. package/dist/e-cna/utils/index.js +0 -28
  157. package/dist/e-cna/utils/index.js.map +0 -1
  158. package/dist/index.d.ts +0 -7
  159. package/dist/index.js.map +0 -1
  160. package/dist/local-storage/index.d.ts +0 -13
  161. package/dist/local-storage/index.js +0 -172
  162. package/dist/local-storage/index.js.map +0 -1
  163. package/dist/object/index.d.ts +0 -6
  164. package/dist/object/index.js +0 -24
  165. package/dist/object/index.js.map +0 -1
  166. package/src/constants/country/index.ts +0 -2
  167. package/src/constants/country/iso-country-code.ts +0 -248
  168. package/src/constants/date-time/index.ts +0 -43
  169. package/src/constants/date-time/international-timezones.ts +0 -157
  170. package/src/constants/e-cna/index.ts +0 -45
  171. package/src/constants/index.ts +0 -2
  172. package/src/country/index.ts +0 -9
  173. package/src/date-time-helper/e-cna.ts +0 -205
  174. package/src/date-time-helper/index.ts +0 -306
  175. package/src/e-cna/flow/aggregator.ts +0 -12
  176. package/src/e-cna/flow/index.ts +0 -1
  177. package/src/e-cna/flow/variants/default.ts +0 -42
  178. package/src/e-cna/flow/variants/index.ts +0 -1
  179. package/src/e-cna/index.ts +0 -249
  180. package/src/e-cna/slides/child_hobbies/index.ts +0 -1
  181. package/src/e-cna/slides/child_hobbies/variants.ts +0 -13
  182. package/src/e-cna/slides/child_personality/index.ts +0 -1
  183. package/src/e-cna/slides/child_personality/variants.ts +0 -12
  184. package/src/e-cna/slides/curriculum/index.ts +0 -1
  185. package/src/e-cna/slides/curriculum/variants.ts +0 -14
  186. package/src/e-cna/slides/grade/index.ts +0 -1
  187. package/src/e-cna/slides/grade/variants.ts +0 -29
  188. package/src/e-cna/slides/index.ts +0 -17
  189. package/src/e-cna/slides/intro/index.ts +0 -1
  190. package/src/e-cna/slides/intro/variants.ts +0 -7
  191. package/src/e-cna/slides/key_need_l1/index.ts +0 -1
  192. package/src/e-cna/slides/key_need_l1/variants.ts +0 -44
  193. package/src/e-cna/slides/key_need_l2/index.ts +0 -1
  194. package/src/e-cna/slides/key_need_l2/variants.ts +0 -143
  195. package/src/e-cna/slides/key_need_l3/index.ts +0 -1
  196. package/src/e-cna/slides/key_need_l3/variants.ts +0 -13
  197. package/src/e-cna/slides/math-perception/index.ts +0 -1
  198. package/src/e-cna/slides/math-perception/variants.ts +0 -30
  199. package/src/e-cna/slides/other_curriculum/index.ts +0 -1
  200. package/src/e-cna/slides/other_curriculum/variants.ts +0 -14
  201. package/src/e-cna/slides/school_performance_5_12/index.ts +0 -1
  202. package/src/e-cna/slides/school_performance_5_12/variants.ts +0 -23
  203. package/src/e-cna/slides/school_performance_kg_4/index.ts +0 -1
  204. package/src/e-cna/slides/school_performance_kg_4/variants.ts +0 -25
  205. package/src/e-cna/slides/secondary_needs/index.ts +0 -1
  206. package/src/e-cna/slides/secondary_needs/variants.ts +0 -26
  207. package/src/e-cna/slides/signup/index.ts +0 -1
  208. package/src/e-cna/slides/signup/variants.ts +0 -7
  209. package/src/e-cna/slides/signup_refer/index.ts +0 -1
  210. package/src/e-cna/slides/signup_refer/variants.ts +0 -16
  211. package/src/e-cna/slides/slot_pick/index.ts +0 -1
  212. package/src/e-cna/slides/slot_pick/variants.ts +0 -7
  213. package/src/e-cna/utils/index.ts +0 -32
  214. package/src/local-storage/index.ts +0 -186
  215. package/src/object/index.ts +0 -26
package/.husky/pre-commit CHANGED
@@ -2,4 +2,3 @@
2
2
  . "$(dirname -- "$0")/_/husky.sh"
3
3
 
4
4
  yarn lint
5
- npx lint-staged
package/dist/index.js CHANGED
@@ -15,10 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./cookie"), exports);
18
- __exportStar(require("./constants"), exports);
19
- __exportStar(require("./local-storage"), exports);
20
- __exportStar(require("./e-cna"), exports);
21
- __exportStar(require("./date-time-helper"), exports);
22
- __exportStar(require("./country"), exports);
23
- __exportStar(require("./object"), exports);
18
+ __exportStar(require("./growth-source"), exports);
24
19
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuemath/web-utils",
3
- "version": "0.0.1-beta.6",
3
+ "version": "0.0.2-beta.0",
4
4
  "description": "Shareable utils package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -8,8 +8,7 @@
8
8
  "build": "tsc",
9
9
  "build-watch": "tsc -w",
10
10
  "prepublishOnly": "rm -rf dist && yarn build",
11
- "prepare": "husky install",
12
- "precommit": "lint-staged"
11
+ "prepare": "husky install"
13
12
  },
14
13
  "repository": {
15
14
  "type": "git",
@@ -25,28 +24,19 @@
25
24
  "@cuemath/eslint-config": "1.0.9",
26
25
  "@cuemath/prettier-config": "1.0.3",
27
26
  "@cuemath/ts-config": "0.0.5",
28
- "@react-native-community/eslint-config": "^3.2.0",
27
+ "@react-native-community/eslint-config": "3.2.0",
29
28
  "@types/uuid": "9.0.0",
30
29
  "@typescript-eslint/eslint-plugin": "5.47.0",
31
30
  "@typescript-eslint/parser": "5.47.0",
32
- "eslint": "^7.32.0",
31
+ "eslint": "8.1.0",
33
32
  "eslint-config-prettier": "8.5.0",
34
33
  "eslint-plugin-import": "2.26.0",
34
+ "eslint-plugin-jest": "^27.2.1",
35
35
  "eslint-plugin-prettier": "4.2.1",
36
36
  "husky": "8.0.2",
37
- "lint-staged": ">=10",
38
- "prettier": "^2.8.1",
37
+ "prettier": "2.4.1",
39
38
  "typescript": "4.9.4"
40
39
  },
41
- "dependencies": {
42
- "@types/node": "^18.11.18",
43
- "dayjs": "^1.11.7",
44
- "typescript": "4.9.4"
45
- },
46
- "lint-staged": {
47
- "*.{js,json,css,scss,html,md,ts}": [
48
- "prettier --write",
49
- "git add"
50
- ]
51
- }
40
+ "dependencies": {},
41
+ "side-effects": false
52
42
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  export const getCookie = (name: string, cookie: string = document.cookie): string => {
3
2
  if (!cookie) {
4
3
  return '';
@@ -29,7 +28,12 @@ export function removeCookie(name: string): void {
29
28
  document.cookie = `${name}=; expires=${date.toUTCString()}; path=/`;
30
29
  }
31
30
 
32
- export function createCookie(name: string, value: string, days: number): void {
31
+ export function createCookie(
32
+ name: string,
33
+ value: string,
34
+ days: number,
35
+ subdomain: boolean,
36
+ ): void {
33
37
  let expires = '';
34
38
 
35
39
  if (days) {
@@ -38,7 +42,9 @@ export function createCookie(name: string, value: string, days: number): void {
38
42
  date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
39
43
  expires = `; expires=${date.toUTCString()}`;
40
44
  }
41
- document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/`;
45
+ document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/${
46
+ subdomain ? '; .cuemath.com' : ''
47
+ }`;
42
48
  }
43
49
 
44
50
  export function createCookieWithMidnightExp(name: string, value: string): void {
@@ -48,4 +54,4 @@ export function createCookieWithMidnightExp(name: string, value: string): void {
48
54
  const expires = `; expires=${date}`;
49
55
 
50
56
  document.cookie = `${name}=${value}${expires}; path=/`;
51
- }
57
+ }
@@ -0,0 +1,172 @@
1
+ import type {
2
+ SourceDetails,
3
+ Platform,
4
+ SignupFlow,
5
+ UTMParams,
6
+ Experiments,
7
+ RevenueChannel,
8
+ UTMParamsKeys,
9
+ } from './types';
10
+
11
+ import { createCookie, getCookie } from '../cookie';
12
+
13
+ const SOURCE_DETAILS_COOKIE = 'source_details_v1';
14
+ const UTM_PARAMS: UTMParamsKeys[] = [
15
+ 'utm_source',
16
+ 'utm_medium',
17
+ 'utm_campaign',
18
+ 'utm_term',
19
+ ];
20
+
21
+ const readSourceCookie = () => {
22
+ const sourceDetails = getCookie(SOURCE_DETAILS_COOKIE);
23
+
24
+ return sourceDetails && JSON.parse(sourceDetails);
25
+ };
26
+
27
+ const writeSourceCookie = (sourceDetails: SourceDetails) => {
28
+ createCookie(SOURCE_DETAILS_COOKIE, JSON.stringify(sourceDetails), 365, true);
29
+ };
30
+
31
+ const updateSourceCookie = (sourceDetail: Partial<SourceDetails>) => {
32
+ const sourceDetails: SourceDetails = readSourceCookie();
33
+ const updatedDetails: SourceDetails = {
34
+ ...sourceDetails,
35
+ ...sourceDetail,
36
+ };
37
+
38
+ writeSourceCookie(updatedDetails);
39
+ };
40
+
41
+ const getRevenueChannel = (platform: Platform, utmParams?: UTMParams) => {
42
+ let revenueChannel: RevenueChannel = 'UNKNOWN';
43
+
44
+ if (platform === 'ASTRO' && utmParams) {
45
+ const { utm_source: utmSource = '' } = utmParams;
46
+
47
+ switch (true) {
48
+ case /^affiliate-/.test(utmSource):
49
+ revenueChannel = 'AFFILIATE';
50
+ break;
51
+ case /^offline-/.test(utmSource):
52
+ revenueChannel = 'OFFLINE';
53
+ break;
54
+ case /^referral-/.test(utmSource):
55
+ revenueChannel = 'REFERRAL';
56
+ break;
57
+ case /^performance-/.test(utmSource):
58
+ default:
59
+ revenueChannel = 'PERFORMANCE';
60
+ }
61
+ }
62
+
63
+ if (platform === 'WEBSITE') {
64
+ revenueChannel = 'ORGANIC';
65
+ }
66
+
67
+ return revenueChannel;
68
+ };
69
+
70
+ /*
71
+ if Platform = website, then decide based on experiment key
72
+ if Platform = Astro, decide logic once BAU is started
73
+ if Platform = APP, decide logic
74
+ if Platform = chatbot, decide based on chatbot experiment key
75
+ */
76
+ const getFlow = (platform: Platform, experiments?: Experiments) => {
77
+ let flow: SignupFlow = 'REGULAR';
78
+
79
+ if (platform === 'WEBSITE') {
80
+ if (experiments) {
81
+ const ecnaExp = Object.keys(experiments).find(
82
+ experiment => experiment.indexOf('ecna') !== -1,
83
+ );
84
+
85
+ flow = ecnaExp && experiments[ecnaExp] === 'b' ? 'ECNA' : 'REGULAR';
86
+ }
87
+ }
88
+
89
+ return flow;
90
+ };
91
+
92
+ const getUTMParams = () => {
93
+ if (typeof window === undefined) return;
94
+
95
+ const search = new URLSearchParams(window.location.search);
96
+ const utmParams = UTM_PARAMS.reduce((acc: UTMParams, param) => {
97
+ const utmParam = search.get(param) as string;
98
+
99
+ if (utmParam) {
100
+ acc[param] = utmParam;
101
+ }
102
+
103
+ return acc;
104
+ }, {});
105
+
106
+ return utmParams;
107
+ };
108
+
109
+ const getFirstPage = () => {
110
+ if (typeof window === undefined) return '';
111
+
112
+ return window.location.pathname;
113
+ };
114
+
115
+ /* TODO: Align Marketing Team on UTM source convention
116
+ affiliate-<channel>
117
+ performance-<channel>
118
+ organic-<channel>
119
+ offline-<channel>
120
+ */
121
+ const getChannel = (utmParams: UTMParams | undefined) => {
122
+ // TODO: UTM source patter for FB, GOOGLE...
123
+ if (!utmParams) return '';
124
+
125
+ const { utm_source: utmSource = '' } = utmParams;
126
+
127
+ return utmSource.split('-')[1];
128
+ };
129
+
130
+ /*
131
+ Set Static Source Details of user on Visit of Platform
132
+ */
133
+ export const initSourceDetails = async ({
134
+ platform,
135
+ experiments,
136
+ utmParams,
137
+ flow,
138
+ affiliateChannel,
139
+ offlineChannel,
140
+ organicChannel,
141
+ performanceChannel,
142
+ revenueChannel,
143
+ }: SourceDetails) => {
144
+ if (!readSourceCookie()) {
145
+ const leadChannel = getChannel(utmParams);
146
+
147
+ const sourceDetails: SourceDetails = {
148
+ platform,
149
+ experiments,
150
+ utmParams: getUTMParams(),
151
+ flow: flow || getFlow(platform, experiments),
152
+ affiliateChannel: affiliateChannel || leadChannel,
153
+ offlineChannel: offlineChannel || leadChannel,
154
+ organicChannel: organicChannel || leadChannel,
155
+ performanceChannel: performanceChannel || leadChannel,
156
+ revenueChannel: revenueChannel || getRevenueChannel(platform, utmParams),
157
+ firstPage: getFirstPage(),
158
+ };
159
+
160
+ writeSourceCookie(sourceDetails);
161
+ }
162
+ };
163
+
164
+ // Last Page which user visited signup before
165
+ export const setLastPage = async (pagePath: string) => {
166
+ updateSourceCookie({ lastPage: pagePath });
167
+ };
168
+
169
+ // set Entry point where user clicked to Signup
170
+ export const setFlowEntryPoint = async (flowEntry: string) => {
171
+ updateSourceCookie({ flowEntry });
172
+ };
@@ -0,0 +1,33 @@
1
+ export type Platform = 'WEBSITE' | 'APP' | 'ASTRO' | 'LEAP_TEACHER' | 'LEAP_ADMIN';
2
+ export type RevenueChannel =
3
+ | 'ORGANIC'
4
+ | 'PERFORMANCE'
5
+ | 'AFFILIATE'
6
+ | 'OFFLINE'
7
+ | 'REFERRAL'
8
+ | 'UNKNOWN';
9
+ export type SignupFlow = 'REGULAR' | 'ECNA' | 'ESALES';
10
+ export type Experiments = Record<string, unknown>;
11
+ export type UTMParams = {
12
+ utm_source?: string;
13
+ utm_medium?: string;
14
+ utm_campaign?: string;
15
+ utm_term?: string;
16
+ };
17
+
18
+ export type UTMParamsKeys = keyof UTMParams;
19
+
20
+ export type SourceDetails = {
21
+ platform: Platform;
22
+ experiments?: Experiments;
23
+ flow?: SignupFlow;
24
+ utmParams?: UTMParams;
25
+ affiliateChannel?: string;
26
+ offlineChannel?: string;
27
+ performanceChannel: string;
28
+ revenueChannel: RevenueChannel;
29
+ organicChannel?: string;
30
+ flowEntry?: string;
31
+ firstPage?: string;
32
+ lastPage?: string;
33
+ };
package/src/index.ts CHANGED
@@ -1,7 +1,2 @@
1
1
  export * from './cookie';
2
- export * from './constants';
3
- export * from './local-storage';
4
- export * from './e-cna';
5
- export * from './date-time-helper';
6
- export * from './country';
7
- export * from './object';
2
+ export * from './growth-source';
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- .next
2
- /dist
package/.huskyrc DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "hooks": {
3
- "pre-commit": "lint-staged"
4
- }
5
- }
package/.lintstagedrc.yml DELETED
@@ -1,5 +0,0 @@
1
- linters:
2
- ./**/*.ts:
3
- - prettier --write
4
- - eslint
5
- - git add
@@ -1,2 +0,0 @@
1
- export { COUNTRY_NAME_COUNTRY_CODE_MAP as ISO_COUNTRY_CODE } from './iso-country-code';
2
- export declare const CUE_COUNTRY_CODE_KEY = "cue_country_code";
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CUE_COUNTRY_CODE_KEY = exports.ISO_COUNTRY_CODE = void 0;
4
- var iso_country_code_1 = require("./iso-country-code");
5
- Object.defineProperty(exports, "ISO_COUNTRY_CODE", { enumerable: true, get: function () { return iso_country_code_1.COUNTRY_NAME_COUNTRY_CODE_MAP; } });
6
- exports.CUE_COUNTRY_CODE_KEY = 'cue_country_code';
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/country/index.ts"],"names":[],"mappings":";;;AAAA,uDAAuF;AAA9E,oHAAA,6BAA6B,OAAoB;AAC7C,QAAA,oBAAoB,GAAG,kBAAkB,CAAC"}
@@ -1,248 +0,0 @@
1
- export declare const COUNTRY_NAME_COUNTRY_CODE_MAP: {
2
- AFGHANISTAN: string;
3
- 'ALAND ISLANDS': string;
4
- ALBANIA: string;
5
- ALGERIA: string;
6
- 'AMERICAN SAMOA': string;
7
- ANDORRA: string;
8
- ANGOLA: string;
9
- ANGUILLA: string;
10
- ANTARCTICA: string;
11
- 'ANTIGUA AND BARBUDA': string;
12
- ARGENTINA: string;
13
- ARMENIA: string;
14
- ARUBA: string;
15
- AUSTRALIA: string;
16
- AUSTRIA: string;
17
- AZERBAIJAN: string;
18
- BAHAMAS: string;
19
- BAHRAIN: string;
20
- BANGLADESH: string;
21
- BARBADOS: string;
22
- BELARUS: string;
23
- BELGIUM: string;
24
- BELIZE: string;
25
- BENIN: string;
26
- BERMUDA: string;
27
- BHUTAN: string;
28
- BOLIVIA: string;
29
- 'BOSNIA AND HERZEGOVINA': string;
30
- BOTSWANA: string;
31
- 'BOUVET ISLAND': string;
32
- BRAZIL: string;
33
- 'BRITISH INDIAN OCEAN TERRITORY': string;
34
- 'BRUNEI DARUSSALAM': string;
35
- BULGARIA: string;
36
- 'BURKINA FASO': string;
37
- BURUNDI: string;
38
- CAMBODIA: string;
39
- CAMEROON: string;
40
- CANADA: string;
41
- 'CAPE VERDE': string;
42
- 'CAYMAN ISLANDS': string;
43
- 'CENTRAL AFRICAN REPUBLIC': string;
44
- CHAD: string;
45
- CHILE: string;
46
- CHINA: string;
47
- 'CHRISTMAS ISLAND': string;
48
- 'COCOS (KEELING) ISLANDS': string;
49
- COLOMBIA: string;
50
- COMOROS: string;
51
- CONGO: string;
52
- 'CONGO, DEMOCRATIC REPUBLIC': string;
53
- 'COOK ISLANDS': string;
54
- 'COSTA RICA': string;
55
- 'COTE D"IVOIRE': string;
56
- CROATIA: string;
57
- CUBA: string;
58
- CYPRUS: string;
59
- 'CZECH REPUBLIC': string;
60
- DENMARK: string;
61
- DJIBOUTI: string;
62
- DOMINICA: string;
63
- 'DOMINICAN REPUBLIC': string;
64
- ECUADOR: string;
65
- EGYPT: string;
66
- 'EL SALVADOR': string;
67
- 'EQUATORIAL GUINEA': string;
68
- ERITREA: string;
69
- ESTONIA: string;
70
- ETHIOPIA: string;
71
- 'FALKLAND ISLANDS (MALVINAS)': string;
72
- 'FAROE ISLANDS': string;
73
- FIJI: string;
74
- FINLAND: string;
75
- FRANCE: string;
76
- 'FRENCH GUIANA': string;
77
- 'FRENCH POLYNESIA': string;
78
- 'FRENCH SOUTHERN TERRITORIES': string;
79
- GABON: string;
80
- GAMBIA: string;
81
- GEORGIA: string;
82
- GERMANY: string;
83
- GHANA: string;
84
- GIBRALTAR: string;
85
- GREECE: string;
86
- GREENLAND: string;
87
- GRENADA: string;
88
- GUADELOUPE: string;
89
- GUAM: string;
90
- GUATEMALA: string;
91
- GUERNSEY: string;
92
- GUINEA: string;
93
- 'GUINEA-BISSAU': string;
94
- GUYANA: string;
95
- HAITI: string;
96
- 'HEARD ISLAND & MCDONALD ISLANDS': string;
97
- 'HOLY SEE (VATICAN CITY STATE)': string;
98
- HONDURAS: string;
99
- 'HONG KONG': string;
100
- HUNGARY: string;
101
- ICELAND: string;
102
- INDIA: string;
103
- INDONESIA: string;
104
- 'IRAN, ISLAMIC REPUBLIC OF': string;
105
- IRAQ: string;
106
- IRELAND: string;
107
- 'ISLE OF MAN': string;
108
- ISRAEL: string;
109
- ITALY: string;
110
- JAMAICA: string;
111
- JAPAN: string;
112
- JERSEY: string;
113
- JORDAN: string;
114
- KAZAKHSTAN: string;
115
- KENYA: string;
116
- KIRIBATI: string;
117
- KOREA: string;
118
- 'NORTH KOREA': string;
119
- KUWAIT: string;
120
- KYRGYZSTAN: string;
121
- 'LAO PEOPLE"S DEMOCRATIC REPUBLIC': string;
122
- LATVIA: string;
123
- LEBANON: string;
124
- LESOTHO: string;
125
- LIBERIA: string;
126
- 'LIBYAN ARAB JAMAHIRIYA': string;
127
- LIECHTENSTEIN: string;
128
- LITHUANIA: string;
129
- LUXEMBOURG: string;
130
- MACAO: string;
131
- MACEDONIA: string;
132
- MADAGASCAR: string;
133
- MALAWI: string;
134
- MALAYSIA: string;
135
- MALDIVES: string;
136
- MALI: string;
137
- MALTA: string;
138
- 'MARSHALL ISLANDS': string;
139
- MARTINIQUE: string;
140
- MAURITANIA: string;
141
- MAURITIUS: string;
142
- MAYOTTE: string;
143
- MEXICO: string;
144
- 'MICRONESIA, FEDERATED STATES OF': string;
145
- MOLDOVA: string;
146
- MONACO: string;
147
- MONGOLIA: string;
148
- MONTENEGRO: string;
149
- MONTSERRAT: string;
150
- MOROCCO: string;
151
- MOZAMBIQUE: string;
152
- MYANMAR: string;
153
- NAMIBIA: string;
154
- NAURU: string;
155
- NEPAL: string;
156
- NETHERLANDS: string;
157
- 'NETHERLANDS ANTILLES': string;
158
- 'NEW CALEDONIA': string;
159
- 'NEW ZEALAND': string;
160
- NICARAGUA: string;
161
- NIGER: string;
162
- NIGERIA: string;
163
- NIUE: string;
164
- 'NORFOLK ISLAND': string;
165
- 'NORTHERN MARIANA ISLANDS': string;
166
- NORWAY: string;
167
- OMAN: string;
168
- PAKISTAN: string;
169
- PALAU: string;
170
- 'PALESTINIAN TERRITORY, OCCUPIED': string;
171
- PANAMA: string;
172
- 'PAPUA NEW GUINEA': string;
173
- PARAGUAY: string;
174
- PERU: string;
175
- PHILIPPINES: string;
176
- PITCAIRN: string;
177
- POLAND: string;
178
- PORTUGAL: string;
179
- 'PUERTO RICO': string;
180
- QATAR: string;
181
- REUNION: string;
182
- ROMANIA: string;
183
- 'RUSSIAN FEDERATION': string;
184
- RWANDA: string;
185
- 'SAINT BARTHELEMY': string;
186
- 'SAINT HELENA': string;
187
- 'SAINT KITTS AND NEVIS': string;
188
- 'SAINT LUCIA': string;
189
- 'SAINT MARTIN': string;
190
- 'SAINT PIERRE AND MIQUELON': string;
191
- 'SAINT VINCENT AND GRENADINES': string;
192
- SAMOA: string;
193
- 'SAN MARINO': string;
194
- 'SAO TOME AND PRINCIPE': string;
195
- 'SAUDI ARABIA': string;
196
- SENEGAL: string;
197
- SERBIA: string;
198
- SEYCHELLES: string;
199
- 'SIERRA LEONE': string;
200
- SINGAPORE: string;
201
- SLOVAKIA: string;
202
- SLOVENIA: string;
203
- 'SOLOMON ISLANDS': string;
204
- SOMALIA: string;
205
- 'SOUTH AFRICA': string;
206
- 'SOUTH GEORGIA AND SANDWICH ISL.': string;
207
- SPAIN: string;
208
- 'SRI LANKA': string;
209
- SUDAN: string;
210
- SURINAME: string;
211
- 'SVALBARD AND JAN MAYEN': string;
212
- SWAZILAND: string;
213
- SWEDEN: string;
214
- SWITZERLAND: string;
215
- 'SYRIAN ARAB REPUBLIC': string;
216
- TAIWAN: string;
217
- TAJIKISTAN: string;
218
- TANZANIA: string;
219
- THAILAND: string;
220
- 'TIMOR-LESTE': string;
221
- TOGO: string;
222
- TOKELAU: string;
223
- TONGA: string;
224
- 'TRINIDAD AND TOBAGO': string;
225
- TUNISIA: string;
226
- TURKEY: string;
227
- TURKMENISTAN: string;
228
- 'TURKS AND CAICOS ISLANDS': string;
229
- TUVALU: string;
230
- UGANDA: string;
231
- UKRAINE: string;
232
- 'UNITED ARAB EMIRATES': string;
233
- 'UNITED KINGDOM': string;
234
- 'UNITED STATES': string;
235
- 'UNITED STATES OUTLYING ISLANDS': string;
236
- URUGUAY: string;
237
- UZBEKISTAN: string;
238
- VANUATU: string;
239
- VENEZUELA: string;
240
- VIETNAM: string;
241
- 'VIRGIN ISLANDS, BRITISH': string;
242
- 'VIRGIN ISLANDS, U.S.': string;
243
- 'WALLIS AND FUTUNA': string;
244
- 'WESTERN SAHARA': string;
245
- YEMEN: string;
246
- ZAMBIA: string;
247
- ZIMBABWE: string;
248
- };