Skip to content

Instantly share code, notes, and snippets.

View MichaelFBA's full-sized avatar
🙃

Michael Bell MichaelFBA

🙃
  • GetYourGuide
  • Zürich
View GitHub Profile
/**
* Setup listener for page unload event
* @see https://developers.google.com/web/updates/2018/07/page-lifecycle-api
*/
const terminationEvent = 'onpagehide' in window ? 'pagehide' : 'unload';
window.addEventListener(
terminationEvent,
() => {
// Note: if the browser is able to cache the page, `event.persisted`
// is `true`, and the state is frozen rather than terminated.
thrift --gen js:ts PagePerformance.thrift
import Task from '../Task';
class PerformanceTask extends Task {
start({ payload }: { payload: PartnerAnalyticsPageRequest }): Promise<any> {
return new Promise(resolve => {
const {
navigationStart,
unloadEventStart,
unloadEventEnd,
redirectStart,
//
// Autogenerated by Thrift Compiler (0.11.0)
//
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
//
/**
* Page Performance gathered from the browser window.performance.timing
*/
/**
* Page Performance gathered from the browser window.performance.timing
*/
struct PagePerformance {
1: optional i64 navigation_start,
2: optional i64 unload_event_start,
3: optional i64 unload_event_end,
4: optional i64 redirect_start,
<script async defer src="//widget.getyourguide.com/v2/widget.js"></script>
<div
data-gyg-id="test"
data-gyg-widget="activities"
data-gyg-href="https://widget.getyourguide.com/default/activites.frame"
data-gyg-number-of-items="4"
data-gyg-locale-code="eu-AU"
data-gyg-iata="TRC"
></div>
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software