Skip to content

Commit

Permalink
connectors to sources
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Nov 20, 2024
1 parent bc6f7a7 commit 8e8347d
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 62 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"workspaces": [
"packages/*",
"packages/config/*",
"packages/connectors/*",
"packages/clients/*",
"packages/destinations/core/*",
"packages/destinations/node/*",
"packages/destinations/web/*",
"packages/sources/*",
"packages/stacks/*"
],
"scripts": {
Expand Down
7 changes: 0 additions & 7 deletions packages/connectors/datalayer/CHANGELOG.md

This file was deleted.

9 changes: 0 additions & 9 deletions packages/connectors/gcp/CHANGELOG.md

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# dataLayer connector for walkerOS
# dataLayer source for walkerOS

Made to be used with
[walker.js](https://www.npmjs.com/package/@elbwalker/walker.js) from
[walkerOS](https://github.com/elbwalker/walkerOS).

More detailed information and examples can be found in the
[documentation](https://www.elbwalker.com/docs/connectors/datalayer).
[documentation](https://www.elbwalker.com/docs/sources/datalayer).

## 🤓 Usage

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elbwalker/connector-datalayer",
"description": "datalayer connector for walkerOS",
"name": "@elbwalker/source-datalayer",
"description": "datalayer source for walkerOS",
"version": "0.0.1",
"license": "MIT",
"main": "dist/index.js",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"repository": {
"url": "git+https://github.com/elbwalker/walkerOS.git",
"directory": "packages/connectors/datalayer"
"directory": "packages/sources/datalayer"
},
"author": "elbwalker <[email protected]>",
"homepage": "https://github.com/elbwalker/walkerOS#readme",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable prefer-rest-params */
import type { DataLayer } from '../types';
import { connectorDataLayer } from '..';
import { sourceDataLayer } from '..';

describe('commands', () => {
const elb = jest.fn(); //.mockImplementation(console.log);
Expand All @@ -16,7 +16,7 @@ describe('commands', () => {
});

test('consent default', () => {
connectorDataLayer({ elb });
sourceDataLayer({ elb });

gtag('consent', 'default', {
ad_user_data: 'denied',
Expand All @@ -30,7 +30,7 @@ describe('commands', () => {
});

test('consent update', () => {
connectorDataLayer({ elb, mapping: { foo: {} } });
sourceDataLayer({ elb, mapping: { foo: {} } });

gtag('consent', 'update', {
ad_user_data: 'denied',
Expand All @@ -47,7 +47,7 @@ describe('commands', () => {
});

test('set', () => {
connectorDataLayer({
sourceDataLayer({
elb,
mapping: {
'set campaign': {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable prefer-rest-params */
import type { DataLayer } from '../types';
import { connectorDataLayer } from '..';
import { sourceDataLayer } from '..';

describe('connector dataLayer', () => {
describe('source dataLayer', () => {
const elb = jest.fn(); //.mockImplementation(console.log);
let dataLayer: DataLayer;

Expand All @@ -19,11 +19,11 @@ describe('connector dataLayer', () => {
window.dataLayer = undefined;
expect(window.dataLayer).toBeUndefined();

connectorDataLayer();
connectorDataLayer({});
sourceDataLayer();
sourceDataLayer({});
expect(window.dataLayer).toBeUndefined();

connectorDataLayer({ elb });
sourceDataLayer({ elb });
expect(Array.isArray(window.dataLayer)).toBe(true);
expect(window.dataLayer!.length).toBe(0);
});
Expand All @@ -32,14 +32,14 @@ describe('connector dataLayer', () => {
const originalPush = dataLayer.push;
expect(originalPush).toBe(dataLayer.push);

connectorDataLayer({ elb });
sourceDataLayer({ elb });
expect(originalPush).not.toBe(dataLayer!.push);
});

test('config dataLayer', () => {
const dataLayer: DataLayer = [];

connectorDataLayer({ elb, dataLayer, name: 'foo' });
sourceDataLayer({ elb, dataLayer, name: 'foo' });
expect(window.foo).toBeUndefined(); // Prefer dataLayer over name
dataLayer.push({ event: 'foo' });
expect(elb).toHaveBeenCalledTimes(1);
Expand All @@ -48,18 +48,18 @@ describe('connector dataLayer', () => {
test('config name', () => {
expect(window.foo).toBeUndefined();

connectorDataLayer({ elb, name: 'foo' });
sourceDataLayer({ elb, name: 'foo' });
expect(Array.isArray(window.foo)).toBe(true);
});

test('original arguments', () => {
connectorDataLayer({ elb, name: 'foo' });
sourceDataLayer({ elb, name: 'foo' });
dataLayer.push('foo');
expect(dataLayer).toEqual(['foo']);
});

test('push', () => {
connectorDataLayer({ elb });
sourceDataLayer({ elb });
dataLayer.push({ event: 'foo' });
expect(elb).toHaveBeenCalledTimes(1);
expect(elb).toHaveBeenCalledWith({
Expand All @@ -71,7 +71,7 @@ describe('connector dataLayer', () => {
});

test('prefix', () => {
connectorDataLayer({ elb, prefix: 'foo' });
sourceDataLayer({ elb, prefix: 'foo' });
dataLayer.push({ event: 'bar baz' });
expect(elb).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -83,7 +83,7 @@ describe('connector dataLayer', () => {
test('existing events', () => {
dataLayer.push({ event: 'add_to_cart' });
dataLayer.push({ event: 'purchase' });
connectorDataLayer({ elb });
sourceDataLayer({ elb });

expect(elb).toHaveBeenCalledTimes(2);
});
Expand All @@ -102,7 +102,7 @@ describe('connector dataLayer', () => {
}),
];

connectorDataLayer({ elb, dataLayer });
sourceDataLayer({ elb, dataLayer });

gtag('event', 'another_arg', {
bar: 'baz',
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('connector dataLayer', () => {
args[1].push('newElement');
});

connectorDataLayer({ elb });
sourceDataLayer({ elb });
dataLayer.push(originalObj, originalArr);
expect(dataLayer[0]).toStrictEqual({});
expect(dataLayer[1]).toStrictEqual([]);
Expand All @@ -158,7 +158,7 @@ describe('connector dataLayer', () => {
test('duplicate prevention', () => {
const processedEvents = new Set<string>();
processedEvents.add('foo');
connectorDataLayer({ elb, processedEvents });
sourceDataLayer({ elb, processedEvents });

dataLayer.push({ event: 'foo', id: 'foo' });
expect(elb).toHaveBeenCalledTimes(0);
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('connector dataLayer', () => {
throw new Error();
});

connectorDataLayer(elb);
sourceDataLayer(elb);
dataLayer.push('foo');
expect(elb).toThrow();
expect(mockOrg).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { WalkerOS } from '@elbwalker/types';
import { clone } from '@elbwalker/utils';
import { gtagToObj } from '../mapping';
import { connectorDataLayer } from '..';
import { sourceDataLayer } from '..';

describe('mapping', () => {
const elb = jest.fn(); //.mockImplementation(console.log);
Expand Down Expand Up @@ -31,7 +31,7 @@ describe('mapping', () => {
beforeEach(() => {});

test('mapping name', () => {
const { dataLayer } = connectorDataLayer({
const { dataLayer } = sourceDataLayer({
elb,
mapping: {
foo: {
Expand All @@ -55,7 +55,7 @@ describe('mapping', () => {
});

test('mapping ignore', () => {
const { dataLayer } = connectorDataLayer({
const { dataLayer } = sourceDataLayer({
elb,
mapping: {
foo: {
Expand All @@ -69,7 +69,7 @@ describe('mapping', () => {
});

test('mapping foo', () => {
const { dataLayer } = connectorDataLayer({
const { dataLayer } = sourceDataLayer({
elb,
mapping: {
foo: {
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('mapping', () => {
});

test('mapping add_to_cart', () => {
const { dataLayer } = connectorDataLayer({
const { dataLayer } = sourceDataLayer({
elb,
mapping: {
add_to_cart: {
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('mapping', () => {
});

test('mapping purchase', () => {
const { dataLayer } = connectorDataLayer({
const { dataLayer } = sourceDataLayer({
elb,
mapping: {
purchase: {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { intercept, push } from './push';

export * as ConnectorDataLayer from './types';

export function connectorDataLayer(
export function sourceDataLayer(
partialConfig: Partial<Config> = {},
): Config | undefined {
const { elb, prefix = 'dataLayer' } = partialConfig;
Expand Down Expand Up @@ -42,4 +42,4 @@ export function connectorDataLayer(
return config;
}

export default connectorDataLayer;
export default sourceDataLayer;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# GCP connector for walkerOS
# GCP source for walkerOS

Made to be used with
[node client](https://www.npmjs.com/package/@elbwalker/client-node) from
[walkerOS](https://github.com/elbwalker/walkerOS).

More detailed information and examples can be found in the
[documentation](https://www.elbwalker.com/docs/connectors/gcp).
[documentation](https://www.elbwalker.com/docs/sources/gcp).

## 🤓 Usage
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elbwalker/connector-gcp",
"description": "GCP connector for walkerOS",
"name": "@elbwalker/source-gcp",
"description": "GCP source for walkerOS",
"version": "0.0.1",
"license": "MIT",
"main": "dist/index.js",
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"repository": {
"url": "git+https://github.com/elbwalker/walkerOS.git",
"directory": "packages/connectors/gcp"
"directory": "packages/sources/gcp"
},
"author": "elbwalker <[email protected]>",
"homepage": "https://github.com/elbwalker/walkerOS#readme",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Request as GCPRequest } from '@google-cloud/functions-framework';
import { connectorGCPHttpFunction } from '..';
import { sourceGCPHttpFunction } from '..';

describe('connector GCP', () => {
describe('source GCP', () => {
const request: GCPRequest = {
get: (header: string) => {
return {
Expand All @@ -21,7 +21,7 @@ describe('connector GCP', () => {
beforeEach(() => {});

test('basic', async () => {
expect(await connectorGCPHttpFunction(request)).toStrictEqual({
expect(await sourceGCPHttpFunction(request)).toStrictEqual({
city: 'Hamburg',
country: 'DE',
encoding: 'gzip',
Expand All @@ -34,10 +34,10 @@ describe('connector GCP', () => {
});

test('anonymizeIp', async () => {
const first = await connectorGCPHttpFunction(request, {
const first = await sourceGCPHttpFunction(request, {
anonymizeIp: true,
});
const second = await connectorGCPHttpFunction(request, {
const second = await sourceGCPHttpFunction(request, {
anonymizeIp: false,
});

Expand All @@ -46,7 +46,7 @@ describe('connector GCP', () => {
});

test('mapping', async () => {
const context = await connectorGCPHttpFunction(request, {
const context = await sourceGCPHttpFunction(request, {
mapping: {
origin: 'foo',
'X-Real-Ip': false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { anonymizeIP, isDefined } from '@elbwalker/utils';

export * as ConnectorGCP from './types';

export async function connectorGCPHttpFunction(
export async function sourceGCPHttpFunction(
request: GCPRequest,
options: HttpFunction = {},
): Promise<Request.Context> {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8e8347d

Please sign in to comment.