@codecademy/tracking 1.0.3-alpha.49041f645.0 → 1.0.3-alpha.baf09f912.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/package.json +2 -2
- package/dist/events/index.d.ts +0 -3
- package/dist/events/track.d.ts +0 -12
- package/dist/events/types.d.ts +0 -250
- package/dist/events/user.d.ts +0 -2
- package/dist/integrations/conditionallyLoadAnalytics.d.ts +0 -9
- package/dist/integrations/consent.d.ts +0 -9
- package/dist/integrations/device.d.ts +0 -13
- package/dist/integrations/fetchDestinationsForWriteKey.d.ts +0 -6
- package/dist/integrations/getConsentDecision.d.ts +0 -8
- package/dist/integrations/index.d.ts +0 -31
- package/dist/integrations/mapDestinations.d.ts +0 -13
- package/dist/integrations/onetrust.d.ts +0 -6
- package/dist/integrations/runSegmentSnippet.d.ts +0 -7
- package/dist/integrations/types.d.ts +0 -24
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.3-alpha.
|
|
4
|
+
"version": "1.0.3-alpha.baf09f912.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": "5a5ccc11f8bb80d0e4b39aef485cba264ffc7b18"
|
|
20
20
|
}
|
package/dist/events/index.d.ts
DELETED
package/dist/events/track.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SegmentAnalytics, UserIntegrationSummary } from './types';
|
|
2
|
-
export declare type AnalyticsLoadOptions = {
|
|
3
|
-
analytics: SegmentAnalytics;
|
|
4
|
-
destinationPreferences: Record<string, boolean>;
|
|
5
|
-
identifyPreferences: Record<string, boolean>;
|
|
6
|
-
user?: UserIntegrationSummary;
|
|
7
|
-
writeKey: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const conditionallyLoadAnalytics: ({ analytics, destinationPreferences, identifyPreferences, user, writeKey, }: AnalyticsLoadOptions) => void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @returns Whether the site is running both in ChromeOS and in PWA mode.
|
|
3
|
-
*/
|
|
4
|
-
export declare const isChromeOSPWA: () => boolean;
|
|
5
|
-
/**
|
|
6
|
-
* @returns Whether the site is running in ChromeOS
|
|
7
|
-
*/
|
|
8
|
-
export declare const isChromeOS: () => boolean;
|
|
9
|
-
export declare enum ClientTypes {
|
|
10
|
-
PWA = "pwa",
|
|
11
|
-
Default = "default"
|
|
12
|
-
}
|
|
13
|
-
export declare const getClientType: () => ClientTypes;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SegmentDestination } from './types';
|
|
2
|
-
export declare type FetchDestinationsSettings = {
|
|
3
|
-
onError: (message: string) => void;
|
|
4
|
-
writeKey: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const fetchDestinationsForWriteKey: ({ writeKey, onError, }: FetchDestinationsSettings) => Promise<SegmentDestination[] | undefined>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Consent } from './consent';
|
|
2
|
-
import { TrackingWindow } from './types';
|
|
3
|
-
export interface ConsentDecisionOptions {
|
|
4
|
-
scope: TrackingWindow;
|
|
5
|
-
optedOutExternalTracking?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare const OPT_OUT_DATALAYER_VAR = "user_opted_out_external_tracking";
|
|
8
|
-
export declare const getConsentDecision: ({ scope, optedOutExternalTracking, }: ConsentDecisionOptions) => Consent[];
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { TrackingWindow, UserIntegrationSummary } from './types';
|
|
2
|
-
export declare type TrackingIntegrationsSettings = {
|
|
3
|
-
/**
|
|
4
|
-
* Called whenever a network request fails.
|
|
5
|
-
*/
|
|
6
|
-
onError: (message: string) => void;
|
|
7
|
-
/**
|
|
8
|
-
* Whether this is running in a production environment.
|
|
9
|
-
*/
|
|
10
|
-
production: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Global scope (often the window) where globals such as analytics are stored.
|
|
13
|
-
*/
|
|
14
|
-
scope: TrackingWindow;
|
|
15
|
-
/**
|
|
16
|
-
* User details to identify in Segment.
|
|
17
|
-
*/
|
|
18
|
-
user?: UserIntegrationSummary;
|
|
19
|
-
/**
|
|
20
|
-
* Whether user has opted out or is excluded from external tracking
|
|
21
|
-
*/
|
|
22
|
-
optedOutExternalTracking?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Segment write key.
|
|
25
|
-
*/
|
|
26
|
-
writeKey: string;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* @see README.md for details and usage.
|
|
30
|
-
*/
|
|
31
|
-
export declare const initializeTrackingIntegrations: ({ onError, production, scope, user, optedOutExternalTracking, writeKey, }: TrackingIntegrationsSettings) => Promise<void>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Consent } from './consent';
|
|
2
|
-
import { SegmentDestination } from './types';
|
|
3
|
-
export declare type DestinationMapOptions = {
|
|
4
|
-
consentDecision?: Consent[];
|
|
5
|
-
destinations: SegmentDestination[];
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* @see https://www.notion.so/codecademy/GDPR-Compliance-141ebcc7ffa542daa0da56e35f482b41
|
|
9
|
-
*/
|
|
10
|
-
export declare const mapDestinations: ({ consentDecision, destinations, }: DestinationMapOptions) => {
|
|
11
|
-
destinationPreferences: Record<string, boolean>;
|
|
12
|
-
identifyPreferences: Record<string, boolean>;
|
|
13
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code is copypasta from the Segment documentation.
|
|
3
|
-
* It creates the global analytics object and loads the Segment Analytics API that uses it.
|
|
4
|
-
*
|
|
5
|
-
* @see https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet
|
|
6
|
-
*/
|
|
7
|
-
export declare const runSegmentSnippet: () => void;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Consent } from './consent';
|
|
2
|
-
export interface UserIntegrationSummary {
|
|
3
|
-
email: string;
|
|
4
|
-
id: string;
|
|
5
|
-
}
|
|
6
|
-
export interface SegmentAnalytics {
|
|
7
|
-
identify(id: string, details: Record<string, string>, options: SegmentAnalyticsOptions): void;
|
|
8
|
-
initialize?: boolean;
|
|
9
|
-
load(writeKey: string, options: SegmentAnalyticsOptions): void;
|
|
10
|
-
page(): void;
|
|
11
|
-
}
|
|
12
|
-
export interface SegmentDestination {
|
|
13
|
-
category: string;
|
|
14
|
-
id: string;
|
|
15
|
-
}
|
|
16
|
-
export interface SegmentAnalyticsOptions {
|
|
17
|
-
integrations: Record<string, boolean>;
|
|
18
|
-
}
|
|
19
|
-
export interface TrackingWindow {
|
|
20
|
-
analytics?: SegmentAnalytics;
|
|
21
|
-
dataLayer?: unknown[];
|
|
22
|
-
OnetrustActiveGroups?: Consent[] | string;
|
|
23
|
-
OptanonWrapper?: () => void;
|
|
24
|
-
}
|