@adhese/sdk-user-sync 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/package.json.cjs +7 -0
- package/dist/cjs/package.json.cjs.map +1 -0
- package/dist/{index.cjs → cjs/userSync.cjs} +3 -4
- package/dist/cjs/userSync.cjs.map +1 -0
- package/dist/package.json.js +7 -0
- package/dist/package.json.js.map +1 -0
- package/dist/{index.js → userSync.js} +2 -3
- package/dist/userSync.js.map +1 -0
- package/package.json +6 -6
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const sdkShared = require("@adhese/sdk-shared");
|
|
4
|
-
const
|
|
5
|
-
const version = "0.1.0";
|
|
4
|
+
const _package = require("./package.json.cjs");
|
|
6
5
|
const userSyncPlugin = (context, plugin) => {
|
|
7
6
|
const logger = sdkShared.useLogger({
|
|
8
|
-
scope: `${name}@${version}`
|
|
7
|
+
scope: `${_package.name}@${_package.version}`
|
|
9
8
|
}, { context, plugin });
|
|
10
9
|
return {
|
|
11
10
|
name: "userSync",
|
|
@@ -39,4 +38,4 @@ const userSyncPlugin = (context, plugin) => {
|
|
|
39
38
|
};
|
|
40
39
|
};
|
|
41
40
|
exports.userSyncPlugin = userSyncPlugin;
|
|
42
|
-
//# sourceMappingURL=
|
|
41
|
+
//# sourceMappingURL=userSync.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userSync.cjs","sources":["../../src/userSync.ts"],"sourcesContent":["import type { AdhesePlugin } from '@adhese/sdk';\nimport { useLogger } from '@adhese/sdk-shared';\nimport { name, version } from '../package.json';\n\nexport type SyncOptions = {\n /**\n * Service handler to sync with. This is provided by Adhese. Make sure to contact Adhese support to have access to this.\n */\n serviceHandler: string;\n /**\n * List of events to sync\n */\n events: ReadonlyArray<string>;\n /**\n * User ID that should be synced\n */\n userId: string;\n /**\n * Expiration time in minutes\n */\n expiration: number;\n};\n\nexport type UserSyncPlugin = {\n name: 'userSync';\n /**\n * Sync user with Adhese. This will send a request to the Adhese user sync endpoint.\n *\n * @warning This method should only be called when the user has given consent to sync their data. Otherwise, it will\n * throw an error.\n */\n sync(options: SyncOptions): Promise<void>;\n};\n\nexport const userSyncPlugin: AdhesePlugin<UserSyncPlugin> = (context, plugin) => {\n const logger = useLogger({\n scope: `${name}@${version}`,\n }, { context, plugin });\n\n return {\n name: 'userSync',\n async sync({\n serviceHandler,\n events,\n userId,\n expiration,\n }: SyncOptions): Promise<void> {\n try {\n if (context.consentString === 'none')\n throw new Error('No consent provided');\n\n const endpoint = new URL(`https://ads-${context.options.account}.adhese.com/usersync/handlers/${serviceHandler}/user_sync`);\n endpoint.searchParams.set('id', events.join(','));\n endpoint.searchParams.set('u', userId);\n endpoint.searchParams.set('ttl', expiration.toString());\n\n const response = await fetch(endpoint);\n\n if (!response.ok)\n throw new Error(response.statusText ?? 'Unknown error');\n\n logger.value.debug('User synced with Adhese', {\n serviceHandler,\n events,\n userId,\n expiration,\n });\n }\n catch (error) {\n logger.value.error(`Failed to sync user. ${(error as Error).message}`);\n throw error;\n }\n },\n };\n};\n"],"names":["useLogger","name","version"],"mappings":";;;;AAkCa,MAAA,iBAA+C,CAAC,SAAS,WAAW;AAC/E,QAAM,SAASA,UAAAA,UAAU;AAAA,IACvB,OAAO,GAAGC,SAAAA,IAAI,IAAIC,SAAO,OAAA;AAAA,EAAA,GACxB,EAAE,SAAS,OAAA,CAAQ;AAEf,SAAA;AAAA,IACL,MAAM;AAAA,IACN,MAAM,KAAK;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAC6B;AACzB,UAAA;AACF,YAAI,QAAQ,kBAAkB;AACtB,gBAAA,IAAI,MAAM,qBAAqB;AAEjC,cAAA,WAAW,IAAI,IAAI,eAAe,QAAQ,QAAQ,OAAO,iCAAiC,cAAc,YAAY;AAC1H,iBAAS,aAAa,IAAI,MAAM,OAAO,KAAK,GAAG,CAAC;AACvC,iBAAA,aAAa,IAAI,KAAK,MAAM;AACrC,iBAAS,aAAa,IAAI,OAAO,WAAW,UAAU;AAEhD,cAAA,WAAW,MAAM,MAAM,QAAQ;AAErC,YAAI,CAAC,SAAS;AACZ,gBAAM,IAAI,MAAM,SAAS,cAAc,eAAe;AAEjD,eAAA,MAAM,MAAM,2BAA2B;AAAA,UAC5C;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,eAEI,OAAO;AACZ,eAAO,MAAM,MAAM,wBAAyB,MAAgB,OAAO,EAAE;AAC/D,cAAA;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useLogger } from "@adhese/sdk-shared";
|
|
2
|
-
|
|
3
|
-
const version = "0.1.0";
|
|
2
|
+
import { name, version } from "./package.json.js";
|
|
4
3
|
const userSyncPlugin = (context, plugin) => {
|
|
5
4
|
const logger = useLogger({
|
|
6
5
|
scope: `${name}@${version}`
|
|
@@ -39,4 +38,4 @@ const userSyncPlugin = (context, plugin) => {
|
|
|
39
38
|
export {
|
|
40
39
|
userSyncPlugin
|
|
41
40
|
};
|
|
42
|
-
//# sourceMappingURL=
|
|
41
|
+
//# sourceMappingURL=userSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userSync.js","sources":["../src/userSync.ts"],"sourcesContent":["import type { AdhesePlugin } from '@adhese/sdk';\nimport { useLogger } from '@adhese/sdk-shared';\nimport { name, version } from '../package.json';\n\nexport type SyncOptions = {\n /**\n * Service handler to sync with. This is provided by Adhese. Make sure to contact Adhese support to have access to this.\n */\n serviceHandler: string;\n /**\n * List of events to sync\n */\n events: ReadonlyArray<string>;\n /**\n * User ID that should be synced\n */\n userId: string;\n /**\n * Expiration time in minutes\n */\n expiration: number;\n};\n\nexport type UserSyncPlugin = {\n name: 'userSync';\n /**\n * Sync user with Adhese. This will send a request to the Adhese user sync endpoint.\n *\n * @warning This method should only be called when the user has given consent to sync their data. Otherwise, it will\n * throw an error.\n */\n sync(options: SyncOptions): Promise<void>;\n};\n\nexport const userSyncPlugin: AdhesePlugin<UserSyncPlugin> = (context, plugin) => {\n const logger = useLogger({\n scope: `${name}@${version}`,\n }, { context, plugin });\n\n return {\n name: 'userSync',\n async sync({\n serviceHandler,\n events,\n userId,\n expiration,\n }: SyncOptions): Promise<void> {\n try {\n if (context.consentString === 'none')\n throw new Error('No consent provided');\n\n const endpoint = new URL(`https://ads-${context.options.account}.adhese.com/usersync/handlers/${serviceHandler}/user_sync`);\n endpoint.searchParams.set('id', events.join(','));\n endpoint.searchParams.set('u', userId);\n endpoint.searchParams.set('ttl', expiration.toString());\n\n const response = await fetch(endpoint);\n\n if (!response.ok)\n throw new Error(response.statusText ?? 'Unknown error');\n\n logger.value.debug('User synced with Adhese', {\n serviceHandler,\n events,\n userId,\n expiration,\n });\n }\n catch (error) {\n logger.value.error(`Failed to sync user. ${(error as Error).message}`);\n throw error;\n }\n },\n };\n};\n"],"names":[],"mappings":";;AAkCa,MAAA,iBAA+C,CAAC,SAAS,WAAW;AAC/E,QAAM,SAAS,UAAU;AAAA,IACvB,OAAO,GAAG,IAAI,IAAI,OAAO;AAAA,EAAA,GACxB,EAAE,SAAS,OAAA,CAAQ;AAEf,SAAA;AAAA,IACL,MAAM;AAAA,IACN,MAAM,KAAK;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAC6B;AACzB,UAAA;AACF,YAAI,QAAQ,kBAAkB;AACtB,gBAAA,IAAI,MAAM,qBAAqB;AAEjC,cAAA,WAAW,IAAI,IAAI,eAAe,QAAQ,QAAQ,OAAO,iCAAiC,cAAc,YAAY;AAC1H,iBAAS,aAAa,IAAI,MAAM,OAAO,KAAK,GAAG,CAAC;AACvC,iBAAA,aAAa,IAAI,KAAK,MAAM;AACrC,iBAAS,aAAa,IAAI,OAAO,WAAW,UAAU;AAEhD,cAAA,WAAW,MAAM,MAAM,QAAQ;AAErC,YAAI,CAAC,SAAS;AACZ,gBAAM,IAAI,MAAM,SAAS,cAAc,eAAe;AAEjD,eAAA,MAAM,MAAM,2BAA2B;AAAA,UAC5C;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,eAEI,OAAO;AACZ,eAAO,MAAM,MAAM,wBAAyB,MAAgB,OAAO,EAAE;AAC/D,cAAA;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhese/sdk-user-sync",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "Adhese SDK",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/adhese/sdk_typescript.git"
|
|
9
9
|
},
|
|
10
|
-
"main": "./dist/
|
|
11
|
-
"module": "./dist/
|
|
12
|
-
"types": "./dist/
|
|
10
|
+
"main": "./dist/cjs/userSync.cjs",
|
|
11
|
+
"module": "./dist/userSync.js",
|
|
12
|
+
"types": "./dist/userSync.d.ts",
|
|
13
13
|
"files": [
|
|
14
14
|
"CHANGELOG.md",
|
|
15
15
|
"LICENSE",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "vite build
|
|
20
|
+
"build": "vite build",
|
|
21
21
|
"lint": "eslint . --ignore-pattern **/*.md/**/*",
|
|
22
22
|
"lint:fix": "eslint --fix . --ignore-pattern **/*.md/**/*",
|
|
23
23
|
"clean": "rm -rf dist",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"@adhese/sdk": ">= 0.20 < 1"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@adhese/sdk-shared": "^0.
|
|
31
|
+
"@adhese/sdk-shared": "^0.10.0"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/userSync.ts"],"sourcesContent":["import type { AdhesePlugin } from '@adhese/sdk';\nimport { useLogger } from '@adhese/sdk-shared';\nimport { name, version } from '../package.json';\n\nexport type SyncOptions = {\n /**\n * Service handler to sync with. This is provided by Adhese. Make sure to contact Adhese support to have access to this.\n */\n serviceHandler: string;\n /**\n * List of events to sync\n */\n events: ReadonlyArray<string>;\n /**\n * User ID that should be synced\n */\n userId: string;\n /**\n * Expiration time in minutes\n */\n expiration: number;\n};\n\nexport type UserSyncPlugin = {\n name: 'userSync';\n /**\n * Sync user with Adhese. This will send a request to the Adhese user sync endpoint.\n *\n * @warning This method should only be called when the user has given consent to sync their data. Otherwise, it will\n * throw an error.\n */\n sync(options: SyncOptions): Promise<void>;\n};\n\nexport const userSyncPlugin: AdhesePlugin<UserSyncPlugin> = (context, plugin) => {\n const logger = useLogger({\n scope: `${name}@${version}`,\n }, { context, plugin });\n\n return {\n name: 'userSync',\n async sync({\n serviceHandler,\n events,\n userId,\n expiration,\n }: SyncOptions): Promise<void> {\n try {\n if (context.consentString === 'none')\n throw new Error('No consent provided');\n\n const endpoint = new URL(`https://ads-${context.options.account}.adhese.com/usersync/handlers/${serviceHandler}/user_sync`);\n endpoint.searchParams.set('id', events.join(','));\n endpoint.searchParams.set('u', userId);\n endpoint.searchParams.set('ttl', expiration.toString());\n\n const response = await fetch(endpoint);\n\n if (!response.ok)\n throw new Error(response.statusText ?? 'Unknown error');\n\n logger.value.debug('User synced with Adhese', {\n serviceHandler,\n events,\n userId,\n expiration,\n });\n }\n catch (error) {\n logger.value.error(`Failed to sync user. ${(error as Error).message}`);\n throw error;\n }\n },\n };\n};\n"],"names":["useLogger"],"mappings":";;;;;AAkCa,MAAA,iBAA+C,CAAC,SAAS,WAAW;AAC/E,QAAM,SAASA,UAAAA,UAAU;AAAA,IACvB,OAAO,GAAG,IAAI,IAAI,OAAO;AAAA,EAAA,GACxB,EAAE,SAAS,OAAA,CAAQ;AAEf,SAAA;AAAA,IACL,MAAM;AAAA,IACN,MAAM,KAAK;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAC6B;AACzB,UAAA;AACF,YAAI,QAAQ,kBAAkB;AACtB,gBAAA,IAAI,MAAM,qBAAqB;AAEjC,cAAA,WAAW,IAAI,IAAI,eAAe,QAAQ,QAAQ,OAAO,iCAAiC,cAAc,YAAY;AAC1H,iBAAS,aAAa,IAAI,MAAM,OAAO,KAAK,GAAG,CAAC;AACvC,iBAAA,aAAa,IAAI,KAAK,MAAM;AACrC,iBAAS,aAAa,IAAI,OAAO,WAAW,UAAU;AAEhD,cAAA,WAAW,MAAM,MAAM,QAAQ;AAErC,YAAI,CAAC,SAAS;AACZ,gBAAM,IAAI,MAAM,SAAS,cAAc,eAAe;AAEjD,eAAA,MAAM,MAAM,2BAA2B;AAAA,UAC5C;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,eAEI,OAAO;AACZ,eAAO,MAAM,MAAM,wBAAyB,MAAgB,OAAO,EAAE;AAC/D,cAAA;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AdhesePlugin } from '@adhese/sdk';
|
|
2
|
-
|
|
3
|
-
type SyncOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* Service handler to sync with. This is provided by Adhese. Make sure to contact Adhese support to have access to this.
|
|
6
|
-
*/
|
|
7
|
-
serviceHandler: string;
|
|
8
|
-
/**
|
|
9
|
-
* List of events to sync
|
|
10
|
-
*/
|
|
11
|
-
events: ReadonlyArray<string>;
|
|
12
|
-
/**
|
|
13
|
-
* User ID that should be synced
|
|
14
|
-
*/
|
|
15
|
-
userId: string;
|
|
16
|
-
/**
|
|
17
|
-
* Expiration time in minutes
|
|
18
|
-
*/
|
|
19
|
-
expiration: number;
|
|
20
|
-
};
|
|
21
|
-
type UserSyncPlugin = {
|
|
22
|
-
name: 'userSync';
|
|
23
|
-
/**
|
|
24
|
-
* Sync user with Adhese. This will send a request to the Adhese user sync endpoint.
|
|
25
|
-
*
|
|
26
|
-
* @warning This method should only be called when the user has given consent to sync their data. Otherwise, it will
|
|
27
|
-
* throw an error.
|
|
28
|
-
*/
|
|
29
|
-
sync(options: SyncOptions): Promise<void>;
|
|
30
|
-
};
|
|
31
|
-
declare const userSyncPlugin: AdhesePlugin<UserSyncPlugin>;
|
|
32
|
-
|
|
33
|
-
export { type UserSyncPlugin, userSyncPlugin };
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/userSync.ts"],"sourcesContent":["import type { AdhesePlugin } from '@adhese/sdk';\nimport { useLogger } from '@adhese/sdk-shared';\nimport { name, version } from '../package.json';\n\nexport type SyncOptions = {\n /**\n * Service handler to sync with. This is provided by Adhese. Make sure to contact Adhese support to have access to this.\n */\n serviceHandler: string;\n /**\n * List of events to sync\n */\n events: ReadonlyArray<string>;\n /**\n * User ID that should be synced\n */\n userId: string;\n /**\n * Expiration time in minutes\n */\n expiration: number;\n};\n\nexport type UserSyncPlugin = {\n name: 'userSync';\n /**\n * Sync user with Adhese. This will send a request to the Adhese user sync endpoint.\n *\n * @warning This method should only be called when the user has given consent to sync their data. Otherwise, it will\n * throw an error.\n */\n sync(options: SyncOptions): Promise<void>;\n};\n\nexport const userSyncPlugin: AdhesePlugin<UserSyncPlugin> = (context, plugin) => {\n const logger = useLogger({\n scope: `${name}@${version}`,\n }, { context, plugin });\n\n return {\n name: 'userSync',\n async sync({\n serviceHandler,\n events,\n userId,\n expiration,\n }: SyncOptions): Promise<void> {\n try {\n if (context.consentString === 'none')\n throw new Error('No consent provided');\n\n const endpoint = new URL(`https://ads-${context.options.account}.adhese.com/usersync/handlers/${serviceHandler}/user_sync`);\n endpoint.searchParams.set('id', events.join(','));\n endpoint.searchParams.set('u', userId);\n endpoint.searchParams.set('ttl', expiration.toString());\n\n const response = await fetch(endpoint);\n\n if (!response.ok)\n throw new Error(response.statusText ?? 'Unknown error');\n\n logger.value.debug('User synced with Adhese', {\n serviceHandler,\n events,\n userId,\n expiration,\n });\n }\n catch (error) {\n logger.value.error(`Failed to sync user. ${(error as Error).message}`);\n throw error;\n }\n },\n };\n};\n"],"names":[],"mappings":";;;AAkCa,MAAA,iBAA+C,CAAC,SAAS,WAAW;AAC/E,QAAM,SAAS,UAAU;AAAA,IACvB,OAAO,GAAG,IAAI,IAAI,OAAO;AAAA,EAAA,GACxB,EAAE,SAAS,OAAA,CAAQ;AAEf,SAAA;AAAA,IACL,MAAM;AAAA,IACN,MAAM,KAAK;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAC6B;AACzB,UAAA;AACF,YAAI,QAAQ,kBAAkB;AACtB,gBAAA,IAAI,MAAM,qBAAqB;AAEjC,cAAA,WAAW,IAAI,IAAI,eAAe,QAAQ,QAAQ,OAAO,iCAAiC,cAAc,YAAY;AAC1H,iBAAS,aAAa,IAAI,MAAM,OAAO,KAAK,GAAG,CAAC;AACvC,iBAAA,aAAa,IAAI,KAAK,MAAM;AACrC,iBAAS,aAAa,IAAI,OAAO,WAAW,UAAU;AAEhD,cAAA,WAAW,MAAM,MAAM,QAAQ;AAErC,YAAI,CAAC,SAAS;AACZ,gBAAM,IAAI,MAAM,SAAS,cAAc,eAAe;AAEjD,eAAA,MAAM,MAAM,2BAA2B;AAAA,UAC5C;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,eAEI,OAAO;AACZ,eAAO,MAAM,MAAM,wBAAyB,MAAgB,OAAO,EAAE;AAC/D,cAAA;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|