PageSourceSearch

https://www.sportingkc.com/assets/js/scripts_libraries__modules_tr…?_t=0f53d29a227a435a6649

js sportingkc.com collected 2026-09-24 09:17:38 UTC 35,421 bytes, 895 lines download raw bytes

1"use strict";
2(self["webpackChunk_mlssoccer_netcore"] = self["webpackChunk_mlssoccer_netcore"] || []).push([["scripts_libraries__modules_tracking_snowplow_snowplowEventTrackers_js-scripts_libraries__modu-33d9b7"],{
3
4/***/ "./scripts/libraries/_modules/tracking/snowplow/schemaValidation.js":
5/*!**************************************************************************!*\
6  !*** ./scripts/libraries/_modules/tracking/snowplow/schemaValidation.js ***!
7  \**************************************************************************/
8/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9
10__webpack_require__.r(__webpack_exports__);
11/* harmony export */ __webpack_require__.d(__webpack_exports__, {
12/* harmony export */   "validateClubContext": () => (/* binding */ validateClubContext),
13/* harmony export */   "validateContentMetadata": () => (/* binding */ validateContentMetadata),
14/* harmony export */   "validateMatchContext": () => (/* binding */ validateMatchContext),
15/* harmony export */   "validatePlayerContext": () => (/* binding */ validatePlayerContext),
16/* harmony export */   "validateTopicContext": () => (/* binding */ validateTopicContext),
17/* harmony export */   "validateUiInteractionEvent": () => (/* binding */ validateUiInteractionEvent)
18/* harmony export */ });
19/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./scripts/libraries/_modules/tracking/snowplow/utils.js");
20
21function validateObjectData({ data, fieldsConfig, requiredFields }) {
22  if (!data)
23    return null;
24  const missingFields = requiredFields.filter((field) => !data[field]);
25  if (missingFields.length > 0) {
26    return null;
27  }
28  const validatedData = {};
29  Object.entries(fieldsConfig).forEach(([field, config]) => {
30    const value = data[field];
31    if (config.type === "string") {
32      validatedData[field] = value ? String(value) : null;
33    } else if (config.type === "number" || config.type === "integer") {
34      validatedData[field] = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.validateNumber)(value);
35    } else if (config.type === "date") {
36      validatedData[field] = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.validateDate)(value);
37    } else if (config.type === "datetime") {
38      validatedData[field] = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.validateDateTime)(value);
39    } else if (config.type === "enum" && value) {
40      validatedData[field] = config.values.includes(value) ? value : null;
41    } else {
42      validatedData[field] = value || null;
43    }
44  });
45  Object.keys(validatedData).forEach((key) => {
46    if (validatedData[key] === null || validatedData[key] === void 0) {
47      delete validatedData[key];
48    }
49  });
50  return validatedData;
51}
52function validateContentMetadata(data) {
53  const fieldsConfig = {
54    content_id: { type: "string" },
55    content_title: { type: "string" },
56    slug: { type: "string" },
57    content_format: { type: "string" },
58    content_type: { type: "string" },
59    embedded_content_id: { type: "string" },
60    asset_type: { type: "string" },
61    word_count: { type: "integer" },
62    duration_time: { type: "number" },
63    publish_date: { type: "date" },
64    topic_primary: { type: "string" },
65    topic_secondary: { type: "string" },
66    language: { type: "string" },
67    author: { type: "string" }
68  };
69  const requiredFields = ["content_id", "content_title", "slug"];
70  return validateObjectData({ data, fieldsConfig, requiredFields });
71}
72function validateUiInteractionEvent(data) {
73  const fieldsConfig = {
74    element_name: { type: "string" },
75    interaction_type: {
76      type: "enum",
77      values: ["click", "tap", "hover", "scroll", "swipe", "drag", "long_press"]
78    },
79    element_type: { type: "string" },
80    element_position: { type: "string" }
81  };
82  const requiredFields = ["element_name", "interaction_type"];
83  return validateObjectData({ data, fieldsConfig, requiredFields });
84}
85function validateMatchContext(data) {
86  const fieldsConfig = {
87    match_id: { type: "string" },
88    home_team: { type: "string" },
89    away_team: { type: "string" },
90    kickoff_time: { type: "datetime" },
91    home_team_id: { type: "string" },
92    away_team_id: { type: "string" },
93    venue: { type: "string" },
94    match_status: { type: "string" }
95  };
96  const requiredFields = ["match_id", "home_team", "away_team", "kickoff_time"];
97  return validateObjectData({ data, fieldsConfig, requiredFields });
98}
99function validateClubContext(data) {
100  const fieldsConfig = {
101    club_id: { type: "string" },
102    club_name: { type: "string" },
103    club_city: { type: "string" },
104    club_fanbase_size: { type: "integer" }
105  };
106  const requiredFields = ["club_id", "club_name"];
107  return validateObjectData({ data, fieldsConfig, requiredFields });
108}
109function validatePlayerContext(data) {
110  const fieldsConfig = {
111    player_id: { type: "string" },
112    player_name: { type: "string" },
113    player_team: { type: "string" },
114    player_position: { type: "string" },
115    jersey_number: { type: "integer" }
116  };
117  const requiredFields = ["player_id", "player_name"];
118  return validateObjectData({ data, fieldsConfig, requiredFields });
119}
120function validateTopicContext(data) {
121  const fieldsConfig = {
122    topic_id: { type: "string" },
123    topic_name: { type: "string" },
124    topic_slug: { type: "string" },
125    topic_type: { type: "string" }
126  };
127  const requiredFields = ["topic_id", "topic_name", "topic_slug", "topic_type"];
128  return validateObjectData({ data, fieldsConfig, requiredFields });
129}
130
131
132/***/ }),
133
134/***/ "./scripts/libraries/_modules/tracking/snowplow/snowplowEventTrackers.js":
135/*!*******************************************************************************!*\
136  !*** ./scripts/libraries/_modules/tracking/snowplow/snowplowEventTrackers.js ***!
137  \*******************************************************************************/
138/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
139
140__webpack_require__.r(__webpack_exports__);
141/* harmony export */ __webpack_require__.d(__webpack_exports__, {
142/* harmony export */   "trackCustomSnowplowEvent": () => (/* binding */ trackCustomSnowplowEvent),
143/* harmony export */   "trackPageView": () => (/* binding */ trackPageView)
144/* harmony export */ });
145function trackCustomSnowplowEvent(primaryEvent, contexts = []) {
146  if (!primaryEvent) {
147    console.warn("No primary event provided. Event not sent.");
148    return;
149  }
150  const validContexts = contexts.filter((context) => context !== null && context !== void 0);
151  if (typeof window !== "undefined" && window.snowplow && typeof window.snowplow === "function") {
152    window.snowplow("trackSelfDescribingEvent", {
153      event: primaryEvent,
154      context: validContexts
155    });
156  } else {
157    console.warn("Snowplow tracker not available or not a function. Event not sent:", { primaryEvent, contexts });
158  }
159}
160function trackPageView({ page_url = window.location.href, page_title = document.title, contexts = [], true_timestamp }) {
161  const validContexts = contexts.filter((context) => context !== null);
162  if (validContexts.length === 0) {
163    console.warn("No valid contexts provided. Page view not tracked:", { page_url, page_title, contexts });
164    return;
165  }
166  if (typeof window !== "undefined" && window.snowplow && typeof window.snowplow === "function") {
167    window.snowplow("trackPageView", {
168      title: page_title,
169      context: validContexts
170    });
171  } else {
172    console.warn("Snowplow tracker not available or not a function. Page view not tracked:", { page_url, page_title, contexts });
173  }
174}
175
176
177/***/ }),
178
179/***/ "./scripts/libraries/_modules/tracking/snowplow/snowplowTracking.js":
180/*!**************************************************************************!*\
181  !*** ./scripts/libraries/_modules/tracking/snowplow/snowplowTracking.js ***!
182  \**************************************************************************/
183/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
184
185__webpack_require__.r(__webpack_exports__);
186/* harmony export */ __webpack_require__.d(__webpack_exports__, {
187/* harmony export */   "CAMPAIGN_CONTEXT_SCHEMA": () => (/* binding */ CAMPAIGN_CONTEXT_SCHEMA),
188/* harmony export */   "CHANNEL_CATEGORY_CONTEXT_SCHEMA": () => (/* binding */ CHANNEL_CATEGORY_CONTEXT_SCHEMA),
189/* harmony export */   "CLUB_CONTEXT_SCHEMA": () => (/* binding */ CLUB_CONTEXT_SCHEMA),
190/* harmony export */   "COMPETITION_CONTEXT_SCHEMA": () => (/* binding */ COMPETITION_CONTEXT_SCHEMA),
191/* harmony export */   "CONTENT_METADATA_CONTEXT_SCHEMA": () => (/* binding */ CONTENT_METADATA_CONTEXT_SCHEMA),
192/* harmony export */   "LIKE_ACTION_SCHEMA": () => (/* binding */ LIKE_ACTION_SCHEMA),
193/* harmony export */   "MATCH_CONTEXT_SCHEMA": () => (/* binding */ MATCH_CONTEXT_SCHEMA),
194/* harmony export */   "PLAYER_CONTEXT_SCHEMA": () => (/* binding */ PLAYER_CONTEXT_SCHEMA),
195/* harmony export */   "SHARE_ACTION_SCHEMA": () => (/* binding */ SHARE_ACTION_SCHEMA),
196/* harmony export */   "TOPIC_CONTEXT_SCHEMA": () => (/* binding */ TOPIC_CONTEXT_SCHEMA),
197/* harmony export */   "UI_INTERACTION_SCHEMA": () => (/* binding */ UI_INTERACTION_SCHEMA),
198/* harmony export */   "composeChannelCategoryContextData": () => (/* binding */ composeChannelCategoryContextData),
199/* harmony export */   "composeContentMetadataContextData": () => (/* binding */ composeContentMetadataContextData),
200/* harmony export */   "composeMLSClubContextData": () => (/* binding */ composeMLSClubContextData),
201/* harmony export */   "composeMLSCompetitionContextData": () => (/* binding */ composeMLSCompetitionContextData),
202/* harmony export */   "composeMLSMatchContextData": () => (/* binding */ composeMLSMatchContextData),
203/* harmony export */   "composeTopicContextData": () => (/* binding */ composeTopicContextData),
204/* harmony export */   "createCampaignContext": () => (/* binding */ createCampaignContext),
205/* harmony export */   "createChannelCategoryContext": () => (/* binding */ createChannelCategoryContext),
206/* harmony export */   "createClubContext": () => (/* binding */ createClubContext),
207/* harmony export */   "createCompetitionContext": () => (/* binding */ createCompetitionContext),
208/* harmony export */   "createContentMetadataContext": () => (/* binding */ createContentMetadataContext),
209/* harmony export */   "createLikeActionEvent": () => (/* binding */ createLikeActionEvent),
210/* harmony export */   "createMatchContext": () => (/* binding */ createMatchContext),
211/* harmony export */   "createPlayerContext": () => (/* binding */ createPlayerContext),
212/* harmony export */   "createShareActionEvent": () => (/* binding */ createShareActionEvent),
213/* harmony export */   "createTopicContext": () => (/* binding */ createTopicContext),
214/* harmony export */   "createUiInteractionPrimaryEvent": () => (/* binding */ createUiInteractionPrimaryEvent),
215/* harmony export */   "getDynamicArticleData": () => (/* binding */ getDynamicArticleData),
216/* harmony export */   "getDynamicClubData": () => (/* binding */ getDynamicClubData),
217/* harmony export */   "getDynamicPlayerData": () => (/* binding */ getDynamicPlayerData),
218/* harmony export */   "getDynamicVideoPlaylistData": () => (/* binding */ getDynamicVideoPlaylistData)
219/* harmony export */ });
220/* harmony import */ var _react_shared_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../react/shared/utils */ "./scripts/react/shared/utils.js");
221/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./scripts/libraries/_modules/tracking/snowplow/utils.js");
222/* harmony import */ var _schemaValidation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./schemaValidation */ "./scripts/libraries/_modules/tracking/snowplow/schemaValidation.js");
223
224
225
226const UI_INTERACTION_SCHEMA = "iglu:com.mlssoccer/ui_interaction_event/jsonschema/1-0-0";
227const LIKE_ACTION_SCHEMA = "iglu:com.mlssoccer/like_context/jsonschema/1-0-0";
228const SHARE_ACTION_SCHEMA = "iglu:com.mlssoccer/share_context/jsonschema/1-0-0";
229const MATCH_CONTEXT_SCHEMA = "iglu:com.mlssoccer/match_context/jsonschema/1-0-0";
230const CLUB_CONTEXT_SCHEMA = "iglu:com.mlssoccer/club_context/jsonschema/1-0-0";
231const COMPETITION_CONTEXT_SCHEMA = "iglu:com.mlssoccer/competition_context/jsonschema/1-0-0";
232const PLAYER_CONTEXT_SCHEMA = "iglu:com.mlssoccer/player_context/jsonschema/1-0-0";
233const CAMPAIGN_CONTEXT_SCHEMA = "iglu:com.mlssoccer/campaign_context/jsonschema/1-0-0";
234const CHANNEL_CATEGORY_CONTEXT_SCHEMA = "iglu:com.mlssoccer/channel_category_context/jsonschema/1-0-0";
235const CONTENT_METADATA_CONTEXT_SCHEMA = "iglu:com.mlssoccer/content_metadata/jsonschema/1-0-0";
236const TOPIC_CONTEXT_SCHEMA = "iglu:com.mlssoccer/topic_context/jsonschema/1-0-0";
237function createUiInteractionPrimaryEvent({ element_name, interaction_type, element_type, element_position }) {
238  const data = {
239    element_name,
240    interaction_type,
241    element_type,
242    element_position
243  };
244  const validatedData = (0,_schemaValidation__WEBPACK_IMPORTED_MODULE_2__.validateUiInteractionEvent)(data);
245  if (!validatedData) {
246    return null;
247  }
248  return {
249    schema: UI_INTERACTION_SCHEMA,
250    data: validatedData
251  };
252}
253function createMatchContext({ match_id, home_team, away_team, kickoff_time, home_team_id, away_team_id, venue, match_status } = {}) {
254  if (!match_id || !home_team || !away_team || !kickoff_time) {
255    return null;
256  }
257  const data = {
258    match_id,
259    home_team,
260    away_team,
261    kickoff_time: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDateTime)(kickoff_time),
262    home_team_id,
263    away_team_id,
264    venue,
265    match_status
266  };
267  const validatedData = (0,_schemaValidation__WEBPACK_IMPORTED_MODULE_2__.validateMatchContext)(data);
268  if (!validatedData) {
269    return null;
270  }
271  return {
272    schema: MATCH_CONTEXT_SCHEMA,
273    data: validatedData
274  };
275}
276function createClubContext({ club_id = null, club_name = null, club_city = null } = {}) {
277  if (!club_id || !club_name) {
278    return null;
279  }
280  const data = {
281    club_id,
282    club_name,
283    club_city
284  };
285  const validatedData = (0,_schemaValidation__WEBPACK_IMPORTED_MODULE_2__.validateClubContext)(data);
286  if (!validatedData) {
287    return null;
288  }
289  return {
290    schema: CLUB_CONTEXT_SCHEMA,
291    data: validatedData
292  };
293}
294function createCompetitionContext({ competition_id = null, competition_name = null, season = null, start_date = null, end_date = null, number_of_teams = null } = {}) {
295  if (!competition_id || !competition_name || !season) {
296    return null;
297  }
298  return {
299    schema: COMPETITION_CONTEXT_SCHEMA,
300    data: {
301      competition_id,
302      competition_name,
303      season: (season || phase).toString(),
304      start_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(start_date),
305      end_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(end_date),
306      number_of_teams: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(number_of_teams)
307    }
308  };
309}
310function createPlayerContext({ player_id = null, player_name = null, player_team = null, player_position = null, jersey_number = null } = {}) {
311  if (!player_id || !player_name) {
312    return null;
313  }
314  const data = {
315    player_id,
316    player_name,
317    player_team,
318    player_position,
319    jersey_number: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(jersey_number)
320  };
321  const validatedData = (0,_schemaValidation__WEBPACK_IMPORTED_MODULE_2__.validatePlayerContext)(data);
322  if (!validatedData) {
323    return null;
324  }
325  return {
326    schema: PLAYER_CONTEXT_SCHEMA,
327    data: validatedData
328  };
329}
330function createCampaignContext({ mls_campaign_id = null, sponsor = null } = {}) {
331  if (!mls_campaign_id) {
332    return null;
333  }
334  return {
335    schema: CAMPAIGN_CONTEXT_SCHEMA,
336    data: {
337      mls_campaign_id,
338      sponsor
339    }
340  };
341}
342function createChannelCategoryContext({ channel_id = null, category_id = null, channel_name = null, category = null, view_type = null } = {}) {
343  if (!channel_id || !category_id) {
344    return null;
345  }
346  return {
347    schema: CHANNEL_CATEGORY_CONTEXT_SCHEMA,
348    data: {
349      channel_id,
350      category_id,
351      channel_name,
352      category,
353      view_type
354    }
355  };
356}
357function createContentMetadataContext({
358  content_id = null,
359  content_title = null,
360  slug = null,
361  content_format = null,
362  content_type = null,
363  embedded_content_id = null,
364  asset_type = null,
365  word_count = null,
366  duration_time = null,
367  publish_date = null,
368  topic_primary = null,
369  topic_secondary = null,
370  language = null,
371  author = null
372} = {}) {
373  if (!content_id || !content_title || !slug) {
374    return null;
375  }
376  const data = {
377    content_id,
378    content_title,
379    slug,
380    content_format,
381    content_type,
382    embedded_content_id,
383    asset_type,
384    word_count: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(word_count),
385    duration_time: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(duration_time),
386    publish_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(publish_date),
387    topic_primary,
388    topic_secondary,
389    language,
390    author
391  };
392  const validatedData = (0,_schemaValidation__WEBPACK_IMPORTED_MODULE_2__.validateContentMetadata)(data);
393  if (!validatedData) {
394    return null;
395  }
396  return {
397    schema: CONTENT_METADATA_CONTEXT_SCHEMA,
398    data: validatedData
399  };
400}
401function createLikeActionEvent({ like_type = null, content_id = null } = {}) {
402  if (!like_type || !content_id) {
403    return null;
404  }
405  return {
406    schema: LIKE_ACTION_SCHEMA,
407    data: {
408      like_type,
409      content_id
410    }
411  };
412}
413function createShareActionEvent({ shared_with = null, content_id = null } = {}) {
414  if (!shared_with || !content_id) {
415    return null;
416  }
417  return {
418    schema: SHARE_ACTION_SCHEMA,
419    data: {
420      shared_with,
421      content_id
422    }
423  };
424}
425function createTopicContext({ topic_id = null, topic_name = null, topic_slug = null, topic_type = null } = {}) {
426  if (!topic_id || !topic_name || !topic_slug || !topic_type) {
427    return null;
428  }
429  const data = {
430    topic_id,
431    topic_name,
432    topic_slug,
433    topic_type
434  };
435  const validatedData = (0,_schemaValidation__WEBPACK_IMPORTED_MODULE_2__.validateTopicContext)(data);
436  if (!validatedData) {
437    return null;
438  }
439  return {
440    schema: TOPIC_CONTEXT_SCHEMA,
441    data: validatedData
442  };
443}
444function composeMLSMatchContextData({ away = null, home = null, environment = null, match_information = null } = {}) {
445  return {
446    venue: environment?.stadium_name,
447    match_id: match_information.match_id,
448    home_team: home?.team_name || home?.team_short_name || home?.team_three_letter_code,
449    away_team: away?.team_name || away?.team_short_name || away?.team_three_letter_code,
450    kickoff_time: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDateTime)(match_information?.kickoff_time),
451    match_status: match_information?.match_status,
452    home_team_id: home?.team_id,
453    away_team_id: away?.team_id
454  };
455}
456function composeMLSClubContextData({ team_id = null, team_name = null, team_city = null } = {}) {
457  return {
458    club_id: team_id,
459    club_name: team_name,
460    club_city: team_city
461  };
462}
463function composeMLSCompetitionContextData({ competition_id = null, competition_name = null, season = null, start_date = null, end_date = null, number_of_teams = null } = {}) {
464  return {
465    competition_id,
466    competition_name,
467    season,
468    start_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(start_date),
469    end_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(end_date),
470    number_of_teams: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(number_of_teams)
471  };
472}
473function composeChannelCategoryContextData() {
474  const { channelName, category, pageType } = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getSnowplowVariables)();
475  return createChannelCategoryContext({
476    channel_id: channelName,
477    channel_name: channelName,
478    category_id: category,
479    category,
480    view_type: pageType
481  });
482}
483function composeContentMetadataContextData({
484  id = null,
485  title = null,
486  slug = null,
487  format = null,
488  type = null,
489  assetType = null,
490  wordCount = null,
491  durationTime = null,
492  publishDate = null,
493  topicPrimary = null,
494  topicSecondary = null,
495  language = null,
496  author = null
497} = {}) {
498  if (!id || !title || !slug) {
499    return null;
500  }
501  return {
502    content_id: id,
503    content_title: title,
504    slug,
505    content_format: format,
506    content_type: type,
507    asset_type: assetType,
508    word_count: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(wordCount),
509    duration_time: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(durationTime),
510    publish_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(publishDate),
511    topic_primary: topicPrimary,
512    topic_secondary: topicSecondary,
513    language,
514    author
515  };
516}
517function composeTopicContextData({ id = null, name = null, slug = null, type = null } = {}) {
518  if (!id || !name || !slug || !type) {
519    return null;
520  }
521  return {
522    topic_id: id,
523    topic_name: name,
524    topic_slug: slug,
525    topic_type: type
526  };
527}
528function getDynamicArticleData() {
529  const data = window.forgeVariables.tracking?.article;
530  if (!data) {
531    return void 0;
532  }
533  return {
534    content_id: data.id,
535    content_title: data.title,
536    slug: data.slug,
537    content_type: data.type,
538    publish_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(data.contentDate),
539    author: data.createdBy,
540    topic_primary: data.topicPrimary,
541    topic_secondary: data.topicSecondary,
542    language: (0,_react_shared_utils__WEBPACK_IMPORTED_MODULE_0__.getPageLanguage)()
543  };
544}
545function getDynamicPlayerData() {
546  const data = window.forgeVariables.tracking?.player;
547  if (!data) {
548    return void 0;
549  }
550  return {
551    player_id: data.player_id,
552    player_name: data.player_name
553  };
554}
555function getDynamicClubData() {
556  const data = window.forgeVariables.tracking?.club;
557  if (!data) {
558    return void 0;
559  }
560  return {
561    club_id: data.club_id,
562    club_name: data.club_name
563  };
564}
565function getDynamicVideoPlaylistData() {
566  const data = window.forgeVariables.tracking?.videoPlaylist;
567  if (!data && data.length > 0) {
568    return void 0;
569  }
570  return {
571    content_id: data._entityId,
572    content_title: data.title,
573    slug: data.slug,
574    content_type: data.type,
575    content_format: "video",
576    asset_type: "video",
577    duration_time: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateNumber)(data?.fields?.duration),
578    publish_date: (0,_utils__WEBPACK_IMPORTED_MODULE_1__.validateDate)(data.contentDate),
579    author: data.createdBy,
580    topic_primary: data.tags[0]?.title,
581    topic_secondary: data.tags[1]?.title,
582    language: (0,_react_shared_utils__WEBPACK_IMPORTED_MODULE_0__.getPageLanguage)()
583  };
584}
585
586
587/***/ }),
588
589/***/ "./scripts/libraries/_modules/tracking/snowplow/utils.js":
590/*!***************************************************************!*\
591  !*** ./scripts/libraries/_modules/tracking/snowplow/utils.js ***!
592  \***************************************************************/
593/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
594
595__webpack_require__.r(__webpack_exports__);
596/* harmony export */ __webpack_require__.d(__webpack_exports__, {
597/* harmony export */   "createPageContexts": () => (/* binding */ createPageContexts),
598/* harmony export */   "createTopicContextsFromTags": () => (/* binding */ createTopicContextsFromTags),
599/* harmony export */   "createVideoTagContext": () => (/* binding */ createVideoTagContext),
600/* harmony export */   "extractCustomEntityValue": () => (/* binding */ extractCustomEntityValue),
601/* harmony export */   "getAvailableTopics": () => (/* binding */ getAvailableTopics),
602/* harmony export */   "getDynamicSchemaContext": () => (/* binding */ getDynamicSchemaContext),
603/* harmony export */   "getDynamicSchemaData": () => (/* binding */ getDynamicSchemaData),
604/* harmony export */   "getSchemaName": () => (/* binding */ getSchemaName),
605/* harmony export */   "getSchemaNameFromVideoTag": () => (/* binding */ getSchemaNameFromVideoTag),
606/* harmony export */   "getSnowplowVariables": () => (/* binding */ getSnowplowVariables),
607/* harmony export */   "getVideoContextsFromTags": () => (/* binding */ getVideoContextsFromTags),
608/* harmony export */   "hasUserAcceptedAllConsent": () => (/* binding */ hasUserAcceptedAllConsent),
609/* harmony export */   "hasUserAcceptedMeasurementConsent": () => (/* binding */ hasUserAcceptedMeasurementConsent),
610/* harmony export */   "hasUserGroup": () => (/* binding */ hasUserGroup),
611/* harmony export */   "runWhenSnowplowReady": () => (/* binding */ runWhenSnowplowReady),
612/* harmony export */   "validateDate": () => (/* binding */ validateDate),
613/* harmony export */   "validateDateTime": () => (/* binding */ validateDateTime),
614/* harmony export */   "validateNumber": () => (/* binding */ validateNumber)
615/* harmony export */ });
616/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! date-fns */ "./.yarn/cache/date-fns-npm-2.29.2-da48c27e93-0ac440a105.zip/node_modules/date-fns/esm/parseISO/index.js");
617/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! date-fns */ "./.yarn/cache/date-fns-npm-2.29.2-da48c27e93-0ac440a105.zip/node_modules/date-fns/esm/isValid/index.js");
618/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! date-fns */ "./.yarn/cache/date-fns-npm-2.29.2-da48c27e93-0ac440a105.zip/node_modules/date-fns/esm/format/index.js");
619/* harmony import */ var _snowplowTracking__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./snowplowTracking */ "./scripts/libraries/_modules/tracking/snowplow/snowplowTracking.js");
620
621
622function getSnowplowVariables() {
623  const { tracking = {} } = window?.forgeVariables || {};
624  return {
625    appId: tracking?.appId,
626    collectorUrl: tracking?.collectorUrl,
627    channelName: tracking?.channelName,
628    category: tracking?.category,
629    nameSpace: tracking?.nameSpace,
630    pageType: tracking?.pageType || "homepage",
631    entityContexts: getEntityContextList(tracking?.entityContexts)
632  };
633}
634function getEntityContextList(entityContexts) {
635  return entityContexts?.split(",").filter((context) => context !== "");
636}
637function createPageContexts({
638  mlsMatch,
639  mlsTeam,
640  mlsHomeTeam,
641  mlsAwayTeam,
642  mlsCompetition,
643  mlsPlayer
644}) {
645  const { entityContexts } = getSnowplowVariables();
646  const contexts = [];
647  entityContexts.forEach((entityContext) => {
648    if (entityContext === "match") {
649      contexts.push((0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createMatchContext)(mlsMatch));
650    } else if (entityContext === "team" || entityContext === "club" || entityContext === "clubs") {
651      if (mlsTeam) {
652        contexts.push((0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createClubContext)(mlsTeam));
653      }
654      if (mlsHomeTeam) {
655        contexts.push((0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createClubContext)(mlsHomeTeam));
656      }
657      if (mlsAwayTeam) {
658        contexts.push((0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createClubContext)(mlsAwayTeam));
659      }
660    } else if (entityContext === "competition") {
661      contexts.push((0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createCompetitionContext)(mlsCompetition));
662    } else if (entityContext === "player") {
663      contexts.push((0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createPlayerContext)(mlsPlayer));
664    }
665  });
666  return contexts;
667}
668function getSchemaName() {
669  const { schema } = window?.forgeVariables?.tracking || {};
670  return schema;
671}
672const schemaDataMapFunctions = {
673  article: _snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.getDynamicArticleData,
674  club: _snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.getDynamicClubData,
675  player: _snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.getDynamicPlayerData
676};
677function getDynamicSchemaData(schemaName) {
678  const schemaDataMapFunction = schemaDataMapFunctions[schemaName];
679  if (!schemaDataMapFunction) {
680    return void 0;
681  }
682  return schemaDataMapFunction();
683}
684function getDynamicSchemaContext(schemaName) {
685  if (schemaName) {
686    const schemaData = getDynamicSchemaData(schemaName);
687    const createSchemaContextFunctions = {
688      player: _snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createPlayerContext,
689      club: _snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createClubContext,
690      article: _snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createContentMetadataContext,
691      videoPlaylist: (video) => video
692    };
693    const schemaContext = createSchemaContextFunctions[schemaName](schemaData);
694    return schemaContext;
695  }
696  return null;
697}
698const categories = ["C0002", "C0003", "C0004"];
699function hasUserAcceptedAllConsent() {
700  const activeGroups = getActiveConsentGroups();
701  return categories.every((category) => activeGroups.includes(category));
702}
703function hasUserAcceptedMeasurementConsent() {
704  const activeGroups = getActiveConsentGroups();
705  return activeGroups.includes("C0002");
706}
707function hasUserGroup(group) {
708  const activeGroups = getActiveConsentGroups();
709  return activeGroups.includes(group);
710}
711function getActiveConsentGroups() {
712  const activeGroups = window?.OptanonActiveGroups || "";
713  const activeGroupsList = activeGroups?.split(",").filter((group) => group !== "");
714  return activeGroupsList;
715}
716function getAvailableTopics(schemaName) {
717  if (!schemaName) {
718    return [];
719  }
720  const { topics = [] } = window?.forgeVariables?.tracking?.[schemaName] || {};
721  return topics?.map((topic) => (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createTopicContext)(
722    (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.composeTopicContextData)({ id: topic?._entityId || topic?.slug, name: topic?.title, slug: topic?.slug, type: extractCustomEntityValue(topic?.externalSourceName ?? topic?.type) })
723  ));
724}
725function createTopicContextsFromTags(tags = [], skipCount = 2) {
726  if (!tags || tags?.length <= skipCount) {
727    return [];
728  }
729  const additionalTags = tags.slice(skipCount);
730  return additionalTags.map((tag) => {
731    const topicData = (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.composeTopicContextData)({
732      id: tag?.slug || tag?._entityId,
733      name: tag?.title,
734      slug: tag?.slug,
735      type: tag?.type
736    });
737    return (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createTopicContext)(topicData);
738  }).filter((context) => context !== null);
739}
740function validateNumber(value) {
741  if (value === null || value === void 0 || value === "") {
742    return null;
743  }
744  const num = Number(value);
745  return isNaN(num) ? null : num;
746}
747function runWhenSnowplowReady(callback, options = {}) {
748  const { maxRetries = 10, retryInterval = 500 } = options;
749  let retryCount = 0;
750  let intervalId = null;
751  let hasExecuted = false;
752  const isSnowplowInitialized = () => {
753    return window?.snowplow && typeof window.snowplow === "function";
754  };
755  const tryExecute = () => {
756    if (hasExecuted) {
757      return true;
758    }
759    if (isSnowplowInitialized()) {
760      hasExecuted = true;
761      callback();
762      return true;
763    }
764    retryCount += 1;
765    if (retryCount >= maxRetries) {
766      hasExecuted = true;
767      return true;
768    }
769    return false;
770  };
771  const success = tryExecute();
772  if (!success) {
773    intervalId = setInterval(() => {
774      const done = tryExecute();
775      if (done && intervalId) {
776        clearInterval(intervalId);
777        intervalId = null;
778      }
779    }, retryInterval);
780  }
781  return () => {
782    if (intervalId) {
783      clearInterval(intervalId);
784      intervalId = null;
785    }
786    hasExecuted = true;
787  };
788}
789function validateDate(dateString) {
790  if (!dateString) {
791    return null;
792  }
793  try {
794    const date = (0,date_fns__WEBPACK_IMPORTED_MODULE_1__["default"])(dateString);
795    return (0,date_fns__WEBPACK_IMPORTED_MODULE_2__["default"])(date) ? (0,date_fns__WEBPACK_IMPORTED_MODULE_3__["default"])(date, "yyyy-MM-dd") : null;
796  } catch (error) {
797    return null;
798  }
799}
800function validateDateTime(dateTimeString) {
801  if (!dateTimeString) {
802    return null;
803  }
804  try {
805    const date = (0,date_fns__WEBPACK_IMPORTED_MODULE_1__["default"])(dateTimeString);
806    if (!(0,date_fns__WEBPACK_IMPORTED_MODULE_2__["default"])(date)) {
807      return null;
808    }
809    const isoString = date.toISOString();
810    return isoString;
811  } catch (error) {
812    return null;
813  }
814}
815function getVideoContextsFromTags(tags = []) {
816  const contexts = tags.map((tag) => {
817    return createVideoTagContext(tag);
818  });
819  return contexts.filter((context) => context !== null);
820}
821const videoTagSchemaMap = {
822  "customentity.topic": "topic",
823  "customentity.match": "match",
824  "customentity.competition": "competition",
825  "customentity.club": "club",
826  "customentity.player": "player"
827};
828function getSchemaNameFromVideoTag(videoTag) {
829  const tagType = videoTag?.externalSourceName || videoTag?.externalSourceReference?.sourceName;
830  const schema = videoTagSchemaMap[tagType];
831  if (!schema) {
832    return null;
833  }
834  return schema;
835}
836const DEFAULT_TAG_VALUE = "Not Defined";
837const getDefaultKickoffTime = () => (/* @__PURE__ */ new Date()).toISOString();
838function createVideoTagContext(videoTag) {
839  const schemaName = getSchemaNameFromVideoTag(videoTag);
840  if (!schemaName) {
841    return null;
842  }
843  switch (schemaName) {
844    case "topic":
845      return (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createTopicContext)({
846        topic_id: videoTag?._entityId || videoTag?.slug,
847        topic_name: videoTag?.title,
848        topic_slug: videoTag?.slug,
849        topic_type: videoTag?.type
850      });
851    case "match":
852      return (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createMatchContext)({
853        // required values
854        match_id: videoTag?.extraData?.sportecId || DEFAULT_TAG_VALUE,
855        home_team: videoTag?.extraData?.homeClubName || DEFAULT_TAG_VALUE,
856        away_team: videoTag?.extraData?.awayClubName || DEFAULT_TAG_VALUE,
857        kickoff_time: videoTag?.extraData?.kickoffTime || getDefaultKickoffTime()
858      });
859    case "competition":
860      return (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createCompetitionContext)({
861        // required values
862        competition_id: videoTag?.extraData?.sportecId || DEFAULT_TAG_VALUE,
863        competition_name: videoTag?.extraData?.name || DEFAULT_TAG_VALUE,
864        season: videoTag?.extraData?.seasonSportecId || DEFAULT_TAG_VALUE
865      });
866    case "club":
867      return (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createClubContext)({
868        // required values
869        club_id: videoTag?.extraData?.sportecId || DEFAULT_TAG_VALUE,
870        club_name: videoTag?.extraData?.name || DEFAULT_TAG_VALUE
871      });
872    case "player":
873      return (0,_snowplowTracking__WEBPACK_IMPORTED_MODULE_0__.createPlayerContext)({
874        // required values
875        player_id: videoTag?.extraData?.sportecId || DEFAULT_TAG_VALUE,
876        player_name: `${videoTag?.extraData?.firstName} ${videoTag?.extraData?.lastName}` || DEFAULT_TAG_VALUE,
877        // optional values
878        player_team: videoTag?.extraData?.clubSportecId
879      });
880  }
881}
882function extractCustomEntityValue(input) {
883  const knownEntities = ["club", "player", "match"];
884  if (input.startsWith("customentity.")) {
885    const type = input.split(".")[1];
886    return knownEntities.includes(type) ? type : "tag";
887  }
888  return input;
889}
890
891
892/***/ })
892
893
894}]);
895//# sourceMappingURL=scripts_libraries__modules_tracking_snowplow_snowplowEventTrackers_js-scripts_libraries__modu-33d9b7.js.map?_t=0f53d29a227a435a6649

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.