jimbrodonovan commited on
Commit
481bdcf
·
1 Parent(s): 8497718

added posthog for tracking

Browse files
Files changed (4) hide show
  1. .vscode/settings.json +2 -0
  2. app.py +16 -0
  3. config.py +5 -0
  4. requirements.txt +1 -0
.vscode/settings.json CHANGED
@@ -5,6 +5,7 @@
5
  "fitz",
6
  "fromarray",
7
  "frombytes",
 
8
  "libgl",
9
  "libglib",
10
  "ndimage",
@@ -12,6 +13,7 @@
12
  "otsu",
13
  "Otsu's",
14
  "pixmap",
 
15
  "pytesseract",
16
  "skimage",
17
  "Tesseract"
 
5
  "fitz",
6
  "fromarray",
7
  "frombytes",
8
+ "huggingface",
9
  "libgl",
10
  "libglib",
11
  "ndimage",
 
13
  "otsu",
14
  "Otsu's",
15
  "pixmap",
16
+ "posthog",
17
  "pytesseract",
18
  "skimage",
19
  "Tesseract"
app.py CHANGED
@@ -10,12 +10,28 @@ import traceback
10
  import gradio as gr
11
  from config import config
12
  from ui import create_ui
 
 
 
 
 
 
 
13
 
14
  def main():
15
  """Kickoff DI processor."""
16
  print("🎯 Document Ingestion 4.0")
17
  print("=" * 50)
18
 
 
 
 
 
 
 
 
 
 
19
  # Validate environment
20
  if not config.validate():
21
  print("❌ Configuration validation failed!")
 
10
  import gradio as gr
11
  from config import config
12
  from ui import create_ui
13
+ from posthog import Posthog
14
+
15
+ # Initialize PostHog
16
+ posthog = Posthog(
17
+ project_api_key=config.posthog_api_key or 'xxx', # Replace 'xxx' with your actual key
18
+ host='https://us.i.posthog.com'
19
+ )
20
 
21
  def main():
22
  """Kickoff DI processor."""
23
  print("🎯 Document Ingestion 4.0")
24
  print("=" * 50)
25
 
26
+ # Track app launch
27
+ posthog.capture(
28
+ distinct_id='app-instance',
29
+ event='app_launched',
30
+ properties={
31
+ 'environment': 'huggingface' if running_on_spaces() else 'local'
32
+ }
33
+ )
34
+
35
  # Validate environment
36
  if not config.validate():
37
  print("❌ Configuration validation failed!")
config.py CHANGED
@@ -36,6 +36,11 @@ class Config:
36
  def openai_api_key(self) -> str:
37
  """Get OpenAI API key from environment."""
38
  return os.getenv("OPENAI_API_KEY", "")
 
 
 
 
 
39
 
40
  def validate(self) -> bool:
41
  """Validate configuration settings."""
 
36
  def openai_api_key(self) -> str:
37
  """Get OpenAI API key from environment."""
38
  return os.getenv("OPENAI_API_KEY", "")
39
+
40
+ @property
41
+ def posthog_api_key(self) -> str:
42
+ """Get PostHog API key from environment."""
43
+ return os.getenv("POSTHOG_API_KEY", "")
44
 
45
  def validate(self) -> bool:
46
  """Validate configuration settings."""
requirements.txt CHANGED
@@ -6,3 +6,4 @@ numpy>=1.24.0
6
  pytesseract>=0.3.10
7
  openai>=1.3.0
8
  python-dotenv>=1.0.0
 
 
6
  pytesseract>=0.3.10
7
  openai>=1.3.0
8
  python-dotenv>=1.0.0
9
+ posthog>=3.0.2