<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cyril</title>
    <description>The latest articles on DEV Community by Cyril (@cnicodeme).</description>
    <link>https://dev.to/cnicodeme</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F239149%2F2b6e7a51-526d-4f8e-804e-c5dca7bb87b1.jpg</url>
      <title>DEV Community: Cyril</title>
      <link>https://dev.to/cnicodeme</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cnicodeme"/>
    <language>en</language>
    <item>
      <title>How to notify your users when a new version is available?</title>
      <dc:creator>Cyril</dc:creator>
      <pubDate>Fri, 15 Nov 2024 15:21:20 +0000</pubDate>
      <link>https://dev.to/fernand/how-to-notify-your-users-when-a-new-version-is-available-4h63</link>
      <guid>https://dev.to/fernand/how-to-notify-your-users-when-a-new-version-is-available-4h63</guid>
      <description>&lt;p&gt;Hey folks!&lt;/p&gt;

&lt;p&gt;Today, I'd like to share with you a new features we are about to push on Fernand that has been bothering us for a while.&lt;/p&gt;

&lt;p&gt;When we were pushing a new version of Fernand in Production, the app tended to have some issues there and there caused by some cache.&lt;/p&gt;

&lt;p&gt;So we wanted to implement a notification to tell the user that a new version was released, and they had to refresh their browser.&lt;/p&gt;

&lt;p&gt;That's what I worked on today, but I was surprised about the suggestion available online.&lt;/p&gt;

&lt;p&gt;Indeed, if your frontend is independant from the backend, how can you tell your frontend that a new version is available?&lt;/p&gt;

&lt;p&gt;Well, simple! You just have to create an endpoint on your backend that will receive a Webhook notification on PUSH from Github/Gitlab/etc.&lt;/p&gt;

&lt;p&gt;When receiving the request, the server will have a few work to do:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Save locally the new version, in case of reload&lt;/li&gt;
&lt;li&gt;Send it to the users when they connects&lt;/li&gt;
&lt;li&gt;Send it to the currently connected users.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For both 2 and 3, I searched online, and found two main possibilities:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using a WebWorker&lt;/li&gt;
&lt;li&gt;Having an endpoint in the backend that will show the latest version and compare it with the front. Show the notification when it differ.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Even though option 1 makes a bit more sense, option 2 is really bad because it requires the frontend to query the backend every X minutes, which might cause a DDoS on the server as the app grows in popularity.&lt;br&gt;
Moreover, it's absolutely not efficient, since the delay between two updates could be weeks, months or even years on old projects!&lt;/p&gt;

&lt;p&gt;But I wasn't a fan of WebWorker neither, because it required installing it on all the browsers, and the update were only interesting when our users were using Fernand only.&lt;/p&gt;

&lt;p&gt;So I come up with another idea. Fernand is relying on WebSockets to exchange data (but stay tuned for a solution when using REST API), so all I had to do, is send a notification to all connected users telling them about the new version.&lt;/p&gt;

&lt;p&gt;On the frontend, what I did was store the current SHA1 COMMIT ID as a javascript variable, and compare that to the version sent by the server. If it differs, it means there is a new version available and we show the "Refresh" notification.&lt;/p&gt;

&lt;p&gt;The current version is first sent by the WebSocket when the user connects, and when a new version is released, that same Websocket will send the same event with the updated version. That way, in the frontend, we use the same code for both scenarios.&lt;/p&gt;

&lt;p&gt;Implementing that in the frontend was relatively easy (I had a much more difficult time finding a way to get the commit ID saved on the app).&lt;/p&gt;

&lt;p&gt;But what do to if you are not using Websockets?&lt;/p&gt;

&lt;p&gt;In this case, an easy alternative is to provide the current known version of your app as an header when sending your responses back to the client. On the frontend, you can setup a request interceptor to read the responses and compare the "app version header" to the local one and trigger the notification when it differ.&lt;/p&gt;

&lt;p&gt;This avoids you to have to setup an interval to check your server.&lt;/p&gt;

&lt;p&gt;And in case your user doesn't send much requests to your server, you can query the version to your server when the user gives focus to your app.&lt;/p&gt;

&lt;p&gt;So in the end, we have the following workflow at &lt;a href="https://getfernand.com" rel="noopener noreferrer"&gt;Fernand&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We push an update to Github for the app&lt;/li&gt;
&lt;li&gt;Github sends a Webhook event to our servers (dev/prod/etc)&lt;/li&gt;
&lt;li&gt;The server will check if the branche matches the server type (branch staging for the staging servers, etc)&lt;/li&gt;
&lt;li&gt;If it does, we wait for a few minutes, while the build completes&lt;/li&gt;
&lt;li&gt;The new SHA1 COMMIT ID is then saved locally, and an event is sent to all connected websocket to provide the new version&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On the frontend, when receiving an event from the websocket about the version, we simply compare the local one against the new one, and if it differs, we show the notification!&lt;/p&gt;

&lt;p&gt;Easy peasy :)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Pricing page and currencies</title>
      <dc:creator>Cyril</dc:creator>
      <pubDate>Fri, 19 Aug 2022 09:41:00 +0000</pubDate>
      <link>https://dev.to/cnicodeme/pricing-page-and-currencies-2883</link>
      <guid>https://dev.to/cnicodeme/pricing-page-and-currencies-2883</guid>
      <description>&lt;p&gt;Prakash Natarajan wrote an interesting post on IndieHacker on June 20 (Experimenting with /pricing?), where he mentions the issue for non-USD people to have a clear understanding of their cost.&lt;/p&gt;

&lt;p&gt;It's true that if you aren't aware of the currency value between USD and the one in your (non-USD) country, you need to do a quick Google search, which isn't ideal and can break your potential user from signing up.&lt;/p&gt;

&lt;p&gt;Now, Prakash suggests a simple script that checks the user's country based on his IP, and converts the amount into the local currency, removing the barrier.&lt;/p&gt;

&lt;p&gt;But offering your service in multiple currencies can have a big drawback in the future: Imagine the relation between USD and EUR is at 0.7. Your user subscribes in EUR for 7 EUR instead of 10 USD.&lt;br&gt;
A few months later, the relation between USD and EUR changed and is now close to 1. That user will still pay 7 EUR whereas a new user will pay 10 EUR per month.&lt;/p&gt;

&lt;p&gt;To avoid this, you can adjust their monthly billing according to the currency value, which is not great for your end user that will never know if they'll pay 7 or 10 EUR.&lt;/p&gt;

&lt;p&gt;Having the local currency displayed is a great idea as it can help your user make the decision faster. But instead of changing the currency, and offering multiple currencies, a good alternative would be to show the price in your unique currency (USD for instance), and show the price in their local currency next to it, either as a tooltip, or well-integrated in the design.&lt;/p&gt;

&lt;p&gt;That way, your user will know the price is in USD, but will also quickly know how much it will exactly cost for them if they subscribe that day.&lt;/p&gt;

&lt;p&gt;What do you think? Those who offer multiple currencies, are you facing this often? Do you consider the variation between the currencies an issue?&lt;/p&gt;

&lt;p&gt;Thanks for sharing your thoughts.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>pricing</category>
    </item>
  </channel>
</rss>
