@siteline/core 1.0.0 → 1.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @siteline/core
2
2
 
3
- ## 1.0.0
3
+ ## 1.0.1
4
4
 
5
5
  Initial release
6
6
 
package/README.md CHANGED
@@ -1,17 +1,16 @@
1
1
  # @siteline/core
2
2
 
3
- Core tracking SDK for Client - Agent Analytics platform for tracking how AI agents, bots, and crawlers interact with your website.
3
+ Core Siteline tracking SDK for monitoring AI agents, bots, and crawlers across your web applications.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@siteline/core.svg)](https://www.npmjs.com/package/@siteline/core)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../../LICENSE)
4
7
 
5
8
  ## Features
6
9
 
7
- - **AI Agent Tracking**: Track bots from OpenAI, Google, Anthropic, Perplexity, and more
8
- - **Lightweight**: ~1.6KB minified + gzipped
9
- - **Type-safe**: Full TypeScript support with exported types
10
- - **Zero dependencies**: No external runtime dependencies
11
- - **Automatic sanitization**: Request data validation and size limits
12
- - **HTTPS enforced**: Secure-only data transmission
13
- - **Configurable**: Custom endpoints and debug mode
14
- - **Edge-ready**: Works in edge runtimes, Node.js, and browsers
10
+ - Track bots from OpenAI, Google, Anthropic, Perplexity, and more
11
+ - Full TypeScript support with exported types
12
+ - Works in Node.js, Edge runtimes, and browsers
13
+ - Automatic data sanitization and validation
15
14
 
16
15
  ## Installation
17
16
 
@@ -19,217 +18,77 @@ Core tracking SDK for Client - Agent Analytics platform for tracking how AI agen
19
18
  npm install @siteline/core
20
19
  ```
21
20
 
22
- ```bash
23
- yarn add @siteline/core
24
- ```
25
-
26
- ```bash
27
- pnpm add @siteline/core
28
- ```
29
-
30
21
  ## Quick Start
31
22
 
32
23
  ```typescript
33
- import { Client } from '@siteline/core';
24
+ import { Siteline } from '@siteline/core';
34
25
 
35
- // Initialize the tracker
36
- const siteline = new Client({
37
- websiteKey: 'siteline_secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
38
- debug: true, // Optional: enable debug logs
39
- });
40
-
41
- // Track a pageview
42
- siteline.track({
43
- url: '/home',
44
- method: 'GET',
45
- status: 200,
46
- duration: 45,
47
- userAgent: 'Mozilla/5.0...',
48
- ref: 'https://google.com',
49
- ip: '192.168.1.1',
50
- sdk: '@siteline/core',
51
- sdk_version: '1.0.0',
52
- integration_type: 'custom',
26
+ const siteline = new Siteline({
53
27
  websiteKey: 'siteline_secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
54
28
  });
55
- ```
56
-
57
- ## API Reference
58
-
59
- ### `new Client(config: SitelineConfig)`
60
-
61
- Creates a new Client tracker instance.
62
-
63
- #### Configuration Options
64
-
65
- ```typescript
66
- type SitelineConfig = {
67
- websiteKey: string; // Required: Your Client website key (format: siteline_secret_<32 hex chars>)
68
- endpoint?: string; // Optional: Custom API endpoint (default: https://api.siteline.ai/v1/intake/pageview)
69
- debug?: boolean; // Optional: Enable debug logging (default: false)
70
- };
71
- ```
72
-
73
- **Example:**
74
-
75
- ```typescript
76
- const siteline = new Client({
77
- websiteKey: 'siteline_secret_abc123...',
78
- endpoint: 'https://custom-endpoint.example.com/track', // Optional
79
- debug: process.env.NODE_ENV === 'development', // Optional
80
- });
81
- ```
82
-
83
- ### `siteline.track(data: PageviewData)`
84
-
85
- Tracks a pageview event. Data is automatically sanitized and sent asynchronously.
86
29
 
87
- #### PageviewData Type
88
-
89
- ```typescript
90
- type PageviewData = {
91
- websiteKey: string; // Your Client website key
92
- sdk: string; // SDK identifier (e.g., '@siteline/core')
93
- sdk_version: string; // SDK version (e.g., '1.0.0')
94
- integration_type: string; // Integration type (e.g., 'nextjs', 'express', 'custom')
95
-
96
- // Request data
97
- url: string; // Request URL path (max 2048 chars)
98
- method: string; // HTTP method (max 10 chars, uppercased)
99
- userAgent: string | null; // User-Agent header (max 512 chars)
100
- ref: string | null; // Referer header (max 2048 chars)
101
- ip: string | null; // Client IP address (max 45 chars for IPv6)
102
-
103
- // Response data
104
- status: number; // HTTP status code (0-999)
105
- duration: number; // Request duration in ms (0-300000)
106
- };
107
- ```
108
-
109
- **Example:**
110
-
111
- ```typescript
112
30
  siteline.track({
113
- websiteKey: 'siteline_secret_abc123...',
114
- sdk: '@siteline/core',
115
- sdk_version: '1.0.0',
116
- integration_type: 'custom',
117
31
  url: '/api/users',
118
32
  method: 'GET',
119
33
  status: 200,
120
34
  duration: 125,
121
- userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...',
122
- ref: 'https://example.com/home',
123
- ip: '203.0.113.42',
35
+ userAgent: request.headers['user-agent'],
36
+ ref: request.headers['referer'],
37
+ ip: request.ip,
124
38
  });
125
39
  ```
126
40
 
127
- ## Data Sanitization
128
-
129
- All tracked data is automatically sanitized to ensure security and data integrity:
130
-
131
- - **URL**: Truncated to 2048 characters
132
- - **Method**: Uppercased, truncated to 10 characters
133
- - **Status**: Clamped to 0-999 range
134
- - **Duration**: Clamped to 0-300000ms (5 minutes)
135
- - **User-Agent**: Truncated to 512 characters
136
- - **Referrer**: Truncated to 2048 characters
137
- - **IP Address**: Truncated to 45 characters (IPv6 compatible)
138
- - **SDK/Integration**: Truncated to safe limits
139
-
140
- ## Error Handling
141
-
142
- The SDK handles errors gracefully:
41
+ ## API Reference
143
42
 
144
- - **Invalid website key format**: Throws error during initialization
145
- - **Non-HTTPS endpoint**: Throws error during initialization
146
- - **Network errors**: Silently caught, logged in debug mode
147
- - **Timeout errors**: Request aborted after 5 seconds
43
+ ### Constructor
148
44
 
149
45
  ```typescript
150
- try {
151
- const tracker = new Client({
152
- websiteKey: 'invalid-key', // Throws error
153
- });
154
- } catch (error) {
155
- console.error(error); // [Client] Invalid websiteKey format...
156
- }
46
+ new Siteline(config: SitelineConfig)
157
47
  ```
158
48
 
159
- ## Debug Mode
49
+ **Configuration Options:**
160
50
 
161
- Enable debug logging to troubleshoot integration issues:
51
+ | Option | Type | Required | Description |
52
+ |--------|------|----------|-------------|
53
+ | `websiteKey` | `string` | Yes | Your Siteline website key |
54
+ | `endpoint` | `string` | No | Custom API endpoint (default: https://api.siteline.ai/v1/intake/pageview) |
55
+ | `debug` | `boolean` | No | Enable debug logging (default: false) |
162
56
 
163
- ```typescript
164
- const tracker = new Client({
165
- websiteKey: 'siteline_secret_abc123...',
166
- debug: true,
167
- });
57
+ ### track()
168
58
 
169
- siteline.track({...});
170
- // Console output:
171
- // [Client] Client initialized { endpoint: 'https://api.siteline.ai/v1/intake/pageview' }
172
- // [Client] Tracked: /home
59
+ ```typescript
60
+ siteline.track(data: PageviewData)
173
61
  ```
174
62
 
175
- ## Environment Compatibility
176
-
177
- - **Node.js**: >=18.0.0
178
- - **Edge Runtimes**: Cloudflare Workers, Vercel Edge, Deno
179
- - **Browsers**: Modern browsers with Fetch API support
180
- - **TypeScript**: Full type safety with exported types
63
+ **Pageview Data:**
181
64
 
182
- ## Security
65
+ | Field | Type | Required | Description |
66
+ |-------|------|----------|-------------|
67
+ | `url` | `string` | Yes | Request URL path |
68
+ | `method` | `string` | Yes | HTTP method |
69
+ | `status` | `number` | Yes | HTTP status code |
70
+ | `duration` | `number` | Yes | Request duration in milliseconds |
71
+ | `userAgent` | `string \| null` | Yes | User-Agent header |
72
+ | `ref` | `string \| null` | Yes | Referer header |
73
+ | `ip` | `string \| null` | Yes | Client IP address |
183
74
 
184
- - **HTTPS Only**: All data transmission over encrypted connections
185
- - **No PII Storage**: IP addresses and user agents are optional
186
- - **Input Validation**: All inputs sanitized and validated
187
- - **Timeout Protection**: 5-second request timeout
188
- - **No Eval**: No use of `eval()` or similar unsafe functions
75
+ ## Framework Integrations
189
76
 
190
- ## Framework Integration
77
+ For framework-specific integrations with automatic tracking:
191
78
 
192
- While `@siteline/core` can be used standalone, we provide official integrations:
79
+ - **[@siteline/nextjs](https://www.npmjs.com/package/@siteline/nextjs)** - Next.js middleware integration
193
80
 
194
- - **[@siteline/nextjs](https://www.npmjs.com/package/@siteline/nextjs)**: Next.js middleware integration
81
+ ## Documentation
195
82
 
196
- ## TypeScript Usage
83
+ - [Full Documentation](https://docs.gptrends.io/agent-analytics)
84
+ - [API Reference](https://api.siteline.ai/docs)
85
+ - [GitHub Repository](https://github.com/siteline-ai/siteline-sdk-js)
197
86
 
198
- All types are exported for use in your application:
87
+ ## Support
199
88
 
200
- ```typescript
201
- import { Client, type SitelineConfig, type PageviewData } from '@siteline/core';
202
-
203
- const config: SitelineConfig = {
204
- websiteKey: 'siteline_secret_abc123...',
205
- debug: true,
206
- };
207
-
208
- const tracker = new Client(config);
209
-
210
- const data: PageviewData = {
211
- websiteKey: config.websiteKey,
212
- sdk: '@siteline/core',
213
- sdk_version: '1.0.0',
214
- integration_type: 'custom',
215
- url: '/api/endpoint',
216
- method: 'POST',
217
- status: 201,
218
- duration: 89,
219
- userAgent: null,
220
- ref: null,
221
- ip: null,
222
- };
223
-
224
- siteline.track(data);
225
- ```
89
+ - [GitHub Issues](https://github.com/siteline-ai/siteline-sdk-js/issues)
90
+ - Email: support@siteline.ai
226
91
 
227
92
  ## License
228
93
 
229
94
  MIT
230
-
231
- ## Support
232
-
233
- - **GitHub Issues**: [github.com/siteline-ai/siteline-sdk-js/issues](https://github.com/siteline-ai/siteline-sdk-js/issues)
234
- - **Documentation**: [docs.gptrends.io/agent-analytics](https://docs.gptrends.io/agent-analytics)
235
- - **Repository**: [github.com/siteline-ai/siteline-sdk-js](https://github.com/siteline-ai/siteline-sdk-js)
@@ -1,6 +1,6 @@
1
- export declare const DEFAULT_ENDPOINT = "https://siteline.ai/v1/intake/pageview";
1
+ export declare const DEFAULT_ENDPOINT = "https://api.gptrends.io/v1/intake/pageview";
2
2
  export declare const DEFAULT_SDK_NAME = "@siteline/core";
3
- export declare const DEFAULT_SDK_VERSION = "1.0.0";
3
+ export declare const DEFAULT_SDK_VERSION = "1.0.1";
4
4
  export declare const DEFAULT_INTEGRATION_TYPE = "custom";
5
5
  export declare const WEBSITEKEY_PATTERN: RegExp;
6
6
  export declare const LIMITS: {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,2CAA2C,CAAC;AACzE,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AACjD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAEjD,eAAO,MAAM,kBAAkB,QAAmC,CAAC;AAEnE,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAaT,CAAC;AAEX,eAAO,MAAM,UAAU,OAAO,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,+CAA+C,CAAC;AAC7E,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AACjD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAEjD,eAAO,MAAM,kBAAkB,QAAqD,CAAC;AAErF,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAaT,CAAC;AAEX,eAAO,MAAM,UAAU,OAAO,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";class e extends Error{constructor(e){super(e),this.name="SitelineError"}}class t extends e{constructor(e){super(e),this.name="SitelineValidationError"}}const i=/^siteline_secret_[a-f0-9]{32}$/;exports.Siteline=class{constructor(e){if(!e.websiteKey?.match(i))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");if(this.key=e.websiteKey,this.endpoint=e.endpoint||"https://siteline.ai/v1/intake/pageview",this.debug=e.debug||!1,this.sdk=e.sdk||"@siteline/core",this.sdkVersion=e.sdkVersion||"1.0.0",this.integrationType=e.integrationType||"custom",!this.endpoint.startsWith("https://"))throw new t("Endpoint must use HTTPS");this.debug&&console.log("[Siteline] Siteline initialized")}track(e){const t=this.sanitize(e);this.send(t).catch(e=>{this.debug&&console.error("[Siteline] Track failed:",e.message)})}sanitize(e){return{websiteKey:this.key,url:(e.url+"").slice(0,2048),method:(e.method+"").toUpperCase().slice(0,10),status:Math.max(0,Math.min(999,Number(e.status)||0)),duration:Math.max(0,Math.min(3e5,Number(e.duration)||0)),userAgent:e.userAgent?(e.userAgent+"").slice(0,512):null,ref:e.ref?(e.ref+"").slice(0,2048):null,ip:e.ip?(e.ip+"").slice(0,45):null,integration_type:this.integrationType.slice(0,50),sdk:this.sdk.slice(0,50),sdk_version:this.sdkVersion.slice(0,20)}}async send(e){const t=new AbortController,i=setTimeout(()=>t.abort(),5e3);try{const i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`${this.sdk}/${this.sdkVersion}`},body:JSON.stringify(e),signal:t.signal});this.debug&&(i.ok?console.log("[Siteline] Tracked:",e.url):console.error("[Siteline] HTTP error:",i.status))}catch(e){this.debug&&console.error("[Siteline] Network error:",e.message)}finally{clearTimeout(i)}}},exports.SitelineError=e,exports.SitelineTransportError=class extends e{constructor(e){super(e),this.name="SitelineTransportError"}},exports.SitelineValidationError=t;
1
+ "use strict";class e extends Error{constructor(e){super(e),this.name="SitelineError"}}class t extends e{constructor(e){super(e),this.name="SitelineValidationError"}}const s=/^(siteline_secret|gptrends_secret)_[a-f0-9]{32}$/;exports.Siteline=class{constructor(e){if(!e.websiteKey?.match(s))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");if(this.key=e.websiteKey,this.endpoint=e.endpoint||"https://api.gptrends.io/v1/intake/pageview",this.debug=e.debug||!1,this.sdk=e.sdk||"@siteline/core",this.sdkVersion=e.sdkVersion||"1.0.1",this.integrationType=e.integrationType||"custom",!this.endpoint.startsWith("https://"))throw new t("Endpoint must use HTTPS");this.debug&&console.log("[Siteline] Siteline initialized")}track(e){const t=this.sanitize(e);this.send(t).catch(e=>{this.debug&&console.error("[Siteline] Track failed:",e.message)})}sanitize(e){return{websiteKey:this.key,url:(e.url+"").slice(0,2048),method:(e.method+"").toUpperCase().slice(0,10),status:Math.max(0,Math.min(999,Number(e.status)||0)),duration:Math.max(0,Math.min(3e5,Number(e.duration)||0)),userAgent:e.userAgent?(e.userAgent+"").slice(0,512):null,ref:e.ref?(e.ref+"").slice(0,2048):null,ip:e.ip?(e.ip+"").slice(0,45):null,integration_type:this.integrationType.slice(0,50),sdk:this.sdk.slice(0,50),sdk_version:this.sdkVersion.slice(0,20)}}async send(e){const t=new AbortController,s=setTimeout(()=>t.abort(),5e3);try{const s=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`${this.sdk}/${this.sdkVersion}`},body:JSON.stringify(e),signal:t.signal});this.debug&&(s.ok?console.log("[Siteline] Tracked:",e.url):console.error("[Siteline] HTTP error:",s.status))}catch(e){this.debug&&console.error("[Siteline] Network error:",e.message)}finally{clearTimeout(s)}}},exports.SitelineError=e,exports.SitelineTransportError=class extends e{constructor(e){super(e),this.name="SitelineTransportError"}},exports.SitelineValidationError=t;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/errors.ts","../src/constants.ts","../src/siteline.ts"],"sourcesContent":[null,null,null],"names":["SitelineError","Error","constructor","message","super","this","name","SitelineValidationError","WEBSITEKEY_PATTERN","config","websiteKey","match","key","endpoint","debug","sdk","sdkVersion","integrationType","startsWith","console","log","track","data","sanitized","sanitize","send","catch","err","error","url","String","slice","method","toUpperCase","status","Math","max","min","Number","duration","userAgent","ref","ip","integration_type","sdk_version","controller","AbortController","timeout","setTimeout","abort","res","fetch","headers","body","JSON","stringify","signal","ok","clearTimeout"],"mappings":"aAAM,MAAOA,UAAsBC,MACjC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,eACd,EAGI,MAAOC,UAAgCP,EAC3C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,yBACd,EC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BhB,IAAKV,KAAKU,IAAIgB,MAAM,EDlDR,ICmDZa,YAAavC,KAAKW,WAAWe,MAAM,EDlDf,ICoDxB,CAEQ,UAAMN,CAAKH,GACjB,MAAMuB,EAAa,IAAIC,gBACjBC,EAAUC,WAAW,IAAMH,EAAWI,QDjDtB,KCmDtB,IACE,MAAMC,QAAYC,MAAM9C,KAAKQ,SAAU,CACrCmB,OAAQ,OACRoB,QAAS,CACP,eAAgB,mBAChB,aAAc,GAAG/C,KAAKU,OAAOV,KAAKW,cAEpCqC,KAAMC,KAAKC,UAAUjC,GACrBkC,OAAQX,EAAWW,SAGjBnD,KAAKS,QACHoC,EAAIO,GACNtC,QAAQC,IAAI,sBAAuBE,EAAKO,KAExCV,QAAQS,MAAM,yBAA0BsB,EAAIhB,QAGlD,CAAE,MAAOP,GACHtB,KAAKS,OAEPK,QAAQS,MAAM,4BADAD,EACmCxB,QAErD,SACEuD,aAAaX,EACf,CACF,0DFrFI,cAAsC/C,EAC1C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,wBACd"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/errors.ts","../src/constants.ts","../src/siteline.ts"],"sourcesContent":[null,null,null],"names":["SitelineError","Error","constructor","message","super","this","name","SitelineValidationError","WEBSITEKEY_PATTERN","config","websiteKey","match","key","endpoint","debug","sdk","sdkVersion","integrationType","startsWith","console","log","track","data","sanitized","sanitize","send","catch","err","error","url","String","slice","method","toUpperCase","status","Math","max","min","Number","duration","userAgent","ref","ip","integration_type","sdk_version","controller","AbortController","timeout","setTimeout","abort","res","fetch","headers","body","JSON","stringify","signal","ok","clearTimeout"],"mappings":"aAAM,MAAOA,UAAsBC,MACjC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,eACd,EAGI,MAAOC,UAAgCP,EAC3C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,yBACd,ECXK,MAKME,EAAqB,0ECehC,WAAAN,CAAYO,GACV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ICmDZa,YAAavC,KAAKW,WAAWe,MAAM,EDlDf,ICoDxB,CAEQ,UAAMN,CAAKH,GACjB,MAAMuB,EAAa,IAAIC,gBACjBC,EAAUC,WAAW,IAAMH,EAAWI,QDjDtB,KCmDtB,IACE,MAAMC,QAAYC,MAAM9C,KAAKQ,SAAU,CACrCmB,OAAQ,OACRoB,QAAS,CACP,eAAgB,mBAChB,aAAc,GAAG/C,KAAKU,OAAOV,KAAKW,cAEpCqC,KAAMC,KAAKC,UAAUjC,GACrBkC,OAAQX,EAAWW,SAGjBnD,KAAKS,QACHoC,EAAIO,GACNtC,QAAQC,IAAI,sBAAuBE,EAAKO,KAExCV,QAAQS,MAAM,yBAA0BsB,EAAIhB,QAGlD,CAAE,MAAOP,GACHtB,KAAKS,OAEPK,QAAQS,MAAM,4BADAD,EACmCxB,QAErD,SACEuD,aAAaX,EACf,CACF,0DFrFI,cAAsC/C,EAC1C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,wBACd"}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- class e extends Error{constructor(e){super(e),this.name="SitelineError"}}class t extends e{constructor(e){super(e),this.name="SitelineValidationError"}}class s extends e{constructor(e){super(e),this.name="SitelineTransportError"}}const i=/^siteline_secret_[a-f0-9]{32}$/;class n{constructor(e){if(!e.websiteKey?.match(i))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");if(this.key=e.websiteKey,this.endpoint=e.endpoint||"https://siteline.ai/v1/intake/pageview",this.debug=e.debug||!1,this.sdk=e.sdk||"@siteline/core",this.sdkVersion=e.sdkVersion||"1.0.0",this.integrationType=e.integrationType||"custom",!this.endpoint.startsWith("https://"))throw new t("Endpoint must use HTTPS");this.debug&&console.log("[Siteline] Siteline initialized")}track(e){const t=this.sanitize(e);this.send(t).catch(e=>{this.debug&&console.error("[Siteline] Track failed:",e.message)})}sanitize(e){return{websiteKey:this.key,url:(e.url+"").slice(0,2048),method:(e.method+"").toUpperCase().slice(0,10),status:Math.max(0,Math.min(999,Number(e.status)||0)),duration:Math.max(0,Math.min(3e5,Number(e.duration)||0)),userAgent:e.userAgent?(e.userAgent+"").slice(0,512):null,ref:e.ref?(e.ref+"").slice(0,2048):null,ip:e.ip?(e.ip+"").slice(0,45):null,integration_type:this.integrationType.slice(0,50),sdk:this.sdk.slice(0,50),sdk_version:this.sdkVersion.slice(0,20)}}async send(e){const t=new AbortController,s=setTimeout(()=>t.abort(),5e3);try{const s=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`${this.sdk}/${this.sdkVersion}`},body:JSON.stringify(e),signal:t.signal});this.debug&&(s.ok?console.log("[Siteline] Tracked:",e.url):console.error("[Siteline] HTTP error:",s.status))}catch(e){this.debug&&console.error("[Siteline] Network error:",e.message)}finally{clearTimeout(s)}}}export{n as Siteline,e as SitelineError,s as SitelineTransportError,t as SitelineValidationError};
1
+ class e extends Error{constructor(e){super(e),this.name="SitelineError"}}class t extends e{constructor(e){super(e),this.name="SitelineValidationError"}}class s extends e{constructor(e){super(e),this.name="SitelineTransportError"}}const i=/^(siteline_secret|gptrends_secret)_[a-f0-9]{32}$/;class n{constructor(e){if(!e.websiteKey?.match(i))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");if(this.key=e.websiteKey,this.endpoint=e.endpoint||"https://api.gptrends.io/v1/intake/pageview",this.debug=e.debug||!1,this.sdk=e.sdk||"@siteline/core",this.sdkVersion=e.sdkVersion||"1.0.1",this.integrationType=e.integrationType||"custom",!this.endpoint.startsWith("https://"))throw new t("Endpoint must use HTTPS");this.debug&&console.log("[Siteline] Siteline initialized")}track(e){const t=this.sanitize(e);this.send(t).catch(e=>{this.debug&&console.error("[Siteline] Track failed:",e.message)})}sanitize(e){return{websiteKey:this.key,url:(e.url+"").slice(0,2048),method:(e.method+"").toUpperCase().slice(0,10),status:Math.max(0,Math.min(999,Number(e.status)||0)),duration:Math.max(0,Math.min(3e5,Number(e.duration)||0)),userAgent:e.userAgent?(e.userAgent+"").slice(0,512):null,ref:e.ref?(e.ref+"").slice(0,2048):null,ip:e.ip?(e.ip+"").slice(0,45):null,integration_type:this.integrationType.slice(0,50),sdk:this.sdk.slice(0,50),sdk_version:this.sdkVersion.slice(0,20)}}async send(e){const t=new AbortController,s=setTimeout(()=>t.abort(),5e3);try{const s=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`${this.sdk}/${this.sdkVersion}`},body:JSON.stringify(e),signal:t.signal});this.debug&&(s.ok?console.log("[Siteline] Tracked:",e.url):console.error("[Siteline] HTTP error:",s.status))}catch(e){this.debug&&console.error("[Siteline] Network error:",e.message)}finally{clearTimeout(s)}}}export{n as Siteline,e as SitelineError,s as SitelineTransportError,t as SitelineValidationError};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/errors.ts","../src/constants.ts","../src/siteline.ts"],"sourcesContent":[null,null,null],"names":["SitelineError","Error","constructor","message","super","this","name","SitelineValidationError","SitelineTransportError","WEBSITEKEY_PATTERN","Siteline","config","websiteKey","match","key","endpoint","debug","sdk","sdkVersion","integrationType","startsWith","console","log","track","data","sanitized","sanitize","send","catch","err","error","url","String","slice","method","toUpperCase","status","Math","max","min","Number","duration","userAgent","ref","ip","integration_type","sdk_version","controller","AbortController","timeout","setTimeout","abort","res","fetch","headers","body","JSON","stringify","signal","ok","clearTimeout"],"mappings":"AAAM,MAAOA,UAAsBC,MACjC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,eACd,EAGI,MAAOC,UAAgCP,EAC3C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,yBACd,EAGI,MAAOE,UAA+BR,EAC1C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,wBACd,EClBK,MAKMG,EAAqB,uCCOrBC,EAQX,WAAAR,CAAYS,GACV,IAAKA,EAAOC,YAAYC,MAAMJ,G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MAAM,EDlDf,ICoDxB,CAEQ,UAAMN,CAAKH,GACjB,MAAMuB,EAAa,IAAIC,gBACjBC,EAAUC,WAAW,IAAMH,EAAWI,QDjDtB,KCmDtB,IACE,MAAMC,QAAYC,MAAMhD,KAAKU,SAAU,CACrCmB,OAAQ,OACRoB,QAAS,CACP,eAAgB,mBAChB,aAAc,GAAGjD,KAAKY,OAAOZ,KAAKa,cAEpCqC,KAAMC,KAAKC,UAAUjC,GACrBkC,OAAQX,EAAWW,SAGjBrD,KAAKW,QACHoC,EAAIO,GACNtC,QAAQC,IAAI,sBAAuBE,EAAKO,KAExCV,QAAQS,MAAM,yBAA0BsB,EAAIhB,QAGlD,CAAE,MAAOP,GACHxB,KAAKW,OAEPK,QAAQS,MAAM,4BADAD,EACmC1B,QAErD,SACEyD,aAAaX,EACf,CACF"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/errors.ts","../src/constants.ts","../src/siteline.ts"],"sourcesContent":[null,null,null],"names":["SitelineError","Error","constructor","message","super","this","name","SitelineValidationError","SitelineTransportError","WEBSITEKEY_PATTERN","Siteline","config","websiteKey","match","key","endpoint","debug","sdk","sdkVersion","integrationType","startsWith","console","log","track","data","sanitized","sanitize","send","catch","err","error","url","String","slice","method","toUpperCase","status","Math","max","min","Number","duration","userAgent","ref","ip","integration_type","sdk_version","controller","AbortController","timeout","setTimeout","abort","res","fetch","headers","body","JSON","stringify","signal","ok","clearTimeout"],"mappings":"AAAM,MAAOA,UAAsBC,MACjC,WAAAC,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,eACd,EAGI,MAAOC,UAAgCP,EAC3C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,yBACd,EAGI,MAAOE,UAA+BR,EAC1C,WAAAE,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,wBACd,EClBK,MAKMG,EAAqB,yDCOrBC,EAQX,WAAAR,CAAYS,GACV,IAAKA,EAAOC,YAAYC,MAAMJ,GAC5B,MA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lDf,ICoDxB,CAEQ,UAAMN,CAAKH,GACjB,MAAMuB,EAAa,IAAIC,gBACjBC,EAAUC,WAAW,IAAMH,EAAWI,QDjDtB,KCmDtB,IACE,MAAMC,QAAYC,MAAMhD,KAAKU,SAAU,CACrCmB,OAAQ,OACRoB,QAAS,CACP,eAAgB,mBAChB,aAAc,GAAGjD,KAAKY,OAAOZ,KAAKa,cAEpCqC,KAAMC,KAAKC,UAAUjC,GACrBkC,OAAQX,EAAWW,SAGjBrD,KAAKW,QACHoC,EAAIO,GACNtC,QAAQC,IAAI,sBAAuBE,EAAKO,KAExCV,QAAQS,MAAM,yBAA0BsB,EAAIhB,QAGlD,CAAE,MAAOP,GACHxB,KAAKW,OAEPK,QAAQS,MAAM,4BADAD,EACmC1B,QAErD,SACEyD,aAAaX,EACf,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siteline/core",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Core tracking SDK for Siteline - Agent Analytics platform for tracking AI agents, bots, and crawlers",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -52,7 +52,7 @@
52
52
  "license": "MIT",
53
53
  "repository": {
54
54
  "type": "git",
55
- "url": "https://github.com/siteline-ai/siteline-sdk-js",
55
+ "url": "git+https://github.com/siteline-ai/siteline-sdk-js.git",
56
56
  "directory": "packages/core"
57
57
  },
58
58
  "bugs": {