@loamly/tracker 2.0.0 → 2.0.2

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": "@loamly/tracker",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "See every AI bot that visits your website. ChatGPT, Claude, Perplexity, Gemini — know when they crawl or refer traffic.",
5
5
  "author": "Loamly <hello@loamly.ai>",
6
6
  "license": "MIT",
package/src/config.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * @see https://github.com/loamly/loamly
7
7
  */
8
8
 
9
- export const VERSION = '2.0.0'
9
+ export const VERSION = '2.0.2'
10
10
 
11
11
  export const DEFAULT_CONFIG = {
12
12
  apiHost: 'https://app.loamly.ai',
package/src/core.ts CHANGED
@@ -194,6 +194,9 @@ function init(userConfig: LoamlyConfig = {}): void {
194
194
  // Set up unload handlers
195
195
  setupUnloadHandlers()
196
196
 
197
+ // Report health status
198
+ reportHealth('initialized')
199
+
197
200
  log('Initialization complete')
198
201
  }
199
202
 
@@ -678,6 +681,50 @@ function isTrackerInitialized(): boolean {
678
681
  return initialized
679
682
  }
680
683
 
684
+ /**
685
+ * Report tracker health status
686
+ * Used for monitoring and debugging
687
+ */
688
+ function reportHealth(status: 'initialized' | 'error' | 'ready', errorMessage?: string): void {
689
+ if (!config.apiKey) return
690
+
691
+ try {
692
+ const healthData = {
693
+ workspace_id: config.apiKey,
694
+ status,
695
+ error_message: errorMessage || null,
696
+ version: VERSION,
697
+ url: typeof window !== 'undefined' ? window.location.href : null,
698
+ user_agent: typeof navigator !== 'undefined' ? navigator.userAgent : null,
699
+ timestamp: new Date().toISOString(),
700
+ features: {
701
+ scroll_tracker: !!scrollTracker,
702
+ time_tracker: !!timeTracker,
703
+ form_tracker: !!formTracker,
704
+ spa_router: !!spaRouter,
705
+ behavioral_ml: !!behavioralClassifier,
706
+ focus_blur: !!focusBlurAnalyzer,
707
+ agentic: !!agenticAnalyzer,
708
+ ping_service: !!pingService,
709
+ event_queue: !!eventQueue,
710
+ },
711
+ }
712
+
713
+ // Fire and forget
714
+ safeFetch(endpoint(DEFAULT_CONFIG.endpoints.health), {
715
+ method: 'POST',
716
+ headers: { 'Content-Type': 'application/json' },
717
+ body: JSON.stringify(healthData),
718
+ }).catch(() => {
719
+ // Ignore health reporting errors
720
+ })
721
+
722
+ log('Health reported:', status)
723
+ } catch {
724
+ // Ignore
725
+ }
726
+ }
727
+
681
728
  /**
682
729
  * Reset the tracker
683
730
  */
@@ -729,7 +776,10 @@ function setDebug(enabled: boolean): void {
729
776
  /**
730
777
  * The Loamly Tracker instance
731
778
  */
732
- export const loamly: LoamlyTracker & { getAgentic: () => AgenticDetectionResult | null } = {
779
+ export const loamly: LoamlyTracker & {
780
+ getAgentic: () => AgenticDetectionResult | null
781
+ reportHealth: (status: 'initialized' | 'error' | 'ready', errorMessage?: string) => void
782
+ } = {
733
783
  init,
734
784
  pageview,
735
785
  track,
@@ -745,6 +795,7 @@ export const loamly: LoamlyTracker & { getAgentic: () => AgenticDetectionResult
745
795
  isInitialized: isTrackerInitialized,
746
796
  reset,
747
797
  debug: setDebug,
798
+ reportHealth,
748
799
  }
749
800
 
750
801
  export default loamly