@ogcio/analytics-sdk 0.0.1-beta.2 → 0.0.1-beta.4
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/base/base-client.d.ts +2 -7
- package/dist/base/base-client.d.ts.map +1 -1
- package/dist/base/base-client.js +3 -15
- package/dist/base/base-client.js.map +1 -0
- package/{types.d.ts → dist/browser-types.d.ts} +1 -1
- package/dist/index.d.ts +403 -1139
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +319 -254
- package/dist/index.js.map +1 -0
- package/dist/matomo/helpers.d.ts +8 -1
- package/dist/matomo/helpers.d.ts.map +1 -1
- package/dist/matomo/helpers.js +2 -1
- package/dist/matomo/helpers.js.map +1 -0
- package/dist/matomo/types.d.ts +2 -1
- package/dist/matomo/types.d.ts.map +1 -1
- package/dist/matomo/types.js +1 -0
- package/dist/matomo/types.js.map +1 -0
- package/dist/schema.d.ts +84 -444
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -0
- package/dist/schema.js.map +1 -0
- package/dist/support-files/auth/index.js +1 -0
- package/dist/support-files/auth/index.js.map +1 -0
- package/dist/support-files/auth/types.d.ts +1 -1
- package/dist/support-files/auth/types.d.ts.map +1 -1
- package/dist/support-files/auth/types.js +1 -0
- package/dist/support-files/auth/types.js.map +1 -0
- package/dist/support-files/building-blocks-sdk.d.ts +1 -1
- package/dist/support-files/building-blocks-sdk.d.ts.map +1 -1
- package/dist/support-files/building-blocks-sdk.js +1 -0
- package/dist/support-files/building-blocks-sdk.js.map +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +22 -11
- package/examples/environment.d.ts +0 -11
- package/examples/index.ts +0 -201
- package/examples/tsconfig.json +0 -15
- package/src/base/base-client.ts +0 -172
- package/src/index.test.ts +0 -92
- package/src/index.ts +0 -543
- package/src/matomo/helpers.ts +0 -115
- package/src/matomo/types.ts +0 -64
- package/src/schema.ts +0 -1491
- package/src/support-files/auth/index.ts +0 -116
- package/src/support-files/auth/types.ts +0 -38
- package/src/support-files/building-blocks-sdk.ts +0 -32
- package/src/utils/index.test.ts +0 -46
- package/src/utils/index.ts +0 -20
- package/test-report.xml +0 -181
- package/tsconfig.json +0 -18
package/src/matomo/helpers.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { WebsiteConfiguration, WebsiteTrackingCode } from "../index.js";
|
|
2
|
-
import type { PushQueueItem } from "./types.js";
|
|
3
|
-
|
|
4
|
-
const MatomoConstants = {
|
|
5
|
-
DimensionPrefix: "dimension",
|
|
6
|
-
Tracker: "/matomo.php",
|
|
7
|
-
TrackerBypass: "/tr4ck3rp",
|
|
8
|
-
TrackerScript: "/matomo.js",
|
|
9
|
-
TrackerScriptBypass: "/tr4ck3rj",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function push(collection: PushQueueItem) {
|
|
13
|
-
if (!window._paq) window._paq = [];
|
|
14
|
-
|
|
15
|
-
window._paq.push(["setCustomUrl", window.location.href]);
|
|
16
|
-
window._paq.push(["setDocumentTitle", document.title]);
|
|
17
|
-
|
|
18
|
-
return window._paq.push(collection);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getTracker(trackerUrl: string, siteId: string) {
|
|
22
|
-
return window.Matomo.getTracker(trackerUrl, siteId);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function initMatomoArray() {
|
|
26
|
-
if (!window._paq) window._paq = [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function initTracker({
|
|
30
|
-
websiteConfiguration,
|
|
31
|
-
overrideConfig,
|
|
32
|
-
}: {
|
|
33
|
-
websiteConfiguration: WebsiteConfiguration;
|
|
34
|
-
overrideConfig?: Partial<WebsiteTrackingCode>;
|
|
35
|
-
}) {
|
|
36
|
-
const config: Partial<WebsiteTrackingCode> & WebsiteConfiguration = {
|
|
37
|
-
...websiteConfiguration,
|
|
38
|
-
...overrideConfig,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const [mainSiteId, ...otherSiteIds] = config.site_ids;
|
|
42
|
-
|
|
43
|
-
const trackerUrl = config.bypass_adblockers
|
|
44
|
-
? config.tracker_url + MatomoConstants.TrackerBypass
|
|
45
|
-
: config.tracker_url + MatomoConstants.Tracker;
|
|
46
|
-
|
|
47
|
-
// Add custom dimensions
|
|
48
|
-
if (config.custom_dimensions) {
|
|
49
|
-
for (const [key, value] of Object.entries(config.custom_dimensions)) {
|
|
50
|
-
window._paq.push([
|
|
51
|
-
"setCustomDimension",
|
|
52
|
-
parseInt(key.replace(MatomoConstants.DimensionPrefix, "")),
|
|
53
|
-
value,
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Set user ID if provided
|
|
59
|
-
if (config?.user_id) {
|
|
60
|
-
window._paq.push(["setUserId", config.user_id]);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Configure tracking options
|
|
64
|
-
if (config.link_tracking) {
|
|
65
|
-
window._paq.push(["enableLinkTracking"]);
|
|
66
|
-
}
|
|
67
|
-
if (config.cookieless) {
|
|
68
|
-
window._paq.push(["disableCookies"]);
|
|
69
|
-
}
|
|
70
|
-
if (config.tracker_url) {
|
|
71
|
-
window._paq.push(["setTrackerUrl", trackerUrl]);
|
|
72
|
-
}
|
|
73
|
-
if (config.track_bots) {
|
|
74
|
-
window._paq.push(["appendToTrackingUrl", "bot=1"]);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (mainSiteId) {
|
|
78
|
-
window._paq.push(["setSiteId", mainSiteId]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Add additional trackers for other site IDs
|
|
82
|
-
if (otherSiteIds.length > 0) {
|
|
83
|
-
for (const siteId of otherSiteIds) {
|
|
84
|
-
window._paq.push(["addTracker", trackerUrl, siteId]);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Configure additional features
|
|
89
|
-
if (config.browser_feature_detection) {
|
|
90
|
-
window._paq.push(["disableBrowserFeatureDetection"]);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (config.heart_beat_timer != null) {
|
|
94
|
-
const timer = Number(config.heart_beat_timer) || 0;
|
|
95
|
-
window._paq.push(["enableHeartBeatTimer", timer]);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Track page view if enabled (should be last)
|
|
99
|
-
if (config.track_page_view) {
|
|
100
|
-
window._paq.push(["trackPageView"]);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Load the tracker script
|
|
104
|
-
const scriptUrl = config.bypass_adblockers
|
|
105
|
-
? config.tracker_url + MatomoConstants.TrackerScriptBypass
|
|
106
|
-
: config.tracker_url + MatomoConstants.TrackerScript;
|
|
107
|
-
|
|
108
|
-
const script = document.createElement("script");
|
|
109
|
-
script.type = "text/javascript";
|
|
110
|
-
script.async = true;
|
|
111
|
-
script.src = scriptUrl;
|
|
112
|
-
|
|
113
|
-
const firstScript = document.getElementsByTagName("script")[0];
|
|
114
|
-
firstScript.parentNode?.insertBefore(script, firstScript);
|
|
115
|
-
}
|
package/src/matomo/types.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
type InitTrackerMethods =
|
|
2
|
-
| "setUserId"
|
|
3
|
-
| "enableLinkTracking"
|
|
4
|
-
| "disableCookies"
|
|
5
|
-
| "setTrackerUrl"
|
|
6
|
-
| "appendToTrackingUrl"
|
|
7
|
-
| "addTracker"
|
|
8
|
-
| "disableBrowserFeatureDetection"
|
|
9
|
-
| "enableHeartBeatTimer"
|
|
10
|
-
| "setSiteId";
|
|
11
|
-
|
|
12
|
-
type SiteSearchTrackEvent = "trackSiteSearch";
|
|
13
|
-
type CustomEventTrackEvent = "trackEvent";
|
|
14
|
-
type PageViewsTrackEvent = "trackPageView";
|
|
15
|
-
type OutlinkTrackEvent = "trackLink";
|
|
16
|
-
type ContentImpressionTrackEvent = "trackContentImpression";
|
|
17
|
-
type ContentInteractionTrackEvent = "trackContentInteraction";
|
|
18
|
-
type PaqServiceMethods = "setCustomUrl" | "setDocumentTitle";
|
|
19
|
-
type CustomDimensionsMethods =
|
|
20
|
-
| "setCustomDimensionValue"
|
|
21
|
-
| "deleteCustomDimension"
|
|
22
|
-
| "setCustomDimension";
|
|
23
|
-
|
|
24
|
-
export type TrackEventMethods =
|
|
25
|
-
| SiteSearchTrackEvent
|
|
26
|
-
| CustomEventTrackEvent
|
|
27
|
-
| PageViewsTrackEvent
|
|
28
|
-
| OutlinkTrackEvent
|
|
29
|
-
| ContentImpressionTrackEvent
|
|
30
|
-
| ContentInteractionTrackEvent;
|
|
31
|
-
|
|
32
|
-
export type PushQueueMethods =
|
|
33
|
-
| CustomDimensionsMethods
|
|
34
|
-
| TrackEventMethods
|
|
35
|
-
| PaqServiceMethods
|
|
36
|
-
| InitTrackerMethods;
|
|
37
|
-
|
|
38
|
-
export type VisitorInfo = [
|
|
39
|
-
isNew: "0" | "1",
|
|
40
|
-
visitorId: string,
|
|
41
|
-
firstVisitTS: number,
|
|
42
|
-
previousVisitCount: string | number,
|
|
43
|
-
currentVisitTS: number,
|
|
44
|
-
lastVisitTS: number | "",
|
|
45
|
-
lastEcommerceOrderTS: number | "",
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
export type Tracker = {
|
|
49
|
-
hasCookies: () => boolean;
|
|
50
|
-
getCookieDomain: () => string;
|
|
51
|
-
getCookiePath: () => string;
|
|
52
|
-
getSessionCookieTimeout: () => number;
|
|
53
|
-
getConfigVisitorCookieTimeout: () => number;
|
|
54
|
-
getCustomDimensionValue: (id: string | number) => string | undefined;
|
|
55
|
-
getLinkTrackingTimer: () => number;
|
|
56
|
-
getEcommerceItems: () => object;
|
|
57
|
-
getUserId: () => string;
|
|
58
|
-
getVisitorId: () => string;
|
|
59
|
-
getVisitorInfo: () => VisitorInfo;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export type PushQueueItem =
|
|
63
|
-
| [PushQueueMethods, ...unknown[]]
|
|
64
|
-
| [(this: Tracker) => void];
|