@amplitude/targeting 0.1.0
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/LICENSE +21 -0
- package/README.md +10 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +5 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/targeting.d.ts +8 -0
- package/lib/cjs/targeting.d.ts.map +1 -0
- package/lib/cjs/targeting.js +23 -0
- package/lib/cjs/targeting.js.map +1 -0
- package/lib/cjs/typings/targeting.d.ts +13 -0
- package/lib/cjs/typings/targeting.d.ts.map +1 -0
- package/lib/cjs/typings/targeting.js +2 -0
- package/lib/cjs/typings/targeting.js.map +1 -0
- package/lib/esm/index.d.ts +2 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/targeting.d.ts +8 -0
- package/lib/esm/targeting.d.ts.map +1 -0
- package/lib/esm/targeting.js +21 -0
- package/lib/esm/targeting.js.map +1 -0
- package/lib/esm/typings/targeting.d.ts +13 -0
- package/lib/esm/typings/targeting.d.ts.map +1 -0
- package/lib/esm/typings/targeting.js +2 -0
- package/lib/esm/typings/targeting.js.map +1 -0
- package/lib/scripts/amplitude-min.js +1 -0
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.umd.js +1 -0
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/index.d.ts +2 -0
- package/lib/scripts/index.d.ts.map +1 -0
- package/lib/scripts/targeting.d.ts +8 -0
- package/lib/scripts/targeting.d.ts.map +1 -0
- package/lib/scripts/typings/targeting.d.ts +13 -0
- package/lib/scripts/typings/targeting.d.ts.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Amplitude Analytics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://amplitude.com" target="_blank" align="center">
|
|
3
|
+
<img src="https://static.amplitude.com/lightning/46c85bfd91905de8047f1ee65c7c93d6fa9ee6ea/static/media/amplitude-logo-with-text.4fb9e463.svg" width="280">
|
|
4
|
+
</a>
|
|
5
|
+
<br />
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
# @amplitude/targeting
|
|
9
|
+
|
|
10
|
+
Internal Node package for Amplitude
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.Targeting = void 0;
|
|
3
|
+
var targeting_1 = require("./targeting");
|
|
4
|
+
Object.defineProperty(exports, "Targeting", { enumerable: true, get: function () { return targeting_1.Targeting; } });
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,yCAAwC;AAA/B,sGAAA,SAAS,OAAA","sourcesContent":["export { Targeting } from './targeting';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EvaluationEngine } from '@amplitude/experiment-core';
|
|
2
|
+
import { Targeting as AmplitudeTargeting, TargetingParameters } from './typings/targeting';
|
|
3
|
+
export declare class Targeting implements AmplitudeTargeting {
|
|
4
|
+
evaluationEngine: EvaluationEngine;
|
|
5
|
+
constructor();
|
|
6
|
+
evaluateTargeting({ event, sessionId, userProperties, deviceId, flag }: TargetingParameters): Record<string, import("@amplitude/experiment-core").EvaluationVariant>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=targeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.d.ts","sourceRoot":"","sources":["../../src/targeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE3F,qBAAa,SAAU,YAAW,kBAAkB;IAClD,gBAAgB,EAAE,gBAAgB,CAAC;;IAMnC,iBAAiB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,mBAAmB;CAW5F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.Targeting = void 0;
|
|
3
|
+
var experiment_core_1 = require("@amplitude/experiment-core");
|
|
4
|
+
var Targeting = /** @class */ (function () {
|
|
5
|
+
function Targeting() {
|
|
6
|
+
this.evaluationEngine = new experiment_core_1.EvaluationEngine();
|
|
7
|
+
}
|
|
8
|
+
Targeting.prototype.evaluateTargeting = function (_a) {
|
|
9
|
+
var event = _a.event, sessionId = _a.sessionId, userProperties = _a.userProperties, deviceId = _a.deviceId, flag = _a.flag;
|
|
10
|
+
var context = {
|
|
11
|
+
session_id: sessionId,
|
|
12
|
+
event: event,
|
|
13
|
+
user: {
|
|
14
|
+
device_id: deviceId,
|
|
15
|
+
user_properties: userProperties,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
return this.evaluationEngine.evaluate(context, [flag]);
|
|
19
|
+
};
|
|
20
|
+
return Targeting;
|
|
21
|
+
}());
|
|
22
|
+
exports.Targeting = Targeting;
|
|
23
|
+
//# sourceMappingURL=targeting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.js","sourceRoot":"","sources":["../../src/targeting.ts"],"names":[],"mappings":";;AAAA,8DAA8D;AAG9D;IAGE;QACE,IAAI,CAAC,gBAAgB,GAAG,IAAI,kCAAgB,EAAE,CAAC;IACjD,CAAC;IAED,qCAAiB,GAAjB,UAAkB,EAAyE;YAAvE,KAAK,WAAA,EAAE,SAAS,eAAA,EAAE,cAAc,oBAAA,EAAE,QAAQ,cAAA,EAAE,IAAI,UAAA;QAClE,IAAM,OAAO,GAAG;YACd,UAAU,EAAE,SAAS;YACrB,KAAK,OAAA;YACL,IAAI,EAAE;gBACJ,SAAS,EAAE,QAAQ;gBACnB,eAAe,EAAE,cAAc;aAChC;SACF,CAAC;QACF,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;IACH,gBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,8BAAS","sourcesContent":["import { EvaluationEngine } from '@amplitude/experiment-core';\nimport { Targeting as AmplitudeTargeting, TargetingParameters } from './typings/targeting';\n\nexport class Targeting implements AmplitudeTargeting {\n evaluationEngine: EvaluationEngine;\n\n constructor() {\n this.evaluationEngine = new EvaluationEngine();\n }\n\n evaluateTargeting({ event, sessionId, userProperties, deviceId, flag }: TargetingParameters) {\n const context = {\n session_id: sessionId,\n event,\n user: {\n device_id: deviceId,\n user_properties: userProperties,\n },\n };\n return this.evaluationEngine.evaluate(context, [flag]);\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Event, IdentifyUserProperties } from '@amplitude/analytics-types';
|
|
2
|
+
import { EvaluationFlag, EvaluationVariant } from '@amplitude/experiment-core';
|
|
3
|
+
export interface TargetingParameters {
|
|
4
|
+
event?: Event;
|
|
5
|
+
userProperties?: IdentifyUserProperties;
|
|
6
|
+
deviceId?: string;
|
|
7
|
+
flag: EvaluationFlag;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Targeting {
|
|
11
|
+
evaluateTargeting(args: TargetingParameters): Record<string, EvaluationVariant>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=targeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.d.ts","sourceRoot":"","sources":["../../../src/typings/targeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CACjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.js","sourceRoot":"","sources":["../../../src/typings/targeting.ts"],"names":[],"mappings":"","sourcesContent":["import { Event, IdentifyUserProperties } from '@amplitude/analytics-types';\nimport { EvaluationFlag, EvaluationVariant } from '@amplitude/experiment-core';\nexport interface TargetingParameters {\n event?: Event;\n userProperties?: IdentifyUserProperties;\n deviceId?: string;\n flag: EvaluationFlag;\n sessionId?: string;\n}\n\nexport interface Targeting {\n evaluateTargeting(args: TargetingParameters): Record<string, EvaluationVariant>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { Targeting } from './targeting';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EvaluationEngine } from '@amplitude/experiment-core';
|
|
2
|
+
import { Targeting as AmplitudeTargeting, TargetingParameters } from './typings/targeting';
|
|
3
|
+
export declare class Targeting implements AmplitudeTargeting {
|
|
4
|
+
evaluationEngine: EvaluationEngine;
|
|
5
|
+
constructor();
|
|
6
|
+
evaluateTargeting({ event, sessionId, userProperties, deviceId, flag }: TargetingParameters): Record<string, import("@amplitude/experiment-core").EvaluationVariant>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=targeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.d.ts","sourceRoot":"","sources":["../../src/targeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE3F,qBAAa,SAAU,YAAW,kBAAkB;IAClD,gBAAgB,EAAE,gBAAgB,CAAC;;IAMnC,iBAAiB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,mBAAmB;CAW5F"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EvaluationEngine } from '@amplitude/experiment-core';
|
|
2
|
+
var Targeting = /** @class */ (function () {
|
|
3
|
+
function Targeting() {
|
|
4
|
+
this.evaluationEngine = new EvaluationEngine();
|
|
5
|
+
}
|
|
6
|
+
Targeting.prototype.evaluateTargeting = function (_a) {
|
|
7
|
+
var event = _a.event, sessionId = _a.sessionId, userProperties = _a.userProperties, deviceId = _a.deviceId, flag = _a.flag;
|
|
8
|
+
var context = {
|
|
9
|
+
session_id: sessionId,
|
|
10
|
+
event: event,
|
|
11
|
+
user: {
|
|
12
|
+
device_id: deviceId,
|
|
13
|
+
user_properties: userProperties,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
return this.evaluationEngine.evaluate(context, [flag]);
|
|
17
|
+
};
|
|
18
|
+
return Targeting;
|
|
19
|
+
}());
|
|
20
|
+
export { Targeting };
|
|
21
|
+
//# sourceMappingURL=targeting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.js","sourceRoot":"","sources":["../../src/targeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D;IAGE;QACE,IAAI,CAAC,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACjD,CAAC;IAED,qCAAiB,GAAjB,UAAkB,EAAyE;YAAvE,KAAK,WAAA,EAAE,SAAS,eAAA,EAAE,cAAc,oBAAA,EAAE,QAAQ,cAAA,EAAE,IAAI,UAAA;QAClE,IAAM,OAAO,GAAG;YACd,UAAU,EAAE,SAAS;YACrB,KAAK,OAAA;YACL,IAAI,EAAE;gBACJ,SAAS,EAAE,QAAQ;gBACnB,eAAe,EAAE,cAAc;aAChC;SACF,CAAC;QACF,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;IACH,gBAAC;AAAD,CAAC,AAlBD,IAkBC","sourcesContent":["import { EvaluationEngine } from '@amplitude/experiment-core';\nimport { Targeting as AmplitudeTargeting, TargetingParameters } from './typings/targeting';\n\nexport class Targeting implements AmplitudeTargeting {\n evaluationEngine: EvaluationEngine;\n\n constructor() {\n this.evaluationEngine = new EvaluationEngine();\n }\n\n evaluateTargeting({ event, sessionId, userProperties, deviceId, flag }: TargetingParameters) {\n const context = {\n session_id: sessionId,\n event,\n user: {\n device_id: deviceId,\n user_properties: userProperties,\n },\n };\n return this.evaluationEngine.evaluate(context, [flag]);\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Event, IdentifyUserProperties } from '@amplitude/analytics-types';
|
|
2
|
+
import { EvaluationFlag, EvaluationVariant } from '@amplitude/experiment-core';
|
|
3
|
+
export interface TargetingParameters {
|
|
4
|
+
event?: Event;
|
|
5
|
+
userProperties?: IdentifyUserProperties;
|
|
6
|
+
deviceId?: string;
|
|
7
|
+
flag: EvaluationFlag;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Targeting {
|
|
11
|
+
evaluateTargeting(args: TargetingParameters): Record<string, EvaluationVariant>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=targeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.d.ts","sourceRoot":"","sources":["../../../src/typings/targeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CACjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.js","sourceRoot":"","sources":["../../../src/typings/targeting.ts"],"names":[],"mappings":"","sourcesContent":["import { Event, IdentifyUserProperties } from '@amplitude/analytics-types';\nimport { EvaluationFlag, EvaluationVariant } from '@amplitude/experiment-core';\nexport interface TargetingParameters {\n event?: Event;\n userProperties?: IdentifyUserProperties;\n deviceId?: string;\n flag: EvaluationFlag;\n sessionId?: string;\n}\n\nexport interface Targeting {\n evaluateTargeting(args: TargetingParameters): Record<string, EvaluationVariant>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var targeting=function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};var r=function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},r.apply(this,arguments)};function n(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}"function"==typeof SuppressedError&&SuppressedError;var a="is",o="is not",i="contains",c="does not contain",s="less",u="less or equal",l="greater",f="greater or equal",h="version less",p="version less or equal",v="version greater",y="version greater or equal",m="set is",d="set is not",g="set contains",b="set does not contain",w="set contains any",x="set does not contain any",S="regex match",C="regex does not match",A=-862048943,N=461845907,O=function(t,e){void 0===e&&(e=0);for(var r=function(t){for(var e=[],r=0,n=0;n<t.length;n++){var a=t.charCodeAt(n);a<128?e[r++]=a:a<2048?(e[r++]=a>>6|192,e[r++]=63&a|128):55296==(64512&a)&&n+1<t.length&&56320==(64512&t.charCodeAt(n+1))?(a=65536+((1023&a)<<10)+(1023&t.charCodeAt(++n)),e[r++]=a>>18|240,e[r++]=a>>12&63|128,e[r++]=a>>6&63|128,e[r++]=63&a|128):(e[r++]=a>>12|224,e[r++]=a>>6&63|128,e[r++]=63&a|128)}return Uint8Array.from(e)}(t),n=r.length,a=n>>2,o=e,i=0;i<a;i++){var c=M(r,i<<2);o=R(c,o)}var s=a<<2,u=0;switch(n-s){case 3:u^=r[s+2]<<16,u^=r[s+1]<<8,u^=r[s],u=Math.imul(u,A),u=E(u,15),o^=u=Math.imul(u,N);break;case 2:u^=r[s+1]<<8,u^=r[s],u=Math.imul(u,A),u=E(u,15),o^=u=Math.imul(u,N);break;case 1:u^=r[s],u=Math.imul(u,A),u=E(u,15),o^=u=Math.imul(u,N)}return j(o^=n)>>>0},R=function(t,e){var r=t,n=e;return r=Math.imul(r,A),r=E(r,15),r=Math.imul(r,N),n=E(n^=r,13),(n=Math.imul(n,5))+-430675100|0},j=function(t){var e=t;return e^=e>>>16,e=Math.imul(e,-2048144789),e^=e>>>13,e=Math.imul(e,-1028477387),e^=e>>>16},E=function(t,e,r){return void 0===r&&(r=32),e>r&&(e%=r),(t<<e|(t&4294967295<<r-e>>>0)>>>0>>>r-e>>>0)>>>0},M=function(t,e){void 0===e&&(e=0);var r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return k(r)},k=function(t){return(-16777216&t)>>>24|(16711680&t)>>>8|(65280&t)<<8|(255&t)<<24},_=function(t,e){var r,a;if(e&&0!==e.length){try{for(var o=n(e),i=o.next();!i.done;i=o.next()){var c=i.value;if(!c||!t||"object"!=typeof t)return;t=t[c]}}catch(t){r={error:t}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}return t||void 0}},T="^".concat("(\\d+)\\.(\\d+)","(\\.").concat("(\\d+)").concat("(-(([-\\w]+\\.?)*))?",")?$"),q=function(){function t(t,e,r,n){void 0===n&&(n=void 0),this.major=t,this.minor=e,this.patch=r,this.preRelease=n}return t.parse=function(e){if(e){var r=new RegExp(T).exec(e);if(r){var n=Number(r[1]),a=Number(r[2]);if(!isNaN(n)&&!isNaN(a))return new t(n,a,Number(r[4])||0,r[5]||void 0)}}},t.prototype.compareTo=function(t){return this.major>t.major?1:this.major<t.major?-1:this.minor>t.minor?1:this.minor<t.minor?-1:this.patch>t.patch?1:this.patch<t.patch||this.preRelease&&!t.preRelease?-1:!this.preRelease&&t.preRelease?1:this.preRelease&&t.preRelease?this.preRelease>t.preRelease?1:this.preRelease<t.preRelease?-1:0:0},t}(),I=function(){function t(){}return t.prototype.evaluate=function(t,e){var r,a,o={},i={context:t,result:o};try{for(var c=n(e),s=c.next();!s.done;s=c.next()){var u=s.value,l=this.evaluateFlag(i,u);l&&(o[u.key]=l)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(a=c.return)&&a.call(c)}finally{if(r)throw r.error}}return o},t.prototype.evaluateFlag=function(t,e){var a,o,i;try{for(var c=n(e.segments),s=c.next();!s.done;s=c.next()){var u=s.value;if(i=this.evaluateSegment(t,e,u)){var l=r(r(r({},e.metadata),u.metadata),i.metadata);i=r(r({},i),{metadata:l});break}}}catch(t){a={error:t}}finally{try{s&&!s.done&&(o=c.return)&&o.call(c)}finally{if(a)throw a.error}}return i},t.prototype.evaluateSegment=function(t,e,r){var a,o,i,c;if(!r.conditions)return void 0!==(l=this.bucket(t,r))?e.variants[l]:void 0;try{for(var s=n(r.conditions),u=s.next();!u.done;u=s.next()){var l,f=u.value,h=!0;try{for(var p=(i=void 0,n(f)),v=p.next();!v.done;v=p.next()){var y=v.value;if(!(h=this.matchCondition(t,y)))break}}catch(t){i={error:t}}finally{try{v&&!v.done&&(c=p.return)&&c.call(p)}finally{if(i)throw i.error}}if(h)return void 0!==(l=this.bucket(t,r))?e.variants[l]:void 0}}catch(t){a={error:t}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(a)throw a.error}}},t.prototype.matchCondition=function(t,e){var r=_(t,e.selector);if(r){if(this.isSetOperator(e.op)){var n=this.coerceStringArray(r);return!!n&&this.matchSet(n,e.op,e.values)}var a=this.coerceString(r);return void 0!==a&&this.matchString(a,e.op,e.values)}return this.matchNull(e.op,e.values)},t.prototype.getHash=function(t){return O(t)},t.prototype.bucket=function(t,e){var r,a,o,i;if(!e.bucket)return e.variant;var c=this.coerceString(_(t,e.bucket.selector));if(!c||0===c.length)return e.variant;var s="".concat(e.bucket.salt,"/").concat(c),u=this.getHash(s),l=u%100,f=Math.floor(u/100);try{for(var h=n(e.bucket.allocations),p=h.next();!p.done;p=h.next()){var v=p.value,y=v.range[0],m=v.range[1];if(l>=y&&l<m)try{for(var d=(o=void 0,n(v.distributions)),g=d.next();!g.done;g=d.next()){var b=g.value,w=b.range[0],x=b.range[1];if(f>=w&&f<x)return b.variant}}catch(t){o={error:t}}finally{try{g&&!g.done&&(i=d.return)&&i.call(d)}finally{if(o)throw o.error}}}}catch(t){r={error:t}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(r)throw r.error}}return e.variant},t.prototype.matchNull=function(t,e){var r=this.containsNone(e);switch(t){case a:case i:case s:case u:case l:case f:case h:case p:case v:case y:case m:case g:case w:return r;case o:case c:case b:case x:return!r;default:return!1}},t.prototype.matchSet=function(t,e,r){switch(e){case m:return this.setEquals(t,r);case d:return!this.setEquals(t,r);case g:return this.matchesSetContainsAll(t,r);case b:return!this.matchesSetContainsAll(t,r);case w:return this.matchesSetContainsAny(t,r);case x:return!this.matchesSetContainsAny(t,r);default:return!1}},t.prototype.matchString=function(t,e,r){var n=this;switch(e){case a:return this.matchesIs(t,r);case o:return!this.matchesIs(t,r);case i:return this.matchesContains(t,r);case c:return!this.matchesContains(t,r);case s:case u:case l:case f:return this.matchesComparable(t,e,r,(function(t){return n.parseNumber(t)}),this.comparator);case h:case p:case v:case y:return this.matchesComparable(t,e,r,(function(t){return q.parse(t)}),this.versionComparator);case S:return this.matchesRegex(t,r);case C:return!this.matchesRegex(t,r);default:return!1}},t.prototype.matchesIs=function(t,e){if(this.containsBooleans(e)){var r=t.toLowerCase();if("true"===r||"false"===r)return e.some((function(t){return t.toLowerCase()===r}))}return e.some((function(e){return t===e}))},t.prototype.matchesContains=function(t,e){var r,a;try{for(var o=n(e),i=o.next();!i.done;i=o.next()){var c=i.value;if(t.toLowerCase().includes(c.toLowerCase()))return!0}}catch(t){r={error:t}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}return!1},t.prototype.matchesComparable=function(t,e,r,n,a){var o=this,i=n(t),c=r.map((function(t){return n(t)})).filter((function(t){return void 0!==t}));return void 0===i||0===c.length?r.some((function(r){return o.comparator(t,e,r)})):c.some((function(t){return a(i,e,t)}))},t.prototype.comparator=function(t,e,r){switch(e){case s:case h:return t<r;case u:case p:return t<=r;case l:case v:return t>r;case f:case y:return t>=r;default:return!1}},t.prototype.versionComparator=function(t,e,r){var n=t.compareTo(r);switch(e){case s:case h:return n<0;case u:case p:return n<=0;case l:case v:return n>0;case f:case y:return n>=0;default:return!1}},t.prototype.matchesRegex=function(t,e){return e.some((function(e){return Boolean(new RegExp(e).exec(t))}))},t.prototype.containsNone=function(t){return t.some((function(t){return"(none)"===t}))},t.prototype.containsBooleans=function(t){return t.some((function(t){switch(t.toLowerCase()){case"true":case"false":return!0;default:return!1}}))},t.prototype.parseNumber=function(t){var e;return null!==(e=Number(t))&&void 0!==e?e:void 0},t.prototype.coerceString=function(t){if(t)return"object"==typeof t?JSON.stringify(t):String(t)},t.prototype.coerceStringArray=function(t){var e=this;if(Array.isArray(t))return t.map((function(t){return e.coerceString(t)})).filter(Boolean);var r=String(t);try{var n=JSON.parse(r);return Array.isArray(n)?t.map((function(t){return e.coerceString(t)})).filter(Boolean):void 0}catch(t){return}},t.prototype.isSetOperator=function(t){switch(t){case m:case d:case g:case b:case w:case x:return!0;default:return!1}},t.prototype.setEquals=function(t,e){var r=new Set(t),n=new Set(e);return r.size===n.size&&function(t,e,r){if(r||2===arguments.length)for(var n,a=0,o=e.length;a<o;a++)!n&&a in e||(n||(n=Array.prototype.slice.call(e,0,a)),n[a]=e[a]);return t.concat(n||Array.prototype.slice.call(e))}([],function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,a,o=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(t){a={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i}(n),!1).every((function(t){return r.has(t)}))},t.prototype.matchesSetContainsAll=function(t,e){var r,a;if(t.length<e.length)return!1;try{for(var o=n(e),i=o.next();!i.done;i=o.next()){var c=i.value;if(!this.matchesIs(c,t))return!1}}catch(t){r={error:t}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}return!0},t.prototype.matchesSetContainsAny=function(t,e){var r,a;try{for(var o=n(e),i=o.next();!i.done;i=o.next()){var c=i.value;if(this.matchesIs(c,t))return!0}}catch(t){r={error:t}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}return!1},t}();"function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder;(t=>{let e={};t.forEach(((t,r)=>e[t]=r))})(Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),String.fromCharCode.bind(String),"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),function(t){function r(e,n){var a=t.call(this,n)||this;return a.statusCode=e,Object.setPrototypeOf(a,r.prototype),a}(function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)})(r,t)}(Error);var P=function(){function t(){this.evaluationEngine=new I}return t.prototype.evaluateTargeting=function(t){var e=t.event,r=t.sessionId,n=t.userProperties,a=t.deviceId,o=t.flag,i={session_id:r,event:e,user:{device_id:a,user_properties:n}};return this.evaluationEngine.evaluate(i,[o])},t}();return t.Targeting=P,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};var r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function n(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}"function"==typeof SuppressedError&&SuppressedError;var o="is",a="is not",i="contains",c="does not contain",s="less",u="less or equal",l="greater",f="greater or equal",h="version less",p="version less or equal",v="version greater",y="version greater or equal",d="set is",m="set is not",g="set contains",b="set does not contain",w="set contains any",x="set does not contain any",S="regex match",C="regex does not match",A=-862048943,j=461845907,N=function(e,t){void 0===t&&(t=0);for(var r=function(e){for(var t=[],r=0,n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=63&o|128):55296==(64512&o)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=63&o|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=63&o|128)}return Uint8Array.from(t)}(e),n=r.length,o=n>>2,a=t,i=0;i<o;i++){var c=M(r,i<<2);a=O(c,a)}var s=o<<2,u=0;switch(n-s){case 3:u^=r[s+2]<<16,u^=r[s+1]<<8,u^=r[s],u=Math.imul(u,A),u=E(u,15),a^=u=Math.imul(u,j);break;case 2:u^=r[s+1]<<8,u^=r[s],u=Math.imul(u,A),u=E(u,15),a^=u=Math.imul(u,j);break;case 1:u^=r[s],u=Math.imul(u,A),u=E(u,15),a^=u=Math.imul(u,j)}return R(a^=n)>>>0},O=function(e,t){var r=e,n=t;return r=Math.imul(r,A),r=E(r,15),r=Math.imul(r,j),n=E(n^=r,13),(n=Math.imul(n,5))+-430675100|0},R=function(e){var t=e;return t^=t>>>16,t=Math.imul(t,-2048144789),t^=t>>>13,t=Math.imul(t,-1028477387),t^=t>>>16},E=function(e,t,r){return void 0===r&&(r=32),t>r&&(t%=r),(e<<t|(e&4294967295<<r-t>>>0)>>>0>>>r-t>>>0)>>>0},M=function(e,t){void 0===t&&(t=0);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return k(r)},k=function(e){return(-16777216&e)>>>24|(16711680&e)>>>8|(65280&e)<<8|(255&e)<<24},T=function(e,t){var r,o;if(t&&0!==t.length){try{for(var a=n(t),i=a.next();!i.done;i=a.next()){var c=i.value;if(!c||!e||"object"!=typeof e)return;e=e[c]}}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return e||void 0}},_="^".concat("(\\d+)\\.(\\d+)","(\\.").concat("(\\d+)").concat("(-(([-\\w]+\\.?)*))?",")?$"),q=function(){function e(e,t,r,n){void 0===n&&(n=void 0),this.major=e,this.minor=t,this.patch=r,this.preRelease=n}return e.parse=function(t){if(t){var r=new RegExp(_).exec(t);if(r){var n=Number(r[1]),o=Number(r[2]);if(!isNaN(n)&&!isNaN(o))return new e(n,o,Number(r[4])||0,r[5]||void 0)}}},e.prototype.compareTo=function(e){return this.major>e.major?1:this.major<e.major?-1:this.minor>e.minor?1:this.minor<e.minor?-1:this.patch>e.patch?1:this.patch<e.patch||this.preRelease&&!e.preRelease?-1:!this.preRelease&&e.preRelease?1:this.preRelease&&e.preRelease?this.preRelease>e.preRelease?1:this.preRelease<e.preRelease?-1:0:0},e}(),I=function(){function e(){}return e.prototype.evaluate=function(e,t){var r,o,a={},i={context:e,result:a};try{for(var c=n(t),s=c.next();!s.done;s=c.next()){var u=s.value,l=this.evaluateFlag(i,u);l&&(a[u.key]=l)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return a},e.prototype.evaluateFlag=function(e,t){var o,a,i;try{for(var c=n(t.segments),s=c.next();!s.done;s=c.next()){var u=s.value;if(i=this.evaluateSegment(e,t,u)){var l=r(r(r({},t.metadata),u.metadata),i.metadata);i=r(r({},i),{metadata:l});break}}}catch(e){o={error:e}}finally{try{s&&!s.done&&(a=c.return)&&a.call(c)}finally{if(o)throw o.error}}return i},e.prototype.evaluateSegment=function(e,t,r){var o,a,i,c;if(!r.conditions)return void 0!==(l=this.bucket(e,r))?t.variants[l]:void 0;try{for(var s=n(r.conditions),u=s.next();!u.done;u=s.next()){var l,f=u.value,h=!0;try{for(var p=(i=void 0,n(f)),v=p.next();!v.done;v=p.next()){var y=v.value;if(!(h=this.matchCondition(e,y)))break}}catch(e){i={error:e}}finally{try{v&&!v.done&&(c=p.return)&&c.call(p)}finally{if(i)throw i.error}}if(h)return void 0!==(l=this.bucket(e,r))?t.variants[l]:void 0}}catch(e){o={error:e}}finally{try{u&&!u.done&&(a=s.return)&&a.call(s)}finally{if(o)throw o.error}}},e.prototype.matchCondition=function(e,t){var r=T(e,t.selector);if(r){if(this.isSetOperator(t.op)){var n=this.coerceStringArray(r);return!!n&&this.matchSet(n,t.op,t.values)}var o=this.coerceString(r);return void 0!==o&&this.matchString(o,t.op,t.values)}return this.matchNull(t.op,t.values)},e.prototype.getHash=function(e){return N(e)},e.prototype.bucket=function(e,t){var r,o,a,i;if(!t.bucket)return t.variant;var c=this.coerceString(T(e,t.bucket.selector));if(!c||0===c.length)return t.variant;var s="".concat(t.bucket.salt,"/").concat(c),u=this.getHash(s),l=u%100,f=Math.floor(u/100);try{for(var h=n(t.bucket.allocations),p=h.next();!p.done;p=h.next()){var v=p.value,y=v.range[0],d=v.range[1];if(l>=y&&l<d)try{for(var m=(a=void 0,n(v.distributions)),g=m.next();!g.done;g=m.next()){var b=g.value,w=b.range[0],x=b.range[1];if(f>=w&&f<x)return b.variant}}catch(e){a={error:e}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(a)throw a.error}}}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}return t.variant},e.prototype.matchNull=function(e,t){var r=this.containsNone(t);switch(e){case o:case i:case s:case u:case l:case f:case h:case p:case v:case y:case d:case g:case w:return r;case a:case c:case b:case x:return!r;default:return!1}},e.prototype.matchSet=function(e,t,r){switch(t){case d:return this.setEquals(e,r);case m:return!this.setEquals(e,r);case g:return this.matchesSetContainsAll(e,r);case b:return!this.matchesSetContainsAll(e,r);case w:return this.matchesSetContainsAny(e,r);case x:return!this.matchesSetContainsAny(e,r);default:return!1}},e.prototype.matchString=function(e,t,r){var n=this;switch(t){case o:return this.matchesIs(e,r);case a:return!this.matchesIs(e,r);case i:return this.matchesContains(e,r);case c:return!this.matchesContains(e,r);case s:case u:case l:case f:return this.matchesComparable(e,t,r,(function(e){return n.parseNumber(e)}),this.comparator);case h:case p:case v:case y:return this.matchesComparable(e,t,r,(function(e){return q.parse(e)}),this.versionComparator);case S:return this.matchesRegex(e,r);case C:return!this.matchesRegex(e,r);default:return!1}},e.prototype.matchesIs=function(e,t){if(this.containsBooleans(t)){var r=e.toLowerCase();if("true"===r||"false"===r)return t.some((function(e){return e.toLowerCase()===r}))}return t.some((function(t){return e===t}))},e.prototype.matchesContains=function(e,t){var r,o;try{for(var a=n(t),i=a.next();!i.done;i=a.next()){var c=i.value;if(e.toLowerCase().includes(c.toLowerCase()))return!0}}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return!1},e.prototype.matchesComparable=function(e,t,r,n,o){var a=this,i=n(e),c=r.map((function(e){return n(e)})).filter((function(e){return void 0!==e}));return void 0===i||0===c.length?r.some((function(r){return a.comparator(e,t,r)})):c.some((function(e){return o(i,t,e)}))},e.prototype.comparator=function(e,t,r){switch(t){case s:case h:return e<r;case u:case p:return e<=r;case l:case v:return e>r;case f:case y:return e>=r;default:return!1}},e.prototype.versionComparator=function(e,t,r){var n=e.compareTo(r);switch(t){case s:case h:return n<0;case u:case p:return n<=0;case l:case v:return n>0;case f:case y:return n>=0;default:return!1}},e.prototype.matchesRegex=function(e,t){return t.some((function(t){return Boolean(new RegExp(t).exec(e))}))},e.prototype.containsNone=function(e){return e.some((function(e){return"(none)"===e}))},e.prototype.containsBooleans=function(e){return e.some((function(e){switch(e.toLowerCase()){case"true":case"false":return!0;default:return!1}}))},e.prototype.parseNumber=function(e){var t;return null!==(t=Number(e))&&void 0!==t?t:void 0},e.prototype.coerceString=function(e){if(e)return"object"==typeof e?JSON.stringify(e):String(e)},e.prototype.coerceStringArray=function(e){var t=this;if(Array.isArray(e))return e.map((function(e){return t.coerceString(e)})).filter(Boolean);var r=String(e);try{var n=JSON.parse(r);return Array.isArray(n)?e.map((function(e){return t.coerceString(e)})).filter(Boolean):void 0}catch(e){return}},e.prototype.isSetOperator=function(e){switch(e){case d:case m:case g:case b:case w:case x:return!0;default:return!1}},e.prototype.setEquals=function(e,t){var r=new Set(e),n=new Set(t);return r.size===n.size&&function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([],function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}(n),!1).every((function(e){return r.has(e)}))},e.prototype.matchesSetContainsAll=function(e,t){var r,o;if(e.length<t.length)return!1;try{for(var a=n(t),i=a.next();!i.done;i=a.next()){var c=i.value;if(!this.matchesIs(c,e))return!1}}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return!0},e.prototype.matchesSetContainsAny=function(e,t){var r,o;try{for(var a=n(t),i=a.next();!i.done;i=a.next()){var c=i.value;if(this.matchesIs(c,e))return!0}}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return!1},e}();"function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder;(e=>{let t={};e.forEach(((e,r)=>t[e]=r))})(Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),String.fromCharCode.bind(String),"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),function(e){function r(t,n){var o=e.call(this,n)||this;return o.statusCode=t,Object.setPrototypeOf(o,r.prototype),o}(function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)})(r,e)}(Error);var P=function(){function e(){this.evaluationEngine=new I}return e.prototype.evaluateTargeting=function(e){var t=e.event,r=e.sessionId,n=e.userProperties,o=e.deviceId,a=e.flag,i={session_id:r,event:t,user:{device_id:o,user_properties:n}};return this.evaluationEngine.evaluate(i,[a])},e}();e.Targeting=P,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EvaluationEngine } from '@amplitude/experiment-core';
|
|
2
|
+
import { Targeting as AmplitudeTargeting, TargetingParameters } from './typings/targeting';
|
|
3
|
+
export declare class Targeting implements AmplitudeTargeting {
|
|
4
|
+
evaluationEngine: EvaluationEngine;
|
|
5
|
+
constructor();
|
|
6
|
+
evaluateTargeting({ event, sessionId, userProperties, deviceId, flag }: TargetingParameters): Record<string, import("@amplitude/experiment-core").EvaluationVariant>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=targeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.d.ts","sourceRoot":"","sources":["../../src/targeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE3F,qBAAa,SAAU,YAAW,kBAAkB;IAClD,gBAAgB,EAAE,gBAAgB,CAAC;;IAMnC,iBAAiB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,mBAAmB;CAW5F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Event, IdentifyUserProperties } from '@amplitude/analytics-types';
|
|
2
|
+
import { EvaluationFlag, EvaluationVariant } from '@amplitude/experiment-core';
|
|
3
|
+
export interface TargetingParameters {
|
|
4
|
+
event?: Event;
|
|
5
|
+
userProperties?: IdentifyUserProperties;
|
|
6
|
+
deviceId?: string;
|
|
7
|
+
flag: EvaluationFlag;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Targeting {
|
|
11
|
+
evaluateTargeting(args: TargetingParameters): Record<string, EvaluationVariant>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=targeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.d.ts","sourceRoot":"","sources":["../../../src/typings/targeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CACjF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amplitude/targeting",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "Amplitude Inc",
|
|
6
|
+
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "lib/cjs/index.js",
|
|
9
|
+
"module": "lib/esm/index.js",
|
|
10
|
+
"types": "lib/esm/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/amplitude/Amplitude-TypeScript.git"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "yarn bundle && yarn build:es5 && yarn build:esm",
|
|
21
|
+
"bundle": "rollup --config rollup.config.js",
|
|
22
|
+
"build:es5": "tsc -p ./tsconfig.es5.json",
|
|
23
|
+
"build:esm": "tsc -p ./tsconfig.esm.json",
|
|
24
|
+
"clean": "rimraf node_modules lib coverage",
|
|
25
|
+
"fix": "yarn fix:eslint & yarn fix:prettier",
|
|
26
|
+
"fix:eslint": "eslint '{src,test}/**/*.ts' --fix",
|
|
27
|
+
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
|
|
28
|
+
"lint": "yarn lint:eslint & yarn lint:prettier",
|
|
29
|
+
"lint:eslint": "eslint '{src,test}/**/*.ts'",
|
|
30
|
+
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
|
|
31
|
+
"publish": "node ../../scripts/publish/upload-to-s3.js",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"typecheck": "tsc -p ./tsconfig.json",
|
|
34
|
+
"version": "yarn add @amplitude/analytics-types@\">=1 <3\" @amplitude/analytics-client-common@\">=1 <3\" @amplitude/analytics-core@\">=1 <3\"",
|
|
35
|
+
"version-file": "node -p \"'export const VERSION = \\'' + require('./package.json').version + '\\';'\" > src/version.ts"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@amplitude/analytics-client-common": ">=1 <3",
|
|
42
|
+
"@amplitude/analytics-core": ">=1 <3",
|
|
43
|
+
"@amplitude/analytics-types": ">=1 <3",
|
|
44
|
+
"@amplitude/experiment-core": "0.7.2",
|
|
45
|
+
"tslib": "^2.4.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@rollup/plugin-commonjs": "^23.0.4",
|
|
49
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
50
|
+
"@rollup/plugin-typescript": "^10.0.1",
|
|
51
|
+
"rollup": "^2.79.1",
|
|
52
|
+
"rollup-plugin-execute": "^1.1.1",
|
|
53
|
+
"rollup-plugin-gzip": "^3.1.0",
|
|
54
|
+
"rollup-plugin-terser": "^7.0.2"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"lib"
|
|
58
|
+
],
|
|
59
|
+
"gitHead": "d8890068210e67d23ab1a853b553e4685a55253c"
|
|
60
|
+
}
|