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

@taplytics/nuxtjs

Package Overview
Dependencies
Maintainers
8
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taplytics/nuxtjs - npm Package Compare versions

Comparing version 0.0.0-rc.5 to 0.0.0-rc.6

1

lib/module.js

@@ -33,2 +33,3 @@ const cheerio = require("cheerio");

const $ = cheerio.load(html);
console.log('webModifications', webModifications)
const webMods = webModifications

@@ -35,0 +36,0 @@ .map((wm) => {

128

lib/plugin/plugin.js

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

import Vue from "vue";
Vue.mixin({
mounted: function () {
this.$Taplytics.modifyDom();
},
});
import setCookie from "set-cookie-parser";

@@ -136,20 +131,39 @@ const matchUrlRules = (urlRules, url) => {

};
const WORKER_URL = "https://js.taplytics-api.com";
// const WORKER_URL = "http://localhost:4002";
const WORKER_URL = "https://js-dev.taplytics-api.workers.dev";
// const WORKER_URL = `http://localhost:4002`;
const fetchAndStoreConfig = (url, store, context) => {
const body = {
userAttributes: context.app.$cookies.get("userAttributes", {
parseJSON: true,
}),
};
const allCookies = context.app.$cookies.getAll();
const cookies = Object.keys(allCookies)
.reduce((acc, item) => {
return acc.concat(
`${item}=${
typeof allCookies[item] === "object"
? JSON.stringify(allCookies[item])
: allCookies[item]
}`
);
}, [])
.join(";");
return fetch(url, {
method: "POST",
headers: {
cookie: cookies,
"X-Tap-IP": context.req.headers["x-real-ip"] || "199.68.122.21",
},
credentials: "include",
body: JSON.stringify(body),
})
.then((res) => {
const cookies = setCookie.parse(
setCookie.splitCookiesString(res.headers.get("set-cookie"))
);
cookies.forEach(({ name, value, expires }) => {
context.app.$cookies.set(name, value, {
encode: (a) => a,
expires,
});
});
return res;
})
.then((res) => {
return res.text();

@@ -173,5 +187,7 @@ })

) => {
const webMods = webModifications
const webMods = (webModifications || [])
.map((wm) => {
const { selector } = webElements.find((we) => wm._element === we._id);
const { selector } = (webElements || []).find(
(we) => wm._element === we._id
);
const utr = wm._urlTargetingRules.map((utr) => {

@@ -201,2 +217,8 @@ const rule = urlTargetingRules.find((tr) => tr._id === utr);

export default async (context, inject) => {
context.app.router.afterEach((to, from) => {
if (!process.server) {
context.app.$Taplytics.init();
context.app.$Taplytics.modifyDom();
}
});
const { token } = JSON.parse(`<%= JSON.stringify(options) %>`);

@@ -238,21 +260,70 @@ const { store } = context;

identify: (body) => {
const userAttributes = {
...context.app.$cookies.get("userAttributes", { parseJSON: true }),
...body,
};
context.app.$cookies.set("userAttributes", userAttributes, {
maxAge: 60 * 60 * 24 * 7 * 52,
post("identify", body).then(() => {
const userDataCookie =
document.cookie
.split("; ")
.find((cookie) => cookie.startsWith("_tl_data")) || "";
const [, userData] = userDataCookie.split("=");
const appExpiry = new Date();
appExpiry.setDate(appExpiry.getDate() + 365 * 10);
if (
userData !== "null" &&
userData !== null &&
userData !== undefined
) {
const parsedUserData = JSON.parse(userData);
const updatedUserData = {
...parsedUserData,
userAttributes: {
...parsedUserData.userAttributes,
...body,
},
};
document.cookie = "_tl_data=".concat(
JSON.stringify(updatedUserData),
`; Path=/; Expires=${appExpiry.toUTCString()}`
);
} else {
document.cookie = "_tl_data=".concat(
JSON.stringify({ userAttributes: body }),
`; Path=/; Expires=${appExpiry.toUTCString()}`
);
}
});
post("identify", body);
},
init: () => {
const cookieKeys = [
"_tl_auid",
"_tl_sid",
"_tl_session_date",
"_tl_sessions",
"_tl_is_new_user",
"_tl_au_user_date_created",
];
const cookieKeysAndValues = cookieKeys.reduce((acc, cookieKey) => {
const cookie =
document.cookie
.split("; ")
.find((cookie) => cookie.startsWith(cookieKey)) || "";
return {
...acc,
[cookieKey]: cookie.split("=")[1],
};
}, {});
return post("init", {
token,
...cookieKeysAndValues,
});
},
track: (eventName, value, attributes) =>
post("track", { eventName, value, attributes }),
page: () => post("page"),
modifyDom: () => {
if (!process.server) {
// setTimeout(() => {
const webModifications =
store.getters["TaplyticsConfig/webModifications"];
const webElements = store.getters["TaplyticsConfig/webElements"];
store.getters["TaplyticsConfig/webModifications"] || [];
const webElements = store.getters["TaplyticsConfig/webElements"] || [];
const urlTargetingRules =
store.getters["TaplyticsConfig/urlTargetingRules"];
store.getters["TaplyticsConfig/urlTargetingRules"] || [];
// eslint-disable-next-line

@@ -265,3 +336,2 @@ processClientModifications(

);
// }, 0)
}

@@ -268,0 +338,0 @@ },

{
"name": "@taplytics/nuxtjs",
"version": "0.0.0-rc.5",
"version": "0.0.0-rc.6",
"description": "Simple Nuxt.js integration with Taplytics Experimentation SDK",

@@ -17,4 +17,5 @@ "main": "lib/module.js",

"dependencies": {
"cheerio": "^1.0.0-rc.3"
"cheerio": "^1.0.0-rc.3",
"set-cookie-parser": "^2.4.5"
}
}
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