Skip to content

Commit

Permalink
final cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jlumbard committed Jan 17, 2025
1 parent 00e0812 commit 46f968c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/FloatingThumbs/FloatingThumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import React, { useState, useEffect } from 'react';
import styles from './FloatingThumbs.module.css'; // Optional: use CSS Modules
import { useLocation } from 'react-router-dom';

const getStatsig = () => {
return Statsig.instances['client-XlqSMkAavOmrePNeWfD0fo2cWcjxkZ0cJZz64w7bfHX']
}

const hasInteractedBefore = () => {
const currentUrl = window.location.href;
return localStorage.getItem(currentUrl) !== null;
Expand All @@ -29,7 +33,7 @@ const FloatingDialog = () => {
setClickedButton(null);
setHoveredButton(null);

const feedbackTimeoutConfig = Statsig.instance().getDynamicConfig('how_long_before_show_feedback_docs')
const feedbackTimeoutConfig = getStatsig().getDynamicConfig('how_long_before_show_feedback_docs')
const timeoutBeforeShow = feedbackTimeoutConfig.get('timeout', 30000)

const timer = setTimeout(() => {
Expand Down Expand Up @@ -71,10 +75,10 @@ const FloatingDialog = () => {
setTimeout(() => {
setIsOpen(false);
localStorage.setItem(currentUrl, 'up');
}, 200000); // Close after 2 seconds
}, 2000); // Close after 2 seconds
}, 300); // Wait 500ms to show the thanks message
}
Statsig.instance().logEvent('ThumbClick', direction,{
getStatsig().logEvent('ThumbClick', direction,{
direction: direction,
url: window.location.href,
});
Expand All @@ -89,17 +93,16 @@ const FloatingDialog = () => {
}, 2000);
setFeedback('');
setShowFeedbackThanks(true);
Statsig.instance().logEvent('FeedbackSubmitted', feedback);
getStatsig().logEvent('FeedbackSubmitted', feedback);
const url = window.location.href
.replace(/^https?:\/\/|^www\./g, '') // Remove protocol and www
.replace(/\?.*$/, '') // Remove query parameters
.replace(/\/$/, ''); // Remove trailing slash only
const assigneeConfig = Statsig.instance().getDynamicConfig('docs_url_assignments');
const assigneeConfig = getStatsig().getDynamicConfig('docs_url_assignments');
const assignee = assigneeConfig.get(url, 'U087FSV8F0S');
sendDocsFeedback(window.location.href, feedback, assignee);
};

if ( !Statsig.instance().checkGate('docs_feedback_enabled') || !isOpen || !hasSpentEnoughTime || (hasInteractedBefore() && (!showFeedback && !showThanks))) return null;
if ( !getStatsig().checkGate('docs_feedback_enabled') || !isOpen || !hasSpentEnoughTime || (hasInteractedBefore() && (!showFeedback && !showThanks))) return null;


return (
Expand Down

0 comments on commit 46f968c

Please sign in to comment.