PageSourceSearch

https://drivetimedevotions.com/scripts/CustomEvents/CoreEventModel…?v=067bac55dc3729ccedc88375e13966800226cff8

js drivetimedevotions.com collected 2026-09-26 03:05:48 UTC 11,443 bytes, 227 lines download raw bytes

1/**
2 * Represents the CoreEventModels object.
3 * @namespace CoreEventModels
4 */
5export var CoreEventModels = {
6    name: 'CoreEventModels',
7    debugPrefix: `DEBUG | 'CoreEventModels.js' | `,
8    debug: false,
9    logStartup: function (message) {
10        console.log(`${this.debugPrefix}message -> '${message}'`);
11        this.debug = true;
12    },
13    /**
14     * Prepares the data for a click event.
15     *
16     * @param {string} linkClass - The class of the link.
17     * @param {string} linkId - The ID of the link.
18     * @param {string} linkUrl - The URL of the link.
19     * @param {string} clickElementType - The type of the clicked element.
20     * @param {string} clickElementLabel - The label of the clicked element.
21     * @param {string} host - The host of the website.
22     * @param {string} actionType - The type of the action.
23     * @returns {Object} An object containing the prepared data for the click event.
24     */
25    prepareClickEventData: function (linkClass, linkId, linkUrl, clickElementType, clickElementLabel, host, actionType) {
26        let linkDomain = linkUrl && linkUrl.startsWith('http') ? new URL(linkUrl).hostname : host;
27        let linkOutbound = linkDomain !== host;
28        let eventData = {
29            'link_class': linkClass ? linkClass : null,
30            'link_id': linkId ? linkId : null,
31            'link_url': linkUrl ? linkUrl : null,
32            'link_domain': linkDomain,
33            'link_outbound': linkOutbound,
34            'click_element_type': clickElementType ? clickElementType : null,
35            'click_element_label': clickElementLabel ? clickElementLabel : null,
36            'action_type': actionType ? actionType : null,
37        };
38        this.debug && console.log(`${this.debugPrefix}Prepared Click event data`, eventData);
39        return eventData;
40    },
41    /**
42     * Prepares the data for an analytics event.
43     *
44     * @param {boolean} enableCollection - Whether to enable analytics collection.
45     * @param {boolean} useCustomCategory - Whether to use a custom category.
46     * @param {string} customCategory - The custom category.
47     * @param {boolean} useCustomValue - Whether to use a custom value.
48     * @param {string} customValue - The custom value.
49     * @returns {Object} An object containing the prepared data for the analytics event.
50     */
51    prepareAnalyticsData: function (enableCollection, useCustomCategory, customCategory, useCustomValue, customValue) {
52        let analyticsData = {
53            'collect_analytics': enableCollection ? enableCollection : false,
54            'custom_category': useCustomCategory ? customCategory : null,
55            'custom_value': useCustomValue ? customValue : null,
56        };
57        this.debug && console.log(`${this.debugPrefix}Prepared Analytics event data`, analyticsData);
58        return analyticsData;
59    },
60    /**
61     * Prepares the data for a page parameter event.
62     *
63     * @param {string} pageElementType - The type of the page element.
64     * @param {string} pageElementTitle - The title of the page element.
65     * @param {string} hostname - The hostname of the website. Added for Azure AppInsights.
66     * @returns {Object} An object containing the prepared data for the page parameter event.
67     */
68    preparePageParameterData: function (pageElementType, pageElementTitle, hostname) {
69        let pageData = {
70            'page_element_type': pageElementType ? pageElementType : null,
71            'page_element_title': pageElementTitle ? pageElementTitle : null,
72            'hostname': hostname ? hostname : null,
73        };
74        this.debug && console.log(`${this.debugPrefix}Prepared Page event data`, pageData);
75        return pageData;
76    },
77    /**
78     * Prepares the data for a set language event.
79     *
80     * @param {string} languageFrom - The language to translate from.
81     * @param {string} languageTo - The language to translate to.
82     * @param {string} deviceValue - The device value.
83     * @param {string} menuLocation - The location of the menu.
84     * @param {string} clickElementType - The type of the clicked element.
85     * @param {string} clickElementLabel - The label of the clicked element.
86     * @returns {Object}
86 An object containing the prepared data for the set language event.
87     */
88    prepareSetLanguageEventData: function (languageFrom, languageTo, deviceValue, menuLocation, clickElementType, clickElementLabel) {
89        let languageData = {
90            'language_from': languageFrom ? languageFrom : null,
91            'language_to': languageTo ? languageTo : null,
92            'device': deviceValue ? deviceValue : null,
93            'menu_location': menuLocation ? menuLocation : null,
94            'click_element_type': clickElementType ? clickElementType : null,
95            'click_element_label': clickElementLabel ? clickElementLabel : null,
96        };
97        this.debug && console.log(`${this.debugPrefix}Prepared Set Language event data`, languageData);
98        return languageData;
99    },
100    /**
101     * Prepares the data for a form event.
102     *
103     * @param {string} formId - The ID of the form.
104     * @param {string} formType - The type of the form.
105     * @param {string} formSource - The source of the form.
106     * @param {string} ministryId - The ID of the ministry.
107     * @param {string} ministryName - The name of the ministry.
108     * @returns {Object} An object containing the prepared data for the form event.
109     */
110    prepareFormEventData: function (formId, formType, formSource, ministryId, ministryName) {
111        let formData = {
112            'form_id': formId ? formId : null,
113            'form_type': formType ? formType : null,
114            'form_source': formSource ? formSource : null,
115            'ministry_id': ministryId ? ministryId : null,
116            'ministry_name': ministryName ? ministryName : null,
117        };
118        this.debug && console.log(`${this.debugPrefix}Prepared Form event data`, formData);
119        return formData;
120    },
121    /**
122     * Prepares the data for a subscription event.
123     *
124     * @param {string} subscriptionMethod - The method used for the subscription.
125     * @param {string} subscriptionType - The type of the subscription.
126     * @param {string} subscriptionId - The ID of the subscription.
127     * @param {string} subscriptionValue - The value of the subscription.
128     * @returns {Object} An object containing the prepared data for the subscription event.
129     */
130    prepareSubscriptionEventData: function (subscriptionMethod, subscriptionType, subscriptionId, subscriptionValue) {
131        let shareData = {
132            'subscription_method': subscriptionMethod ? subscriptionMethod : null,
133            'subscription_type': subscriptionType ? subscriptionType : null,
134            'subscription_id': subscriptionId ? subscriptionId : null,
135            'subscription_value': subscriptionValue ? subscriptionValue : null,
136        };
137        this.debug && console.log(`${this.debugPrefix}Prepared Share event data`, shareData);
138        return shareData;
139    },
140
141    /**
142     * Prepares the data for a pop-up event based on the provided action type.
143     *
144     * @param {string} actionType - The type of action for the pop-up event.
145     * @param {string} videoPlayerSource - The source of the video player (only applicable if actionType is 'VideoPopup').
146     * @param {string} videoId - The ID of the video (only applicable if actionType is 'VideoPopup').
147     * @param {string} hcFormType - The type of the HC form (only applicable if actionType is 'HCFormModal').
148     * @param {string} hcFormId - The ID of the HC form (only applicable if actionType is 'HCFormModal').
149     * @param {string} htmlModalTitle - The title of the HTML modal (only applicable if actionType is 'CustomHtmlModal').
150     * @param {string} htmlModalText - The text of the HTML modal (only applicable if actionType is 'CustomHtmlModal').
151     * @returns {object} - The prepared pop-up event data.
152     */
153    preparePopUpEventData(actionType, videoProvider, videoUrl, hcFormType, hcFormId, htmlModalTitle, htmlModalText, clickElementType, clickElementLabel) {
154        let popupData = {
155            'click_element_type': clickElementType ? clickElementType : null,
156            'click_element_label': clickElementLabel ? clickElementLabel : null,
157        };
158
159        if (actionType === 'VideoPopup') {
160            popupData['video_provider'] = videoProvider ? videoProvider : null;
161            popupData['video_url'] = videoUrl ? videoUrl : null;
162
163            // video_provider
164            // video_url
165
166        } else if (actionType === 'HCFormModal') {
167            popupData['hc_form_type'] = hcFormType ? hcFormType : null;
168            popupData['hc_form_id'] = hcFormId ? hcFormId : null;
169
170        } else if (actionType === 'CustomHtmlModal') {
171            popupData['html_modal_title'] = htmlModalTitle ? htmlModalTitle : null;
172            popupData['html_modal_text'] = htmlModalText ? htmlModalText : null;
173
174        } else {
175            console.log(`${this.debugPrefix}Unknown action type: ${actionType}`);
176        }
177        this.debug && console.log(`${this.debugPrefix}Prepared PopUp event data`, popupData);
178        return popupData;
179    },
180    /**
181     * Prepares the event data for the SelectItem event.
182     *
183     * @param {string} itemId - The ID of the item.
184     * @param {string} itemValue - The value of the item.
185     * @returns {Object} - The prepared event data object.
186     */
187    prepareSelectItemEventData(itemId, itemValue) {
188        let selectItemData = {
189            'item_id': itemId ? itemId : null,
190            'item_value': itemValue ? itemValue : null,
191        };
192        this.debug && console.log(`${this.debugPrefix}Prepared SelectItem event data`, selectItemData);
193        return selectItemData;
194    },
195    prepareFileDownloadEventData(fileUrl) {
196        this.debug && console.log(`${this.debugPrefix}Received the fileUrl -> `, fileUrl);
197
198        let fileId = null;
199        let fileName = null;
200
201        let tmpUrl = new URL(fileUrl);
202        if (tmpUrl.hostname === 'media.saddlebackfamily.com') {
203            // example: https://media.saddlebackfamily.com/bfed8c57-1371-4aac-b6a3-400a45537b93.aspx?z={authToken}
204            fileId = tmpUrl.pathname.split('/').pop().replace('.aspx', '');
205
206        } else if (tmpUrl.hostname === 'saddleback.com') {
207            // example: https://saddleback.com/media/arslfb4y/sb_fallbackimage.jpg
208            fileId = tmpUrl.pathname.replace(/^\//, '').replace(/\//g, '-');
209            fileName = tmpUrl.pathname.split('/').pop();
210
211        } else if (tmpUrl.hostname === 'sbstoragecdnprod.blob.core.windows.net') {
212            // example: https://sbstoragecdnprod.blob.core.windows.net/media/Giving/Instructions_for_Stock_Donations.pdf
213            fileId = tmpUrl.pathname.replace(/^\//, '').replace(/\//g, '-');
214            fileName = tmpUrl.pathname.split('/').pop();
215
216        } else {
217            fileName = tmpUrl.pathname;
218        }
219
220        let fileDownloadData = {
221            'file_id': fileId,
222            'file_name': fileName,
223        };
224        this.debug && console.log(`${this.debugPrefix}Prepared FileDownload event data`, fileDownloadData);
225        return fileDownloadData;
226    },
227};

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.