{"version":3,"file":"segmentS2S-CTfRYFKA.js","sources":["../../../app/javascript/modules/segmentS2S.js"],"sourcesContent":["import { ready } from \"../utils/listeners\";\nimport api from \"../api\";\n\nconst PERMITTED_TRACK_EVENTS = [\n \"Viewed Product\",\n \"Customised Product\",\n \"Search\",\n \"Added Product\",\n \"Checkout Started\",\n \"Completed Order\",\n \"Submitted B2B Form\",\n \"PageView\",\n \"Cart Viewed\",\n \"Checkout Step Completed\",\n \"Added Sample\",\n \"Completed A Wedding Purchase\",\n \"Completed A Sample Purchase\",\n \"Completed A Wedding Sample Purchase\",\n \"Feature Viewed\"\n];\n\nwindow.serverSideAnalytics = {\n // Look at the _segment partial in the layout\n // to see the middleware that calls this method\n setupServerEvent({ obj, options }) {\n const vm = this;\n // Timeout to ensure that the client side event is sent first\n setTimeout(() => {\n switch (obj.type) {\n case \"identify\":\n vm.identifyServer(obj);\n break;\n case \"page\":\n vm.pageServer(obj);\n break;\n case \"track\":\n vm.trackServer(obj, options);\n break;\n default:\n break;\n }\n }, 1000);\n },\n identifyServer({ messageId, userId, traits, context }) {\n api.post(\"/segment_s2s/identify\", {\n user_id: userId,\n traits,\n pixel_event_id: messageId,\n consent: context.consent\n });\n },\n pageServer({ messageId, name, properties, context }) {\n api.post(\"/segment_s2s/page\", {\n name,\n properties,\n pixel_event_id: messageId,\n consent: context.consent\n });\n },\n trackServer({ messageId, event, properties, context }) {\n if (PERMITTED_TRACK_EVENTS.includes(event)) {\n api.post(\"/segment_s2s/track\", {\n event,\n properties,\n pixel_event_id: messageId,\n consent: context.consent\n });\n }\n }\n};\n\nready(() => {\n window.analyticsIdentifyQueue.forEach(identifyArgs => {\n analytics.identify(...identifyArgs);\n });\n window.analyticsPageViewQueue.forEach(pageArgs => {\n analytics.page(...pageArgs);\n });\n window.analyticsTrackQueue.forEach(trackArgs => {\n analytics.track(...trackArgs);\n });\n});\n"],"names":["PERMITTED_TRACK_EVENTS","obj","options","vm","messageId","userId","traits","context","api","name","properties","event","ready","identif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