<?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: Kemal Ahmed</title>
    <description>The latest articles on DEV Community by Kemal Ahmed (@goatandsheep).</description>
    <link>https://dev.to/goatandsheep</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%2F319925%2F1629ca76-59eb-4fc8-989e-5afc5c8f0432.jpg</url>
      <title>DEV Community: Kemal Ahmed</title>
      <link>https://dev.to/goatandsheep</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/goatandsheep"/>
    <language>en</language>
    <item>
      <title>How to use Babel's new addExternalDependency API</title>
      <dc:creator>Kemal Ahmed</dc:creator>
      <pubDate>Sat, 12 Nov 2022 05:10:04 +0000</pubDate>
      <link>https://dev.to/goatandsheep/how-to-use-babels-new-addexternaldependency-api-338h</link>
      <guid>https://dev.to/goatandsheep/how-to-use-babels-new-addexternaldependency-api-338h</guid>
      <description>&lt;p&gt;The story begins with me as a clout-chasing, NPM library maintainer. The library is a Babel plugin, known as &lt;code&gt;react-native-dotenv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The problem? Babel was caching the non-Javascript files the library was meant to load. The real problem? My ego was being obliterated by developers who were replacing my library as a dependency because they needed a functional way to load environment variables into their react native apps.&lt;/p&gt;

&lt;p&gt;To solve it, I scoured the Babel feature pipeline, a.k.a. random draft PRs people had created to add any file to the Babel watchlist. I bumped it, did no extra work, watched the Babel team pick it up and do an epic job on it, and planned to write a blog to take full credit for my prod.&lt;/p&gt;

&lt;p&gt;When addExternalDependency was born, the release had so many other amazing features, the docs were not up to par of the other Babel docs. So I made a pact with the devs that I would write some documentation in exchange for help on fixing up my library and this is my lousy attempt at it.&lt;/p&gt;

&lt;p&gt;So to begin, in my &lt;code&gt;module.exports&lt;/code&gt; function, I made sure to tell Babel what and how to cache the alien files that are dear to my library. I use a function to verify if they've been updated recently&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;mtime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;statSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;mtimeMs&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and for each file path I'm checking I add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;using&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;mtime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we tell Babel to watch for changes and recompile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addExternalDependency&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And for the hardest part? Convince every library to upgrade their versions of Babel. Or tell your users to add the following to their &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;resolutions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@babel/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^7.20.2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;babel-loader&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;8.3.0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As of writing this article I am searching for a job. If I've tricked you into thinking I'm a half-decent Javascript developer, please tell a hiring manager near you because I'm competing against other exceptional devs from Twitter and Meta.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>reactnative</category>
      <category>opensource</category>
      <category>node</category>
    </item>
    <item>
      <title>Stop donating your customers' data to Google Analytics</title>
      <dc:creator>Kemal Ahmed</dc:creator>
      <pubDate>Tue, 21 Jan 2020 05:53:07 +0000</pubDate>
      <link>https://dev.to/goatandsheep/stop-donating-your-customers-data-to-google-analytics-191</link>
      <guid>https://dev.to/goatandsheep/stop-donating-your-customers-data-to-google-analytics-191</guid>
      <description>&lt;p&gt;In 2020, with better alternatives available, using Google Analytics (GA) to track your web usage is nothing short of donating data to a multinational corporation. Aside from only letting you sample 25% of your traffic, GA is a free ticket for them to sell your customers' data to their advertising partners.&lt;/p&gt;

&lt;p&gt;Compared to AWS Pinpoint, which is even &lt;a href="https://aws.amazon.com/about-aws/whats-new/2019/07/amazon-pinpoint-achieves-hipaa-eligibility/" rel="noopener noreferrer"&gt;HIPAA compliant&lt;/a&gt;, GA works by asking you to add a tracker to your website that cross examines your customers' habits across all the websites they use to find out everything about them.&lt;/p&gt;

&lt;p&gt;And if you think that's okay, you should take your head out of the sand because consumers are demanding it. Please tell me how many of your users like the large cookie agreement popups that they have to dismiss...I-I mean read and accept just to consume your content. Agreements that you're forced to have them agree to because you're using cookie-based trackers like GA.&lt;/p&gt;

&lt;p&gt;Tracker blockers are increasing in popularity so consumers can protect themselves against this tracking, reducing the effectiveness of your analytics.&lt;/p&gt;

&lt;p&gt;Even if you want to be selling your customers' data, data is the new oil and GA is Deepwater Horizon. As in raking it in, but also about to catch fire and sink. Tools like Pinpoint on the other hand keep the data in your closed system and even allows you to attach more extensive analytics like Kinesis. To train machine learning models on data you've collected would require you to create pipelines between data centres. It's a single click:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz005zqn81ac3c4t0q2nx.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz005zqn81ac3c4t0q2nx.PNG" alt="Alt Text" width="645" height="88"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Currently, AWS Pinpoint requires you to import Amplify to your project. If you're looking for a tracking-tag solution like for Google Analytics, it's now that simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script
    &lt;/span&gt;&lt;span class="na"&gt;data-id-pool=&lt;/span&gt;&lt;span class="s"&gt;"us-east-1:abcd1234-abcd-1234-5678-abcd12345678"&lt;/span&gt;
    &lt;span class="na"&gt;data-pinpoint-id=&lt;/span&gt;&lt;span class="s"&gt;"1234abcd5678abcd7890abcd1234"&lt;/span&gt;
    &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"aws-web-analytics"&lt;/span&gt;
    &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://goatandsheep.github.io/aws-web-analytics/dist/aws-web-analytics.js"&lt;/span&gt;
    &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/javascript"&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is thanks to an analytics package I built that uses Amplify to connect to AWS Pinpoint. If you're interested in contributing, please &lt;a href="https://github.com/goatandsheep/aws-web-analytics/" rel="noopener noreferrer"&gt;visit the project repo&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>amplify</category>
      <category>contributorswanted</category>
      <category>analytics</category>
    </item>
  </channel>
</rss>
