@codecademy/tracking 1.0.3-alpha.37044bcdd.0 → 1.0.3-alpha.4641cabd2.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/index.d.ts +3 -3
- package/dist/events/index.js +3 -0
- package/dist/events/track.d.ts +12 -12
- package/dist/events/track.js +115 -0
- package/dist/events/types.d.ts +251 -250
- package/dist/events/types.js +1 -0
- package/dist/events/user.d.ts +2 -2
- package/dist/events/user.js +41 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -595
- package/dist/integrations/conditionallyLoadAnalytics.d.ts +9 -9
- package/dist/integrations/conditionallyLoadAnalytics.js +27 -0
- package/dist/integrations/consent.d.ts +9 -9
- package/dist/integrations/consent.js +11 -0
- package/dist/integrations/device.d.ts +13 -13
- package/dist/integrations/device.js +25 -0
- package/dist/integrations/fetchDestinationsForWriteKey.d.ts +6 -6
- package/dist/integrations/fetchDestinationsForWriteKey.js +88 -0
- package/dist/integrations/getConsentDecision.d.ts +8 -8
- package/dist/integrations/getConsentDecision.js +32 -0
- package/dist/integrations/index.d.ts +31 -31
- package/dist/integrations/index.js +90 -0
- package/dist/integrations/mapDestinations.d.ts +13 -13
- package/dist/integrations/mapDestinations.js +55 -0
- package/dist/integrations/onetrust.d.ts +6 -6
- package/dist/integrations/onetrust.js +53 -0
- package/dist/integrations/runSegmentSnippet.d.ts +7 -7
- package/dist/integrations/runSegmentSnippet.js +64 -0
- package/dist/integrations/types.d.ts +24 -24
- package/dist/integrations/types.js +1 -0
- package/package.json +2 -2
- package/dist/README.md +0 -100
- package/dist/index.cjs +0 -711
- package/dist/package.json +0 -21
package/dist/events/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './track';
|
|
2
|
-
export * from './user';
|
|
3
|
-
export * from './types';
|
|
1
|
+
export * from './track';
|
|
2
|
+
export * from './user';
|
|
3
|
+
export * from './types';
|
package/dist/events/track.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { BaseEventData, EventDataTypes, TrackingOptions, UserClickData, UserImpressionData, UserVisitData } from './types';
|
|
2
|
-
export declare type TrackerOptions = {
|
|
3
|
-
apiBaseUrl: string;
|
|
4
|
-
verbose?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare const createTracker: ({ apiBaseUrl, verbose }: TrackerOptions) => {
|
|
7
|
-
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
|
-
click: (data: UserClickData) => void;
|
|
9
|
-
impression: (data: UserImpressionData) => void;
|
|
10
|
-
visit: (data: UserVisitData) => void;
|
|
11
|
-
pushDataLayerEvent: (eventName: string) => void;
|
|
12
|
-
};
|
|
1
|
+
import type { BaseEventData, EventDataTypes, TrackingOptions, UserClickData, UserImpressionData, UserVisitData } from './types';
|
|
2
|
+
export declare type TrackerOptions = {
|
|
3
|
+
apiBaseUrl: string;
|
|
4
|
+
verbose?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const createTracker: ({ apiBaseUrl, verbose }: TrackerOptions) => {
|
|
7
|
+
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
|
+
click: (data: UserClickData) => void;
|
|
9
|
+
impression: (data: UserImpressionData) => void;
|
|
10
|
+
visit: (data: UserVisitData) => void;
|
|
11
|
+
pushDataLayerEvent: (eventName: string) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
+
|
|
15
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
16
|
+
|
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
|
|
19
|
+
import { getClientType } from '../integrations/device';
|
|
20
|
+
|
|
21
|
+
var browserSupportsKeepalive = function browserSupportsKeepalive() {
|
|
22
|
+
return 'keepalive' in window.Request.prototype;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export var createTracker = function createTracker(_ref) {
|
|
26
|
+
var apiBaseUrl = _ref.apiBaseUrl,
|
|
27
|
+
verbose = _ref.verbose;
|
|
28
|
+
|
|
29
|
+
var beacon = function beacon(endpoint, data) {
|
|
30
|
+
var uri = new URL(endpoint, apiBaseUrl).toString();
|
|
31
|
+
var form = new FormData();
|
|
32
|
+
|
|
33
|
+
for (var _i2 = 0, _Object$entries = Object.entries(data); _i2 < _Object$entries.length; _i2++) {
|
|
34
|
+
var _ref4 = _Object$entries[_i2];
|
|
35
|
+
|
|
36
|
+
var _ref3 = _slicedToArray(_ref4, 2);
|
|
37
|
+
|
|
38
|
+
var k = _ref3[0];
|
|
39
|
+
var v = _ref3[1];
|
|
40
|
+
form.append(k, v.toString());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
// Firefox allows users to disable navigator.sendBeacon, and very old Safari versions don't have it.
|
|
45
|
+
// [WEB-1700]: Additionally, Chrome 79-80 gives "Illegal invocation" with ?., so through 2022 we should support them.
|
|
46
|
+
// It seems similar to this: https://github.com/vercel/next.js/issues/23856
|
|
47
|
+
if (navigator.sendBeacon && navigator.sendBeacon(uri, form)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
} catch (_unused) {// Even with the proper scoping, Chrome 79-80 still gives "Illegal invocation" crashes. Sigh.
|
|
51
|
+
} // Either way, we fall back to standard fetch if sendBeacon fails.
|
|
52
|
+
// We don't mind this rejecting with an error because it's tracking, and we'll know if that starts to fail.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
window.fetch(uri, _objectSpread({
|
|
56
|
+
method: 'POST',
|
|
57
|
+
body: form
|
|
58
|
+
}, browserSupportsKeepalive() && {
|
|
59
|
+
keepalive: true
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var event = function event(category, _event, userData) {
|
|
64
|
+
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
65
|
+
|
|
66
|
+
var properties = _objectSpread(_objectSpread({}, userData), {}, {
|
|
67
|
+
fullpath: window.location.pathname + window.location.search,
|
|
68
|
+
search: window.location.search,
|
|
69
|
+
path: window.location.pathname,
|
|
70
|
+
title: window.document.title,
|
|
71
|
+
url: window.location.href,
|
|
72
|
+
referrer: userData.referrer || window.document.referrer,
|
|
73
|
+
client: getClientType()
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (verbose) {
|
|
77
|
+
console.groupCollapsed("%cTracking Event Fired: ".concat(category, ":").concat(_event), 'color: #4b35ef; font-style: italic;');
|
|
78
|
+
console.log({
|
|
79
|
+
category: category,
|
|
80
|
+
event: _event,
|
|
81
|
+
properties: properties
|
|
82
|
+
});
|
|
83
|
+
console.groupEnd();
|
|
84
|
+
} // This allows the UTM query params to get registered in the user session.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
var queryParams = window.location.search;
|
|
88
|
+
beacon("/analytics/".concat(category).concat(queryParams), {
|
|
89
|
+
category: category,
|
|
90
|
+
event: _event,
|
|
91
|
+
properties: JSON.stringify(properties),
|
|
92
|
+
gdpr_safe: "".concat(options.gdprSafe)
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
event: event,
|
|
98
|
+
click: function click(data) {
|
|
99
|
+
return event('user', 'click', data);
|
|
100
|
+
},
|
|
101
|
+
impression: function impression(data) {
|
|
102
|
+
return event('user', 'impression', data);
|
|
103
|
+
},
|
|
104
|
+
visit: function visit(data) {
|
|
105
|
+
return event('user', 'visit', data);
|
|
106
|
+
},
|
|
107
|
+
pushDataLayerEvent: function pushDataLayerEvent(eventName) {
|
|
108
|
+
var _ref5;
|
|
109
|
+
|
|
110
|
+
((_ref5 = window).dataLayer || (_ref5.dataLayer = [])).push({
|
|
111
|
+
event: eventName
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
};
|
package/dist/events/types.d.ts
CHANGED
|
@@ -1,250 +1,251 @@
|
|
|
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
|
-
export declare type EventDataTypes = {
|
|
7
|
-
user: {
|
|
8
|
-
click: UserClickData;
|
|
9
|
-
visit: UserVisitData;
|
|
10
|
-
impression: UserImpressionData;
|
|
11
|
-
email_trigger: BaseEventAnyData;
|
|
12
|
-
content_completed: BaseEventAnyData;
|
|
13
|
-
submit: BaseEventAnyData;
|
|
14
|
-
workspace_init: BaseEventAnyData;
|
|
15
|
-
meaningful_content_loaded: BaseEventAnyData;
|
|
16
|
-
practice_completed: BaseEventAnyData;
|
|
17
|
-
};
|
|
18
|
-
ad: {
|
|
19
|
-
click: BaseEventAnyData;
|
|
20
|
-
impression: BaseEventAnyData;
|
|
21
|
-
};
|
|
22
|
-
calendar: {
|
|
23
|
-
reminder: BaseEventAnyData;
|
|
24
|
-
};
|
|
25
|
-
notification: {
|
|
26
|
-
clicked: BaseEventAnyData;
|
|
27
|
-
ion: BaseEventAnyData;
|
|
28
|
-
};
|
|
29
|
-
form: {
|
|
30
|
-
submit: BaseEventAnyData;
|
|
31
|
-
};
|
|
32
|
-
sorting_quiz: {
|
|
33
|
-
result: BaseEventAnyData;
|
|
34
|
-
impression: BaseEventAnyData;
|
|
35
|
-
answer: EventAnswerData;
|
|
36
|
-
};
|
|
37
|
-
onboarding_survey: {
|
|
38
|
-
answer: BaseEventAnyData;
|
|
39
|
-
recommendation: BaseEventAnyData;
|
|
40
|
-
user_selected_recommendation: BaseEventAnyData;
|
|
41
|
-
};
|
|
42
|
-
exercise: {
|
|
43
|
-
force_pass: BaseEventAnyData;
|
|
44
|
-
};
|
|
45
|
-
experiment: {
|
|
46
|
-
contentful_experiment_assignment_event: BaseEventAnyData;
|
|
47
|
-
};
|
|
48
|
-
payments: {
|
|
49
|
-
cancel_survey: BaseEventAnyData;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
target
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
context
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
version
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
export declare type
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
+
export declare type EventDataTypes = {
|
|
7
|
+
user: {
|
|
8
|
+
click: UserClickData;
|
|
9
|
+
visit: UserVisitData;
|
|
10
|
+
impression: UserImpressionData;
|
|
11
|
+
email_trigger: BaseEventAnyData;
|
|
12
|
+
content_completed: BaseEventAnyData;
|
|
13
|
+
submit: BaseEventAnyData;
|
|
14
|
+
workspace_init: BaseEventAnyData;
|
|
15
|
+
meaningful_content_loaded: BaseEventAnyData;
|
|
16
|
+
practice_completed: BaseEventAnyData;
|
|
17
|
+
};
|
|
18
|
+
ad: {
|
|
19
|
+
click: BaseEventAnyData;
|
|
20
|
+
impression: BaseEventAnyData;
|
|
21
|
+
};
|
|
22
|
+
calendar: {
|
|
23
|
+
reminder: BaseEventAnyData;
|
|
24
|
+
};
|
|
25
|
+
notification: {
|
|
26
|
+
clicked: BaseEventAnyData;
|
|
27
|
+
ion: BaseEventAnyData;
|
|
28
|
+
};
|
|
29
|
+
form: {
|
|
30
|
+
submit: BaseEventAnyData;
|
|
31
|
+
};
|
|
32
|
+
sorting_quiz: {
|
|
33
|
+
result: BaseEventAnyData;
|
|
34
|
+
impression: BaseEventAnyData;
|
|
35
|
+
answer: EventAnswerData;
|
|
36
|
+
};
|
|
37
|
+
onboarding_survey: {
|
|
38
|
+
answer: BaseEventAnyData;
|
|
39
|
+
recommendation: BaseEventAnyData;
|
|
40
|
+
user_selected_recommendation: BaseEventAnyData;
|
|
41
|
+
};
|
|
42
|
+
exercise: {
|
|
43
|
+
force_pass: BaseEventAnyData;
|
|
44
|
+
};
|
|
45
|
+
experiment: {
|
|
46
|
+
contentful_experiment_assignment_event: BaseEventAnyData;
|
|
47
|
+
};
|
|
48
|
+
payments: {
|
|
49
|
+
cancel_survey: BaseEventAnyData;
|
|
50
|
+
extend_trial_survey: BaseEventAnyData;
|
|
51
|
+
};
|
|
52
|
+
search: {
|
|
53
|
+
visit: BaseEventAnyData;
|
|
54
|
+
click: BaseEventAnyData;
|
|
55
|
+
query: BaseEventAnyData;
|
|
56
|
+
result: BaseEventAnyData;
|
|
57
|
+
};
|
|
58
|
+
page: {
|
|
59
|
+
career_path_visited: PagePathVisitedData;
|
|
60
|
+
skill_path_visited: PagePathVisitedData;
|
|
61
|
+
course_page_visited: CoursePageVisitedData;
|
|
62
|
+
};
|
|
63
|
+
business: {
|
|
64
|
+
filter_event: BusinessFilterData;
|
|
65
|
+
search_event: BusinessSearchData;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Base event data shared by all events
|
|
70
|
+
*/
|
|
71
|
+
export declare type BaseEventData = {
|
|
72
|
+
fullpath?: null;
|
|
73
|
+
search?: null;
|
|
74
|
+
path?: null;
|
|
75
|
+
title?: null;
|
|
76
|
+
url?: null;
|
|
77
|
+
referrer?: string | null;
|
|
78
|
+
id?: null;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Generic type to use for event data not typed yet
|
|
82
|
+
*/
|
|
83
|
+
export declare type BaseEventAnyData = BaseEventData & {
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Options to pass to the tracking function
|
|
88
|
+
*/
|
|
89
|
+
export declare type TrackingOptions = {
|
|
90
|
+
/** tells backend not to merge user-identifying data onto the event payload */
|
|
91
|
+
gdprSafe?: boolean;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The Content IDs related to the current event, to help build the content context of the event.
|
|
95
|
+
* These IDs get hashed into a single value and overwrite content_id before they are sent to
|
|
96
|
+
* redshift in lib/content_group_id.rb
|
|
97
|
+
*/
|
|
98
|
+
export declare type TrackingContentIds = {
|
|
99
|
+
assessment_id?: string;
|
|
100
|
+
content_item_id?: string;
|
|
101
|
+
exercise_id?: string;
|
|
102
|
+
learning_standard_id?: string;
|
|
103
|
+
module_id?: string;
|
|
104
|
+
path_id?: string;
|
|
105
|
+
program_id?: string;
|
|
106
|
+
program_unit_id?: string;
|
|
107
|
+
review_card_id?: string;
|
|
108
|
+
track_id?: string;
|
|
109
|
+
journey_id?: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Shared data relevant for all user events
|
|
113
|
+
*/
|
|
114
|
+
export declare type UserSharedData = BaseEventData & {
|
|
115
|
+
/** the click target of the event */
|
|
116
|
+
target?: string;
|
|
117
|
+
/** the page the event is coming from */
|
|
118
|
+
page_name?: string;
|
|
119
|
+
/** a context id for the event, for events that occur in more than one place */
|
|
120
|
+
context?: string;
|
|
121
|
+
/** the link being clicked on */
|
|
122
|
+
href?: string;
|
|
123
|
+
/** a version id for the element (ex. different version ids for redesigns) */
|
|
124
|
+
version?: string;
|
|
125
|
+
/** an object of content ids related to this event */
|
|
126
|
+
content_ids?: TrackingContentIds;
|
|
127
|
+
/** the repo that this event is being fired from */
|
|
128
|
+
source_codebase?: string;
|
|
129
|
+
/** Should be used for arbitrary JSON that has been passed through JSON.stringify. */
|
|
130
|
+
misc?: string;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Data sent to user click event table
|
|
134
|
+
* NOTE: avoid adding additional properties to these objects
|
|
135
|
+
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
136
|
+
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
137
|
+
*/
|
|
138
|
+
export declare type UserClickData = UserSharedData & {
|
|
139
|
+
target: string;
|
|
140
|
+
id?: string;
|
|
141
|
+
distinct_id?: string;
|
|
142
|
+
content_id?: string;
|
|
143
|
+
slug?: string;
|
|
144
|
+
name?: string;
|
|
145
|
+
action?: string;
|
|
146
|
+
type?: string;
|
|
147
|
+
location?: string;
|
|
148
|
+
element?: string;
|
|
149
|
+
weekly_goal?: string | number;
|
|
150
|
+
complete?: string;
|
|
151
|
+
video_url?: string;
|
|
152
|
+
path_id?: string;
|
|
153
|
+
path_slug?: string;
|
|
154
|
+
event_name?: string;
|
|
155
|
+
onboarding_entrypoint?: string;
|
|
156
|
+
content_slug?: string;
|
|
157
|
+
module_id?: string;
|
|
158
|
+
track_slug?: string;
|
|
159
|
+
module_slug?: string;
|
|
160
|
+
button?: string;
|
|
161
|
+
current_challenge_day?: string | number;
|
|
162
|
+
track_id?: string;
|
|
163
|
+
course?: string;
|
|
164
|
+
path_name?: string;
|
|
165
|
+
event_id?: string;
|
|
166
|
+
unit?: string;
|
|
167
|
+
lesson?: string;
|
|
168
|
+
community_prompt?: string;
|
|
169
|
+
contentItem?: any;
|
|
170
|
+
unit_slug?: string;
|
|
171
|
+
course_slug?: string;
|
|
172
|
+
course_progress?: number;
|
|
173
|
+
assessment_id?: string;
|
|
174
|
+
container_slugs?: string[];
|
|
175
|
+
search_id?: string;
|
|
176
|
+
is_ugc?: boolean;
|
|
177
|
+
business_user?: BaseEventAnyData;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Data sent to user visit event table
|
|
181
|
+
* NOTE: avoid adding additional properties to these objects
|
|
182
|
+
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
183
|
+
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
184
|
+
*/
|
|
185
|
+
export declare type UserVisitData = UserSharedData & {
|
|
186
|
+
page_name: string;
|
|
187
|
+
category?: string;
|
|
188
|
+
distinct_id?: string;
|
|
189
|
+
type?: string;
|
|
190
|
+
target?: string;
|
|
191
|
+
section?: string;
|
|
192
|
+
plan?: string;
|
|
193
|
+
path_id?: string;
|
|
194
|
+
post?: string;
|
|
195
|
+
story_type?: string;
|
|
196
|
+
path_title?: string;
|
|
197
|
+
onboarding_entrypoint?: string;
|
|
198
|
+
course_slug?: string;
|
|
199
|
+
course?: string;
|
|
200
|
+
interstitial_name?: string;
|
|
201
|
+
content_id?: string;
|
|
202
|
+
story_slug?: string;
|
|
203
|
+
unit?: string;
|
|
204
|
+
lesson?: string;
|
|
205
|
+
is_ugc?: boolean;
|
|
206
|
+
};
|
|
207
|
+
export declare type UserImpressionData = Pick<UserSharedData, 'context' | 'source_codebase' | 'content_ids'> & {
|
|
208
|
+
page_name: string;
|
|
209
|
+
target: string;
|
|
210
|
+
slug?: string;
|
|
211
|
+
is_ugc?: boolean;
|
|
212
|
+
};
|
|
213
|
+
export declare type EventAnswerData = BaseEventData & {
|
|
214
|
+
question_index: number;
|
|
215
|
+
answer_index: number;
|
|
216
|
+
answer: any;
|
|
217
|
+
answer_slug: string;
|
|
218
|
+
};
|
|
219
|
+
export declare type User = {
|
|
220
|
+
id?: string;
|
|
221
|
+
auth_token: string;
|
|
222
|
+
profile_image_url?: string;
|
|
223
|
+
email?: string;
|
|
224
|
+
is_pro?: boolean;
|
|
225
|
+
username?: string;
|
|
226
|
+
location: {
|
|
227
|
+
in_eu: boolean;
|
|
228
|
+
geo_country: string;
|
|
229
|
+
};
|
|
230
|
+
features: string[];
|
|
231
|
+
};
|
|
232
|
+
export declare type UseUserResponse = {
|
|
233
|
+
user?: User;
|
|
234
|
+
status: string;
|
|
235
|
+
};
|
|
236
|
+
export declare type PagePathVisitedData = BaseEventData & {
|
|
237
|
+
path_id: string;
|
|
238
|
+
path_full_title: string;
|
|
239
|
+
};
|
|
240
|
+
export declare type CoursePageVisitedData = BaseEventData & {
|
|
241
|
+
course_id: string;
|
|
242
|
+
course_full_title: string;
|
|
243
|
+
};
|
|
244
|
+
export declare type FilterType = string | string[] | number | boolean;
|
|
245
|
+
export declare type BusinessFilterData = BaseEventData & {
|
|
246
|
+
filter_key: string;
|
|
247
|
+
filter_value: FilterType;
|
|
248
|
+
};
|
|
249
|
+
export declare type BusinessSearchData = BaseEventData & {
|
|
250
|
+
search_query: string;
|
|
251
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|