This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router, UiState } from "instantsearch.js"; | |
import NextRouter from "next/router"; | |
import qs from "qs"; | |
/** | |
* This file is a copy of the InstantSearch.js router middleware: | |
* https://github.com/algolia/instantsearch.js/blob/5d79d92b30e188e5206dcb5fe86fcac058c3f09b/src/lib/routers/history.ts | |
* | |
* It's internals have been adapted to use the NextJS Router (singleton) instead | |
* of native browser history. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nextPushId () { | |
// Modeled after base64 web-safe chars, but ordered by ASCII. | |
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' | |
// Timestamp of last push, used to prevent local collisions if you push twice | |
// in one ms. | |
var lastPushTime = 0 | |
// We generate 72-bits of randomness which get turned into 12 characters and | |
// appended to the timestamp to prevent collisions with other clients. We | |
// store the last characters we generated because in the event of a collision, | |
// we'll use those same characters except "incremented" by one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function () { | |
'use strict'; | |
return function (obj, opts) { | |
if (!opts) { | |
opts = {}; | |
} | |
if (typeof opts === 'function') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var analyticsId = ''; | |
if (window.localStorage && window.localStorage.setItem) { | |
window.ga('create', analyticsId, { | |
'storage': 'none', | |
'clientId': window.localStorage.getItem('clientId') | |
}); | |
window.ga(function(tracker) { |