@rockfeller/sdk 0.1.0
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/sdk.constants.d.ts +13 -0
- package/dist/constants/sdk.constants.d.ts.map +1 -0
- package/dist/core/auto-identify.d.ts +2 -0
- package/dist/core/auto-identify.d.ts.map +1 -0
- package/dist/core/auto-init.d.ts +2 -0
- package/dist/core/auto-init.d.ts.map +1 -0
- package/dist/core/config-loader.d.ts +3 -0
- package/dist/core/config-loader.d.ts.map +1 -0
- package/dist/core/identity.d.ts +4 -0
- package/dist/core/identity.d.ts.map +1 -0
- package/dist/core/init.d.ts +5 -0
- package/dist/core/init.d.ts.map +1 -0
- package/dist/core/pixels/google.d.ts +13 -0
- package/dist/core/pixels/google.d.ts.map +1 -0
- package/dist/core/pixels/index.d.ts +7 -0
- package/dist/core/pixels/index.d.ts.map +1 -0
- package/dist/core/pixels/meta.d.ts +13 -0
- package/dist/core/pixels/meta.d.ts.map +1 -0
- package/dist/core/scroll-tracker.d.ts +3 -0
- package/dist/core/scroll-tracker.d.ts.map +1 -0
- package/dist/core/state.d.ts +4 -0
- package/dist/core/state.d.ts.map +1 -0
- package/dist/core/tracker.d.ts +6 -0
- package/dist/core/tracker.d.ts.map +1 -0
- package/dist/core/transport.d.ts +2 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/sdk.mjs +420 -0
- package/dist/sdk.umd.js +1 -0
- package/dist/types/sdk.types.d.ts +48 -0
- package/dist/types/sdk.types.d.ts.map +1 -0
- package/dist/utils/id.utils.d.ts +2 -0
- package/dist/utils/id.utils.d.ts.map +1 -0
- package/dist/utils/logger.utils.d.ts +2 -0
- package/dist/utils/logger.utils.d.ts.map +1 -0
- package/dist/utils/utm.utils.d.ts +2 -0
- package/dist/utils/utm.utils.d.ts.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const STORAGE_KEY = "rmv_visitor_id";
|
|
2
|
+
export declare const SESSION_KEY = "rmv_session_id";
|
|
3
|
+
export declare const DEFAULT_API_URL = "https://api.rockmarketvisor.com";
|
|
4
|
+
export declare const ID_PREFIX = "rmv_";
|
|
5
|
+
export declare const ID_LENGTH = 20;
|
|
6
|
+
export declare const CONFIG_CACHE_KEY = "rmv_config";
|
|
7
|
+
export declare const CONFIG_CACHE_TTL: number;
|
|
8
|
+
export declare const UTM_KEYS: readonly ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "utm_id", "gclid", "fbclid"];
|
|
9
|
+
export declare const FORM_EMAIL_SELECTORS: readonly ["input[type=\"email\"]", "input[name*=\"email\"]", "input[name*=\"e-mail\"]", "input[autocomplete=\"email\"]"];
|
|
10
|
+
export declare const FORM_PHONE_SELECTORS: readonly ["input[type=\"tel\"]", "input[name*=\"phone\"]", "input[name*=\"tel\"]", "input[name*=\"celular\"]", "input[name*=\"whatsapp\"]", "input[autocomplete=\"tel\"]"];
|
|
11
|
+
export declare const FORM_NAME_SELECTORS: readonly ["input[name*=\"name\"]", "input[name*=\"nome\"]", "input[autocomplete=\"name\"]", "input[autocomplete=\"given-name\"]"];
|
|
12
|
+
export declare const FORM_CPF_SELECTORS: readonly ["input[name*=\"cpf\"]", "input[name*=\"documento\"]"];
|
|
13
|
+
//# sourceMappingURL=sdk.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.constants.d.ts","sourceRoot":"","sources":["../../src/constants/sdk.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,eAAe,oCAAoC,CAAC;AACjE,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,gBAAgB,QAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,+GASX,CAAC;AAEX,eAAO,MAAM,oBAAoB,0HAKvB,CAAC;AAEX,eAAO,MAAM,oBAAoB,4KAOvB,CAAC;AAEX,eAAO,MAAM,mBAAmB,mIAKtB,CAAC;AAEX,eAAO,MAAM,kBAAkB,iEAGrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-identify.d.ts","sourceRoot":"","sources":["../../src/core/auto-identify.ts"],"names":[],"mappings":"AA2DA,wBAAgB,iBAAiB,SAsBhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-init.d.ts","sourceRoot":"","sources":["../../src/core/auto-init.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,SAuBvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAmCvD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAgCrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,IAAI,MAAM,CAsB7C;AAED,wBAAgB,YAAY,IAAI,MAAM,CAsBrC;AAED,wBAAgB,aAAa,SAO5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/core/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAYtD,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,iBAuG9C;AAED,wBAAgB,KAAK,SAGpB;AAED,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAE5C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PixelGoogle } from '../../types/sdk.types';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
dataLayer: unknown[];
|
|
5
|
+
gtag: (...args: unknown[]) => void;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function loadGoogleAds(config: PixelGoogle): void;
|
|
9
|
+
export declare function googleTrackPageView(): void;
|
|
10
|
+
export declare function googleTrackLead(data?: Record<string, unknown>): void;
|
|
11
|
+
export declare function googleTrackConversion(value: number, currency?: string): void;
|
|
12
|
+
export declare function googleTrackCustom(eventName: string, data?: Record<string, unknown>): void;
|
|
13
|
+
//# sourceMappingURL=google.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/core/pixels/google.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,SAAS,EAAE,OAAO,EAAE,CAAC;QACrB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;KACpC;CACF;AAMD,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,QAoChD;AAED,wBAAgB,mBAAmB,SAGlC;AAED,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAG7D;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAQ,QAUpE;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAGlF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RemoteConfig } from '../../types/sdk.types';
|
|
2
|
+
export declare function initPixels(config: RemoteConfig): void;
|
|
3
|
+
export declare function pixelPageView(): void;
|
|
4
|
+
export declare function pixelLead(data?: Record<string, unknown>): void;
|
|
5
|
+
export declare function pixelConversion(value: number, currency?: string): void;
|
|
6
|
+
export declare function pixelCustomEvent(eventName: string, data?: Record<string, unknown>): void;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/pixels/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAgB1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,QAG9C;AAED,wBAAgB,aAAa,SAG5B;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAGvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAQ,QAG9D;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAGjF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PixelMeta } from '../../types/sdk.types';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
fbq: (...args: unknown[]) => void;
|
|
5
|
+
_fbq: unknown;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function loadMetaPixel(config: PixelMeta): void;
|
|
9
|
+
export declare function metaTrackPageView(): void;
|
|
10
|
+
export declare function metaTrackLead(data?: Record<string, unknown>): void;
|
|
11
|
+
export declare function metaTrackPurchase(value: number, currency?: string): void;
|
|
12
|
+
export declare function metaTrackCustom(eventName: string, data?: Record<string, unknown>): void;
|
|
13
|
+
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/core/pixels/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QAClC,IAAI,EAAE,OAAO,CAAC;KACf;CACF;AAID,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,QAoC9C;AAED,wBAAgB,iBAAiB,SAGhC;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAG3D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAQ,QAGhE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAGhF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-tracker.d.ts","sourceRoot":"","sources":["../../src/core/scroll-tracker.ts"],"names":[],"mappings":"AAKA,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,MAAM,EAAsB,QAqC3E;AAED,wBAAgB,mBAAmB,SAElC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/core/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,eAAO,MAAM,KAAK,EAAE,QAUnB,CAAC;AAEF,wBAAgB,UAAU,SAUzB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IdentifyData } from '../types/sdk.types';
|
|
2
|
+
export declare function page(properties?: Record<string, unknown>): void;
|
|
3
|
+
export declare function track(eventType: string, properties?: Record<string, unknown>): void;
|
|
4
|
+
export declare function identify(data: IdentifyData): void;
|
|
5
|
+
export declare function conversion(type: string, value: number, properties?: Record<string, unknown>): void;
|
|
6
|
+
//# sourceMappingURL=tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/core/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMvD,wBAAgB,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAgBxD;AAED,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAQ5E;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY,QAK1C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAS3F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/core/transport.ts"],"names":[],"mappings":"AAIA,wBAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,iBAwC5E"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getVisitorId, init, reset } from './core/init';
|
|
2
|
+
import { conversion, identify, page, track } from './core/tracker';
|
|
3
|
+
export type { IdentifyData, InitOptions } from './types/sdk.types';
|
|
4
|
+
export declare const TrackFlow: {
|
|
5
|
+
init: typeof init;
|
|
6
|
+
page: typeof page;
|
|
7
|
+
track: typeof track;
|
|
8
|
+
identify: typeof identify;
|
|
9
|
+
conversion: typeof conversion;
|
|
10
|
+
reset: typeof reset;
|
|
11
|
+
getVisitorId: typeof getVisitorId;
|
|
12
|
+
};
|
|
13
|
+
export default TrackFlow;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEnE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,eAAO,MAAM,SAAS;;;;;;;;CAQrB,CAAC;AAKF,eAAe,SAAS,CAAC"}
|
package/dist/sdk.mjs
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
const I = "rmv_visitor_id", h = "rmv_session_id", E = "https://api.rockmarketvisor.com", K = "rmv_";
|
|
2
|
+
const y = "rmv_config";
|
|
3
|
+
const q = [
|
|
4
|
+
"utm_source",
|
|
5
|
+
"utm_medium",
|
|
6
|
+
"utm_campaign",
|
|
7
|
+
"utm_term",
|
|
8
|
+
"utm_content",
|
|
9
|
+
"utm_id",
|
|
10
|
+
"gclid",
|
|
11
|
+
"fbclid"
|
|
12
|
+
], U = [
|
|
13
|
+
'input[type="email"]',
|
|
14
|
+
'input[name*="email"]',
|
|
15
|
+
'input[name*="e-mail"]',
|
|
16
|
+
'input[autocomplete="email"]'
|
|
17
|
+
], x = [
|
|
18
|
+
'input[type="tel"]',
|
|
19
|
+
'input[name*="phone"]',
|
|
20
|
+
'input[name*="tel"]',
|
|
21
|
+
'input[name*="celular"]',
|
|
22
|
+
'input[name*="whatsapp"]',
|
|
23
|
+
'input[autocomplete="tel"]'
|
|
24
|
+
], M = [
|
|
25
|
+
'input[name*="name"]',
|
|
26
|
+
'input[name*="nome"]',
|
|
27
|
+
'input[autocomplete="name"]',
|
|
28
|
+
'input[autocomplete="given-name"]'
|
|
29
|
+
], j = [
|
|
30
|
+
'input[name*="cpf"]',
|
|
31
|
+
'input[name*="documento"]'
|
|
32
|
+
], o = {
|
|
33
|
+
publicKey: null,
|
|
34
|
+
apiUrl: E,
|
|
35
|
+
debug: !1,
|
|
36
|
+
projectId: null,
|
|
37
|
+
franchiseId: null,
|
|
38
|
+
visitorId: null,
|
|
39
|
+
sessionId: null,
|
|
40
|
+
remoteConfig: null,
|
|
41
|
+
initialized: !1
|
|
42
|
+
};
|
|
43
|
+
function N() {
|
|
44
|
+
o.publicKey = null, o.apiUrl = E, o.debug = !1, o.projectId = null, o.franchiseId = null, o.visitorId = null, o.sessionId = null, o.remoteConfig = null, o.initialized = !1;
|
|
45
|
+
}
|
|
46
|
+
function c(...e) {
|
|
47
|
+
o.debug && console.log("[TrackFlow]", ...e);
|
|
48
|
+
}
|
|
49
|
+
function L() {
|
|
50
|
+
const e = new URLSearchParams(window.location.search), t = {};
|
|
51
|
+
for (const n of q) {
|
|
52
|
+
const i = e.get(n);
|
|
53
|
+
i && (t[n] = i);
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
}
|
|
57
|
+
let d = !1, v = null, m = null;
|
|
58
|
+
function R(e) {
|
|
59
|
+
var s;
|
|
60
|
+
if (!e.enabled || d) return;
|
|
61
|
+
const t = !!e.adsId, n = !!e.analyticsId;
|
|
62
|
+
if (!t && !n) return;
|
|
63
|
+
const i = e.adsId ?? e.analyticsId;
|
|
64
|
+
c("[Google] Carregando:", i), window.dataLayer = window.dataLayer || [], window.gtag = function(...l) {
|
|
65
|
+
window.dataLayer.push(l);
|
|
66
|
+
}, window.gtag("js", /* @__PURE__ */ new Date());
|
|
67
|
+
const r = document.createElement("script");
|
|
68
|
+
r.async = !0, r.src = `https://www.googletagmanager.com/gtag/js?id=${i}`;
|
|
69
|
+
const a = document.getElementsByTagName("script")[0];
|
|
70
|
+
(s = a == null ? void 0 : a.parentNode) == null || s.insertBefore(r, a), t && (window.gtag("config", e.adsId), m = e.adsId, v = e.conversionLabel), n && window.gtag("config", e.analyticsId), d = !0, c("[Google] Inicializado");
|
|
71
|
+
}
|
|
72
|
+
function H() {
|
|
73
|
+
!d || !window.gtag || window.gtag("event", "page_view");
|
|
74
|
+
}
|
|
75
|
+
function D(e) {
|
|
76
|
+
!d || !window.gtag || window.gtag("event", "generate_lead", e);
|
|
77
|
+
}
|
|
78
|
+
function $(e, t = "BRL") {
|
|
79
|
+
if (!d || !window.gtag || !m) return;
|
|
80
|
+
const n = {
|
|
81
|
+
send_to: v ? `${m}/${v}` : m,
|
|
82
|
+
value: e,
|
|
83
|
+
currency: t
|
|
84
|
+
};
|
|
85
|
+
window.gtag("event", "conversion", n);
|
|
86
|
+
}
|
|
87
|
+
function z(e, t) {
|
|
88
|
+
!d || !window.gtag || window.gtag("event", e, t);
|
|
89
|
+
}
|
|
90
|
+
let f = !1;
|
|
91
|
+
function G(e) {
|
|
92
|
+
var s;
|
|
93
|
+
if (!e.enabled || !e.pixelId || f) return;
|
|
94
|
+
c("[Meta Pixel] Carregando:", e.pixelId);
|
|
95
|
+
const t = window, n = document;
|
|
96
|
+
if (typeof t.fbq == "function") return;
|
|
97
|
+
const i = t.fbq = (...l) => {
|
|
98
|
+
i.callMethod ? i.callMethod.apply(i, l) : i.queue.push(l);
|
|
99
|
+
};
|
|
100
|
+
t._fbq || (t._fbq = i), i.push = i, i.loaded = !0, i.version = "2.0", i.queue = [];
|
|
101
|
+
const r = n.createElement("script");
|
|
102
|
+
r.async = !0, r.src = "https://connect.facebook.net/en_US/fbevents.js";
|
|
103
|
+
const a = n.getElementsByTagName("script")[0];
|
|
104
|
+
(s = a == null ? void 0 : a.parentNode) == null || s.insertBefore(r, a), window.fbq("init", e.pixelId), window.fbq("track", "PageView"), f = !0, c("[Meta Pixel] Inicializado");
|
|
105
|
+
}
|
|
106
|
+
function B() {
|
|
107
|
+
!f || !window.fbq || window.fbq("track", "PageView");
|
|
108
|
+
}
|
|
109
|
+
function V(e) {
|
|
110
|
+
!f || !window.fbq || window.fbq("track", "Lead", e);
|
|
111
|
+
}
|
|
112
|
+
function Y(e, t = "BRL") {
|
|
113
|
+
!f || !window.fbq || window.fbq("track", "Purchase", { value: e, currency: t });
|
|
114
|
+
}
|
|
115
|
+
function J(e, t) {
|
|
116
|
+
!f || !window.fbq || window.fbq("trackCustom", e, t);
|
|
117
|
+
}
|
|
118
|
+
function X(e) {
|
|
119
|
+
G(e.pixels.meta), R(e.pixels.google);
|
|
120
|
+
}
|
|
121
|
+
function W() {
|
|
122
|
+
B(), H();
|
|
123
|
+
}
|
|
124
|
+
function Q(e) {
|
|
125
|
+
V(e), D(e);
|
|
126
|
+
}
|
|
127
|
+
function Z(e, t = "BRL") {
|
|
128
|
+
Y(e, t), $(e, t);
|
|
129
|
+
}
|
|
130
|
+
function A(e, t) {
|
|
131
|
+
J(e, t), z(e, t);
|
|
132
|
+
}
|
|
133
|
+
function F() {
|
|
134
|
+
return K + crypto.randomUUID().replace(/-/g, "").slice(0, 20);
|
|
135
|
+
}
|
|
136
|
+
function _() {
|
|
137
|
+
if (o.visitorId) return o.visitorId;
|
|
138
|
+
try {
|
|
139
|
+
const e = localStorage.getItem(I);
|
|
140
|
+
if (e)
|
|
141
|
+
return o.visitorId = e, e;
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
o.visitorId = F();
|
|
145
|
+
try {
|
|
146
|
+
localStorage.setItem(I, o.visitorId);
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
return o.visitorId;
|
|
150
|
+
}
|
|
151
|
+
function O() {
|
|
152
|
+
if (o.sessionId) return o.sessionId;
|
|
153
|
+
try {
|
|
154
|
+
const e = sessionStorage.getItem(h);
|
|
155
|
+
if (e)
|
|
156
|
+
return o.sessionId = e, e;
|
|
157
|
+
} catch {
|
|
158
|
+
}
|
|
159
|
+
o.sessionId = F();
|
|
160
|
+
try {
|
|
161
|
+
sessionStorage.setItem(h, o.sessionId);
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
return o.sessionId;
|
|
165
|
+
}
|
|
166
|
+
function ee() {
|
|
167
|
+
try {
|
|
168
|
+
localStorage.removeItem(I), sessionStorage.removeItem(h);
|
|
169
|
+
} catch {
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function u(e, t) {
|
|
173
|
+
if (!o.initialized || !o.projectId) {
|
|
174
|
+
console.warn("[TrackFlow] SDK nao inicializado. Chame TrackFlow.init() primeiro.");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const n = `${o.apiUrl}${e}`, i = {
|
|
178
|
+
...t,
|
|
179
|
+
projectId: o.projectId,
|
|
180
|
+
visitorId: _(),
|
|
181
|
+
sessionId: O(),
|
|
182
|
+
franchiseId: o.franchiseId,
|
|
183
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
184
|
+
};
|
|
185
|
+
c(`-> ${e}`, i);
|
|
186
|
+
try {
|
|
187
|
+
const r = {
|
|
188
|
+
"Content-Type": "application/json"
|
|
189
|
+
};
|
|
190
|
+
o.publicKey && (r["X-API-Key"] = o.publicKey);
|
|
191
|
+
const a = await fetch(n, {
|
|
192
|
+
method: "POST",
|
|
193
|
+
headers: r,
|
|
194
|
+
body: JSON.stringify(i),
|
|
195
|
+
keepalive: !0
|
|
196
|
+
});
|
|
197
|
+
a.ok || c(`Erro ${a.status}:`, await a.text());
|
|
198
|
+
} catch (r) {
|
|
199
|
+
c("Erro ao enviar evento:", r);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function g(e) {
|
|
203
|
+
u("/api/events", {
|
|
204
|
+
type: "pageview",
|
|
205
|
+
properties: {
|
|
206
|
+
title: document.title,
|
|
207
|
+
path: window.location.pathname,
|
|
208
|
+
search: window.location.search,
|
|
209
|
+
referrer: document.referrer,
|
|
210
|
+
...L(),
|
|
211
|
+
...e
|
|
212
|
+
},
|
|
213
|
+
url: window.location.href,
|
|
214
|
+
referrer: document.referrer
|
|
215
|
+
}), W();
|
|
216
|
+
}
|
|
217
|
+
function te(e, t) {
|
|
218
|
+
u("/api/events", {
|
|
219
|
+
type: e,
|
|
220
|
+
properties: t ?? {},
|
|
221
|
+
url: window.location.href
|
|
222
|
+
}), A(e, t);
|
|
223
|
+
}
|
|
224
|
+
function P(e) {
|
|
225
|
+
u("/api/identify", {
|
|
226
|
+
...e,
|
|
227
|
+
visitorId: _()
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function ne(e, t, n) {
|
|
231
|
+
u("/api/conversions", {
|
|
232
|
+
type: e,
|
|
233
|
+
value: t,
|
|
234
|
+
properties: n ?? {}
|
|
235
|
+
}), Z(t), A(e, { value: t, ...n });
|
|
236
|
+
}
|
|
237
|
+
const T = /* @__PURE__ */ new WeakSet();
|
|
238
|
+
function p(e, t) {
|
|
239
|
+
var n;
|
|
240
|
+
for (const i of t) {
|
|
241
|
+
const r = e.querySelector(i);
|
|
242
|
+
if ((n = r == null ? void 0 : r.value) != null && n.trim())
|
|
243
|
+
return r.value.trim();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function oe(e) {
|
|
247
|
+
const t = e.target;
|
|
248
|
+
if (!t || !(t instanceof HTMLFormElement)) return;
|
|
249
|
+
const n = {};
|
|
250
|
+
if (n.email = p(t, U), n.phone = p(t, x), n.name = p(t, M), n.cpf = p(t, j), !n.email && !n.phone) {
|
|
251
|
+
c("[AutoIdentify] Form sem email ou telefone, ignorando");
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
c("[AutoIdentify] Lead detectado:", n), P(n), Q({
|
|
255
|
+
content_name: n.email ?? n.phone,
|
|
256
|
+
email: n.email
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function w(e) {
|
|
260
|
+
T.has(e) || (T.add(e), e.addEventListener("submit", oe), c("[AutoIdentify] Observando form:", e.action || e.id || "(sem id)"));
|
|
261
|
+
}
|
|
262
|
+
function ie() {
|
|
263
|
+
document.querySelectorAll("form").forEach(w), new MutationObserver((n) => {
|
|
264
|
+
for (const i of n)
|
|
265
|
+
i.addedNodes.forEach((r) => {
|
|
266
|
+
r instanceof HTMLFormElement && w(r), r instanceof HTMLElement && r.querySelectorAll("form").forEach(w);
|
|
267
|
+
});
|
|
268
|
+
}).observe(document.body, { childList: !0, subtree: !0 }), c("[AutoIdentify] Ativo");
|
|
269
|
+
}
|
|
270
|
+
function re() {
|
|
271
|
+
try {
|
|
272
|
+
const e = localStorage.getItem(y);
|
|
273
|
+
if (!e) return null;
|
|
274
|
+
const t = JSON.parse(e);
|
|
275
|
+
return Date.now() - t.cachedAt > 3e5 ? (localStorage.removeItem(y), null) : t.data;
|
|
276
|
+
} catch {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function ae(e) {
|
|
281
|
+
try {
|
|
282
|
+
const t = { data: e, cachedAt: Date.now() };
|
|
283
|
+
localStorage.setItem(y, JSON.stringify(t));
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async function ce() {
|
|
288
|
+
if (!o.publicKey) return null;
|
|
289
|
+
const e = re();
|
|
290
|
+
if (e)
|
|
291
|
+
return c("[Config] Usando cache local"), e;
|
|
292
|
+
try {
|
|
293
|
+
const t = `${o.apiUrl}/api/sdk/config?key=${o.publicKey}`;
|
|
294
|
+
c("[Config] Buscando:", t);
|
|
295
|
+
const n = await fetch(t);
|
|
296
|
+
if (!n.ok)
|
|
297
|
+
return c(`[Config] Erro ${n.status}`), null;
|
|
298
|
+
const i = await n.json();
|
|
299
|
+
if (!i.success || !i.data) return null;
|
|
300
|
+
const r = i.data;
|
|
301
|
+
return ae(r), c("[Config] Carregada:", r), r;
|
|
302
|
+
} catch (t) {
|
|
303
|
+
return c("[Config] Erro ao buscar:", t), null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const b = /* @__PURE__ */ new Set();
|
|
307
|
+
function se(e = [25, 50, 75, 100]) {
|
|
308
|
+
let t = !1;
|
|
309
|
+
function n() {
|
|
310
|
+
const i = document.documentElement.scrollHeight - window.innerHeight;
|
|
311
|
+
if (i <= 0) return;
|
|
312
|
+
const r = Math.round(window.scrollY / i * 100);
|
|
313
|
+
for (const a of e)
|
|
314
|
+
r >= a && !b.has(a) && (b.add(a), c(`[Scroll] ${a}%`), u("/api/events", {
|
|
315
|
+
type: "scroll_depth",
|
|
316
|
+
properties: { depth: a },
|
|
317
|
+
url: window.location.href
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
window.addEventListener(
|
|
321
|
+
"scroll",
|
|
322
|
+
() => {
|
|
323
|
+
t || (t = !0, requestAnimationFrame(() => {
|
|
324
|
+
n(), t = !1;
|
|
325
|
+
}));
|
|
326
|
+
},
|
|
327
|
+
{ passive: !0 }
|
|
328
|
+
), c("[Scroll] Tracking ativo:", e);
|
|
329
|
+
}
|
|
330
|
+
function C() {
|
|
331
|
+
b.clear();
|
|
332
|
+
}
|
|
333
|
+
async function S(e) {
|
|
334
|
+
if (o.initialized) {
|
|
335
|
+
c("SDK ja inicializado, ignorando.");
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
o.publicKey = e.publicKey, o.apiUrl = e.apiUrl ?? E, o.debug = e.debug ?? !1, _(), O();
|
|
339
|
+
const t = L();
|
|
340
|
+
t.utm_id && (o.franchiseId = t.utm_id);
|
|
341
|
+
const n = await ce();
|
|
342
|
+
n && (o.projectId = n.projectId, o.remoteConfig = n, X(n)), o.initialized = !0, c("Inicializado", {
|
|
343
|
+
publicKey: o.publicKey,
|
|
344
|
+
projectId: o.projectId,
|
|
345
|
+
visitorId: o.visitorId,
|
|
346
|
+
franchiseId: o.franchiseId
|
|
347
|
+
}), Object.keys(t).length > 0 && u("/api/events", {
|
|
348
|
+
type: "utm_capture",
|
|
349
|
+
properties: t,
|
|
350
|
+
url: window.location.href,
|
|
351
|
+
referrer: document.referrer
|
|
352
|
+
});
|
|
353
|
+
const i = (n == null ? void 0 : n.features) ?? {
|
|
354
|
+
autoPageview: !0,
|
|
355
|
+
autoIdentify: !0,
|
|
356
|
+
autoScroll: !1,
|
|
357
|
+
scrollThresholds: [25, 50, 75, 100]
|
|
358
|
+
};
|
|
359
|
+
if (i.autoPageview) {
|
|
360
|
+
g();
|
|
361
|
+
const r = history.pushState;
|
|
362
|
+
history.pushState = function(...a) {
|
|
363
|
+
r.apply(this, a), C(), g();
|
|
364
|
+
}, window.addEventListener("popstate", () => {
|
|
365
|
+
C(), g();
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
i.autoIdentify && ie(), i.autoScroll && se(i.scrollThresholds), document.addEventListener("click", (r) => {
|
|
369
|
+
var l, k;
|
|
370
|
+
const a = (l = r.target) == null ? void 0 : l.closest("[data-tf-track]");
|
|
371
|
+
if (!a) return;
|
|
372
|
+
const s = a.dataset.tfTrack;
|
|
373
|
+
s && u("/api/events", {
|
|
374
|
+
type: s,
|
|
375
|
+
properties: {
|
|
376
|
+
text: (k = a.textContent) == null ? void 0 : k.trim().slice(0, 100),
|
|
377
|
+
href: a instanceof HTMLAnchorElement ? a.href : void 0
|
|
378
|
+
},
|
|
379
|
+
url: window.location.href
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
function le() {
|
|
384
|
+
ee(), N();
|
|
385
|
+
}
|
|
386
|
+
function ue() {
|
|
387
|
+
return o.visitorId;
|
|
388
|
+
}
|
|
389
|
+
function de() {
|
|
390
|
+
if (typeof document > "u") return;
|
|
391
|
+
const e = document.currentScript;
|
|
392
|
+
if (e != null && e.dataset.key) {
|
|
393
|
+
S({
|
|
394
|
+
publicKey: e.dataset.key,
|
|
395
|
+
apiUrl: e.dataset.apiUrl,
|
|
396
|
+
debug: e.dataset.debug === "true"
|
|
397
|
+
});
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const t = window.TrackFlowConfig;
|
|
401
|
+
t != null && t.publicKey && S({
|
|
402
|
+
publicKey: t.publicKey,
|
|
403
|
+
apiUrl: t.apiUrl,
|
|
404
|
+
debug: t.debug === !0
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
const fe = {
|
|
408
|
+
init: S,
|
|
409
|
+
page: g,
|
|
410
|
+
track: te,
|
|
411
|
+
identify: P,
|
|
412
|
+
conversion: ne,
|
|
413
|
+
reset: le,
|
|
414
|
+
getVisitorId: ue
|
|
415
|
+
};
|
|
416
|
+
de();
|
|
417
|
+
export {
|
|
418
|
+
fe as TrackFlow,
|
|
419
|
+
fe as default
|
|
420
|
+
};
|
package/dist/sdk.umd.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.TrackFlow={}))})(this,(function(l){"use strict";const u="rmv_visitor_id",I="rmv_session_id",y="https://api.rockmarketvisor.com",M="rmv_",v="rmv_config",j=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","utm_id","gclid","fbclid"],U=['input[type="email"]','input[name*="email"]','input[name*="e-mail"]','input[autocomplete="email"]'],x=['input[type="tel"]','input[name*="phone"]','input[name*="tel"]','input[name*="celular"]','input[name*="whatsapp"]','input[autocomplete="tel"]'],N=['input[name*="name"]','input[name*="nome"]','input[autocomplete="name"]','input[autocomplete="given-name"]'],R=['input[name*="cpf"]','input[name*="documento"]'],o={publicKey:null,apiUrl:y,debug:!1,projectId:null,franchiseId:null,visitorId:null,sessionId:null,remoteConfig:null,initialized:!1};function H(){o.publicKey=null,o.apiUrl=y,o.debug=!1,o.projectId=null,o.franchiseId=null,o.visitorId=null,o.sessionId=null,o.remoteConfig=null,o.initialized=!1}function c(...e){o.debug&&console.log("[TrackFlow]",...e)}function k(){const e=new URLSearchParams(window.location.search),t={};for(const n of j){const i=e.get(n);i&&(t[n]=i)}return t}let p=!1,b=null,g=null;function D(e){var s;if(!e.enabled||p)return;const t=!!e.adsId,n=!!e.analyticsId;if(!t&&!n)return;const i=e.adsId??e.analyticsId;c("[Google] Carregando:",i),window.dataLayer=window.dataLayer||[],window.gtag=function(...f){window.dataLayer.push(f)},window.gtag("js",new Date);const r=document.createElement("script");r.async=!0,r.src=`https://www.googletagmanager.com/gtag/js?id=${i}`;const a=document.getElementsByTagName("script")[0];(s=a==null?void 0:a.parentNode)==null||s.insertBefore(r,a),t&&(window.gtag("config",e.adsId),g=e.adsId,b=e.conversionLabel),n&&window.gtag("config",e.analyticsId),p=!0,c("[Google] Inicializado")}function $(){!p||!window.gtag||window.gtag("event","page_view")}function z(e){!p||!window.gtag||window.gtag("event","generate_lead",e)}function G(e,t="BRL"){if(!p||!window.gtag||!g)return;const n={send_to:b?`${g}/${b}`:g,value:e,currency:t};window.gtag("event","conversion",n)}function B(e,t){!p||!window.gtag||window.gtag("event",e,t)}let m=!1;function V(e){var s;if(!e.enabled||!e.pixelId||m)return;c("[Meta Pixel] Carregando:",e.pixelId);const t=window,n=document;if(typeof t.fbq=="function")return;const i=t.fbq=(...f)=>{i.callMethod?i.callMethod.apply(i,f):i.queue.push(f)};t._fbq||(t._fbq=i),i.push=i,i.loaded=!0,i.version="2.0",i.queue=[];const r=n.createElement("script");r.async=!0,r.src="https://connect.facebook.net/en_US/fbevents.js";const a=n.getElementsByTagName("script")[0];(s=a==null?void 0:a.parentNode)==null||s.insertBefore(r,a),window.fbq("init",e.pixelId),window.fbq("track","PageView"),m=!0,c("[Meta Pixel] Inicializado")}function Y(){!m||!window.fbq||window.fbq("track","PageView")}function J(e){!m||!window.fbq||window.fbq("track","Lead",e)}function X(e,t="BRL"){!m||!window.fbq||window.fbq("track","Purchase",{value:e,currency:t})}function W(e,t){!m||!window.fbq||window.fbq("trackCustom",e,t)}function Q(e){V(e.pixels.meta),D(e.pixels.google)}function Z(){Y(),$()}function ee(e){J(e),z(e)}function te(e,t="BRL"){X(e,t),G(e,t)}function C(e,t){W(e,t),B(e,t)}function L(){return M+crypto.randomUUID().replace(/-/g,"").slice(0,20)}function S(){if(o.visitorId)return o.visitorId;try{const e=localStorage.getItem(u);if(e)return o.visitorId=e,e}catch{}o.visitorId=L();try{localStorage.setItem(u,o.visitorId)}catch{}return o.visitorId}function F(){if(o.sessionId)return o.sessionId;try{const e=sessionStorage.getItem(I);if(e)return o.sessionId=e,e}catch{}o.sessionId=L();try{sessionStorage.setItem(I,o.sessionId)}catch{}return o.sessionId}function ne(){try{localStorage.removeItem(u),sessionStorage.removeItem(I)}catch{}}async function d(e,t){if(!o.initialized||!o.projectId){console.warn("[TrackFlow] SDK nao inicializado. Chame TrackFlow.init() primeiro.");return}const n=`${o.apiUrl}${e}`,i={...t,projectId:o.projectId,visitorId:S(),sessionId:F(),franchiseId:o.franchiseId,timestamp:new Date().toISOString()};c(`-> ${e}`,i);try{const r={"Content-Type":"application/json"};o.publicKey&&(r["X-API-Key"]=o.publicKey);const a=await fetch(n,{method:"POST",headers:r,body:JSON.stringify(i),keepalive:!0});a.ok||c(`Erro ${a.status}:`,await a.text())}catch(r){c("Erro ao enviar evento:",r)}}function w(e){d("/api/events",{type:"pageview",properties:{title:document.title,path:window.location.pathname,search:window.location.search,referrer:document.referrer,...k(),...e},url:window.location.href,referrer:document.referrer}),Z()}function oe(e,t){d("/api/events",{type:e,properties:t??{},url:window.location.href}),C(e,t)}function A(e){d("/api/identify",{...e,visitorId:S()})}function ie(e,t,n){d("/api/conversions",{type:e,value:t,properties:n??{}}),te(t),C(e,{value:t,...n})}const O=new WeakSet;function h(e,t){var n;for(const i of t){const r=e.querySelector(i);if((n=r==null?void 0:r.value)!=null&&n.trim())return r.value.trim()}}function re(e){const t=e.target;if(!t||!(t instanceof HTMLFormElement))return;const n={};if(n.email=h(t,U),n.phone=h(t,x),n.name=h(t,N),n.cpf=h(t,R),!n.email&&!n.phone){c("[AutoIdentify] Form sem email ou telefone, ignorando");return}c("[AutoIdentify] Lead detectado:",n),A(n),ee({content_name:n.email??n.phone,email:n.email})}function _(e){O.has(e)||(O.add(e),e.addEventListener("submit",re),c("[AutoIdentify] Observando form:",e.action||e.id||"(sem id)"))}function ae(){document.querySelectorAll("form").forEach(_),new MutationObserver(n=>{for(const i of n)i.addedNodes.forEach(r=>{r instanceof HTMLFormElement&&_(r),r instanceof HTMLElement&&r.querySelectorAll("form").forEach(_)})}).observe(document.body,{childList:!0,subtree:!0}),c("[AutoIdentify] Ativo")}function ce(){try{const e=localStorage.getItem(v);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.cachedAt>3e5?(localStorage.removeItem(v),null):t.data}catch{return null}}function se(e){try{const t={data:e,cachedAt:Date.now()};localStorage.setItem(v,JSON.stringify(t))}catch{}}async function le(){if(!o.publicKey)return null;const e=ce();if(e)return c("[Config] Usando cache local"),e;try{const t=`${o.apiUrl}/api/sdk/config?key=${o.publicKey}`;c("[Config] Buscando:",t);const n=await fetch(t);if(!n.ok)return c(`[Config] Erro ${n.status}`),null;const i=await n.json();if(!i.success||!i.data)return null;const r=i.data;return se(r),c("[Config] Carregada:",r),r}catch(t){return c("[Config] Erro ao buscar:",t),null}}const E=new Set;function ue(e=[25,50,75,100]){let t=!1;function n(){const i=document.documentElement.scrollHeight-window.innerHeight;if(i<=0)return;const r=Math.round(window.scrollY/i*100);for(const a of e)r>=a&&!E.has(a)&&(E.add(a),c(`[Scroll] ${a}%`),d("/api/events",{type:"scroll_depth",properties:{depth:a},url:window.location.href}))}window.addEventListener("scroll",()=>{t||(t=!0,requestAnimationFrame(()=>{n(),t=!1}))},{passive:!0}),c("[Scroll] Tracking ativo:",e)}function P(){E.clear()}async function T(e){if(o.initialized){c("SDK ja inicializado, ignorando.");return}o.publicKey=e.publicKey,o.apiUrl=e.apiUrl??y,o.debug=e.debug??!1,S(),F();const t=k();t.utm_id&&(o.franchiseId=t.utm_id);const n=await le();n&&(o.projectId=n.projectId,o.remoteConfig=n,Q(n)),o.initialized=!0,c("Inicializado",{publicKey:o.publicKey,projectId:o.projectId,visitorId:o.visitorId,franchiseId:o.franchiseId}),Object.keys(t).length>0&&d("/api/events",{type:"utm_capture",properties:t,url:window.location.href,referrer:document.referrer});const i=(n==null?void 0:n.features)??{autoPageview:!0,autoIdentify:!0,autoScroll:!1,scrollThresholds:[25,50,75,100]};if(i.autoPageview){w();const r=history.pushState;history.pushState=function(...a){r.apply(this,a),P(),w()},window.addEventListener("popstate",()=>{P(),w()})}i.autoIdentify&&ae(),i.autoScroll&&ue(i.scrollThresholds),document.addEventListener("click",r=>{var f,q;const a=(f=r.target)==null?void 0:f.closest("[data-tf-track]");if(!a)return;const s=a.dataset.tfTrack;s&&d("/api/events",{type:s,properties:{text:(q=a.textContent)==null?void 0:q.trim().slice(0,100),href:a instanceof HTMLAnchorElement?a.href:void 0},url:window.location.href})})}function de(){ne(),H()}function fe(){return o.visitorId}function pe(){if(typeof document>"u")return;const e=document.currentScript;if(e!=null&&e.dataset.key){T({publicKey:e.dataset.key,apiUrl:e.dataset.apiUrl,debug:e.dataset.debug==="true"});return}const t=window.TrackFlowConfig;t!=null&&t.publicKey&&T({publicKey:t.publicKey,apiUrl:t.apiUrl,debug:t.debug===!0})}const K={init:T,page:w,track:oe,identify:A,conversion:ie,reset:de,getVisitorId:fe};pe(),l.TrackFlow=K,l.default=K,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface InitOptions {
|
|
2
|
+
publicKey: string;
|
|
3
|
+
apiUrl?: string;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface IdentifyData {
|
|
7
|
+
email?: string;
|
|
8
|
+
phone?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
cpf?: string;
|
|
11
|
+
externalId?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PixelMeta {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
pixelId: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface PixelGoogle {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
adsId: string | null;
|
|
20
|
+
conversionLabel: string | null;
|
|
21
|
+
analyticsId: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface RemoteFeatures {
|
|
24
|
+
autoPageview: boolean;
|
|
25
|
+
autoIdentify: boolean;
|
|
26
|
+
autoScroll: boolean;
|
|
27
|
+
scrollThresholds: number[];
|
|
28
|
+
}
|
|
29
|
+
export interface RemoteConfig {
|
|
30
|
+
projectId: string;
|
|
31
|
+
pixels: {
|
|
32
|
+
meta: PixelMeta;
|
|
33
|
+
google: PixelGoogle;
|
|
34
|
+
};
|
|
35
|
+
features: RemoteFeatures;
|
|
36
|
+
}
|
|
37
|
+
export interface SdkState {
|
|
38
|
+
publicKey: string | null;
|
|
39
|
+
apiUrl: string;
|
|
40
|
+
debug: boolean;
|
|
41
|
+
projectId: string | null;
|
|
42
|
+
franchiseId: string | null;
|
|
43
|
+
visitorId: string | null;
|
|
44
|
+
sessionId: string | null;
|
|
45
|
+
remoteConfig: RemoteConfig | null;
|
|
46
|
+
initialized: boolean;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=sdk.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.types.d.ts","sourceRoot":"","sources":["../../src/types/sdk.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QACN,IAAI,EAAE,SAAS,CAAC;QAChB,MAAM,EAAE,WAAW,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.utils.d.ts","sourceRoot":"","sources":["../../src/utils/id.utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.utils.d.ts","sourceRoot":"","sources":["../../src/utils/logger.utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,QAIrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utm.utils.d.ts","sourceRoot":"","sources":["../../src/utils/utm.utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUrD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rockfeller/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TrackFlow SDK — tracking de marketing e atribuicao para Rock Market Visor",
|
|
5
|
+
"main": "./dist/sdk.umd.js",
|
|
6
|
+
"module": "./dist/sdk.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/sdk.mjs",
|
|
12
|
+
"require": "./dist/sdk.umd.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"tracking",
|
|
20
|
+
"analytics",
|
|
21
|
+
"marketing",
|
|
22
|
+
"attribution",
|
|
23
|
+
"utm",
|
|
24
|
+
"pixel",
|
|
25
|
+
"rockfeller"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/rockfellerfranchising/rock-market-visor-repo",
|
|
30
|
+
"directory": "packages/sdk"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
38
|
+
"dev": "vite build --watch",
|
|
39
|
+
"prepublishOnly": "bun run build"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"typescript": "^5.7",
|
|
43
|
+
"vite": "^6"
|
|
44
|
+
}
|
|
45
|
+
}
|