Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Bell MichaelFBA

View GitHub Profile
View UnloadAndSend.ts
/**
* 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.
View thrift-compile-ts
thrift --gen js:ts PagePerformance.thrift
View PagePerformance.ts
import Task from '../Task';
class PerformanceTask extends Task {
start({ payload }: { payload: PartnerAnalyticsPageRequest }): Promise<any> {
return new Promise(resolve => {
const {
navigationStart,
unloadEventStart,
unloadEventEnd,
redirectStart,
View PagePerformance_types.d.ts
//
// 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
*/
View PagePerformance.thrift
/**
* 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,
View Activities loader
<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>
View gist:7373881
/*
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