@codecademy/tracking 1.0.2 → 1.0.3-alpha.37044bcdd.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/README.md +100 -0
- package/dist/events/index.d.ts +3 -3
- package/dist/events/track.d.ts +12 -12
- package/dist/events/types.d.ts +250 -250
- package/dist/events/user.d.ts +2 -2
- package/dist/index.cjs +711 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +595 -3
- package/dist/integrations/conditionallyLoadAnalytics.d.ts +9 -9
- package/dist/integrations/consent.d.ts +9 -9
- package/dist/integrations/device.d.ts +13 -13
- package/dist/integrations/fetchDestinationsForWriteKey.d.ts +6 -6
- package/dist/integrations/getConsentDecision.d.ts +8 -8
- package/dist/integrations/index.d.ts +31 -31
- package/dist/integrations/mapDestinations.d.ts +13 -13
- package/dist/integrations/onetrust.d.ts +6 -6
- package/dist/integrations/runSegmentSnippet.d.ts +7 -7
- package/dist/integrations/types.d.ts +24 -24
- package/dist/package.json +21 -0
- package/package.json +2 -2
- package/dist/events/index.js +0 -3
- package/dist/events/track.js +0 -115
- package/dist/events/types.js +0 -1
- package/dist/events/user.js +0 -41
- package/dist/integrations/conditionallyLoadAnalytics.js +0 -27
- package/dist/integrations/consent.js +0 -11
- package/dist/integrations/device.js +0 -25
- package/dist/integrations/fetchDestinationsForWriteKey.js +0 -88
- package/dist/integrations/getConsentDecision.js +0 -32
- package/dist/integrations/index.js +0 -90
- package/dist/integrations/mapDestinations.js +0 -55
- package/dist/integrations/onetrust.js +0 -53
- package/dist/integrations/runSegmentSnippet.js +0 -64
- package/dist/integrations/types.js +0 -1
package/dist/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# `@codecademy/tracking`
|
|
2
|
+
|
|
3
|
+
This package contains our user "telemetry" (tracking metrics such as `click` and `visit`) integrations that are shared across multiple web properties.
|
|
4
|
+
|
|
5
|
+
We've consolidated them here for a few reasons:
|
|
6
|
+
|
|
7
|
+
- To standardize APIs around events like tracking user clicks
|
|
8
|
+
- To make sure any third party integrations are CCPA & GDPR compliant
|
|
9
|
+
- Because this repository already has a sweet CI setup for previewing and auto-publishing new versions 😎
|
|
10
|
+
|
|
11
|
+
There are two kinds of tracking we package in this library:
|
|
12
|
+
|
|
13
|
+
- **Internal** tracking ([`createTracker`](#createTracker)): sent directly to our `/analytics/` endpoint
|
|
14
|
+
- **External** tracking ([`useTrackingIntegrations`](#useTrackingIntegrations)): scripts loaded via Google Tag Manager
|
|
15
|
+
|
|
16
|
+
## `createTracker`
|
|
17
|
+
|
|
18
|
+
Creates a "tracker" object that includes methods for user telemetry such as `click` and `visit`.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { createTracker } from '@codecademy/tracking';
|
|
22
|
+
|
|
23
|
+
const tracker = createTracker('apiBaseUrl', 'authToken');
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Event Usage
|
|
27
|
+
|
|
28
|
+
#### `click`
|
|
29
|
+
|
|
30
|
+
Tracks that a user has clicked an element on the page.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
tracker.click({
|
|
34
|
+
page_name: 'my_page',
|
|
35
|
+
target: 'my_button',
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Calls to _`event`_ internally.
|
|
40
|
+
|
|
41
|
+
#### `visit`
|
|
42
|
+
|
|
43
|
+
Tracks that a user has visited a page or sub-page.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
tracker.visit({
|
|
47
|
+
page_name: 'my_page',
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Calls to _`event`_ internally.
|
|
52
|
+
|
|
53
|
+
#### `event`
|
|
54
|
+
|
|
55
|
+
Generic event for any other event.
|
|
56
|
+
Events that are allowed to be used here are strongly typed in the `types.d.ts` file included in the package.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
tracker.event('calendar', 'reminder', data);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Miscellaneous Usage
|
|
63
|
+
|
|
64
|
+
#### `pushDataLayerEvent`
|
|
65
|
+
|
|
66
|
+
Adds a [GTM `dataLayer` event](https://developers.google.com/tag-manager/devguide) to the global `dataLayer` array.
|
|
67
|
+
If `dataLayer` does not exist, it will be created.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
tracker.pushDataLayerEvent('user_sign_up');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## `initializeTrackingIntegrations`
|
|
74
|
+
|
|
75
|
+
> See [GDPR Compliance on Notion](https://www.notion.so/codecademy/GDPR-Compliance-141ebcc7ffa542daa0da56e35f482b41) for full docs on external tracking.
|
|
76
|
+
|
|
77
|
+
Starts the initialization process for our third-party integrations.
|
|
78
|
+
|
|
79
|
+
Integrations are loaded in an intentionally layered manner for CCPA/GDPR compliance:
|
|
80
|
+
|
|
81
|
+
1. Wait 1000ms to allow any other post-hydration logic to run first
|
|
82
|
+
2. Load in OneTrust's banner and wait for its `OptanonWrapper` callback
|
|
83
|
+
3. [Segment's copy-and-paste snippet](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet) is run to load the Segment global library
|
|
84
|
+
4. Destination integrations for Segment are fetched
|
|
85
|
+
5. Those integrations are compared against the user's consent decisions into a list of allowed destinations
|
|
86
|
+
6. We load only those allowed destinations using Segment's `analytics.load`
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { initializeTrackingIntegrations } from '@codecademy/tracking';
|
|
90
|
+
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
initializeTrackingIntegrations({
|
|
93
|
+
onError: logger.error,
|
|
94
|
+
production: true,
|
|
95
|
+
scope: window,
|
|
96
|
+
user: { email: 'my@email.com', id: 'my-user-id' },
|
|
97
|
+
writeKey: 'my-segment-write-key',
|
|
98
|
+
});
|
|
99
|
+
}, 1000);
|
|
100
|
+
```
|
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
|
+
};
|
package/dist/events/types.d.ts
CHANGED
|
@@ -1,250 +1,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
|
-
};
|
|
51
|
-
search: {
|
|
52
|
-
visit: BaseEventAnyData;
|
|
53
|
-
click: BaseEventAnyData;
|
|
54
|
-
query: BaseEventAnyData;
|
|
55
|
-
result: BaseEventAnyData;
|
|
56
|
-
};
|
|
57
|
-
page: {
|
|
58
|
-
career_path_visited: PagePathVisitedData;
|
|
59
|
-
skill_path_visited: PagePathVisitedData;
|
|
60
|
-
course_page_visited: CoursePageVisitedData;
|
|
61
|
-
};
|
|
62
|
-
business: {
|
|
63
|
-
filter_event: BusinessFilterData;
|
|
64
|
-
search_event: BusinessSearchData;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Base event data shared by all events
|
|
69
|
-
*/
|
|
70
|
-
export declare type BaseEventData = {
|
|
71
|
-
fullpath?: null;
|
|
72
|
-
search?: null;
|
|
73
|
-
path?: null;
|
|
74
|
-
title?: null;
|
|
75
|
-
url?: null;
|
|
76
|
-
referrer?: string | null;
|
|
77
|
-
id?: null;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Generic type to use for event data not typed yet
|
|
81
|
-
*/
|
|
82
|
-
export declare type BaseEventAnyData = BaseEventData & {
|
|
83
|
-
[key: string]: any;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Options to pass to the tracking function
|
|
87
|
-
*/
|
|
88
|
-
export declare type TrackingOptions = {
|
|
89
|
-
/** tells backend not to merge user-identifying data onto the event payload */
|
|
90
|
-
gdprSafe?: boolean;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* The Content IDs related to the current event, to help build the content context of the event.
|
|
94
|
-
* These IDs get hashed into a single value and overwrite content_id before they are sent to
|
|
95
|
-
* redshift in lib/content_group_id.rb
|
|
96
|
-
*/
|
|
97
|
-
export declare type TrackingContentIds = {
|
|
98
|
-
assessment_id?: string;
|
|
99
|
-
content_item_id?: string;
|
|
100
|
-
exercise_id?: string;
|
|
101
|
-
learning_standard_id?: string;
|
|
102
|
-
module_id?: string;
|
|
103
|
-
path_id?: string;
|
|
104
|
-
program_id?: string;
|
|
105
|
-
program_unit_id?: string;
|
|
106
|
-
review_card_id?: string;
|
|
107
|
-
track_id?: string;
|
|
108
|
-
journey_id?: string;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Shared data relevant for all user events
|
|
112
|
-
*/
|
|
113
|
-
export declare type UserSharedData = BaseEventData & {
|
|
114
|
-
/** the click target of the event */
|
|
115
|
-
target?: string;
|
|
116
|
-
/** the page the event is coming from */
|
|
117
|
-
page_name?: string;
|
|
118
|
-
/** a context id for the event, for events that occur in more than one place */
|
|
119
|
-
context?: string;
|
|
120
|
-
/** the link being clicked on */
|
|
121
|
-
href?: string;
|
|
122
|
-
/** a version id for the element (ex. different version ids for redesigns) */
|
|
123
|
-
version?: string;
|
|
124
|
-
/** an object of content ids related to this event */
|
|
125
|
-
content_ids?: TrackingContentIds;
|
|
126
|
-
/** the repo that this event is being fired from */
|
|
127
|
-
source_codebase?: string;
|
|
128
|
-
/** Should be used for arbitrary JSON that has been passed through JSON.stringify. */
|
|
129
|
-
misc?: string;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Data sent to user click event table
|
|
133
|
-
* NOTE: avoid adding additional properties to these objects
|
|
134
|
-
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
135
|
-
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
136
|
-
*/
|
|
137
|
-
export declare type UserClickData = UserSharedData & {
|
|
138
|
-
target: string;
|
|
139
|
-
id?: string;
|
|
140
|
-
distinct_id?: string;
|
|
141
|
-
content_id?: string;
|
|
142
|
-
slug?: string;
|
|
143
|
-
name?: string;
|
|
144
|
-
action?: string;
|
|
145
|
-
type?: string;
|
|
146
|
-
location?: string;
|
|
147
|
-
element?: string;
|
|
148
|
-
weekly_goal?: string | number;
|
|
149
|
-
complete?: string;
|
|
150
|
-
video_url?: string;
|
|
151
|
-
path_id?: string;
|
|
152
|
-
path_slug?: string;
|
|
153
|
-
event_name?: string;
|
|
154
|
-
onboarding_entrypoint?: string;
|
|
155
|
-
content_slug?: string;
|
|
156
|
-
module_id?: string;
|
|
157
|
-
track_slug?: string;
|
|
158
|
-
module_slug?: string;
|
|
159
|
-
button?: string;
|
|
160
|
-
current_challenge_day?: string | number;
|
|
161
|
-
track_id?: string;
|
|
162
|
-
course?: string;
|
|
163
|
-
path_name?: string;
|
|
164
|
-
event_id?: string;
|
|
165
|
-
unit?: string;
|
|
166
|
-
lesson?: string;
|
|
167
|
-
community_prompt?: string;
|
|
168
|
-
contentItem?: any;
|
|
169
|
-
unit_slug?: string;
|
|
170
|
-
course_slug?: string;
|
|
171
|
-
course_progress?: number;
|
|
172
|
-
assessment_id?: string;
|
|
173
|
-
container_slugs?: string[];
|
|
174
|
-
search_id?: string;
|
|
175
|
-
is_ugc?: boolean;
|
|
176
|
-
business_user?: BaseEventAnyData;
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Data sent to user visit event table
|
|
180
|
-
* NOTE: avoid adding additional properties to these objects
|
|
181
|
-
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
182
|
-
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
183
|
-
*/
|
|
184
|
-
export declare type UserVisitData = UserSharedData & {
|
|
185
|
-
page_name: string;
|
|
186
|
-
category?: string;
|
|
187
|
-
distinct_id?: string;
|
|
188
|
-
type?: string;
|
|
189
|
-
target?: string;
|
|
190
|
-
section?: string;
|
|
191
|
-
plan?: string;
|
|
192
|
-
path_id?: string;
|
|
193
|
-
post?: string;
|
|
194
|
-
story_type?: string;
|
|
195
|
-
path_title?: string;
|
|
196
|
-
onboarding_entrypoint?: string;
|
|
197
|
-
course_slug?: string;
|
|
198
|
-
course?: string;
|
|
199
|
-
interstitial_name?: string;
|
|
200
|
-
content_id?: string;
|
|
201
|
-
story_slug?: string;
|
|
202
|
-
unit?: string;
|
|
203
|
-
lesson?: string;
|
|
204
|
-
is_ugc?: boolean;
|
|
205
|
-
};
|
|
206
|
-
export declare type UserImpressionData = Pick<UserSharedData, 'context' | 'source_codebase' | 'content_ids'> & {
|
|
207
|
-
page_name: string;
|
|
208
|
-
target: string;
|
|
209
|
-
slug?: string;
|
|
210
|
-
is_ugc?: boolean;
|
|
211
|
-
};
|
|
212
|
-
export declare type EventAnswerData = BaseEventData & {
|
|
213
|
-
question_index: number;
|
|
214
|
-
answer_index: number;
|
|
215
|
-
answer: any;
|
|
216
|
-
answer_slug: string;
|
|
217
|
-
};
|
|
218
|
-
export declare type User = {
|
|
219
|
-
id?: string;
|
|
220
|
-
auth_token: string;
|
|
221
|
-
profile_image_url?: string;
|
|
222
|
-
email?: string;
|
|
223
|
-
is_pro?: boolean;
|
|
224
|
-
username?: string;
|
|
225
|
-
location: {
|
|
226
|
-
in_eu: boolean;
|
|
227
|
-
geo_country: string;
|
|
228
|
-
};
|
|
229
|
-
features: string[];
|
|
230
|
-
};
|
|
231
|
-
export declare type UseUserResponse = {
|
|
232
|
-
user?: User;
|
|
233
|
-
status: string;
|
|
234
|
-
};
|
|
235
|
-
export declare type PagePathVisitedData = BaseEventData & {
|
|
236
|
-
path_id: string;
|
|
237
|
-
path_full_title: string;
|
|
238
|
-
};
|
|
239
|
-
export declare type CoursePageVisitedData = BaseEventData & {
|
|
240
|
-
course_id: string;
|
|
241
|
-
course_full_title: string;
|
|
242
|
-
};
|
|
243
|
-
export declare type FilterType = string | string[] | number | boolean;
|
|
244
|
-
export declare type BusinessFilterData = BaseEventData & {
|
|
245
|
-
filter_key: string;
|
|
246
|
-
filter_value: FilterType;
|
|
247
|
-
};
|
|
248
|
-
export declare type BusinessSearchData = BaseEventData & {
|
|
249
|
-
search_query: string;
|
|
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
|
+
};
|
|
51
|
+
search: {
|
|
52
|
+
visit: BaseEventAnyData;
|
|
53
|
+
click: BaseEventAnyData;
|
|
54
|
+
query: BaseEventAnyData;
|
|
55
|
+
result: BaseEventAnyData;
|
|
56
|
+
};
|
|
57
|
+
page: {
|
|
58
|
+
career_path_visited: PagePathVisitedData;
|
|
59
|
+
skill_path_visited: PagePathVisitedData;
|
|
60
|
+
course_page_visited: CoursePageVisitedData;
|
|
61
|
+
};
|
|
62
|
+
business: {
|
|
63
|
+
filter_event: BusinessFilterData;
|
|
64
|
+
search_event: BusinessSearchData;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Base event data shared by all events
|
|
69
|
+
*/
|
|
70
|
+
export declare type BaseEventData = {
|
|
71
|
+
fullpath?: null;
|
|
72
|
+
search?: null;
|
|
73
|
+
path?: null;
|
|
74
|
+
title?: null;
|
|
75
|
+
url?: null;
|
|
76
|
+
referrer?: string | null;
|
|
77
|
+
id?: null;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Generic type to use for event data not typed yet
|
|
81
|
+
*/
|
|
82
|
+
export declare type BaseEventAnyData = BaseEventData & {
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Options to pass to the tracking function
|
|
87
|
+
*/
|
|
88
|
+
export declare type TrackingOptions = {
|
|
89
|
+
/** tells backend not to merge user-identifying data onto the event payload */
|
|
90
|
+
gdprSafe?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The Content IDs related to the current event, to help build the content context of the event.
|
|
94
|
+
* These IDs get hashed into a single value and overwrite content_id before they are sent to
|
|
95
|
+
* redshift in lib/content_group_id.rb
|
|
96
|
+
*/
|
|
97
|
+
export declare type TrackingContentIds = {
|
|
98
|
+
assessment_id?: string;
|
|
99
|
+
content_item_id?: string;
|
|
100
|
+
exercise_id?: string;
|
|
101
|
+
learning_standard_id?: string;
|
|
102
|
+
module_id?: string;
|
|
103
|
+
path_id?: string;
|
|
104
|
+
program_id?: string;
|
|
105
|
+
program_unit_id?: string;
|
|
106
|
+
review_card_id?: string;
|
|
107
|
+
track_id?: string;
|
|
108
|
+
journey_id?: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Shared data relevant for all user events
|
|
112
|
+
*/
|
|
113
|
+
export declare type UserSharedData = BaseEventData & {
|
|
114
|
+
/** the click target of the event */
|
|
115
|
+
target?: string;
|
|
116
|
+
/** the page the event is coming from */
|
|
117
|
+
page_name?: string;
|
|
118
|
+
/** a context id for the event, for events that occur in more than one place */
|
|
119
|
+
context?: string;
|
|
120
|
+
/** the link being clicked on */
|
|
121
|
+
href?: string;
|
|
122
|
+
/** a version id for the element (ex. different version ids for redesigns) */
|
|
123
|
+
version?: string;
|
|
124
|
+
/** an object of content ids related to this event */
|
|
125
|
+
content_ids?: TrackingContentIds;
|
|
126
|
+
/** the repo that this event is being fired from */
|
|
127
|
+
source_codebase?: string;
|
|
128
|
+
/** Should be used for arbitrary JSON that has been passed through JSON.stringify. */
|
|
129
|
+
misc?: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Data sent to user click event table
|
|
133
|
+
* NOTE: avoid adding additional properties to these objects
|
|
134
|
+
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
135
|
+
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
136
|
+
*/
|
|
137
|
+
export declare type UserClickData = UserSharedData & {
|
|
138
|
+
target: string;
|
|
139
|
+
id?: string;
|
|
140
|
+
distinct_id?: string;
|
|
141
|
+
content_id?: string;
|
|
142
|
+
slug?: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
action?: string;
|
|
145
|
+
type?: string;
|
|
146
|
+
location?: string;
|
|
147
|
+
element?: string;
|
|
148
|
+
weekly_goal?: string | number;
|
|
149
|
+
complete?: string;
|
|
150
|
+
video_url?: string;
|
|
151
|
+
path_id?: string;
|
|
152
|
+
path_slug?: string;
|
|
153
|
+
event_name?: string;
|
|
154
|
+
onboarding_entrypoint?: string;
|
|
155
|
+
content_slug?: string;
|
|
156
|
+
module_id?: string;
|
|
157
|
+
track_slug?: string;
|
|
158
|
+
module_slug?: string;
|
|
159
|
+
button?: string;
|
|
160
|
+
current_challenge_day?: string | number;
|
|
161
|
+
track_id?: string;
|
|
162
|
+
course?: string;
|
|
163
|
+
path_name?: string;
|
|
164
|
+
event_id?: string;
|
|
165
|
+
unit?: string;
|
|
166
|
+
lesson?: string;
|
|
167
|
+
community_prompt?: string;
|
|
168
|
+
contentItem?: any;
|
|
169
|
+
unit_slug?: string;
|
|
170
|
+
course_slug?: string;
|
|
171
|
+
course_progress?: number;
|
|
172
|
+
assessment_id?: string;
|
|
173
|
+
container_slugs?: string[];
|
|
174
|
+
search_id?: string;
|
|
175
|
+
is_ugc?: boolean;
|
|
176
|
+
business_user?: BaseEventAnyData;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Data sent to user visit event table
|
|
180
|
+
* NOTE: avoid adding additional properties to these objects
|
|
181
|
+
* Instead, reuse existing properties, or make any additional properties generic so that they can be reused.
|
|
182
|
+
* https://www.notion.so/codecademy/Guide-to-Event-Tracking-Schema-5d40b09a297743f7a30a2690208194c8#800bbf6cdf2e44de9823cd75bcc574e5
|
|
183
|
+
*/
|
|
184
|
+
export declare type UserVisitData = UserSharedData & {
|
|
185
|
+
page_name: string;
|
|
186
|
+
category?: string;
|
|
187
|
+
distinct_id?: string;
|
|
188
|
+
type?: string;
|
|
189
|
+
target?: string;
|
|
190
|
+
section?: string;
|
|
191
|
+
plan?: string;
|
|
192
|
+
path_id?: string;
|
|
193
|
+
post?: string;
|
|
194
|
+
story_type?: string;
|
|
195
|
+
path_title?: string;
|
|
196
|
+
onboarding_entrypoint?: string;
|
|
197
|
+
course_slug?: string;
|
|
198
|
+
course?: string;
|
|
199
|
+
interstitial_name?: string;
|
|
200
|
+
content_id?: string;
|
|
201
|
+
story_slug?: string;
|
|
202
|
+
unit?: string;
|
|
203
|
+
lesson?: string;
|
|
204
|
+
is_ugc?: boolean;
|
|
205
|
+
};
|
|
206
|
+
export declare type UserImpressionData = Pick<UserSharedData, 'context' | 'source_codebase' | 'content_ids'> & {
|
|
207
|
+
page_name: string;
|
|
208
|
+
target: string;
|
|
209
|
+
slug?: string;
|
|
210
|
+
is_ugc?: boolean;
|
|
211
|
+
};
|
|
212
|
+
export declare type EventAnswerData = BaseEventData & {
|
|
213
|
+
question_index: number;
|
|
214
|
+
answer_index: number;
|
|
215
|
+
answer: any;
|
|
216
|
+
answer_slug: string;
|
|
217
|
+
};
|
|
218
|
+
export declare type User = {
|
|
219
|
+
id?: string;
|
|
220
|
+
auth_token: string;
|
|
221
|
+
profile_image_url?: string;
|
|
222
|
+
email?: string;
|
|
223
|
+
is_pro?: boolean;
|
|
224
|
+
username?: string;
|
|
225
|
+
location: {
|
|
226
|
+
in_eu: boolean;
|
|
227
|
+
geo_country: string;
|
|
228
|
+
};
|
|
229
|
+
features: string[];
|
|
230
|
+
};
|
|
231
|
+
export declare type UseUserResponse = {
|
|
232
|
+
user?: User;
|
|
233
|
+
status: string;
|
|
234
|
+
};
|
|
235
|
+
export declare type PagePathVisitedData = BaseEventData & {
|
|
236
|
+
path_id: string;
|
|
237
|
+
path_full_title: string;
|
|
238
|
+
};
|
|
239
|
+
export declare type CoursePageVisitedData = BaseEventData & {
|
|
240
|
+
course_id: string;
|
|
241
|
+
course_full_title: string;
|
|
242
|
+
};
|
|
243
|
+
export declare type FilterType = string | string[] | number | boolean;
|
|
244
|
+
export declare type BusinessFilterData = BaseEventData & {
|
|
245
|
+
filter_key: string;
|
|
246
|
+
filter_value: FilterType;
|
|
247
|
+
};
|
|
248
|
+
export declare type BusinessSearchData = BaseEventData & {
|
|
249
|
+
search_query: string;
|
|
250
|
+
};
|
package/dist/events/user.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { User } from './types';
|
|
2
|
-
export declare const fetchUser: (apiBaseUrl: string) => Promise<User>;
|
|
1
|
+
import { User } from './types';
|
|
2
|
+
export declare const fetchUser: (apiBaseUrl: string) => Promise<User>;
|