@codecademy/tracking 1.0.12-alpha.fa473cbdf3.0 → 1.0.12
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.js +12 -9
- package/dist/events/types.d.ts +13 -0
- package/dist/events/types.js +51 -1
- package/package.json +5 -2
package/dist/events/track.js
CHANGED
|
@@ -49,7 +49,8 @@ export var createTracker = function createTracker(_ref) {
|
|
|
49
49
|
};
|
|
50
50
|
var event = function event(category, _event, userData) {
|
|
51
51
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
52
|
-
|
|
52
|
+
// support server-side-only as well as client-side events
|
|
53
|
+
var properties = typeof window !== 'undefined' ? _objectSpread(_objectSpread({}, userData), {}, {
|
|
53
54
|
fullpath: window.location.pathname + window.location.search,
|
|
54
55
|
search: window.location.search,
|
|
55
56
|
path: window.location.pathname,
|
|
@@ -57,7 +58,7 @@ export var createTracker = function createTracker(_ref) {
|
|
|
57
58
|
url: window.location.href,
|
|
58
59
|
referrer: userData.referrer || window.document.referrer,
|
|
59
60
|
client: getClientType()
|
|
60
|
-
});
|
|
61
|
+
}) : userData;
|
|
61
62
|
if (verbose) {
|
|
62
63
|
console.groupCollapsed("%cTracking Event Fired: ".concat(category, ":").concat(_event), 'color: #4b35ef; font-style: italic;');
|
|
63
64
|
console.log({
|
|
@@ -69,13 +70,15 @@ export var createTracker = function createTracker(_ref) {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// This allows the UTM query params to get registered in the user session.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
category
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
if (typeof window !== 'undefined') {
|
|
74
|
+
var queryParams = window.location.search;
|
|
75
|
+
beacon("/analytics/".concat(category).concat(queryParams), {
|
|
76
|
+
category: category,
|
|
77
|
+
event: _event,
|
|
78
|
+
properties: JSON.stringify(properties),
|
|
79
|
+
gdpr_safe: "".concat(options.gdprSafe)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
79
82
|
};
|
|
80
83
|
return {
|
|
81
84
|
event: event,
|
package/dist/events/types.d.ts
CHANGED
|
@@ -65,6 +65,9 @@ export type EventDataTypes = {
|
|
|
65
65
|
filter_event: BusinessFilterData;
|
|
66
66
|
search_event: BusinessSearchData;
|
|
67
67
|
};
|
|
68
|
+
gpt_plugin: {
|
|
69
|
+
search: ChatGPTPluginSearchEventData;
|
|
70
|
+
};
|
|
68
71
|
};
|
|
69
72
|
/**
|
|
70
73
|
* Base event data shared by all events
|
|
@@ -250,3 +253,13 @@ export type BusinessFilterData = BaseEventData & {
|
|
|
250
253
|
export type BusinessSearchData = BaseEventData & {
|
|
251
254
|
search_query: string;
|
|
252
255
|
};
|
|
256
|
+
export declare enum ChatGPTSearchResource {
|
|
257
|
+
ALL = "all",
|
|
258
|
+
ARTICLES = "articles",
|
|
259
|
+
CATALOG = "catalog",
|
|
260
|
+
DOCS = "docs"
|
|
261
|
+
}
|
|
262
|
+
export type ChatGPTPluginSearchEventData = {
|
|
263
|
+
resource: ChatGPTSearchResource;
|
|
264
|
+
query: string;
|
|
265
|
+
};
|
package/dist/events/types.js
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The Data types for all of our events.
|
|
3
|
+
* Follows the format EventDataTypes[Category].[Event].EventData
|
|
4
|
+
* Category + Event gives the corresponding event table in redshift
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base event data shared by all events
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Generic type to use for event data not typed yet
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Options to pass to the tracking function
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The Content IDs related to the current event, to help build the content context of the event.
|
|
21
|
+
* These IDs get hashed into a single value and overwrite content_id before they are sent to
|
|
22
|
+
* redshift in lib/content_group_id.rb
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Shared data relevant for all user events
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Data sent to user click event table
|
|
31
|
+
* NOTE: avoid adding additional properties to these objects
|
|
32
|
+
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
33
|
+
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Data sent to user visit event table
|
|
38
|
+
* NOTE: avoid adding additional properties to these objects
|
|
39
|
+
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
40
|
+
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export var ChatGPTSearchResource = /*#__PURE__*/function (ChatGPTSearchResource) {
|
|
44
|
+
ChatGPTSearchResource["ALL"] = "all";
|
|
45
|
+
ChatGPTSearchResource["ARTICLES"] = "articles";
|
|
46
|
+
ChatGPTSearchResource["CATALOG"] = "catalog";
|
|
47
|
+
ChatGPTSearchResource["DOCS"] = "docs";
|
|
48
|
+
return ChatGPTSearchResource;
|
|
49
|
+
}({});
|
|
50
|
+
|
|
51
|
+
// does not extend base event (all client side fields there)
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/tracking",
|
|
3
3
|
"description": "Tracking library for Codecademy",
|
|
4
|
-
"version": "1.0.12
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@babel/runtime": "^7.12.1"
|
|
8
|
+
},
|
|
6
9
|
"files": [
|
|
7
10
|
"dist/**"
|
|
8
11
|
],
|
|
@@ -13,5 +16,5 @@
|
|
|
13
16
|
"access": "public"
|
|
14
17
|
},
|
|
15
18
|
"repository": "git@github.com:codecademy-engineering/mono.git",
|
|
16
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "05bb6adfc2b1c065b9955db531c23039e696b1ad"
|
|
17
20
|
}
|