@formo/analytics 1.13.3-alpha.4 → 1.13.3-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formo/analytics",
3
- "version": "1.13.3-alpha.4",
3
+ "version": "1.13.3-alpha.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/getformo/sdk.git"
package/src/lib/utils.ts CHANGED
@@ -7,13 +7,15 @@ const toSnake = (str: string) =>
7
7
  // Converts object keys to snake_case, omitting keys in the omitKeys array
8
8
  export function toSnakeCase(obj: any, omitKeys: string[] = []) {
9
9
  const convert = (data: any): any => {
10
- if (Array.isArray(obj)) {
11
- return obj.map(convert);
12
- } else if (obj !== null && typeof obj === "object") {
13
- return Object.keys(obj).reduce((acc: any, key) => {
10
+ if (Array.isArray(data)) {
11
+ return data.map(convert); // Recursively handle array elements
12
+ } else if (data !== null && typeof data === "object") {
13
+ return Object.keys(data).reduce((acc: any, key) => {
14
14
  // If the key is in omitKeys, keep it as it is
15
15
  const resultKey = omitKeys.includes(key) ? key : toSnake(key);
16
- acc[resultKey] = omitKeys.includes(key) ? obj[key] : convert(obj[key]);
16
+ acc[resultKey] = omitKeys.includes(key)
17
+ ? data[key]
18
+ : convert(data[key]);
17
19
  return acc;
18
20
  }, {});
19
21
  }