PageSourceSearch

https://secure.backblaze.com/bzapp_web_assets/scripts/pendo_util.js

js backblaze.com collected 2026-10-01 06:59:38 UTC 25,267 bytes, 357 lines download raw bytes

1/*
2 * Copyright 2022, Backblaze, Inc.  All rights reserved.
3 */
4'use strict';
5(function() {
6    const PENDO_UTIL_DEBUG = 'pendoUtil.debug';
7    const CONSOLE = "console";
8    const ALERT = "alert";
9    const OFF = "0";
10    window.PendoUtil = {
11
12        enableDebugAlert: () => {
13            localStorage.setItem(PENDO_UTIL_DEBUG, ALERT);
14        },
15        enableDebugConsole: () => {
16            localStorage.setItem(PENDO_UTIL_DEBUG, CONSOLE);
17        },
18        disableDebug: () => {
19            localStorage.setItem(PENDO_UTIL_DEBUG, OFF);
20        },
21        clickEvent: (name, data) => {
22            PendoUtil.event(name + " Clicked", data);
23        },
24        event: (name, data) => {
25            const debugMode = localStorage.getItem(PENDO_UTIL_DEBUG);
26            const showConsoleMessage = debugMode === CONSOLE;
27            const showAlertMessage = debugMode === ALERT;
28            if (showConsoleMessage || showAlertMessage) {
29                let readableEvent = "Event Name: " + name;
30                if (data && Object.keys(data).length > 0) {
31                    readableEvent += "\nData" + JSON.stringify(data, null, 2);
32                }
33                if (showConsoleMessage) {
34                    console.log(readableEvent);
35                } else {
36                    alert(readableEvent);
37                }
38            }
39            if (window.pendo) {
40                window.pendo.track(name, data);
41            }
42        },
43        registerClick: (selector, name) => {
44            const elements = $(selector);
45            // Remove previous click handler if one was set
46            elements.off('click.pendo');
47            elements.on('click.pendo', (e) => {
48                PendoUtil.clickEvent(name);
49            });
50        },
51        appendMetadata: (metadata) => {
52            if (window.pendo) {
53                window.pendo.identify(metadata);
54            } else {
55                console.error("Pendo is not loaded yet, metadata will be lost");
56            }
57        },
58        // Dynamic pages manually call PendoUtil with the constants here
59        MySharedFiles: {
60            DeleteButton: 'B1 My Shared Files - Delete Button',
61            SelectAllFilesCheckbox: 'B1 My Shared Files - Select All Files Checkbox',
62            SelectFileCheckbox: 'B1 My Shared Files - Select File Checkbox',
63        },
64        CloudReplication: {
65            ReplicateYourDataButton: 'B2 Cloud Replication - Replicate Your Data Button',
66            RuleSettingsModal: {
67                Cancel: 'B2 Cloud Replication - Rule Settings Modal - Cancel Button',
68                Next: 'B2 Cloud Replication - Rule Settings Modal - Next Button',
69                CreateNewBucket: 'B2 Cloud Replication - Rule Settings Modal - Create New Bucket',
70                SelectExistingBucket: 'B2 Cloud Replication - Rule Settings Modal - Select Existing Bucket',
71                AuthenticateToExistingAccount: 'B2 Cloud Replication - Rule Settings Modal - Authenticate to existing account',
72                CreateNewDestinationAccount: 'B2 Cloud Replication - Rule Settings Modal - Create new destination account',
73                CreateAccount: {
74                    AddPayment: {
75                        Back: 'B2 Cloud Replication - Rule Settings Modal - Create Account - Add Payment - Back Button',
76                        Cancel: 'B2 Cloud Replication - Rule Settings Modal - Create Account - Add Payment - Cancel Button',
77                        Create: 'B2 Cloud Replication - Rule Settings Modal - Create Account - Add Payment - Create Button',
78                    },
79                    Back: 'B2 Cloud Replication - Rule Settings Modal - Create Account - Back Button',
80                    Cancel: 'B2 Cloud Replication - Rule Settings Modal - Create Account - Cancel Button',
81                    Next: 'B2 Cloud Replication - Rule Settings Modal - Create Account - Next Button'
82                },
83                NewRuleConfirmation: {
84                    Back: 'B2 Cloud Replication - Rule Settings Modal - Confirmation - Back Button',
85                    CreateReplication: 'B2 Cloud Replication - Rule Settings Modal - Confirmation - Create Replication Button',
86                    Cancel: 'B2 Cloud Replication - Rule Settings Modal - Confirmation - Cancel Button',
87                },
88                AuthenticateDestinationAccount: {
89                    Next: 'B2 Cloud Replication - Authenticate Destination Account Modal - Next Button',
90                    SignIn: 'B2 Cloud Replication - Authenticate Destination Account Modal - Sign in Button',
91                    Cancel: 'B2 Cloud Replication - Authenticate Destination Account Modal - Cancel Button',
92                },
93            }
94        },
95        InviteAndApprove: {
96            AdvancedInstructions: 'Groups Invite & Approve - Advanced Instru
96ctions Button',
97            CopyLink: 'Groups Invite & Approve - Copy Link Button',
98            SendInviteEmails: 'Groups Invite & Approve - Send Invite Emails Button',
99        },
100        UsersComputers: {
101            B2Details: 'Groups Users/Computers - B2 Storage Details',
102            ComputerDetails: 'Groups Users/Computers - Computer Details',
103            ManageB2UserAccount: 'Groups Users/Computers - Manage B2 User Account',
104            ManageUserAccount: 'Groups Users/Computers - Manage User Account',
105            RemoveFromGroup: 'Groups Users/Computers - Remove from Group',
106        },
107        GroupManagement: {
108            AddLicenses: 'Groups Management - Add Licenses Button',
109            Approve: 'Groups Management - Approve',
110            BuyButton: 'Groups Management - Buy Button',
111            ChangeVersionHistory: 'Groups Management - Change Version History Link',
112            CreateANewGroup: 'Groups Management - Create a New Group Button',
113            EditGroupButton: 'Groups Management - Edit Group Button',
114            EditPayment: 'Groups Management - Edit Payment',
115            SendInvites: 'Groups Management - Send Invites',
116            UpdateGroupContactInfo: 'Groups Management - Update Group Contact Info',
117            UpdateVersionHistory: 'Groups Management - Update Version History Button',
118            UsersComputers: 'Groups Management - Users/Computers',
119            Buy: {
120                BuyButton: 'Groups Management - Buy Modal - Buy Button',
121                Cancel: 'Groups Management - Buy Modal - Cancel Button',
122                LearnHowToCancel: 'Groups Management - Buy Modal - Learn how to cancel Link',
123                OneYear: 'Groups Management - Buy Modal - 1-Year Radio Button',
124                PerMonth: 'Groups Management - Buy Modal - Per Month Radio Button',
125                TwoYear: 'Groups Management - Buy Modal - 2-Year Radio Button',
126                VersionHistoryDropdown: 'Groups Management - Buy Modal - Version History Dropdown',
127                VersionHistoryLearnMore: 'Groups Management - Buy Modal - Version History Learn More Link',
128            },
129            CreateGroup: {
130                AdministratorPrivilegesOff: 'Groups Management - Create Group Modal - Administrator Privileges Off Radio Button',
131                AdministratorPrivilegesOn: 'Groups Management - Create Group Modal - Administrator Privileges On Radio Button',
132                B2CloudStorage: 'Groups Management - Create Group Modal - B2 Cloud Storage Checkbox',
133                Close: 'Groups Management - Create Group Modal - Close',
134                CreateGroup: 'Groups Management - Create Group Modal - Create Group Button',
135                OneYearVersionHistory: 'Groups Management - Create Group Modal - 1-Year Version History Checkbox',
136                OnlineBackup: 'Groups Management - Create Group Modal - Online Backup Checkbox',
137                AddPayment: {
138                    LearnHowToCancel: 'Groups Management - Create Group Modal - Add Payment - Learn how to cancel Link',
139                    OneYear: 'Groups Management - Create Group Modal - Add Payment - 1-Year Radio Button',
140                    PerMonth: 'Groups Management - Create Group Modal - Add Payment - Per Month Radio Button',
141                    Purchase: 'Groups Management - Create Group Modal - Add Payment - Purchase Button',
142                    SkipPayment: 'Groups Management - Create Group Modal - Add Payment - Skip Payment & Try for Free Link',
143                    TwoYear: 'Groups Management - Create Group Modal - Add Payment - 2-Year Radio Button',
144                    VersionHistoryDropdown: 'Groups Management - Create Group Modal - Add Payment - Version History Dropdown',
145                    VersionHistoryLearnMore: 'Groups Management - Create Group Modal - Add Payment - Version History Learn More Link',
146                    InviteMembersToGroup: {
147                        Copy: 'Groups Management - Create Group Modal - Invite Members to Group - Copy Button',
148                        IllInviteLater: "Groups Management - Create Group Modal - Invite Members to Group - I'll Invite Later",
149                        InviteAndNext: 'Groups Management - Create Group Modal - Invite Members to Group - Invite and Next Button',
150                        PreviewMessage: 'Groups Management - Create Group Modal - Invite Members to Group - Preview message Link',
151                        Success: {
152                            AddMyself: 'Groups Management - Create Group Modal - Success - Add Myself to the Group Button'
153                        }
154                    }
155                }
156            },
157            EditGroup: {
158                AddAdmin: 'Groups Management - Edit Group Modal - Add Admin Button',
159                AddDomain: 'Groups Management - Edit Group Modal - Add Domain',
160                AutoApprovalPolicy: 'Groups Management - Edit Group Modal - Automatically approve member requests Checkbox',
161                Cancel: 'Groups Management - Edit Group Modal - Cancel Button',
162                DissolveGroup: 'Groups Management - Edit Group Modal - Dissolve Group Button',
163                EmailsToGroupAdmins: 'Groups Management - Edit Group Modal - Include computer details in summary email Checkbox',
164                EnableB2: 'Groups Management - Edit Group Modal - Enable B2 Link',
165                EnableOnlineBackup: 'Groups Management - Edit Group Modal - Enable Online Backup Link',
166                MemberBackupSummaryEmails: 'Groups Management - Edit Group Modal - Disable summary emails Checkbox',
167                RemoveAdmin: 'Groups Management - Edit Group Modal - Remove Admin Link',
168                RemoveDomain: 'Groups Management - Edit Group Modal - Remove Domain',
169                SsoDropdown: 'Groups Management - Edit Group Modal - SSO Provider Dropdown',
170                UpdateGroup: 'Groups Management - Edit Group Modal - Upd
170ate Group Button',
171            },
172            VersionHistory: {
173                Cancel: 'Groups Management - Version History Modal - Cancel Button',
174                Forever: 'Groups Management - Version History Modal - Forever Version History Radio Button',
175                LearnMore: 'Groups Management - Version History Modal - Learn More Link',
176                OneYear: 'Groups Management - Version History Modal - 1-Year Version History Radio Button',
177                Submit: 'Groups Management - Version History Modal - Submit Button',
178                ThirtyDay: 'Groups Management - Version History Modal - 30-Day Version History Radio Button',
179            },
180        },
181        AppKeys: {
182            GenerateMasterKey: 'Settings App Keys - Generate New Master Application Key Button',
183            MasterKey: {
184                ConfirmGenerate: 'Settings App Keys - Generate Master Key Confirm - Generate Master Key Button',
185                ConfirmCancel: 'Settings App Keys - Generate Master Key Confirm - Cancel Button',
186            },
187            AddNewApplicationKey: 'Settings App Keys - Add a New Application Key Button',
188            AddApplicationKey: {
189                ReadAndWrite: 'Settings App Keys - Add Application Key Modal - Read and Write Radio Button',
190                ReadOnly: 'Settings App Keys - Add Application Key Modal - Read Only Radio Button',
191                WriteOnly: 'Settings App Keys - Add Application Key Modal - Write Only Radio Button',
192                CreateNewKey: 'Settings App Keys - Add Application Key Modal - Create New Key Button',
193                Cancel: 'Settings App Keys - Add Application Key Modal - Cancel Button',
194            }
195        },
196        SignUp: {
197            SsoButton: 'Buy - Create Account Or Sign In - SSO Button',
198        },
199        // Static pages have bindings setup on page load. This way we don't have to litter the old pages with click handlers.
200        setStaticBindings: () => {
201            const page = window.location.pathname;
202            switch (page) {
203                case "/user_overview.htm":
204                    PendoUtil.registerClick('.button_restore', 'B1 Overview - Restore Button');
205                    break;
206                case "/user_restore.htm":
207                    PendoUtil.registerClick('#downloadFree', 'B1 View/Restore Files - Download Free');
208                    PendoUtil.registerClick('#saveFilesToB2', 'B1 View/Restore Files - Save Files to B2');
209                    PendoUtil.registerClick('#usbHardDrive', 'B1 View/Restore Files - USB Hard Drive');
210                    PendoUtil.registerClick('.continue_restore', 'B1 View/Restore Files - Continue with Restore Button');
211                    PendoUtil.registerClick('#ck-all', 'B1 View/Restore Files - Select all folders and files Button');
212                    break;
213                case "/user_myrestores.htm":
214                    PendoUtil.registerClick('#downloadBackblazeDownloader', 'B1 My Restores - Download Backblaze Downloader Button');
215                    PendoUtil.registerClick('#viewB2Snapshots', 'B1 My Restores - View B2 Snapshots Button');
216                    PendoUtil.registerClick('.download-button', 'B1 My Restores - Download Button');
217                    PendoUtil.registerClick('.delete-link', 'B1 My Restores - Remove from List');
218                    PendoUtil.registerClick('.cancel-link', 'B1 My Restores - Cancel');
219                    PendoUtil.registerClick('.rename-link', 'B1 My Restores - Rename');
220                    PendoUtil.registerClick('.upload-to-b2-link', 'B1 My Restores - Keep Longer - Save to B2');
221                    break;
222                case "/locate_my_computer.htm":
223                    PendoUtil.registerClick('#locate_switch_false', 'B1 Locate My Computer - Turn Off Button');
224                    PendoUtil.registerClick('#locate_switch_true', 'B1 Locate My Computer - Turn On Button');
225                    PendoUtil.registerClick('.bigbutton_locate', 'B1 Locate My Computer - Map This Button');
226                    break;
227                case "/backup_preferences.htm":
228                    PendoUtil.registerClick('#unsubscribe_marketing_link', 'B1 Preferences - Unsubscribe from Marketing Emails');
229                    PendoUtil.registerClick('.delete-backup-link', 'B1 Preferences - Delete Backup');
230                    break;
231                case "/b2_buckets.htm":
232                    PendoUtil.registerClick('#create-bucket-button', 'B2 Buckets - Create a Bucket Button');
233                    PendoUtil.registerClick('.upload-download-button', 'B2 Buckets - Upload/Download Button');
234                    PendoUtil.registerClick('#create-bucket-type-private', 'B2 Buckets - Create a Bucket Modal - Private');
235                    PendoUtil.registerClick('#create-bucket-type-public', 'B2 Buckets - Create a Bucket Modal - Public');
236                    PendoUtil.registerClick('#default-sse-disabled', 'B2 Buckets - Create a Bucket Modal - Encryption Disabled');
237                    PendoUtil.registerClick('#default-see-enabled', 'B2 Buckets - Create a Bucket Modal - Encryption 
237Enabled');
238                    PendoUtil.registerClick('#object-lock-type-disabled', 'B2 Buckets - Create a Bucket Modal - Object Lock Disabled');
239                    PendoUtil.registerClick('#object-lock-type-enabled', 'B2 Buckets - Create a Bucket Modal - Object Lock Enabled');
240                    PendoUtil.registerClick('#createBucketObjectLockLearnMoreLink', 'B2 Buckets - Create a Bucket Modal - Object Lock Learn More');
241                    PendoUtil.registerClick('#createBucket', 'B2 Buckets - Create a Bucket Modal - Create Button');
242                    PendoUtil.registerClick('#cancelCreateBucket', 'B2 Buckets - Create a Bucket Modal - Cancel Button');
243                    break;
244                case "/b2_browse_files2.htm":
245                    PendoUtil.registerClick('#upload-button', 'B2 Browse Files - Upload Button');
246                    PendoUtil.registerClick('#download-button', 'B2 Browse Files - Download Button');
247                    PendoUtil.registerClick('#new-folder-button', 'B2 Browse Files - New Folder Button');
248                    PendoUtil.registerClick('#delete-button', 'B2 Browse Files - Delete Button');
249                    PendoUtil.registerClick('#snapshot-button', 'B2 Browse Files - Snapshot Button');
250                    break;
251                case "/b2_caps_alerts.htm":
252                    PendoUtil.registerClick('#triggerEditCapsModalButtonId', 'B2 Caps & Alerts - Edit Caps Button');
253                    PendoUtil.registerClick('#UpdateCaps', 'B2 Caps & Alerts - Edit Caps Modal - Upd
253ate Caps Button');
254                    PendoUtil.registerClick('#cancelUpdateCaps', 'B2 Caps & Alerts - Edit Caps Modal - Cancel Button');
255                    PendoUtil.registerClick('#editCapsEnterPaymentLink', 'B2 Caps & Alerts - Edit Caps Modal - Enter Payment Link');
256                    break;
257                case "/business_groups.htm":
258                    PendoUtil.registerClick('#createGroupLinkId', 'Groups Management - Email Verification - Create Group Button');
259                    PendoUtil.registerClick('#dismissVerifyEmailLinkId', "Groups Management - Email Verification - I'll create a group later Link");
260                    break;
261                case "/account_settings.htm":
262                    PendoUtil.registerClick('#change_email_link', 'Settings - My Settings - Change Email Address');
263                    PendoUtil.registerClick('.add-phone-number-link', 'Settings - My Settings - Add Phone Number');
264                    PendoUtil.registerClick('.change-phone-number-link', 'Settings - My Settings - Change Phone Number');
265                    PendoUtil.registerClick('#remove_phone_link', 'Settings - My Settings - Remove Phone Number');
266                    PendoUtil.registerClick('#close_account_link,#close_account_has_data_link', 'Settings - My Settings - Delete Account');
267                    PendoUtil.registerClick('#signin_with_email,#signin_with_emailnever', 'Settings - My Settings - Sign In Using My Email Radio Button');
268                    PendoUtil.registerClick('#signin_with_google', 'Settings - My Settings - Sign In Using Google Radio Button');
269                    PendoUtil.registerClick('#verify_sso_link', 'Settings - My Settings - Verify Login to Enable');
270                    PendoUtil.registerClick('#change_password_link', 'Settings - My Settings - Change Password');
271                    PendoUtil.registerClick('#trigger_totp_link', 'Settings - My Settings - Sign In Settings');
272                    PendoUtil.registerClick('#unsubscribe_marketing_link', '
272Settings - My Settings - Unsubscribe from Marketing Emails');
273                    PendoUtil.registerClick('#enabledComputerBackupCheckboxId', 'Settings - My Settings - Computer Backup Checkbox');
274                    PendoUtil.registerClick('#enabledB2CloudStorageId', 'Settings - My Settings - B2 Cloud Storage Checkbox');
275                    PendoUtil.registerClick('#enabledGroupsCheckboxId', 'Settings - My Settings - Business Groups Checkbox');
276                    break;
277                case "/billing_card.htm":
278                    PendoUtil.registerClick('#billingBuyButton', 'Settings - Billing - Online Backup Buy Button');
279                    PendoUtil.registerClick('.enter-payment-method', 'Settings - Billing - Enter Payment Method');
280                    PendoUtil.registerClick('.update-payment-method', 'Settings - Billing - Update Payment Method');
281                    PendoUtil.registerClick('#confirmForgetPaymentMethodButtonId', 'Settings - Billing - Remove Payment Method');
282                    break;
283                case "/buy.htm":
284                    PendoUtil.registerClick('#needToMakeAccountRadioId,#needToMakeAccountRadioIdnew', 'Buy - Create Account Or Sign In - I need to create an account Radio Button');
285                    PendoUtil.registerClick('#existingAccountRadioId,#existingAccountRadioIdexisting', 'Buy - Create Account Or Sign In - I have an existing account Radio Button');
286                    PendoUtil.registerClick('#createAccountId', 'Buy - Create Account Or Sign In - Create Account Button');
287                    break;
288                case "/buy_plan.htm":
289                    PendoUtil.registerClick('#printUnusedLicenseId', 'Buy - Buy Computer Backup - Additional Licenses Dropdown');
290                    PendoUtil.registerClick('#buy_two_year', 'Buy - Buy Computer Backup - 2-Year Radio Button');
291                    PendoUtil.registerClick('#buy_one_year', 'Buy - Buy Computer Backup - 1-Year Radio Button');
292                    PendoUtil.registerClick('#buy_month_to_month', 'Buy - Buy Computer Backup - Per Month Radio Button');
293                    PendoUtil.registerClick('#upgradeCheckbox', 'Buy - Buy Computer Backup - Extended Version History Checkbox');
294                    PendoUtil.registerClick('#upgradeCheckboxLearnMoreLink', 'Buy - Buy Computer Backup - Extended Version History Learn More Link');
295                    PendoUtil.registerClick('#paymentMethod__cc,#paymentMethod__cccredit_card', 'Buy - Buy Computer Backup - Credit Card Radio Button');
296                    PendoUtil.registerClick('#paymentMethod_pc,#paymentMethod_pcprepaid_code', 'Buy - Buy Computer Backup - Prepaid Code Radio Button');
297                    PendoUtil.registerClick('#applyPrepaidCodeButtonId', 'Buy - Buy Computer Backup - Buy with Prepaid Code Button');
298                    PendoUtil.registerClick('#buyWithCreditCardButtonId', 'Buy - Buy Computer Backup - Buy with Credit Card Button');
299                    PendoUtil.registerClick('#renewMessageLink', 'Buy - Buy Computer Backup - Learn how to cancel Link');
300                    PendoUtil.registerClick('#paymentAndRefundPolicyLink', 'Buy - Buy Computer Backup - Payment and Refund Policy Link');
301                    break;
302            }
303        },
304        setupCopyEventsOnPageNavigation: () => {
305            // When user is navigating away, copy unsent events to localStorage and send them on next page load
306            const BZ_PENDO_EVENTS = "bz_pendo_events";
307            const BZ_PENDO_TRACK_EVENTS = "bz_pendo_track_events";
308            $(window).off('beforeunload.pendo');
309            $(window).on('beforeunload.pendo', () => {
310                if (window.pendo) {
311                    if (window.pendo.buffers && window.pendo.buffers.trackEvents && window.pendo.buffers.trackEvents.length > 0) {
312                        localStorage.setItem(BZ_PENDO_TRACK_EVENTS, JSON.stringify(window.pendo.buffers.trackEvents))
313                        window.pendo.buffers.trackEvents = [];
314                    }
315                    if (window.pendo.eventCache.length > 0) {
316                        localStorage.setItem(BZ_PENDO_EVENTS, JSON.stringify(window.pendo.eventCache));
317                        window.pendo.eventCache = [];
318                    }
319                }
320            });
321            let retries = 200;
322            const flushPendoEventsWhenReady = () => {
323                if (window.pendo && window.pendo.isReady && window.pendo.isReady()) {
324                    try {
325                        const json = localStorage.getItem(BZ_PENDO_TRACK_EVENTS);
326                        if (json && json.length > 0) {
327                            window.pendo.buffers.trackEvents.push(...JSON.parse(json));
328                            window.pendo.buffers.flushTrackEvents();
329                        }
330                    } finally {
331                        localStorage.removeItem(BZ_PENDO_TRACK_EVENTS);
332                    }
333                    try {
334                        const json = localStorage.getItem(BZ_PENDO_EVENTS);
335                        if (json && json.length > 0) {
336                            window.pendo.eventCache.push(...JSON.parse(json));
337                            window.pendo.flushNow();
338                        }
339                    } finally {
340                        localStorage.removeItem(BZ_PENDO_EVENTS);
341                    }
342                } else if (retries-- > 0) {
343                    setTimeout(flushPendoEventsWhenReady, 10);
344                }
345            }
346            // Wait for Pendo to be ready before sending the missing events
347            setTimeout(flushPendoEventsWhenReady, 0);
348        },
349    };
350    // Verify jquery exists before attempting this (will break karma tests)
351    if (window.$) {
352        $(document).ready(() => {
353            PendoUtil.setupCopyEventsOnPageNavigation();
354            PendoUtil.setStaticBindings();
355        });
356    }
357})();

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.