@multiplayer-app/session-recorder-react-native 0.0.1-alpha.1

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 (128) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +226 -0
  3. package/babel.config.js +13 -0
  4. package/dist/config/masking.d.ts +30 -0
  5. package/dist/config/masking.js +1 -0
  6. package/dist/config/masking.js.map +1 -0
  7. package/dist/expo.d.ts +11 -0
  8. package/dist/expo.js +1 -0
  9. package/dist/expo.js.map +1 -0
  10. package/dist/index.d.ts +11 -0
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/otel/helpers.d.ts +3 -0
  14. package/dist/otel/helpers.js +1 -0
  15. package/dist/otel/helpers.js.map +1 -0
  16. package/dist/otel/index.d.ts +40 -0
  17. package/dist/otel/index.js +1 -0
  18. package/dist/otel/index.js.map +1 -0
  19. package/dist/otel/instrumentations/gestureInstrumentation.d.ts +15 -0
  20. package/dist/otel/instrumentations/gestureInstrumentation.js +1 -0
  21. package/dist/otel/instrumentations/gestureInstrumentation.js.map +1 -0
  22. package/dist/otel/instrumentations/index.d.ts +5 -0
  23. package/dist/otel/instrumentations/index.js +1 -0
  24. package/dist/otel/instrumentations/index.js.map +1 -0
  25. package/dist/otel/instrumentations/reactNativeInstrumentation.d.ts +8 -0
  26. package/dist/otel/instrumentations/reactNativeInstrumentation.js +1 -0
  27. package/dist/otel/instrumentations/reactNativeInstrumentation.js.map +1 -0
  28. package/dist/otel/instrumentations/reactNavigationInstrumentation.d.ts +12 -0
  29. package/dist/otel/instrumentations/reactNavigationInstrumentation.js +1 -0
  30. package/dist/otel/instrumentations/reactNavigationInstrumentation.js.map +1 -0
  31. package/dist/recorder/gestureRecorder.d.ts +42 -0
  32. package/dist/recorder/gestureRecorder.js +1 -0
  33. package/dist/recorder/gestureRecorder.js.map +1 -0
  34. package/dist/recorder/index.d.ts +16 -0
  35. package/dist/recorder/index.js +1 -0
  36. package/dist/recorder/index.js.map +1 -0
  37. package/dist/recorder/navigationTracker.d.ts +43 -0
  38. package/dist/recorder/navigationTracker.js +1 -0
  39. package/dist/recorder/navigationTracker.js.map +1 -0
  40. package/dist/recorder/screenRecorder.d.ts +46 -0
  41. package/dist/recorder/screenRecorder.js +1 -0
  42. package/dist/recorder/screenRecorder.js.map +1 -0
  43. package/dist/services/api.service.d.ts +20 -0
  44. package/dist/services/api.service.js +1 -0
  45. package/dist/services/api.service.js.map +1 -0
  46. package/dist/services/storage.service.d.ts +23 -0
  47. package/dist/services/storage.service.js +1 -0
  48. package/dist/services/storage.service.js.map +1 -0
  49. package/dist/sessionRecorder.d.ts +54 -0
  50. package/dist/sessionRecorder.js +1 -0
  51. package/dist/sessionRecorder.js.map +1 -0
  52. package/dist/types/index.d.ts +81 -0
  53. package/dist/types/index.js +1 -0
  54. package/dist/types/index.js.map +1 -0
  55. package/dist/utils/platform.d.ts +9 -0
  56. package/dist/utils/platform.js +1 -0
  57. package/dist/utils/platform.js.map +1 -0
  58. package/dist/version.d.ts +1 -0
  59. package/dist/version.js +1 -0
  60. package/dist/version.js.map +1 -0
  61. package/examples/sample-expo-app/README.md +142 -0
  62. package/examples/sample-expo-app/app/(tabs)/_layout.tsx +60 -0
  63. package/examples/sample-expo-app/app/(tabs)/explore.tsx +110 -0
  64. package/examples/sample-expo-app/app/(tabs)/index.tsx +125 -0
  65. package/examples/sample-expo-app/app/(tabs)/posts.tsx +96 -0
  66. package/examples/sample-expo-app/app/(tabs)/users.tsx +131 -0
  67. package/examples/sample-expo-app/app/+not-found.tsx +32 -0
  68. package/examples/sample-expo-app/app/_layout.tsx +53 -0
  69. package/examples/sample-expo-app/app/post/[id].tsx +199 -0
  70. package/examples/sample-expo-app/app/user/[id].tsx +270 -0
  71. package/examples/sample-expo-app/app.json +42 -0
  72. package/examples/sample-expo-app/assets/fonts/SpaceMono-Regular.ttf +0 -0
  73. package/examples/sample-expo-app/assets/images/adaptive-icon.png +0 -0
  74. package/examples/sample-expo-app/assets/images/favicon.png +0 -0
  75. package/examples/sample-expo-app/assets/images/icon.png +0 -0
  76. package/examples/sample-expo-app/assets/images/partial-react-logo.png +0 -0
  77. package/examples/sample-expo-app/assets/images/react-logo.png +0 -0
  78. package/examples/sample-expo-app/assets/images/react-logo@2x.png +0 -0
  79. package/examples/sample-expo-app/assets/images/react-logo@3x.png +0 -0
  80. package/examples/sample-expo-app/assets/images/splash-icon.png +0 -0
  81. package/examples/sample-expo-app/components/Collapsible.tsx +45 -0
  82. package/examples/sample-expo-app/components/ErrorView.tsx +52 -0
  83. package/examples/sample-expo-app/components/ExternalLink.tsx +24 -0
  84. package/examples/sample-expo-app/components/HapticTab.tsx +18 -0
  85. package/examples/sample-expo-app/components/HelloWave.tsx +40 -0
  86. package/examples/sample-expo-app/components/LoadingSpinner.tsx +34 -0
  87. package/examples/sample-expo-app/components/ParallaxScrollView.tsx +82 -0
  88. package/examples/sample-expo-app/components/ThemedText.tsx +60 -0
  89. package/examples/sample-expo-app/components/ThemedView.tsx +14 -0
  90. package/examples/sample-expo-app/components/ui/IconSymbol.ios.tsx +32 -0
  91. package/examples/sample-expo-app/components/ui/IconSymbol.tsx +41 -0
  92. package/examples/sample-expo-app/components/ui/TabBarBackground.ios.tsx +19 -0
  93. package/examples/sample-expo-app/components/ui/TabBarBackground.tsx +6 -0
  94. package/examples/sample-expo-app/constants/Colors.ts +26 -0
  95. package/examples/sample-expo-app/eslint.config.js +10 -0
  96. package/examples/sample-expo-app/hooks/useApi.ts +41 -0
  97. package/examples/sample-expo-app/hooks/useColorScheme.ts +1 -0
  98. package/examples/sample-expo-app/hooks/useColorScheme.web.ts +21 -0
  99. package/examples/sample-expo-app/hooks/useThemeColor.ts +21 -0
  100. package/examples/sample-expo-app/metro.config.js +26 -0
  101. package/examples/sample-expo-app/package-lock.json +26296 -0
  102. package/examples/sample-expo-app/package.json +59 -0
  103. package/examples/sample-expo-app/scripts/reset-project.js +112 -0
  104. package/examples/sample-expo-app/services/api.ts +98 -0
  105. package/examples/sample-expo-app/tsconfig.json +17 -0
  106. package/examples/sample-expo-app/utils/navigation.ts +19 -0
  107. package/package.json +98 -0
  108. package/src/config/masking.ts +78 -0
  109. package/src/expo.ts +41 -0
  110. package/src/index.ts +20 -0
  111. package/src/otel/helpers.ts +21 -0
  112. package/src/otel/index.ts +348 -0
  113. package/src/otel/instrumentations/gestureInstrumentation.ts +141 -0
  114. package/src/otel/instrumentations/index.ts +86 -0
  115. package/src/otel/instrumentations/reactNativeInstrumentation.ts +164 -0
  116. package/src/otel/instrumentations/reactNavigationInstrumentation.ts +114 -0
  117. package/src/recorder/gestureRecorder.ts +429 -0
  118. package/src/recorder/index.ts +71 -0
  119. package/src/recorder/navigationTracker.ts +447 -0
  120. package/src/recorder/screenRecorder.ts +411 -0
  121. package/src/services/api.service.ts +78 -0
  122. package/src/services/storage.service.ts +130 -0
  123. package/src/sessionRecorder.ts +367 -0
  124. package/src/types/expo.d.ts +23 -0
  125. package/src/types/index.ts +88 -0
  126. package/src/utils/platform.ts +75 -0
  127. package/src/version.ts +1 -0
  128. package/tsconfig.json +24 -0
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "sample-expo-app",
3
+ "main": "expo-router/entry",
4
+ "version": "1.0.0",
5
+ "scripts": {
6
+ "start": "expo start",
7
+ "reset-project": "node ./scripts/reset-project.js",
8
+ "android": "expo start --android",
9
+ "ios": "expo start --ios",
10
+ "web": "expo start --web",
11
+ "lint": "expo lint",
12
+ "postinstall": "expo-yarn-workspaces check workspaces"
13
+ },
14
+ "dependencies": {
15
+ "@expo/vector-icons": "^14.1.0",
16
+ "@multiplayer-app/session-recorder-react-native": "file:../..",
17
+ "@react-native-async-storage/async-storage": "2.1.2",
18
+ "@react-native-community/netinfo": "^11.1.0",
19
+ "@react-navigation/bottom-tabs": "^7.3.10",
20
+ "@react-navigation/elements": "^2.3.8",
21
+ "@react-navigation/native": "^7.1.6",
22
+ "axios": "^1.6.0",
23
+ "expo": "~53.0.22",
24
+ "expo-blur": "~14.1.5",
25
+ "expo-constants": "~17.1.7",
26
+ "expo-font": "~13.3.2",
27
+ "expo-haptics": "~14.1.4",
28
+ "expo-image": "~2.4.0",
29
+ "expo-linking": "~7.1.7",
30
+ "expo-router": "~5.1.5",
31
+ "expo-splash-screen": "~0.30.10",
32
+ "expo-status-bar": "~2.2.3",
33
+ "expo-symbols": "~0.4.5",
34
+ "expo-system-ui": "~5.0.11",
35
+ "expo-web-browser": "~14.2.0",
36
+ "react": "19.0.0",
37
+ "react-dom": "19.0.0",
38
+ "react-native": "^0.79.5",
39
+ "react-native-gesture-handler": "~2.24.0",
40
+ "react-native-mmkv": "^2.11.0",
41
+ "react-native-reanimated": "~3.17.4",
42
+ "react-native-safe-area-context": "5.4.0",
43
+ "react-native-screens": "~4.11.1",
44
+ "react-native-screenshot": "^1.0.0",
45
+ "react-native-view-shot": "^4.0.3",
46
+ "react-native-web": "~0.20.0",
47
+ "react-native-webview": "13.13.5"
48
+ },
49
+ "devDependencies": {
50
+ "@babel/core": "^7.25.2",
51
+ "@react-native/metro-config": "^0.81.1",
52
+ "@types/react": "~19.0.10",
53
+ "eslint": "^9.25.0",
54
+ "eslint-config-expo": "~9.2.0",
55
+ "expo-yarn-workspaces": "^2.3.2",
56
+ "typescript": "~5.8.3"
57
+ },
58
+ "private": true
59
+ }
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * This script is used to reset the project to a blank state.
5
+ * It deletes or moves the /app, /components, /hooks, /scripts, and /constants directories to /app-example based on user input and creates a new /app directory with an index.tsx and _layout.tsx file.
6
+ * You can remove the `reset-project` script from package.json and safely delete this file after running it.
7
+ */
8
+
9
+ const fs = require("fs");
10
+ const path = require("path");
11
+ const readline = require("readline");
12
+
13
+ const root = process.cwd();
14
+ const oldDirs = ["app", "components", "hooks", "constants", "scripts"];
15
+ const exampleDir = "app-example";
16
+ const newAppDir = "app";
17
+ const exampleDirPath = path.join(root, exampleDir);
18
+
19
+ const indexContent = `import { Text, View } from "react-native";
20
+
21
+ export default function Index() {
22
+ return (
23
+ <View
24
+ style={{
25
+ flex: 1,
26
+ justifyContent: "center",
27
+ alignItems: "center",
28
+ }}
29
+ >
30
+ <Text>Edit app/index.tsx to edit this screen.</Text>
31
+ </View>
32
+ );
33
+ }
34
+ `;
35
+
36
+ const layoutContent = `import { Stack } from "expo-router";
37
+
38
+ export default function RootLayout() {
39
+ return <Stack />;
40
+ }
41
+ `;
42
+
43
+ const rl = readline.createInterface({
44
+ input: process.stdin,
45
+ output: process.stdout,
46
+ });
47
+
48
+ const moveDirectories = async (userInput) => {
49
+ try {
50
+ if (userInput === "y") {
51
+ // Create the app-example directory
52
+ await fs.promises.mkdir(exampleDirPath, { recursive: true });
53
+ console.log(`📁 /${exampleDir} directory created.`);
54
+ }
55
+
56
+ // Move old directories to new app-example directory or delete them
57
+ for (const dir of oldDirs) {
58
+ const oldDirPath = path.join(root, dir);
59
+ if (fs.existsSync(oldDirPath)) {
60
+ if (userInput === "y") {
61
+ const newDirPath = path.join(root, exampleDir, dir);
62
+ await fs.promises.rename(oldDirPath, newDirPath);
63
+ console.log(`➡️ /${dir} moved to /${exampleDir}/${dir}.`);
64
+ } else {
65
+ await fs.promises.rm(oldDirPath, { recursive: true, force: true });
66
+ console.log(`❌ /${dir} deleted.`);
67
+ }
68
+ } else {
69
+ console.log(`➡️ /${dir} does not exist, skipping.`);
70
+ }
71
+ }
72
+
73
+ // Create new /app directory
74
+ const newAppDirPath = path.join(root, newAppDir);
75
+ await fs.promises.mkdir(newAppDirPath, { recursive: true });
76
+ console.log("\n📁 New /app directory created.");
77
+
78
+ // Create index.tsx
79
+ const indexPath = path.join(newAppDirPath, "index.tsx");
80
+ await fs.promises.writeFile(indexPath, indexContent);
81
+ console.log("📄 app/index.tsx created.");
82
+
83
+ // Create _layout.tsx
84
+ const layoutPath = path.join(newAppDirPath, "_layout.tsx");
85
+ await fs.promises.writeFile(layoutPath, layoutContent);
86
+ console.log("📄 app/_layout.tsx created.");
87
+
88
+ console.log("\n✅ Project reset complete. Next steps:");
89
+ console.log(
90
+ `1. Run \`npx expo start\` to start a development server.\n2. Edit app/index.tsx to edit the main screen.${
91
+ userInput === "y"
92
+ ? `\n3. Delete the /${exampleDir} directory when you're done referencing it.`
93
+ : ""
94
+ }`
95
+ );
96
+ } catch (error) {
97
+ console.error(`❌ Error during script execution: ${error.message}`);
98
+ }
99
+ };
100
+
101
+ rl.question(
102
+ "Do you want to move existing files to /app-example instead of deleting them? (Y/n): ",
103
+ (answer) => {
104
+ const userInput = answer.trim().toLowerCase() || "y";
105
+ if (userInput === "y" || userInput === "n") {
106
+ moveDirectories(userInput).finally(() => rl.close());
107
+ } else {
108
+ console.log("❌ Invalid input. Please enter 'Y' or 'N'.");
109
+ rl.close();
110
+ }
111
+ }
112
+ );
@@ -0,0 +1,98 @@
1
+ import axios from 'axios';
2
+
3
+ const API_BASE_URL = 'https://jsonplaceholder.typicode.com';
4
+
5
+ export interface Post {
6
+ id: number;
7
+ title: string;
8
+ body: string;
9
+ userId: number;
10
+ }
11
+
12
+ export interface User {
13
+ id: number;
14
+ name: string;
15
+ username: string;
16
+ email: string;
17
+ phone: string;
18
+ website: string;
19
+ company: {
20
+ name: string;
21
+ catchPhrase: string;
22
+ bs: string;
23
+ };
24
+ address: {
25
+ street: string;
26
+ suite: string;
27
+ city: string;
28
+ zipcode: string;
29
+ geo: {
30
+ lat: string;
31
+ lng: string;
32
+ };
33
+ };
34
+ }
35
+
36
+ export interface Comment {
37
+ id: number;
38
+ postId: number;
39
+ name: string;
40
+ email: string;
41
+ body: string;
42
+ }
43
+
44
+ class ApiService {
45
+ private api = axios.create({
46
+ baseURL: API_BASE_URL,
47
+ timeout: 10000,
48
+ });
49
+
50
+ // Posts
51
+ async getPosts(): Promise<Post[]> {
52
+ const response = await this.api.get('/posts');
53
+ return response.data;
54
+ }
55
+
56
+ async getPost(id: number): Promise<Post> {
57
+ const response = await this.api.get(`/posts/${id}`);
58
+ return response.data;
59
+ }
60
+
61
+ async getPostComments(postId: number): Promise<Comment[]> {
62
+ const response = await this.api.get(`/posts/${postId}/comments`);
63
+ return response.data;
64
+ }
65
+
66
+ // Users
67
+ async getUsers(): Promise<User[]> {
68
+ const response = await this.api.get('/users');
69
+ return response.data;
70
+ }
71
+
72
+ async getUser(id: number): Promise<User> {
73
+ const response = await this.api.get(`/users/${id}`);
74
+ return response.data;
75
+ }
76
+
77
+ async getUserPosts(userId: number): Promise<Post[]> {
78
+ const response = await this.api.get(`/users/${userId}/posts`);
79
+ return response.data;
80
+ }
81
+
82
+ // Create/Update/Delete operations (for demo purposes)
83
+ async createPost(post: Omit<Post, 'id'>): Promise<Post> {
84
+ const response = await this.api.post('/posts', post);
85
+ return response.data;
86
+ }
87
+
88
+ async updatePost(id: number, post: Partial<Post>): Promise<Post> {
89
+ const response = await this.api.put(`/posts/${id}`, post);
90
+ return response.data;
91
+ }
92
+
93
+ async deletePost(id: number): Promise<void> {
94
+ await this.api.delete(`/posts/${id}`);
95
+ }
96
+ }
97
+
98
+ export const apiService = new ApiService();
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "expo/tsconfig.base",
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "paths": {
6
+ "@/*": [
7
+ "./*"
8
+ ]
9
+ }
10
+ },
11
+ "include": [
12
+ "**/*.ts",
13
+ "**/*.tsx",
14
+ ".expo/types/**/*.ts",
15
+ "expo-env.d.ts"
16
+ ]
17
+ }
@@ -0,0 +1,19 @@
1
+ // Navigation utility to avoid router import issues
2
+ export const navigateTo = {
3
+ post: (id: number) => {
4
+ // This will be handled by the router in the component
5
+ return `/post/${id}`
6
+ },
7
+ user: (id: number) => {
8
+ return `/user/${id}`
9
+ },
10
+ posts: () => {
11
+ return '/(tabs)/posts'
12
+ },
13
+ users: () => {
14
+ return '/(tabs)/users'
15
+ },
16
+ home: () => {
17
+ return '/(tabs)/'
18
+ },
19
+ }
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@multiplayer-app/session-recorder-react-native",
3
+ "version": "0.0.1-alpha.1",
4
+ "description": "Multiplayer Fullstack Session Recorder for React Native",
5
+ "author": {
6
+ "name": "Multiplayer Software, Inc.",
7
+ "url": "https://www.multiplayer.app"
8
+ },
9
+ "license": "MIT",
10
+ "bugs": {
11
+ "url": "https://github.com/multiplayer-app/multiplayer-session-recorder-javascript/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/multiplayer-app/multiplayer-session-recorder-javascript.git"
16
+ },
17
+ "main": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.js"
23
+ },
24
+ "./expo": {
25
+ "import": "./dist/expo.js",
26
+ "require": "./dist/expo.js"
27
+ }
28
+ },
29
+ "engines": {
30
+ "node": ">=18",
31
+ "npm": ">=8"
32
+ },
33
+ "keywords": [
34
+ "multiplayer",
35
+ "debugger",
36
+ "platform",
37
+ "platform debugger",
38
+ "session recorder",
39
+ "otlp",
40
+ "fullstack session recorder",
41
+ "react-native",
42
+ "expo"
43
+ ],
44
+ "scripts": {
45
+ "clean": "rimraf dist",
46
+ "lint": "eslint src/**/*.ts",
47
+ "lint:fix": "eslint src/**/*.ts --fix",
48
+ "prepublishOnly": "npm run lint && npm run build",
49
+ "prebuild": "node -p \"'export const version = ' + JSON.stringify(require('./package.json').version)\" > src/version.ts",
50
+ "build": "tsc && babel ./dist --out-dir dist --extensions '.js'"
51
+ },
52
+ "devDependencies": {
53
+ "@babel/cli": "^7.19.3",
54
+ "@babel/plugin-transform-class-properties": "^7.24.1",
55
+ "@babel/plugin-transform-private-methods": "^7.24.1",
56
+ "@babel/plugin-transform-private-property-in-object": "^7.27.1",
57
+ "@babel/preset-env": "^7.24.1",
58
+ "@babel/preset-react": "^7.24.1",
59
+ "@babel/preset-typescript": "^7.24.1",
60
+ "@react-native/babel-preset": "^0.80.1",
61
+ "@types/react": "^18.2.0",
62
+ "@types/react-native": "^0.72.0",
63
+ "eslint": "8.48.0",
64
+ "rimraf": "^5.0.5",
65
+ "typescript": "5.7.3"
66
+ },
67
+ "dependencies": {
68
+ "@multiplayer-app/session-recorder-common": "1.2.6",
69
+ "@opentelemetry/core": "2.0.1",
70
+ "@opentelemetry/exporter-trace-otlp-http": "0.203.0",
71
+ "@opentelemetry/instrumentation": "0.203.0",
72
+ "@opentelemetry/instrumentation-fetch": "0.203.0",
73
+ "@opentelemetry/instrumentation-xml-http-request": "0.203.0",
74
+ "@opentelemetry/otlp-exporter-base": "0.203.0",
75
+ "@opentelemetry/otlp-transformer": "0.203.0",
76
+ "@opentelemetry/resources": "2.0.1",
77
+ "@opentelemetry/sdk-trace-base": "2.0.1",
78
+ "@opentelemetry/semantic-conventions": "1.36.0",
79
+ "@react-native-async-storage/async-storage": "^1.21.0",
80
+ "@react-native-community/netinfo": "^11.1.0",
81
+ "lib0": "0.2.82",
82
+ "react-native-gesture-handler": "^2.14.0",
83
+ "react-native-mmkv": "^2.11.0",
84
+ "react-native-reanimated": "^3.6.0",
85
+ "react-native-screenshot": "^1.0.0",
86
+ "react-native-view-shot": "^4.0.3",
87
+ "socket.io-client": "4.7.5"
88
+ },
89
+ "peerDependencies": {
90
+ "@opentelemetry/api": "1.9.0",
91
+ "expo": "^49.0.0 || ^52.0.0",
92
+ "react": "^18.0.0 || ^19.0.0",
93
+ "react-native": "^0.72.0 || ^0.81.0"
94
+ },
95
+ "optionalDependencies": {
96
+ "expo-constants": "^15.0.0"
97
+ }
98
+ }
@@ -0,0 +1,78 @@
1
+ import { SessionRecorderSdk } from '@multiplayer-app/session-recorder-common'
2
+
3
+ const { mask, sensitiveFields, sensitiveHeaders } = SessionRecorderSdk
4
+
5
+ /**
6
+ * HTTP Masking Configuration Interface
7
+ * Focused only on HTTP request/response masking for OpenTelemetry traces
8
+ */
9
+ export interface HttpMaskingConfig {
10
+ /** If true, enables masking for debug span payload in traces */
11
+ isContentMaskingEnabled?: boolean
12
+ /** Custom function for masking body in traces */
13
+ maskBody?: (payload: any, span: any) => any
14
+ /** Custom function for masking headers in traces */
15
+ maskHeaders?: (headers: any, span: any) => any
16
+ /** List of body fields to mask in traces */
17
+ maskBodyFieldsList?: string[]
18
+ /** List of headers to mask in traces */
19
+ maskHeadersList?: string[]
20
+ /** List of headers to include in traces (if specified, only these headers will be captured) */
21
+ headersToInclude?: string[]
22
+ /** List of headers to exclude from traces */
23
+ headersToExclude?: string[]
24
+ }
25
+
26
+ /**
27
+ * Default HTTP masking configuration
28
+ */
29
+ export const DEFAULT_HTTP_MASKING_CONFIG: HttpMaskingConfig = {
30
+ isContentMaskingEnabled: true,
31
+ maskBody: mask(sensitiveFields),
32
+ maskHeaders: mask(sensitiveHeaders),
33
+ maskBodyFieldsList: sensitiveFields,
34
+ maskHeadersList: sensitiveHeaders,
35
+ headersToInclude: [],
36
+ headersToExclude: [],
37
+ }
38
+
39
+ /**
40
+ * Validation helper functions
41
+ */
42
+ const isValidArray = (value: any[] | undefined, defaultValue: any[]): any[] => {
43
+ return Array.isArray(value) ? value : defaultValue
44
+ }
45
+
46
+ const isValidBoolean = (value: boolean | undefined, defaultValue: boolean): boolean => {
47
+ return typeof value === 'boolean' ? value : defaultValue
48
+ }
49
+
50
+ const isValidFunction = (value: any, defaultValue: any): any => {
51
+ return typeof value === 'function' ? value : defaultValue
52
+ }
53
+
54
+ /**
55
+ * Get HTTP masking configuration
56
+ * @param masking Optional masking configuration
57
+ * @returns Processed HTTP masking configuration
58
+ */
59
+ export const getHttpMaskingConfig = (masking?: HttpMaskingConfig): HttpMaskingConfig => {
60
+ const baseMasking = DEFAULT_HTTP_MASKING_CONFIG
61
+
62
+ if (typeof masking !== 'object') {
63
+ return baseMasking
64
+ }
65
+
66
+ const maskHeadersList = isValidArray(masking.maskHeadersList, sensitiveHeaders)
67
+ const maskBodyFieldsList = isValidArray(masking.maskBodyFieldsList, sensitiveFields)
68
+
69
+ return {
70
+ isContentMaskingEnabled: isValidBoolean(masking.isContentMaskingEnabled, baseMasking.isContentMaskingEnabled ?? true),
71
+ maskBody: isValidFunction(masking.maskBody, mask(maskBodyFieldsList)),
72
+ maskHeaders: isValidFunction(masking.maskHeaders, mask(maskHeadersList)),
73
+ maskBodyFieldsList,
74
+ maskHeadersList,
75
+ headersToInclude: isValidArray(masking.headersToInclude, baseMasking.headersToInclude ?? []),
76
+ headersToExclude: isValidArray(masking.headersToExclude, baseMasking.headersToExclude ?? []),
77
+ }
78
+ }
package/src/expo.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { SessionRecorder } from './sessionRecorder'
2
+ import { isExpoEnvironment } from './utils/platform'
3
+
4
+ // Create a specialized instance for Expo
5
+ const SessionRecorderExpoInstance = new SessionRecorder()
6
+
7
+ // Add Expo-specific initialization
8
+ const originalInit = SessionRecorderExpoInstance.init.bind(SessionRecorderExpoInstance)
9
+
10
+ SessionRecorderExpoInstance.init = async function(options: any) {
11
+ // Add Expo-specific configuration
12
+ const expoOptions = {
13
+ ...options,
14
+ // Add Expo-specific defaults
15
+ platform: 'expo',
16
+ }
17
+
18
+ // Log Expo environment detection
19
+ if (isExpoEnvironment()) {
20
+ console.log('Multiplayer Session Recorder: Running in Expo environment')
21
+ }
22
+
23
+ return originalInit(expoOptions)
24
+ }
25
+
26
+ // Export the Expo instance as default
27
+ export default SessionRecorderExpoInstance
28
+
29
+ // Export types and classes
30
+ export * from './types'
31
+ export { SessionRecorder } from './sessionRecorder'
32
+ export { TracerReactNativeSDK } from './otel'
33
+ export { RecorderReactNativeSDK } from './recorder'
34
+ export { ApiService } from './services/api.service'
35
+ export { StorageService } from './services/storage.service'
36
+
37
+ // Export common types
38
+ export * from '@multiplayer-app/session-recorder-common'
39
+
40
+ // Export Expo-specific utilities
41
+ export { isExpoEnvironment, getPlatformAttributes } from './utils/platform'
package/src/index.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { SessionRecorder } from './sessionRecorder'
2
+
3
+ const SessionRecorderInstance = new SessionRecorder()
4
+
5
+ // Export the instance as default
6
+ export default SessionRecorderInstance
7
+
8
+ // Export types and classes
9
+ export * from './types'
10
+ export { SessionRecorder } from './sessionRecorder'
11
+ export { TracerReactNativeSDK } from './otel'
12
+ export { RecorderReactNativeSDK } from './recorder'
13
+ export { ApiService } from './services/api.service'
14
+ export { StorageService } from './services/storage.service'
15
+
16
+ // Export common types
17
+ export * from '@multiplayer-app/session-recorder-common'
18
+
19
+ // Export platform utilities
20
+ export { isExpoEnvironment, getPlatformAttributes, detectPlatform } from './utils/platform'
@@ -0,0 +1,21 @@
1
+
2
+ export function getExporterEndpoint(endpoint?: string): string {
3
+ return endpoint || 'http://localhost:4318/v1/traces'
4
+ }
5
+
6
+ export function processHttpPayload(payload: string, maxSize: number = 1000000): string {
7
+ if (payload.length <= maxSize) {
8
+ return payload
9
+ }
10
+
11
+ // Truncate payload if it's too large
12
+ return payload.substring(0, maxSize) + '... [truncated]'
13
+ }
14
+
15
+ export function headersToObject(headers: Headers): Record<string, string> {
16
+ const result: Record<string, string> = {}
17
+ headers.forEach((value: string, key: string) => {
18
+ result[key] = value
19
+ })
20
+ return result
21
+ }