@solomon-tech/webanalytics-sdk 1.0.5 → 1.0.7
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.
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { randomUUID } from "crypto";
|
|
11
11
|
const DEFAULT_WEBANALYTICS_URL = "https://webanalytics.solomon.com.br/event?mode=web";
|
|
12
12
|
const DEFAULT_PIXEL_URL = "https://pixel.solomon.com.br/event";
|
|
13
|
-
const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; SolomonSDK-Node/1.0.
|
|
13
|
+
const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; SolomonSDK-Node/1.0.7)";
|
|
14
14
|
const BRENDI_COMPANY_ID = "G6fGRIcYL8qJ06SukNdV";
|
|
15
15
|
const DUMMY_SESSION_ID = "00000000-0000-4000-8000-000000000000";
|
|
16
16
|
export class SolomonSDK {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var o={d:(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},e={};o.r(e),o.d(e,{SolomonSDK:()=>SolomonSDK,default:()=>SolomonSDK});const t=require("crypto");var __awaiter=function(o,e,t,n){return new(t||(t=Promise))((function(i,r){function fulfilled(o){try{step(n.next(o))}catch(o){r(o)}}function rejected(o){try{step(n.throw(o))}catch(o){r(o)}}function step(o){var e;o.done?i(o.value):(e=o.value,e instanceof t?e:new t((function(o){o(e)}))).then(fulfilled,rejected)}step((n=n.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK:Node] initialized",{companyId:o.companyId,useTouchpoint:o.useTouchpoint})}track(o,e,n){return __awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK:Node] Tracking event:",o,e);const i=(this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==n?void 0:n.user_id)?n.user_id:(0,t.randomUUID)(),r={company_id:this.config.companyId,event_id:(0,t.randomUUID)(),event_time:(new Date).toISOString(),session_id:"00000000-0000-4000-8000-000000000000",user_id:i,fbp:"",fbc:"",legacy_id:"",custom_aliases:{user_id:(null==n?void 0:n.user_id)||"",email:(null==n?void 0:n.email)||"",phone:(null==n?void 0:n.phone)||"",customer_id:(null==n?void 0:n.customer_id)||"",cart_token:(null==n?void 0:n.cart_token)||"",order_id:(null==n?void 0:n.order_id)||""},event_type:o,page_referrer:"",page_path:"",utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:"",sol_source:"",sol_medium:"",sol_campaign:"",sol_content:"",event_payload:e||{},voxus_url:""},c=this.config.webanalyticsUrl||"https://webanalytics.solomon.com.br/event?mode=web",s=this.config.pixelUrl||"https://pixel.solomon.com.br/event",l={"Content-Type":"application/json","User-Agent":this.config.userAgent||"Mozilla/5.0 (compatible; SolomonSDK-Node/1.0.7)"};try{const e=[fetch(c,{method:"POST",headers:l,body:JSON.stringify(r)})];if(this.config.useTouchpoint){const o=this.buildTouchpointEvent(i);e.push(fetch(s,{method:"POST",headers:l,body:JSON.stringify(o)}))}const t=yield Promise.all(e);if(!t[0].ok)throw new Error(`Event HTTP ${t[0].status}: ${yield t[0].text()}`);t[1]&&!t[1].ok&&console.error(`[SolomonSDK:Node] Touchpoint HTTP ${t[1].status}: ${yield t[1].text()}`),this.config.debug&&console.log("[SolomonSDK:Node] Event sent:",o,this.config.useTouchpoint?"(+ touchpoint)":"")}catch(o){throw console.error("[SolomonSDK:Node] Error sending event:",o),o}}))}buildTouchpointEvent(o){return{id:o,referrer:"",path:"",utm_source:"",utm_medium:"",utm_campaign:"",utm_term:o,utm_content:"",sol_source:"",sol_medium:"",sol_campaign:"",sol_content:"",fbp:"",fbc:"",ga_id:"",fbclid:"",locale:"",timezone:"",osVersion:"",screenWidth:0,screenHeight:0,density:1,cpuCores:0,queryParams:"",debug:"",old_id:"",shopify_id:this.config.companyId,current_domain:"",cart_token:o,email:"",utmsTrack:""}}}module.exports=e})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as o}from"node:module";var e={d:(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e)},t={};e.d(t,{C:()=>SolomonSDK,A:()=>SolomonSDK});const n=o(import.meta.url)("crypto");var __awaiter=function(o,e,t,n){return new(t||(t=Promise))((function(i,r){function fulfilled(o){try{step(n.next(o))}catch(o){r(o)}}function rejected(o){try{step(n.throw(o))}catch(o){r(o)}}function step(o){var e;o.done?i(o.value):(e=o.value,e instanceof t?e:new t((function(o){o(e)}))).then(fulfilled,rejected)}step((n=n.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK:Node] initialized",{companyId:o.companyId,useTouchpoint:o.useTouchpoint})}track(o,e,t){return __awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK:Node] Tracking event:",o,e);const i=(this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==t?void 0:t.user_id)?t.user_id:(0,n.randomUUID)(),r={company_id:this.config.companyId,event_id:(0,n.randomUUID)(),event_time:(new Date).toISOString(),session_id:"00000000-0000-4000-8000-000000000000",user_id:i,fbp:"",fbc:"",legacy_id:"",custom_aliases:{user_id:(null==t?void 0:t.user_id)||"",email:(null==t?void 0:t.email)||"",phone:(null==t?void 0:t.phone)||"",customer_id:(null==t?void 0:t.customer_id)||"",cart_token:(null==t?void 0:t.cart_token)||"",order_id:(null==t?void 0:t.order_id)||""},event_type:o,page_referrer:"",page_path:"",utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:"",sol_source:"",sol_medium:"",sol_campaign:"",sol_content:"",event_payload:e||{},voxus_url:""},c=this.config.webanalyticsUrl||"https://webanalytics.solomon.com.br/event?mode=web",s=this.config.pixelUrl||"https://pixel.solomon.com.br/event",l={"Content-Type":"application/json","User-Agent":this.config.userAgent||"Mozilla/5.0 (compatible; SolomonSDK-Node/1.0.
|
|
1
|
+
import{createRequire as o}from"node:module";var e={d:(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e)},t={};e.d(t,{C:()=>SolomonSDK,A:()=>SolomonSDK});const n=o(import.meta.url)("crypto");var __awaiter=function(o,e,t,n){return new(t||(t=Promise))((function(i,r){function fulfilled(o){try{step(n.next(o))}catch(o){r(o)}}function rejected(o){try{step(n.throw(o))}catch(o){r(o)}}function step(o){var e;o.done?i(o.value):(e=o.value,e instanceof t?e:new t((function(o){o(e)}))).then(fulfilled,rejected)}step((n=n.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK:Node] initialized",{companyId:o.companyId,useTouchpoint:o.useTouchpoint})}track(o,e,t){return __awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK:Node] Tracking event:",o,e);const i=(this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==t?void 0:t.user_id)?t.user_id:(0,n.randomUUID)(),r={company_id:this.config.companyId,event_id:(0,n.randomUUID)(),event_time:(new Date).toISOString(),session_id:"00000000-0000-4000-8000-000000000000",user_id:i,fbp:"",fbc:"",legacy_id:"",custom_aliases:{user_id:(null==t?void 0:t.user_id)||"",email:(null==t?void 0:t.email)||"",phone:(null==t?void 0:t.phone)||"",customer_id:(null==t?void 0:t.customer_id)||"",cart_token:(null==t?void 0:t.cart_token)||"",order_id:(null==t?void 0:t.order_id)||""},event_type:o,page_referrer:"",page_path:"",utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:"",sol_source:"",sol_medium:"",sol_campaign:"",sol_content:"",event_payload:e||{},voxus_url:""},c=this.config.webanalyticsUrl||"https://webanalytics.solomon.com.br/event?mode=web",s=this.config.pixelUrl||"https://pixel.solomon.com.br/event",l={"Content-Type":"application/json","User-Agent":this.config.userAgent||"Mozilla/5.0 (compatible; SolomonSDK-Node/1.0.7)"};try{const e=[fetch(c,{method:"POST",headers:l,body:JSON.stringify(r)})];if(this.config.useTouchpoint){const o=this.buildTouchpointEvent(i);e.push(fetch(s,{method:"POST",headers:l,body:JSON.stringify(o)}))}const t=yield Promise.all(e);if(!t[0].ok)throw new Error(`Event HTTP ${t[0].status}: ${yield t[0].text()}`);t[1]&&!t[1].ok&&console.error(`[SolomonSDK:Node] Touchpoint HTTP ${t[1].status}: ${yield t[1].text()}`),this.config.debug&&console.log("[SolomonSDK:Node] Event sent:",o,this.config.useTouchpoint?"(+ touchpoint)":"")}catch(o){throw console.error("[SolomonSDK:Node] Error sending event:",o),o}}))}buildTouchpointEvent(o){return{id:o,referrer:"",path:"",utm_source:"",utm_medium:"",utm_campaign:"",utm_term:o,utm_content:"",sol_source:"",sol_medium:"",sol_campaign:"",sol_content:"",fbp:"",fbc:"",ga_id:"",fbclid:"",locale:"",timezone:"",osVersion:"",screenWidth:0,screenHeight:0,density:1,cpuCores:0,queryParams:"",debug:"",old_id:"",shopify_id:this.config.companyId,current_domain:"",cart_token:o,email:"",utmsTrack:""}}}var i=t.C,r=t.A;export{i as SolomonSDK,r as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solomon-tech/webanalytics-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Solomon WebAnalytics SDK — browser and Node.js event tracking",
|
|
5
5
|
"main": "./dist/sdk/solomon-sdk.esm.min.js",
|
|
6
6
|
"types": "./dist/sdk/sdk/index.d.ts",
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
"types": "./dist/sdk/sdk/index.d.ts"
|
|
11
11
|
},
|
|
12
12
|
"./node": {
|
|
13
|
+
"types": "./dist/sdk/sdk/node/index.d.ts",
|
|
13
14
|
"import": "./dist/sdk/solomon-sdk.node.esm.min.js",
|
|
14
|
-
"
|
|
15
|
+
"require": "./dist/sdk/solomon-sdk.node.cjs.min.js"
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
18
|
-
"dist/sdk"
|
|
19
|
+
"dist/sdk",
|
|
20
|
+
"node"
|
|
19
21
|
],
|
|
20
22
|
"scripts": {
|
|
21
23
|
"watch": "webpack -w",
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
"build:linx": "webpack --env platform=linx",
|
|
45
47
|
"build:loja_integrada": "webpack --env platform=loja_integrada",
|
|
46
48
|
"build:sdk": "webpack --config webpack.sdk.config.js && npm run build:sdk:types",
|
|
47
|
-
"build:sdk:npm": "webpack --config webpack.sdk.npm.config.js && webpack --config webpack.sdk.node.config.js && npm run build:sdk:types && npm run build:sdk:cleanup",
|
|
49
|
+
"build:sdk:npm": "webpack --config webpack.sdk.npm.config.js && webpack --config webpack.sdk.node.config.js && webpack --config webpack.sdk.node.cjs.config.js && npm run build:sdk:types && npm run build:sdk:cleanup",
|
|
48
50
|
"build:sdk:cleanup": "rm -f dist/sdk/types.d.ts dist/sdk/types.js",
|
|
49
51
|
"build:sdk:types": "tsc --project tsconfig.sdk.json",
|
|
50
52
|
"build:sdk:watch": "webpack --config webpack.sdk.config.js --watch",
|