@ns8/ns8-shopify-switches
Advanced tools
Comparing version 1.0.154 to 1.0.155
@@ -104,2 +104,25 @@ "use strict"; | ||
}); | ||
const parseDemoSession = (noteAttributes = []) => { | ||
const ip = noteAttributes | ||
.filter((note) => note.name === 'ip') | ||
.map((note) => note.value) | ||
.join(); | ||
const userAgent = noteAttributes | ||
.filter((note) => note.name === 'ua') | ||
.map((note) => note.value) | ||
.join(); | ||
const acceptLanguage = noteAttributes | ||
.filter((note) => note.name === 'accept_language') | ||
.map((note) => note.value) | ||
.join(); | ||
return mapSession({ | ||
accept_language: acceptLanguage, | ||
browser_height: null, | ||
browser_ip: ip, | ||
browser_width: null, | ||
session_hash: null, | ||
user_agent: userAgent, | ||
}); | ||
}; | ||
exports.parseDemoSession = parseDemoSession; | ||
const mapSession = (clientDetails) => { | ||
@@ -135,3 +158,3 @@ const { accept_language, browser_ip, user_agent, } = clientDetails; | ||
const { id: merchantId } = switchContext.merchant; | ||
const { id, name, currency, billing_address, shipping_address, customer, total_price, line_items = [], created_at, client_details, test, } = shopifyOrder; | ||
const { id, name, currency, billing_address, shipping_address, customer, total_price, line_items = [], created_at, client_details, test, source_name, note_attributes, } = shopifyOrder; | ||
const addresses = []; | ||
@@ -149,3 +172,6 @@ if (billing_address) { | ||
let session; | ||
if (test && (!client_details || Object.keys(client_details).length === 0)) { | ||
if (source_name === 'demo' && (!client_details || Object.keys(client_details).length === 0)) { | ||
session = parseDemoSession(note_attributes); | ||
} | ||
else if (test && (!client_details || Object.keys(client_details).length === 0)) { | ||
session = makeTestSession(); | ||
@@ -156,3 +182,3 @@ } | ||
} | ||
if (session) { | ||
if (session && session.ip) { | ||
return new ns8_protect_models_1.Order({ | ||
@@ -159,0 +185,0 @@ name, |
{ | ||
"name": "@ns8/ns8-shopify-switches", | ||
"version": "1.0.154", | ||
"version": "1.0.155", | ||
"description": "Custom switches for the shopify integration", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
75232
886