@codecademy/tracking 1.0.11 → 1.0.12-alpha.2ae4ecfbb1.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 +1 -1
- package/dist/events/track.js +12 -9
- package/dist/events/types.d.ts +30 -17
- package/dist/events/types.js +51 -1
- package/dist/integrations/conditionallyLoadAnalytics.d.ts +1 -1
- package/dist/integrations/fetchDestinationsForWriteKey.d.ts +1 -1
- package/dist/integrations/index.d.ts +1 -1
- package/dist/integrations/mapDestinations.d.ts +1 -1
- package/dist/integrations/onetrust.d.ts +1 -1
- package/package.json +2 -2
package/dist/events/track.d.ts
CHANGED
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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Follows the format EventDataTypes[Category].[Event].EventData
|
|
4
4
|
* Category + Event gives the corresponding event table in redshift
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type EventDataTypes = {
|
|
7
7
|
user: {
|
|
8
8
|
click: UserClickData;
|
|
9
9
|
visit: UserVisitData;
|
|
@@ -65,11 +65,14 @@ export declare 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
|
|
71
74
|
*/
|
|
72
|
-
export
|
|
75
|
+
export type BaseEventData = {
|
|
73
76
|
fullpath?: null;
|
|
74
77
|
search?: null;
|
|
75
78
|
path?: null;
|
|
@@ -81,13 +84,13 @@ export declare type BaseEventData = {
|
|
|
81
84
|
/**
|
|
82
85
|
* Generic type to use for event data not typed yet
|
|
83
86
|
*/
|
|
84
|
-
export
|
|
87
|
+
export type BaseEventAnyData = BaseEventData & {
|
|
85
88
|
[key: string]: any;
|
|
86
89
|
};
|
|
87
90
|
/**
|
|
88
91
|
* Options to pass to the tracking function
|
|
89
92
|
*/
|
|
90
|
-
export
|
|
93
|
+
export type TrackingOptions = {
|
|
91
94
|
/** tells backend not to merge user-identifying data onto the event payload */
|
|
92
95
|
gdprSafe?: boolean;
|
|
93
96
|
};
|
|
@@ -96,7 +99,7 @@ export declare type TrackingOptions = {
|
|
|
96
99
|
* These IDs get hashed into a single value and overwrite content_id before they are sent to
|
|
97
100
|
* redshift in lib/content_group_id.rb
|
|
98
101
|
*/
|
|
99
|
-
export
|
|
102
|
+
export type TrackingContentIds = {
|
|
100
103
|
assessment_id?: string;
|
|
101
104
|
content_item_id?: string;
|
|
102
105
|
exercise_id?: string;
|
|
@@ -112,7 +115,7 @@ export declare type TrackingContentIds = {
|
|
|
112
115
|
/**
|
|
113
116
|
* Shared data relevant for all user events
|
|
114
117
|
*/
|
|
115
|
-
export
|
|
118
|
+
export type UserSharedData = BaseEventData & {
|
|
116
119
|
/** the click target of the event */
|
|
117
120
|
target?: string;
|
|
118
121
|
/** the page the event is coming from */
|
|
@@ -136,7 +139,7 @@ export declare type UserSharedData = BaseEventData & {
|
|
|
136
139
|
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
137
140
|
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
138
141
|
*/
|
|
139
|
-
export
|
|
142
|
+
export type UserClickData = UserSharedData & {
|
|
140
143
|
target: string;
|
|
141
144
|
id?: string;
|
|
142
145
|
distinct_id?: string;
|
|
@@ -183,7 +186,7 @@ export declare type UserClickData = UserSharedData & {
|
|
|
183
186
|
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
184
187
|
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
185
188
|
*/
|
|
186
|
-
export
|
|
189
|
+
export type UserVisitData = UserSharedData & {
|
|
187
190
|
page_name: string;
|
|
188
191
|
category?: string;
|
|
189
192
|
distinct_id?: string;
|
|
@@ -205,19 +208,19 @@ export declare type UserVisitData = UserSharedData & {
|
|
|
205
208
|
lesson?: string;
|
|
206
209
|
is_ugc?: boolean;
|
|
207
210
|
};
|
|
208
|
-
export
|
|
211
|
+
export type UserImpressionData = Pick<UserSharedData, 'context' | 'source_codebase' | 'content_ids'> & {
|
|
209
212
|
page_name: string;
|
|
210
213
|
target: string;
|
|
211
214
|
slug?: string;
|
|
212
215
|
is_ugc?: boolean;
|
|
213
216
|
};
|
|
214
|
-
export
|
|
217
|
+
export type EventAnswerData = BaseEventData & {
|
|
215
218
|
question_index: number;
|
|
216
219
|
answer_index: number;
|
|
217
220
|
answer: any;
|
|
218
221
|
answer_slug: string;
|
|
219
222
|
};
|
|
220
|
-
export
|
|
223
|
+
export type User = {
|
|
221
224
|
id?: string;
|
|
222
225
|
auth_token: string;
|
|
223
226
|
profile_image_url?: string;
|
|
@@ -230,23 +233,33 @@ export declare type User = {
|
|
|
230
233
|
};
|
|
231
234
|
features: string[];
|
|
232
235
|
};
|
|
233
|
-
export
|
|
236
|
+
export type UseUserResponse = {
|
|
234
237
|
user?: User;
|
|
235
238
|
status: string;
|
|
236
239
|
};
|
|
237
|
-
export
|
|
240
|
+
export type PagePathVisitedData = BaseEventData & {
|
|
238
241
|
path_id: string;
|
|
239
242
|
path_full_title: string;
|
|
240
243
|
};
|
|
241
|
-
export
|
|
244
|
+
export type CoursePageVisitedData = BaseEventData & {
|
|
242
245
|
course_id: string;
|
|
243
246
|
course_full_title: string;
|
|
244
247
|
};
|
|
245
|
-
export
|
|
246
|
-
export
|
|
248
|
+
export type FilterType = string | string[] | number | boolean;
|
|
249
|
+
export type BusinessFilterData = BaseEventData & {
|
|
247
250
|
filter_key: string;
|
|
248
251
|
filter_value: FilterType;
|
|
249
252
|
};
|
|
250
|
-
export
|
|
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)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SegmentAnalytics, UserIntegrationSummary } from './types';
|
|
2
|
-
export
|
|
2
|
+
export type AnalyticsLoadOptions = {
|
|
3
3
|
analytics: SegmentAnalytics;
|
|
4
4
|
destinationPreferences: Record<string, boolean>;
|
|
5
5
|
identifyPreferences: Record<string, boolean>;
|
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.
|
|
4
|
+
"version": "1.0.12-alpha.2ae4ecfbb1.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@babel/runtime": "^7.12.1"
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"repository": "git@github.com:codecademy-engineering/mono.git",
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "e71b065e639b6c26415f2633603b7f20cd065ae2"
|
|
20
20
|
}
|