@siteline/core 1.0.5 → 1.0.6
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/constants.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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.
|
|
3
|
+
export declare const DEFAULT_SDK_VERSION = "1.0.6";
|
|
4
4
|
export declare const DEFAULT_INTEGRATION_TYPE = "custom";
|
|
5
5
|
export declare const WEBSITEKEY_PATTERN: RegExp;
|
|
6
6
|
export declare const LIMITS: {
|
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|gptrends_secret)_/;exports.Siteline=class{constructor(e){if(!e.websiteKey?.match(i))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");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
|
+
"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|gptrends_secret)_/;exports.Siteline=class{constructor(e){if(!e.websiteKey?.match(i))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");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.6",this.integrationType=e.integrationType||"custom",this.debug&&console.log("[Siteline] Siteline initialized")}async track(e){const t=this.sanitize(e);try{return await 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,integrationType:this.integrationType.slice(0,50),sdk:this.sdk.slice(0,50),sdkVersion: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,{endpoint:this.endpoint,sdk:this.sdk,sdkVersion:this.sdkVersion,integrationType:this.integrationType}):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;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
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|gptrends_secret)_/;class n{constructor(e){if(!e.websiteKey?.match(i))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");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
|
+
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)_/;class n{constructor(e){if(!e.websiteKey?.match(i))throw new t("Invalid websiteKey format. Expected: siteline_secret_<32 hex chars>");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.6",this.integrationType=e.integrationType||"custom",this.debug&&console.log("[Siteline] Siteline initialized")}async track(e){const t=this.sanitize(e);try{return await 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,integrationType:this.integrationType.slice(0,50),sdk:this.sdk.slice(0,50),sdkVersion: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,{endpoint:this.endpoint,sdk:this.sdk,sdkVersion:this.sdkVersion,integrationType:this.integrationType}):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
|
package/package.json
CHANGED