Skip to content

Commit d14702f

Browse files
Embed stats tweet into Shopify page
1 parent 68b26f0 commit d14702f

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React, { useEffect, useRef } from "react";
2+
3+
interface Props {
4+
id: string;
5+
className?: string;
6+
children?: React.ReactNode;
7+
}
8+
9+
export default function Tweet({ id, className, children }: Props) {
10+
const ref = useRef<HTMLDivElement | null>(null);
11+
12+
useEffect(() => {
13+
if (typeof window === "undefined") return;
14+
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
16+
const win = window as any;
17+
18+
const runLoad = () => {
19+
try {
20+
if (win.twttr && win.twttr.widgets && ref.current) {
21+
win.twttr.widgets.load(ref.current);
22+
}
23+
} catch (e) {
24+
// ignore
25+
}
26+
};
27+
28+
if (win.twttr && win.twttr.widgets) {
29+
runLoad();
30+
return;
31+
}
32+
33+
const script = document.createElement("script");
34+
script.src = "https://platform.twitter.com/widgets.js";
35+
script.async = true;
36+
script.charset = "utf-8";
37+
script.onload = runLoad;
38+
document.body.appendChild(script);
39+
40+
return () => {
41+
// leave script in place (fast subsequent loads) and don't mutate global twttr
42+
};
43+
}, [id]);
44+
45+
return (
46+
<div ref={ref} className={className}>
47+
<blockquote className="twitter-tweet">
48+
{children ?? (
49+
<a href={`https://twitter.com/ShopifyEng/status/${id}`}>View Tweet</a>
50+
)}
51+
</blockquote>
52+
</div>
53+
);
54+
}

app/content/work/shopify.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ There were three main projects we undertook while I was managing the team: porti
4949

5050
- [Improved storefront performance globally](https://www.shopify.com/partners/blog/storefront-renderer)
5151
- [3x Storefront API performance after porting to SFR](https://www.shopify.com/news/performance%F0%9F%91%86-complexity%F0%9F%91%87-killer-updates-from-shopify-engineering)
52-
- Highly resilient systems with no incidents during BFCM 2022 or 2023
52+
- Highly resilient systems with no incidents during BFCM 2022 or 2023 (see tweet)
5353
- An ongoing initiative to build team-wide confidence and improve onboarding for team members on the SFR on-call rotation, through presentations and table top excercises.
5454

55+
import Tweet from "~/components/TweetEmbed/TweetEmbed";
56+
57+
<Tweet id="1729500623773573265" className="flex justify-center">
58+
<p lang="en" dir="ltr">That&#39;s a wrap on another incredible BFCM! You got a nerdy preview from <a href="https://twitter.com/tobi?ref_src=twsrc%5Etfw">@tobi</a>, and we&#39;re back with the final stats. Let’s go!🧵👇<br/><br/>We achieved 99.999+% uptime, handling 29.7 PB of data served from across our infrastructure over the entire event! That’s over 5 TB/min. <a href="https://t.co/YfqIOR4YQ7">https://t.co/YfqIOR4YQ7</a></p>
59+
&mdash; Shopify Engineering (@ShopifyEng) <a href="https://twitter.com/ShopifyEng/status/1729500623773573265?ref_src=twsrc%5Etfw">November 28, 2023</a>
60+
</Tweet>
61+
5562
## Carts
5663

5764
While managing the Storefront API team, there was a focus on supporting enterprise merchants and custom storefronts. One of the main areas of the Storefront API that was most critical but least developed was the Cart API.

0 commit comments

Comments
 (0)