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 type { NextApiRequest, NextApiResponse } from "next"; | |
import Statsig from "statsig-node"; | |
import { getSession } from "next-auth/react"; | |
enum Command { | |
chat, | |
g, | |
gh, | |
google, |
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
// app.js | |
const messageChannel = new MessageChannel(); | |
function setup() { | |
navigator.serviceWorker.controller.postMessage({ | |
type: 'INIT_PORT', | |
}, [messageChannel.port2]); | |
messageChannel.port1.onmessage = (event) => { | |
console.log(event.data); |
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
const statsig = require('statsig-node'); | |
let requestsHandled = 0; | |
const initStart = Date.now(); | |
let initEnd = 0; | |
let initialized = false; | |
const initializationPromise = statsig.initialize(process.env.sdkKey).then(() => { | |
initEnd = Date.now(); | |
initialized = true; | |
}); |
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 logo from './logo.svg'; | |
import './App.css'; | |
import {StatsigProvider, Statsig, useConfig, useGate, useExperiment, StatsigContext} from 'statsig-react'; | |
import {useEffect, useState, useContext} from 'react'; | |
function Component({updateUser}) { | |
const config = useConfig('test_config'); | |
const gate = useGate('always_on_gate').value; | |
console.log(gate); | |
console.log(config); |
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 React from 'react'; | |
import StatsigContext from './StatsigContext'; | |
import Statsig from './Statsig'; | |
type Props = { | |
children: React.ReactNode | React.ReactNode[]; | |
userVersion: number; | |
}; | |
export default function StatsigManuallyInitializedProvider({ |
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
<?php | |
// Usage | |
// $user = (object)[]; | |
// $user->userID = 3; | |
// checkGate($user, "gate_name"); | |
// getConfig($user, "config_name")); | |
// getExperiment($user, "product_logo_icon_shapes"); |
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
let mockGates: Record<string, boolean> = {}; | |
jest.mock('statsig-react', () => { | |
return { | |
useGate: (gateName: string) => { | |
return { | |
isLoading: false, | |
value: mockGates[gateName] ?? false, | |
}; | |
}, | |
useConfig: () => { |
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
from ctypes import * | |
lib = cdll.LoadLibrary("./statsigshared.so") | |
class GoString(Structure): | |
_fields_ = [("p", c_char_p), ("n", c_longlong)] | |
lib.Initialize.argtypes = [GoString] | |
key = GoString(b"secret-XXXXXXXXXXXXXXXXXXXXXXXXXXX", 34) |
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
if (Statsig.checkGate("search_ranking_v2") { | |
// use new ranking feature | |
} else { | |
// default/fallback to existing experience | |
} |
NewerOlder