ninetwo-user-tracking 1.0.10 → 1.0.11
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/index.js +22 -8
- package/dist/index.mjs +22 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,14 +36,28 @@ var import_react = require("react");
|
|
|
36
36
|
var pushToDataLayer = (props) => {
|
|
37
37
|
if (typeof window === "undefined")
|
|
38
38
|
return;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const { event, category, label, type, ...rest } = props;
|
|
40
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
41
|
+
const params = {
|
|
42
|
+
event_category: category,
|
|
43
|
+
event_label: label,
|
|
44
|
+
event_type: type,
|
|
45
|
+
interaction_time: timestamp,
|
|
46
|
+
...rest
|
|
47
|
+
// permite enviar dados extras
|
|
48
|
+
};
|
|
49
|
+
if (typeof window.gtag === "function") {
|
|
50
|
+
try {
|
|
51
|
+
window.gtag("event", event, params);
|
|
52
|
+
return;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.warn("[NineTwo Tracking] gtag falhou, fallback para dataLayer", err);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
window.dataLayer = window.dataLayer || [];
|
|
58
|
+
window.dataLayer.push({
|
|
59
|
+
event,
|
|
60
|
+
...params
|
|
47
61
|
});
|
|
48
62
|
};
|
|
49
63
|
|
package/dist/index.mjs
CHANGED
|
@@ -8,14 +8,28 @@ import { useEffect } from "react";
|
|
|
8
8
|
var pushToDataLayer = (props) => {
|
|
9
9
|
if (typeof window === "undefined")
|
|
10
10
|
return;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const { event, category, label, type, ...rest } = props;
|
|
12
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
13
|
+
const params = {
|
|
14
|
+
event_category: category,
|
|
15
|
+
event_label: label,
|
|
16
|
+
event_type: type,
|
|
17
|
+
interaction_time: timestamp,
|
|
18
|
+
...rest
|
|
19
|
+
// permite enviar dados extras
|
|
20
|
+
};
|
|
21
|
+
if (typeof window.gtag === "function") {
|
|
22
|
+
try {
|
|
23
|
+
window.gtag("event", event, params);
|
|
24
|
+
return;
|
|
25
|
+
} catch (err) {
|
|
26
|
+
console.warn("[NineTwo Tracking] gtag falhou, fallback para dataLayer", err);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
window.dataLayer = window.dataLayer || [];
|
|
30
|
+
window.dataLayer.push({
|
|
31
|
+
event,
|
|
32
|
+
...params
|
|
19
33
|
});
|
|
20
34
|
};
|
|
21
35
|
|