Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

utm-synapse

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utm-synapse - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

12

dist/cjs/index.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.utmSynapse = exports.UtmSynapse = exports.UtmParamEnum = void 0;
const memorystorage_1 = __importDefault(require("memorystorage"));
var UtmParamEnum;

@@ -24,8 +28,10 @@ (function (UtmParamEnum) {

// In the future we could allow customizing the `sessionStorage` key...
this.storage = sessionStorage;
// In case the storage is missing, log this plugin won't work normally
if (typeof Storage === 'undefined') {
console.warn(`Using the UTM package without having a storage won't work properly`);
this.storage = null;
console.warn("Using the UTM package without having a storage won't work properly");
this.storage = new memorystorage_1.default();
}
else {
this.storage = sessionStorage;
}
}

@@ -32,0 +38,0 @@ /** Extract UTM parameters from a URL or by default `window.location.href` */

@@ -0,1 +1,2 @@

import MemoryStorage from 'memorystorage';
export var UtmParamEnum;

@@ -21,8 +22,10 @@ (function (UtmParamEnum) {

// In the future we could allow customizing the `sessionStorage` key...
this.storage = sessionStorage;
// In case the storage is missing, log this plugin won't work normally
if (typeof Storage === 'undefined') {
console.warn(`Using the UTM package without having a storage won't work properly`);
this.storage = null;
console.warn("Using the UTM package without having a storage won't work properly");
this.storage = new MemoryStorage();
}
else {
this.storage = sessionStorage;
}
}

@@ -29,0 +32,0 @@ /** Extract UTM parameters from a URL or by default `window.location.href` */

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.UtmSynapse = {}));
})(this, (function (exports) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('memorystorage')) :
typeof define === 'function' && define.amd ? define(['exports', 'memorystorage'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.UtmSynapse = {}, global.MemoryStorage));
})(this, (function (exports, MemoryStorage) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var MemoryStorage__default = /*#__PURE__*/_interopDefaultLegacy(MemoryStorage);
exports.UtmParamEnum = void 0;

@@ -27,8 +31,10 @@ (function (UtmParamEnum) {

// In the future we could allow customizing the `sessionStorage` key...
this.storage = sessionStorage;
// In case the storage is missing, log this plugin won't work normally
if (typeof Storage === 'undefined') {
console.warn(`Using the UTM package without having a storage won't work properly`);
this.storage = null;
console.warn("Using the UTM package without having a storage won't work properly");
this.storage = new MemoryStorage__default["default"]();
}
else {
this.storage = sessionStorage;
}
}

@@ -35,0 +41,0 @@ /** Extract UTM parameters from a URL or by default `window.location.href` */

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).UtmSynapse={})}(this,function(o){"use strict";o.UtmParamEnum=void 0,(t=o.UtmParamEnum||(o.UtmParamEnum={})).Source="utm_source",t.Medium="utm_medium",t.Campaign="utm_campaign",t.Content="utm_content",t.Name="utm_name",t.Term="utm_term",t.InitialSource="initial_utm_source",t.InitialMedium="initial_utm_medium",t.InitialCampaign="initial_utm_campaign",t.InitialContent="initial_utm_content",t.InitialName="initial_utm_name",t.InitialTerm="initial_utm_term",t.Gclid="gclid";class s{constructor(){this.storage=sessionStorage,"undefined"==typeof Storage&&(console.warn("Using the UTM package without having a storage won't work properly"),this.storage=null)}parse(t){const a=new URL(t||window.location.href).searchParams,n={};return Object.values(o.UtmParamEnum).forEach(t=>{var e=a.get(t);e&&(n[t]=e)}),Object.keys(n).length?n:null}save(e){if(this.storage){var t=this.storage.getItem(s.StorageKey);const i=JSON.parse(JSON.stringify(e));if(t){var t=JSON.parse(t),a={[o.UtmParamEnum.Source]:o.UtmParamEnum.InitialSource,[o.UtmParamEnum.Medium]:o.UtmParamEnum.InitialMedium,[o.UtmParamEnum.Campaign]:o.UtmParamEnum.InitialCampaign,[o.UtmParamEnum.Content]:o.UtmParamEnum.InitialContent,[o.UtmParamEnum.Name]:o.UtmParamEnum.InitialName,[o.UtmParamEnum.Term]:o.UtmParamEnum.InitialTerm};if(!Object.values(a).filter(t=>Object.keys(e).includes(t)).length){const m=Object.keys(a);for(var[n,r]of Object.entries(t))m.includes(n)&&(n=a[n],i[n]=r)}}this.storage.setItem(s.StorageKey,JSON.stringify(i))}}load(){if(!this.storage)return null;var t=this.storage.getItem(s.StorageKey);return t?JSON.parse(t):null}clear(){this.storage&&this.storage.removeItem(s.StorageKey)}trimUrl(t){const e=new URL(t),a=e.searchParams;if(!a)return t;for(const n of Object.values(o.UtmParamEnum))a.delete(n);return e.toString()}cleanDisplayedUrl(){var t,e;window&&history&&(t=this.trimUrl(window.location.href),e=history.state,history.replaceState(e,"",t))}setIntoUrl(t,e){var a,n,t=this.trimUrl(t);const r=new URL(t),i=r.searchParams;for([a,n]of Object.entries(e))n&&i.append(a,n);return r.toString()}}s.StorageKey="utmParams";var t=new s;o.UtmSynapse=s,o.utmSynapse=t,Object.defineProperty(o,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("memorystorage")):"function"==typeof define&&define.amd?define(["exports","memorystorage"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).UtmSynapse={},t.MemoryStorage)}(this,function(o,t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=e(t);o.UtmParamEnum=void 0,(t=o.UtmParamEnum||(o.UtmParamEnum={})).Source="utm_source",t.Medium="utm_medium",t.Campaign="utm_campaign",t.Content="utm_content",t.Name="utm_name",t.Term="utm_term",t.InitialSource="initial_utm_source",t.InitialMedium="initial_utm_medium",t.InitialCampaign="initial_utm_campaign",t.InitialContent="initial_utm_content",t.InitialName="initial_utm_name",t.InitialTerm="initial_utm_term",t.Gclid="gclid";class s{constructor(){"undefined"==typeof Storage?(console.warn("Using the UTM package without having a storage won't work properly"),this.storage=new a.default):this.storage=sessionStorage}parse(t){const a=new URL(t||window.location.href).searchParams,r={};return Object.values(o.UtmParamEnum).forEach(t=>{var e=a.get(t);e&&(r[t]=e)}),Object.keys(r).length?r:null}save(e){if(this.storage){var t=this.storage.getItem(s.StorageKey);const i=JSON.parse(JSON.stringify(e));if(t){var t=JSON.parse(t),a={[o.UtmParamEnum.Source]:o.UtmParamEnum.InitialSource,[o.UtmParamEnum.Medium]:o.UtmParamEnum.InitialMedium,[o.UtmParamEnum.Campaign]:o.UtmParamEnum.InitialCampaign,[o.UtmParamEnum.Content]:o.UtmParamEnum.InitialContent,[o.UtmParamEnum.Name]:o.UtmParamEnum.InitialName,[o.UtmParamEnum.Term]:o.UtmParamEnum.InitialTerm};if(!Object.values(a).filter(t=>Object.keys(e).includes(t)).length){const m=Object.keys(a);for(var[r,n]of Object.entries(t))m.includes(r)&&(r=a[r],i[r]=n)}}this.storage.setItem(s.StorageKey,JSON.stringify(i))}}load(){if(!this.storage)return null;var t=this.storage.getItem(s.StorageKey);return t?JSON.parse(t):null}clear(){this.storage&&this.storage.removeItem(s.StorageKey)}trimUrl(t){const e=new URL(t),a=e.searchParams;if(!a)return t;for(const r of Object.values(o.UtmParamEnum))a.delete(r);return e.toString()}cleanDisplayedUrl(){var t,e;window&&history&&(t=this.trimUrl(window.location.href),e=history.state,history.replaceState(e,"",t))}setIntoUrl(t,e){var a,r,t=this.trimUrl(t);const n=new URL(t),i=n.searchParams;for([a,r]of Object.entries(e))r&&i.append(a,r);return n.toString()}}s.StorageKey="utmParams";t=new s;o.UtmSynapse=s,o.utmSynapse=t,Object.defineProperty(o,"__esModule",{value:!0})});
{
"name": "utm-synapse",
"version": "1.1.0",
"version": "1.2.0",
"description": "Track and report UTM parameters along a browser session",

@@ -19,3 +19,5 @@ "main": "./dist/cjs/index.js",

"build:umd:min": "uglifyjs --compress --mangle --source-map --comments -o dist/umd/index.min.js -- dist/umd/index.js",
"dev": "npm run clean && tsc -p tsconfig.build.json --outDir dist/esm --watch",
"dev": "npm run dev:esm",
"dev:esm": "npm run clean && tsc -p tsconfig.build.json --outDir dist/esm --watch",
"dev:cjs": "npm run clean && tsc -p tsconfig.build.json --module commonjs --outDir dist/cjs --watch",
"clean": "rm -rf ./dist/",

@@ -98,3 +100,6 @@ "cm": "cz",

]
},
"dependencies": {
"memorystorage": "^0.12.0"
}
}

@@ -121,1 +121,21 @@ # utm-synapse

[commitizen-url]: http://commitizen.github.io/cz-cli/
### Development & pull requests
If you are willing to contribute to this library, you can easily watch tests while developing:
```bash
yarn run test:watch
```
In you intend while developing on this library to test directly into a parent project (thanks to `yarn link ...`), you can use the following so modifications are reflected with just a page refresh (it can be used in parallel to the previous command):
```
yarn run dev
```
_Note: in case your "parent project" uses CommonJS it's required to use `yarn run dev:cjs`_
**[IMPORTANT] To develop, and in case your package manager is `npm` you should be able to install dependencies to do some testing... but to submit a pull request please use `yarn` because our dependency tree is managed through `yarn.lock` (and not `package-lock.json` from `npm`).**
Thanks in advance! 🚀

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc