PageSourceSearch

https://www.turkticaret.net/new_assets_2015/js/posthog_extras.js?v=20260916-customer-replay2

js turkticaret.net collected 2026-09-24 12:18:29 UTC 10,520 bytes, 254 lines download raw bytes

1(function startExtras() {
2    'use strict';
3
4    var host = (window.location && window.location.hostname) || '';
5    if (/(^|\.)devel\./i.test(host) ||
6        host === 'localhost' ||
7        /^127\./.test(host) ||
8        /^192\.168\./.test(host) ||
9        /^10\./.test(host)) {
10        return;
11    }
12
13    var privacy = window.TTPosthogPrivacy;
14    var runtime = window.TTPosthogRuntime;
15    if (!privacy || !runtime) {
16        window.addEventListener('tt:posthog-bootstrap', startExtras);
17        return;
18    }
19    window.removeEventListener('tt:posthog-bootstrap', startExtras);
20    if (window.__ttPosthogExtras) return;
21    window.__ttPosthogExtras = true;
22
23    var OWN_HOST_PATTERN = /(^|\.)turkticaret\.net$/i;
24    var pageLeaving = false;
25    if (typeof window.addEventListener === 'function') {
26        window.addEventListener('pagehide', function () { pageLeaving = true; });
27        window.addEventListener('pageshow', function () { pageLeaving = false; });
28    }
29    function clockMs() {
30        return window.performance && typeof window.performance.now === 'function' ? window.performance.now() : Date.now();
31    }
32    function networkContext(started, kind) {
33        return {
34            network_failure_kind: kind,
35            request_duration_ms: Math.max(0, Math.round(clockMs() - started)),
36            page_lifecycle: pageLeaving ? 'leaving' : (document.visibilityState === 'hidden' ? 'hidden' : 'active')
37        };
38    }
39    function addNetworkContext(props, started, kind) {
40        var context = networkContext(started, kind);
41        Object.keys(context).forEach(function (key) { props[key] = context[key]; });
42        return props;
43    }
44
45    var IGNORED_PATH_FRAGMENTS = [
46        'manifest.json',
47        'firebase-messaging-sw.js',
48        'posthog-context.php'
49    ];
50
51    function shouldSkipUrl(url) {
52        if (!url) return false;
53        if (url.indexOf('chrome-extension://') === 0) return true;
54        if (url.indexOf('moz-extension://') === 0) return true;
55        if (url.indexOf('properties://') === 0) return true;
56
57        var hostname, pathname;
58        try {
59            var u = new URL(url, window.location.origin);
60            hostname = u.hostname;
61            pathname = u.pathname || '';
62        } catch (e) {
63            return false;
64        }
65
66        for (var i = 0; i < IGNORED_PATH_FRAGMENTS.length; i++) {
67            if (pathname.indexOf(IGNORED_PATH_FRAGMENTS[i]) !== -1) return true;
68        }
69
70        if (hostname === 'posthog.turkticaret.net') return true;
71
72        if (!OWN_HOST_PATTERN.test(hostname)) return true;
73
74        return false;
75    }
76
77    function extractUrl(input) {
78        if (!input) return '';
79        if (typeof input === 'string') return input;
80        if (typeof URL !== 'undefined' && input instanceof URL) return input.href;
81        if (typeof input.url === 'string') return input.url;
82        try { return String(input); } catch (e) { return ''; }
83    }
84
85    function ph() {
86        return (runtime.isReady() && window.posthog && window.posthog.__loaded) ? window.posthog : null;
87    }
88
89    function applyIdentity() {
90        try { return privacy.applyIdentity(ph()); } catch (e) { return false; }
91    }
92
93    var identityStarted = false, identityInterval = null;
94    runtime.onChange(function (state) {
95        if (!state.ready) {
96            if (identityInterval !== null) clearInterval(identityInterval);
97            identityInterval = null;
98            return;
99        }
100        if (identityStarted) return;
101        identityStarted = true;
102        if (applyIdentity()) return;
103        var identityTries = 0;
104        identityInterval = setInterval(function () {
105            if (applyIdentity() || identityTries++ > 60) {
106                clearInterval(identityInterval);
107                identityInterval = null;
108            }
109        }, 100);
110    });
111
112    function safeCapture(err, props) {
113        try {
114            var p = ph();
115            if (!p) return;
116            var cleanError = new Error(privacy.text(err && err.message ? err.message : 'Unknown error'));
117            if (err && err.name) cleanError.name = privacy.text(err.name);
118            if (err && err.stack) cleanError.stack = privacy.text(err.stack);
119            p.captureException(cleanError, privacy.value(props || {}));
120        } catch (e) { /* noop */ }
121    }
122
123    var CONSOLE_ERROR_SKIP_PATTERNS = [
124        'Firebase ba',
125        'messaging/unsupported',
126        'Service Worker kay',
127        'firebase-messaging-sw.js',
128        'fcmregistrations.googleapis.com',
129        'firebaseinstallations.googleapis.com'
130    ];
131
132    function shouldSkipConsoleErrorMessage(msg) {
133        if (!msg) return false;
134        if (msg.indexOf('[PostHog.js]') === 0) return true;
135        for (var i = 0; i < CONSOLE_ERROR_SKIP_PATTERNS.length; i++) {
136            if (msg.indexOf(CONSOLE_ERROR_SKIP_PATTERNS[i]) !== -1) return true;
137        }
138        return false;
139    }
140
141    var origConsoleError = console.error;
142    console.error = function () {
143        if (!runtime.isReady()) return origConsoleError.apply(console, arguments);
144        try {
145            var msg = Array.prototype.map.call(arguments, function (a) {
146                if (a instanceof Error) return a.message;
147                if (typeof a === 'object' && a !== null) {
148                    return '[object omitted]';
149                }
150                return privacy.text(a);
151            }).join(' ');
152            if (msg.indexOf('posthog') === -1 || msg.indexOf('turkticaret.net') === -1) {
153                if (!shouldSkipConsoleErrorMessage(msg)) {
154                    var sourceError = Array.prototype.filter.call(arguments, function (a) { return a instanceof Error; })[0];
155                    safeCapture(sourceError || new Error(msg), {
156                        $exception_source: 'console.error',
157                        $exception_handled: true
158                    });
159                }
160            }
161        } catch (e) { /* noop */ }
162        return origConsoleError.apply(console, arguments);
163    };
164
165    if (typeof window.fetch === 'function') {
166        var origFetch = window.fetch;
167        window.fetch = function (input, init) {
168            if (!runtime.isReady()) return origFetch.apply(this, arguments);
169            var url = extractUrl(input);
170            var safeUrl = privacy.url(url);
171            var method = (init && init.method) || (input && input.method) || 'GET';
172            if (shouldSkipUrl(url)) {
173                return origFetch.apply(this, arguments);
174            }
175            var started = clockMs();
176            return origFetch.apply(this, arguments).then(function (res) {
177                try {
178                    if (!res.ok && res.status !== 0 && res.type !== 'opaque' && !shouldSkipUrl(url)) {
179                        safeCapture(
180                            new Error('fetch ' + res.status + ' ' + (res.statusText || '') + ' ' + method + ' ' + safeUrl),
181                            addNetworkContext({
182                                $exception_source: 'fetch',
183                                $exception_handled: true,
184                                http_status: res.status,
185                                http_url: safeUrl,
186                                http_method: method
187                            }, started, 'http')
188                        );
189                    }
190                } catch (e) { /* noop */ }
191                return res;
192            }).catch(function (err) {
193                try {
194                    if (!shouldSkipUrl(url)) {
195                        var kind = err && err.name === 'AbortError' ? 'abort' : 'network';
196                        safeCapture(err, addNetworkContext({
197                            $exception_source: kind === 'abort' ? 'fetch_abort' : 'fetch_network',
198                            $exception_handled: true,
199                            http_url: safeUrl,
200                            http_method: method
201                        }, started, kind));
202                    }
203                } catch (e) { /* noop */ }
204                throw err;
205            });
206        };
207    }
208
209    if (typeof window.XMLHttpRequest === 'function') {
210        var origOpen = XMLHttpRequest.prototype.open;
211        var origSend = XMLHttpRequest.prototype.send;
212        XMLHttpRequest.prototype.open = function (method, url) {
213            var result = origOpen.apply(this, arguments);
214            this._ph_method = method;
215            this._ph_url = extractUrl(url);
216            this._ph_failure_kind = 'unknown';
217            return result;
218        };
219        XMLHttpRequest.prototype.send = function () {
220            var xhr = this;
221            xhr._ph_capture_active = runtime.isReady();
222            if (!xhr._ph_capture_active) return origSend.apply(this, arguments);
223            try {
224                xhr._ph_started = clockMs();
225                xhr._ph_failure_kind = 'unknown';
226                if (!xhr._ph_observed) {
227                    xhr._ph_observed = true;
228                    ['abort', 'timeout', 'error'].forEach(function (type) {
229                        xhr.addEventListener(type, function () {
230                            xhr._ph_failure_kind = type === 'error' ? 'network' : type;
231                        });
232                    });
233                    xhr.addEventListener('loadend', function () {
234                        try {
235                            if (xhr._ph_capture_active && (xhr.status >= 400 || xhr.status === 0) && !shouldSkipUrl(xhr._ph_url)) {
236                                var safeUrl = privacy.url(xhr._ph_url);
237                                var kind = xhr.status === 0 ? xhr._ph_failure_kind : 'http';
238                                var source = xhr.status !== 0 ? 'xhr' : (kind === 'abort' ? 'xhr_abort' : (kind === 'timeout' ? 'xhr_timeout' : 'xhr_network'));
239                                safeCapture(new Error('xhr ' + xhr.status + ' ' + (xhr._ph_method || '?') + ' ' + safeUrl), addNetworkContext({
240                                    $exception_source: source,
241                                    $exception_handled: true,
242                                    http_status: xhr.status,
243                                    http_url: safeUrl,
244                                    http_method: xhr._ph_method
245                                }, xhr._ph_started, kind));
246                            }
247                        } catch (e) { /* noop */ }
248                    });
249                }
250            } catch (e) { /* noop */ }
251            return origSend.apply(this, arguments);
252        };
253    }
254})();

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.