@loamly/tracker 2.0.1 → 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/dist/index.cjs +37 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +37 -2
- package/dist/index.mjs.map +1 -1
- package/dist/loamly.iife.global.js +37 -2
- package/dist/loamly.iife.global.js.map +1 -1
- package/dist/loamly.iife.min.global.js +1 -1
- package/dist/loamly.iife.min.global.js.map +1 -1
- package/package.json +11 -9
- package/src/config.ts +1 -1
- package/src/core.ts +52 -1
- package/LICENSE +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loamly/tracker",
|
|
3
|
-
"version": "2.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",
|
|
@@ -46,6 +46,13 @@
|
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=18"
|
|
48
48
|
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsup",
|
|
51
|
+
"dev": "tsup --watch",
|
|
52
|
+
"typecheck": "tsc --noEmit",
|
|
53
|
+
"test": "vitest run",
|
|
54
|
+
"clean": "rm -rf dist"
|
|
55
|
+
},
|
|
49
56
|
"devDependencies": {
|
|
50
57
|
"@types/node": "^20.10.0",
|
|
51
58
|
"tsup": "^8.0.1",
|
|
@@ -55,12 +62,7 @@
|
|
|
55
62
|
"publishConfig": {
|
|
56
63
|
"access": "public",
|
|
57
64
|
"registry": "https://registry.npmjs.org/"
|
|
58
|
-
},
|
|
59
|
-
"scripts": {
|
|
60
|
-
"build": "tsup",
|
|
61
|
-
"dev": "tsup --watch",
|
|
62
|
-
"typecheck": "tsc --noEmit",
|
|
63
|
-
"test": "vitest run",
|
|
64
|
-
"clean": "rm -rf dist"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
package/src/config.ts
CHANGED
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 & {
|
|
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
|
package/LICENSE
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025-present Loamly
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
23
|
-
|