@codecademy/tracking 1.0.26-alpha.77dafde082.0 → 1.0.26-alpha.902606f273.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/events/track.d.ts +2 -1
- package/dist/events/track.js +9 -4
- package/package.json +2 -2
package/dist/events/track.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import type { BaseEventData, EventDataTypes, TrackingOptions, UserClickData, Use
|
|
|
2
2
|
export type TrackerOptions = {
|
|
3
3
|
apiBaseUrl: string;
|
|
4
4
|
verbose?: boolean;
|
|
5
|
+
customUrlPath?: string;
|
|
5
6
|
};
|
|
6
|
-
export declare const createTracker: ({ apiBaseUrl, verbose }: TrackerOptions) => {
|
|
7
|
+
export declare const createTracker: ({ apiBaseUrl, verbose, customUrlPath, }: TrackerOptions) => {
|
|
7
8
|
event: <Category extends keyof EventDataTypes, Event_1 extends string & keyof EventDataTypes[Category], Data extends EventDataTypes[Category][Event_1] & BaseEventData>(category: Category, event: Event_1, userData: Data, options?: TrackingOptions) => void;
|
|
8
9
|
click: (data: UserClickData) => void;
|
|
9
10
|
impression: (data: UserImpressionData) => void;
|
package/dist/events/track.js
CHANGED
|
@@ -13,9 +13,11 @@ import { getClientType } from '../integrations/device';
|
|
|
13
13
|
const browserSupportsKeepalive = () => 'keepalive' in window.Request.prototype;
|
|
14
14
|
export const createTracker = _ref => {
|
|
15
15
|
let apiBaseUrl = _ref.apiBaseUrl,
|
|
16
|
-
verbose = _ref.verbose
|
|
16
|
+
verbose = _ref.verbose,
|
|
17
|
+
customUrlPath = _ref.customUrlPath;
|
|
18
|
+
console.log("createTracker > customUrlPath: ".concat(customUrlPath));
|
|
17
19
|
const beacon = (endpoint, data) => {
|
|
18
|
-
const uri = new URL(apiBaseUrl
|
|
20
|
+
const uri = new URL(endpoint, apiBaseUrl).toString();
|
|
19
21
|
const form = new FormData();
|
|
20
22
|
for (const _ref2 of Object.entries(data)) {
|
|
21
23
|
var _ref3 = _slicedToArray(_ref2, 2);
|
|
@@ -78,17 +80,20 @@ export const createTracker = _ref => {
|
|
|
78
80
|
});
|
|
79
81
|
console.groupEnd();
|
|
80
82
|
}
|
|
83
|
+
|
|
84
|
+
// If present, use custom endpoint and trim starting and ending slashes
|
|
85
|
+
const baseEndpoint = customUrlPath ? customUrlPath.replace(/\/$/, '').replace(/^\//, '') : 'analytics';
|
|
81
86
|
if (typeof window !== 'undefined') {
|
|
82
87
|
// This allows the UTM query params to get registered in the user session.
|
|
83
88
|
const queryParams = window.location.search;
|
|
84
|
-
beacon("/".concat(category).concat(queryParams), {
|
|
89
|
+
beacon("/".concat(baseEndpoint, "/").concat(category).concat(queryParams), {
|
|
85
90
|
category,
|
|
86
91
|
event,
|
|
87
92
|
properties: JSON.stringify(properties),
|
|
88
93
|
gdpr_safe: "".concat(options.gdprSafe)
|
|
89
94
|
});
|
|
90
95
|
} else {
|
|
91
|
-
serverSideBeacon("/".concat(category), {
|
|
96
|
+
serverSideBeacon("/".concat(baseEndpoint, "/").concat(category), {
|
|
92
97
|
category,
|
|
93
98
|
event,
|
|
94
99
|
properties: JSON.stringify(properties)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/tracking",
|
|
3
3
|
"description": "Tracking library for Codecademy",
|
|
4
|
-
"version": "1.0.26-alpha.
|
|
4
|
+
"version": "1.0.26-alpha.902606f273.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/**"
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"repository": "git@github.com:codecademy-engineering/mono.git",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "5ab51287a51b234256a7a4c6d230ff6a9cff38f9"
|
|
17
17
|
}
|