Skip to content

Instantly share code, notes, and snippets.

View johndavidsimmons's full-sized avatar

John Simmons johndavidsimmons

View GitHub Profile
@johndavidsimmons
johndavidsimmons / brokenDataElementAssurance.js
Created December 3, 2024 19:07
Adobe Assurance function for finding broken data elements in props and evars
function(events, params) {
const processedHits = events.filter(e => e.vendor === "com.adobe.analytics.hitdebugger")
const allEvarValues = processedHits.map(item => Object.values(item.payload.evars)).flat()
const allPropValues = processedHits.map(item => Object.values(item.payload.props)).flat()
const dataElementSyntaxRE = '^\%.+\%$'
const brokenDataElements = [
...allEvarValues,
...allPropValues
]
.filter(val => val.match(dataElementSyntaxRE))
var redirect = function(url) {
var params = new URLSearchParams(location.search);
var qls = params.get("qls") || "";
var adobe_mc_sdid = s.visitor ? s.visitor._supplementalDataIDCurrent : "";
var adobe_mc_ref = window.location.href;
var now = Date.now().toString().slice(0,10);
var redirect_url = url + "?qls=" + qls + "&adobe_mc_sdid=SDID" + adobe_mc_sdid + "&adobe_mc_ref=" + adobe_mc_ref + "&|MCORGID=5D60123F5245B13E0A490D45@AdobeOrg|TS=" + now;
window.location.replace(redirect_url);
}
import React, { useState, useEffect } from "react"
import { Link } from "gatsby"
import Datatable from "../components/datatable"
// Fetching data
require("es6-promise").polyfill();
require("isomorphic-fetch")
const IndexPage = () => {
// This variable grabs the query string from the anchors href element (the destination link)
// and makes formats it in order to pass it into URLSearchParams which makes a searchable object of
// the query parameters. Because the rule was triggered by an anchor element, "this" in the custom
// code refers to that anchor element
var qs = "?" + this.href.split("?")[1].split("#")[0]
// Creates an object of key/value pairs out of the query string
// this is the best way to grab the internal_link param
var params = new URLSearchParams(qs);
@johndavidsimmons
johndavidsimmons / griffon_lowercase.js
Created September 9, 2020 21:50
Griffon validation script test lowercase actions
/**
* Returns true, false, or an object { status: false, events: [uuids] }
* @param {Object[]} events All of the events for the session
* @returns {(boolean|Object)} true, false, or an object that contains a status property
* and optionally an events property that is an array of eventUuids
*/
function (events) {
const analyticsTrackEvents = events.filter(event => event.type === 'AnalyticsTrack');
let valid = true;
let invalidEvents = [];
@johndavidsimmons
johndavidsimmons / csv2json.js
Created October 1, 2019 17:09
The function for converting csv 2 json
const button = document.querySelector("#convert");
const outputTextarea = document.querySelector("#outputdata");
button.addEventListener("click", function() {
let inputData = document.querySelector("#inputdata").value;
// remove newlines
let cleanedData = inputData.replace(/\n/g, ",");
// make it an array
import os
import pkgutil
from terminaltables import AsciiTable # type: ignore
from termcolor import colored # type: ignore
from typing import List
rocket:str = u"\U0001F680"
table_data: List[list] = [
from datetime import datetime
import os
import pkgutil
from typing import Dict, List, Optional
from analytics_check.items import ScriptCheckItem
import scrapy # type: ignore
import scrapy_splash # type: ignore
from scrapy.loader import ItemLoader # type: ignore
/**
* Mparticle
* https://docs.mparticle.com/developers/sdk/javascript/getting-started
*
* @class
* @extends BaseProvider
*/
class MparticleProvider extends BaseProvider {
constructor() {
#!/usr/bin/env python3
import discogs_client
import os
d = discogs_client.Client('John_Python_API_Test/0.1')
if os.path.exists('.env'):
for line in open(".env"):
var = line.strip().split('=')
if len(var) == 2: