@vibiz/analytics 0.1.0 → 0.2.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/README.md +5 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +1 -1
- package/dist/node.cjs +7 -9
- package/dist/node.d.cts +5 -8
- package/dist/node.d.ts +5 -8
- package/dist/node.js +7 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npm i @vibiz/analytics
|
|
|
9
9
|
```ts
|
|
10
10
|
import { init, track, identify } from '@vibiz/analytics';
|
|
11
11
|
|
|
12
|
-
init({
|
|
12
|
+
init({ workspaceId: 'org_xxx' });
|
|
13
13
|
|
|
14
14
|
identify('cust_8842', { email: 'mario.rossi@example.com' });
|
|
15
15
|
track('purchase', { value: 4200, currency: 'EUR', order_id: '84213' });
|
|
@@ -32,7 +32,7 @@ One implementation, two ways to reach it. If you have no bundler, skip this
|
|
|
32
32
|
package entirely:
|
|
33
33
|
|
|
34
34
|
```html
|
|
35
|
-
<script async src="https://www.vibiz.ai/sdk/v1/v.js" data-vibiz-
|
|
35
|
+
<script async src="https://www.vibiz.ai/sdk/v1/v.js" data-vibiz-id="org_xxx"></script>
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
## Notes
|
|
@@ -42,8 +42,9 @@ package entirely:
|
|
|
42
42
|
than throwing.
|
|
43
43
|
- **Safe before the tag loads.** Calls are queued and replayed once it arrives,
|
|
44
44
|
so you can track from the first line of your app.
|
|
45
|
-
- **The
|
|
46
|
-
Meta pixel id
|
|
45
|
+
- **The workspace id is public.** `org_…` ships in the page source either way,
|
|
46
|
+
like a Meta pixel id, which is why there is no separate key. Traffic is bound
|
|
47
|
+
to your workspace by the domains you allow.
|
|
47
48
|
- **Contact details are never hashed here.** They are hashed by the collector,
|
|
48
49
|
because a digest computed in a browser cannot be re-normalised — and
|
|
49
50
|
normalisation is exactly where matching fails silently.
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ function init(config) {
|
|
|
30
30
|
script.id = SCRIPT_ID;
|
|
31
31
|
script.async = true;
|
|
32
32
|
script.src = config.scriptUrl ?? DEFAULT_SCRIPT;
|
|
33
|
-
script.setAttribute("data-vibiz-
|
|
33
|
+
script.setAttribute("data-vibiz-id", config.workspaceId);
|
|
34
34
|
if (config.endpoint)
|
|
35
35
|
script.setAttribute("data-vibiz-endpoint", config.endpoint);
|
|
36
36
|
if (config.autocapture === false)
|
package/dist/index.d.cts
CHANGED
|
@@ -51,8 +51,14 @@ interface Contact {
|
|
|
51
51
|
country?: string;
|
|
52
52
|
}
|
|
53
53
|
interface VibizConfig {
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Your Vibiz workspace id, `org_…`.
|
|
56
|
+
*
|
|
57
|
+
* Public by design, and safe in client code: it ships in the page source of
|
|
58
|
+
* every tracked site either way, exactly like a Meta pixel id. Where an
|
|
59
|
+
* event may come from is decided by your domain allowlist, not by this.
|
|
60
|
+
*/
|
|
61
|
+
workspaceId: string;
|
|
56
62
|
/** Point this at a first-party subdomain to survive ad blockers. */
|
|
57
63
|
endpoint?: string;
|
|
58
64
|
/** Page views, clicks, form submits and time on page without any code. Default true. */
|
package/dist/index.d.ts
CHANGED
|
@@ -51,8 +51,14 @@ interface Contact {
|
|
|
51
51
|
country?: string;
|
|
52
52
|
}
|
|
53
53
|
interface VibizConfig {
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Your Vibiz workspace id, `org_…`.
|
|
56
|
+
*
|
|
57
|
+
* Public by design, and safe in client code: it ships in the page source of
|
|
58
|
+
* every tracked site either way, exactly like a Meta pixel id. Where an
|
|
59
|
+
* event may come from is decided by your domain allowlist, not by this.
|
|
60
|
+
*/
|
|
61
|
+
workspaceId: string;
|
|
56
62
|
/** Point this at a first-party subdomain to survive ad blockers. */
|
|
57
63
|
endpoint?: string;
|
|
58
64
|
/** Page views, clicks, form submits and time on page without any code. Default true. */
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ function init(config) {
|
|
|
26
26
|
script.id = SCRIPT_ID;
|
|
27
27
|
script.async = true;
|
|
28
28
|
script.src = config.scriptUrl ?? DEFAULT_SCRIPT;
|
|
29
|
-
script.setAttribute("data-vibiz-
|
|
29
|
+
script.setAttribute("data-vibiz-id", config.workspaceId);
|
|
30
30
|
if (config.endpoint)
|
|
31
31
|
script.setAttribute("data-vibiz-endpoint", config.endpoint);
|
|
32
32
|
if (config.autocapture === false)
|
package/dist/node.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var DEFAULT_ENDPOINT = "https://www.vibiz.ai/api/ingest";
|
|
5
5
|
var PROTOCOL_VERSION = 1;
|
|
6
6
|
async function track(input) {
|
|
7
|
-
if (!input.
|
|
7
|
+
if (!input.workspaceId) return { ok: false, reason: "missing workspaceId" };
|
|
8
8
|
if (!input.event) return { ok: false, reason: "missing event" };
|
|
9
9
|
if (!input.visitorId && !input.userId && !input.contact) {
|
|
10
10
|
return {
|
|
@@ -14,7 +14,7 @@ async function track(input) {
|
|
|
14
14
|
}
|
|
15
15
|
const body = {
|
|
16
16
|
v: PROTOCOL_VERSION,
|
|
17
|
-
k: input.
|
|
17
|
+
k: input.workspaceId,
|
|
18
18
|
n: input.event,
|
|
19
19
|
vid: input.visitorId ?? `srv-${input.userId ?? "anon"}`
|
|
20
20
|
};
|
|
@@ -26,15 +26,13 @@ async function track(input) {
|
|
|
26
26
|
body.cad = true;
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
|
-
const headers = {
|
|
30
|
-
// text/plain matches what the tag sends, so both halves hit the same
|
|
31
|
-
// parsing path on the collector rather than two that can diverge.
|
|
32
|
-
"Content-Type": "text/plain;charset=UTF-8"
|
|
33
|
-
};
|
|
34
|
-
if (input.serverKey) headers["x-vibiz-server-key"] = input.serverKey;
|
|
35
29
|
const response = await fetch(input.endpoint ?? DEFAULT_ENDPOINT, {
|
|
36
30
|
method: "POST",
|
|
37
|
-
headers
|
|
31
|
+
headers: {
|
|
32
|
+
// text/plain matches what the tag sends, so both halves hit the same
|
|
33
|
+
// parsing path on the collector rather than two that can diverge.
|
|
34
|
+
"Content-Type": "text/plain;charset=UTF-8"
|
|
35
|
+
},
|
|
38
36
|
body: JSON.stringify(body)
|
|
39
37
|
});
|
|
40
38
|
return response.ok ? { ok: true } : { ok: false, reason: `HTTP ${response.status}` };
|
package/dist/node.d.cts
CHANGED
|
@@ -37,17 +37,14 @@ interface ServerEventProperties {
|
|
|
37
37
|
[key: string]: unknown;
|
|
38
38
|
}
|
|
39
39
|
interface ServerTrackInput {
|
|
40
|
-
/** Public write key. Says which workspace the event belongs to. */
|
|
41
|
-
key: string;
|
|
42
40
|
/**
|
|
43
|
-
*
|
|
44
|
-
* keep it in your environment and never send it to a browser.
|
|
41
|
+
* Your Vibiz workspace id, `org_…`. Says which workspace the event belongs to.
|
|
45
42
|
*
|
|
46
|
-
*
|
|
47
|
-
* carries no `Origin
|
|
48
|
-
*
|
|
43
|
+
* The same value the browser tag uses. There is no separate server
|
|
44
|
+
* credential: a server call carries no `Origin`, so the domain allowlist has
|
|
45
|
+
* nothing to check it against and accepts it.
|
|
49
46
|
*/
|
|
50
|
-
|
|
47
|
+
workspaceId: string;
|
|
51
48
|
event: string;
|
|
52
49
|
/**
|
|
53
50
|
* The visitor id the browser minted, when you have it.
|
package/dist/node.d.ts
CHANGED
|
@@ -37,17 +37,14 @@ interface ServerEventProperties {
|
|
|
37
37
|
[key: string]: unknown;
|
|
38
38
|
}
|
|
39
39
|
interface ServerTrackInput {
|
|
40
|
-
/** Public write key. Says which workspace the event belongs to. */
|
|
41
|
-
key: string;
|
|
42
40
|
/**
|
|
43
|
-
*
|
|
44
|
-
* keep it in your environment and never send it to a browser.
|
|
41
|
+
* Your Vibiz workspace id, `org_…`. Says which workspace the event belongs to.
|
|
45
42
|
*
|
|
46
|
-
*
|
|
47
|
-
* carries no `Origin
|
|
48
|
-
*
|
|
43
|
+
* The same value the browser tag uses. There is no separate server
|
|
44
|
+
* credential: a server call carries no `Origin`, so the domain allowlist has
|
|
45
|
+
* nothing to check it against and accepts it.
|
|
49
46
|
*/
|
|
50
|
-
|
|
47
|
+
workspaceId: string;
|
|
51
48
|
event: string;
|
|
52
49
|
/**
|
|
53
50
|
* The visitor id the browser minted, when you have it.
|
package/dist/node.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var DEFAULT_ENDPOINT = "https://www.vibiz.ai/api/ingest";
|
|
3
3
|
var PROTOCOL_VERSION = 1;
|
|
4
4
|
async function track(input) {
|
|
5
|
-
if (!input.
|
|
5
|
+
if (!input.workspaceId) return { ok: false, reason: "missing workspaceId" };
|
|
6
6
|
if (!input.event) return { ok: false, reason: "missing event" };
|
|
7
7
|
if (!input.visitorId && !input.userId && !input.contact) {
|
|
8
8
|
return {
|
|
@@ -12,7 +12,7 @@ async function track(input) {
|
|
|
12
12
|
}
|
|
13
13
|
const body = {
|
|
14
14
|
v: PROTOCOL_VERSION,
|
|
15
|
-
k: input.
|
|
15
|
+
k: input.workspaceId,
|
|
16
16
|
n: input.event,
|
|
17
17
|
vid: input.visitorId ?? `srv-${input.userId ?? "anon"}`
|
|
18
18
|
};
|
|
@@ -24,15 +24,13 @@ async function track(input) {
|
|
|
24
24
|
body.cad = true;
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
|
-
const headers = {
|
|
28
|
-
// text/plain matches what the tag sends, so both halves hit the same
|
|
29
|
-
// parsing path on the collector rather than two that can diverge.
|
|
30
|
-
"Content-Type": "text/plain;charset=UTF-8"
|
|
31
|
-
};
|
|
32
|
-
if (input.serverKey) headers["x-vibiz-server-key"] = input.serverKey;
|
|
33
27
|
const response = await fetch(input.endpoint ?? DEFAULT_ENDPOINT, {
|
|
34
28
|
method: "POST",
|
|
35
|
-
headers
|
|
29
|
+
headers: {
|
|
30
|
+
// text/plain matches what the tag sends, so both halves hit the same
|
|
31
|
+
// parsing path on the collector rather than two that can diverge.
|
|
32
|
+
"Content-Type": "text/plain;charset=UTF-8"
|
|
33
|
+
},
|
|
36
34
|
body: JSON.stringify(body)
|
|
37
35
|
});
|
|
38
36
|
return response.ok ? { ok: true } : { ok: false, reason: `HTTP ${response.status}` };
|