@dropout-ai/runtime 0.3.10 → 0.3.11
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 +8 -1
- package/src/autoload.js +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dropout-ai/runtime",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Invisible Node.js runtime for understanding behavoiral impact of AI interactions.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -30,6 +30,13 @@
|
|
|
30
30
|
"url": "git+https://github.com/vaibhavv4re/dropout.git",
|
|
31
31
|
"directory": "packages/runtime"
|
|
32
32
|
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"dotenv": "^16.4.5"
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": "./src/index.js",
|
|
38
|
+
"./register": "./src/autoload.js"
|
|
39
|
+
},
|
|
33
40
|
"files": [
|
|
34
41
|
"src",
|
|
35
42
|
"bin"
|
package/src/autoload.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// packages/runtime/src/autoload.js
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const Dropout = require('./index');
|
|
5
|
+
|
|
6
|
+
// 1. Force Load Environment Variables (Fixes the "undefined" error)
|
|
7
|
+
try {
|
|
8
|
+
const dotenv = require('dotenv');
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
|
|
11
|
+
// We explicitly look for .env.local first (Next.js standard), then .env
|
|
12
|
+
const envFiles = ['.env.local', '.env'];
|
|
13
|
+
|
|
14
|
+
envFiles.forEach(file => {
|
|
15
|
+
const envPath = path.resolve(cwd, file);
|
|
16
|
+
if (fs.existsSync(envPath)) {
|
|
17
|
+
dotenv.config({ path: envPath, override: true });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
} catch (e) {
|
|
21
|
+
// dotenv might not be installed, ignore if using system env vars
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 2. Initialize Immediately
|
|
25
|
+
if (process.env.DROPOUT_PROJECT_ID && process.env.DROPOUT_API_KEY) {
|
|
26
|
+
new Dropout({
|
|
27
|
+
projectId: process.env.DROPOUT_PROJECT_ID,
|
|
28
|
+
apiKey: process.env.DROPOUT_API_KEY,
|
|
29
|
+
debug: process.env.DROPOUT_DEBUG === 'true'
|
|
30
|
+
});
|
|
31
|
+
// Log strictly for debug verification
|
|
32
|
+
if (process.env.DROPOUT_DEBUG === 'true') {
|
|
33
|
+
console.log(`[Dropout] 🚀 Global Autoload Active: ${process.env.DROPOUT_PROJECT_ID}`);
|
|
34
|
+
}
|
|
35
|
+
}
|