@ht-sdks/events-sdk-js-browser 1.3.2 → 1.5.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/dist/cjs/browser/index.js +4 -4
- package/dist/cjs/browser/index.js.map +1 -1
- package/dist/cjs/generated/version.js +1 -1
- package/dist/cjs/lib/tsub/index.js +13 -0
- package/dist/cjs/lib/tsub/index.js.map +1 -0
- package/dist/cjs/lib/tsub/matchers.js +416 -0
- package/dist/cjs/lib/tsub/matchers.js.map +1 -0
- package/dist/cjs/lib/tsub/store.js +23 -0
- package/dist/cjs/lib/tsub/store.js.map +1 -0
- package/dist/cjs/lib/tsub/transformers.js +218 -0
- package/dist/cjs/lib/tsub/transformers.js.map +1 -0
- package/dist/cjs/lib/tsub/unset.js +20 -0
- package/dist/cjs/lib/tsub/unset.js.map +1 -0
- package/dist/cjs/plugins/routing-middleware/index.js +1 -1
- package/dist/cjs/plugins/routing-middleware/index.js.map +1 -1
- package/dist/pkg/browser/index.js +4 -4
- package/dist/pkg/browser/index.js.map +1 -1
- package/dist/pkg/generated/version.js +1 -1
- package/dist/pkg/lib/tsub/index.js +4 -0
- package/dist/pkg/lib/tsub/index.js.map +1 -0
- package/dist/pkg/lib/tsub/matchers.js +412 -0
- package/dist/pkg/lib/tsub/matchers.js.map +1 -0
- package/dist/pkg/lib/tsub/store.js +21 -0
- package/dist/pkg/lib/tsub/store.js.map +1 -0
- package/dist/pkg/lib/tsub/transformers.js +214 -0
- package/dist/pkg/lib/tsub/transformers.js.map +1 -0
- package/dist/pkg/lib/tsub/unset.js +15 -0
- package/dist/pkg/lib/tsub/unset.js.map +1 -0
- package/dist/pkg/plugins/routing-middleware/index.js +1 -1
- package/dist/pkg/plugins/routing-middleware/index.js.map +1 -1
- package/dist/types/core/buffer/index.d.ts +1 -1
- package/dist/types/generated/version.d.ts +1 -1
- package/dist/types/lib/tsub/index.d.ts +4 -0
- package/dist/types/lib/tsub/index.d.ts.map +1 -0
- package/dist/types/lib/tsub/matchers.d.ts +5 -0
- package/dist/types/lib/tsub/matchers.d.ts.map +1 -0
- package/dist/types/lib/tsub/store.d.ts +22 -0
- package/dist/types/lib/tsub/store.d.ts.map +1 -0
- package/dist/types/lib/tsub/transformers.d.ts +20 -0
- package/dist/types/lib/tsub/transformers.d.ts.map +1 -0
- package/dist/types/lib/tsub/unset.d.ts +2 -0
- package/dist/types/lib/tsub/unset.d.ts.map +1 -0
- package/dist/types/plugins/routing-middleware/index.d.ts +3 -3
- package/dist/types/plugins/routing-middleware/index.d.ts.map +1 -1
- package/dist/umd/events.min.js +1 -1
- package/dist/umd/events.min.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/tsub-middleware.bundle.59e8d6916920ab24b51c.js +2 -0
- package/dist/umd/tsub-middleware.bundle.59e8d6916920ab24b51c.js.map +1 -0
- package/package.json +3 -2
- package/src/browser/index.ts +7 -7
- package/src/core/analytics/index.ts +1 -1
- package/src/generated/version.ts +1 -1
- package/src/lib/tsub/README.md +9 -0
- package/src/lib/tsub/index.ts +3 -0
- package/src/lib/tsub/matchers.ts +498 -0
- package/src/lib/tsub/store.ts +42 -0
- package/src/lib/tsub/transformers.ts +282 -0
- package/src/lib/tsub/unset.ts +14 -0
- package/src/plugins/routing-middleware/index.ts +3 -4
- package/dist/umd/870.bundle.6d7307379da86a3bf277.js +0 -2
- package/dist/umd/870.bundle.6d7307379da86a3bf277.js.map +0 -1
- package/dist/umd/tsub-middleware.bundle.a9604b3195f6189e429b.js +0 -2
- package/dist/umd/tsub-middleware.bundle.a9604b3195f6189e429b.js.map +0 -1
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { Transformer } from './store'
|
|
2
|
+
import MD5 from 'spark-md5'
|
|
3
|
+
import get from 'dlv'
|
|
4
|
+
import { dset } from 'dset'
|
|
5
|
+
import { unset } from './unset'
|
|
6
|
+
|
|
7
|
+
export type KeyTarget = Record<string, string[]>
|
|
8
|
+
|
|
9
|
+
export interface TransformerConfig {
|
|
10
|
+
allow?: KeyTarget
|
|
11
|
+
drop?: KeyTarget
|
|
12
|
+
sample?: TransformerConfigSample
|
|
13
|
+
map?: Record<string, TransformerConfigMap>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TransformerConfigSample {
|
|
17
|
+
percent: number
|
|
18
|
+
path: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TransformerConfigMap {
|
|
22
|
+
set?: any
|
|
23
|
+
copy?: string
|
|
24
|
+
move?: string
|
|
25
|
+
to_string?: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function transform(
|
|
29
|
+
payload: any,
|
|
30
|
+
transformers: Transformer[]
|
|
31
|
+
): any {
|
|
32
|
+
const transformedPayload = payload
|
|
33
|
+
|
|
34
|
+
for (const transformer of transformers) {
|
|
35
|
+
switch (transformer.type) {
|
|
36
|
+
case 'drop':
|
|
37
|
+
return null
|
|
38
|
+
case 'drop_properties':
|
|
39
|
+
dropProperties(transformedPayload, transformer.config!)
|
|
40
|
+
break
|
|
41
|
+
case 'allow_properties':
|
|
42
|
+
allowProperties(transformedPayload, transformer.config!)
|
|
43
|
+
break
|
|
44
|
+
case 'sample_event':
|
|
45
|
+
if (sampleEvent(transformedPayload, transformer.config!)) {
|
|
46
|
+
break
|
|
47
|
+
}
|
|
48
|
+
return null
|
|
49
|
+
case 'map_properties':
|
|
50
|
+
mapProperties(transformedPayload, transformer.config!)
|
|
51
|
+
break
|
|
52
|
+
case 'hash_properties':
|
|
53
|
+
// Not yet supported, but don't throw an error. Just ignore.
|
|
54
|
+
break
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Transformer of type "${transformer.type}" is unsupported.`
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return transformedPayload
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// dropProperties removes all specified props from the object.
|
|
66
|
+
function dropProperties(payload: any, config: TransformerConfig) {
|
|
67
|
+
filterProperties(payload, config.drop!, (matchedObj, dropList) => {
|
|
68
|
+
dropList.forEach((k) => delete matchedObj[k])
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// allowProperties ONLY allows the specific targets within the keys. (e.g. "a.foo": ["bar", "baz"]
|
|
73
|
+
// on {a: {foo: {bar: 1, baz: 2}, other: 3}} will not have any drops, as it only looks inside a.foo
|
|
74
|
+
function allowProperties(payload: any, config: TransformerConfig) {
|
|
75
|
+
filterProperties(payload, config.allow!, (matchedObj, preserveList) => {
|
|
76
|
+
Object.keys(matchedObj).forEach((key) => {
|
|
77
|
+
if (!preserveList.includes(key)) {
|
|
78
|
+
delete matchedObj[key]
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function filterProperties(
|
|
85
|
+
payload: any,
|
|
86
|
+
ruleSet: KeyTarget,
|
|
87
|
+
filterCb: (matchedObject: any, targets: string[]) => void
|
|
88
|
+
) {
|
|
89
|
+
Object.entries(ruleSet).forEach(([key, targets]) => {
|
|
90
|
+
const filter = (obj: any) => {
|
|
91
|
+
// Can only act on objects.
|
|
92
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
filterCb(obj, targets)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// If key is empty, it refers to the top-level object.
|
|
100
|
+
const matchedObject = key === '' ? payload : get(payload, key)
|
|
101
|
+
|
|
102
|
+
if (Array.isArray(matchedObject)) {
|
|
103
|
+
matchedObject.forEach(filter)
|
|
104
|
+
} else {
|
|
105
|
+
filter(matchedObject)
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function mapProperties(payload: any, config: TransformerConfig) {
|
|
111
|
+
// Some configs might try to modify or read from a field multiple times. We will only ever read
|
|
112
|
+
// values as they were before any modifications began. Thus, if you try to override e.g.
|
|
113
|
+
// {a: {b: 1}} with set(a, 'b', 2) (which results in {a: {b: 2}}) and then try to copy a.b into
|
|
114
|
+
// a.c, you will get {a: {b: 2, c:1}} and NOT {a: {b:2, c:2}}. This prevents map evaluation
|
|
115
|
+
// order from mattering, and === what server-side does.
|
|
116
|
+
// See: https://github.com/segmentio/tsub/blob/661695a63b60b90471796e667458f076af788c19/transformers/map_properties.go#L179-L200
|
|
117
|
+
const initialPayload = JSON.parse(JSON.stringify(payload))
|
|
118
|
+
|
|
119
|
+
for (const key in config.map) {
|
|
120
|
+
if (!Object.prototype.hasOwnProperty.call(config.map, key)) {
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const actionMap: TransformerConfigMap = config.map[key]
|
|
125
|
+
|
|
126
|
+
// Can't manipulate non-objects. Check that the parent is one. Strip the last .field
|
|
127
|
+
// from the string.
|
|
128
|
+
const splitKey = key.split('.')
|
|
129
|
+
let parent
|
|
130
|
+
if (splitKey.length > 1) {
|
|
131
|
+
splitKey.pop()
|
|
132
|
+
parent = get(initialPayload, splitKey.join('.'))
|
|
133
|
+
} else {
|
|
134
|
+
parent = payload
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (typeof parent !== 'object') {
|
|
138
|
+
continue
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// These actions are exclusive to each other.
|
|
142
|
+
if (actionMap.copy) {
|
|
143
|
+
const valueToCopy = get(initialPayload, actionMap.copy)
|
|
144
|
+
if (valueToCopy !== undefined) {
|
|
145
|
+
dset(payload, key, valueToCopy)
|
|
146
|
+
}
|
|
147
|
+
} else if (actionMap.move) {
|
|
148
|
+
const valueToMove = get(initialPayload, actionMap.move)
|
|
149
|
+
if (valueToMove !== undefined) {
|
|
150
|
+
dset(payload, key, valueToMove)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
unset(payload, actionMap.move)
|
|
154
|
+
}
|
|
155
|
+
// Have to check only if property exists, as null, undefined, and other vals could be explicitly set.
|
|
156
|
+
else if (Object.prototype.hasOwnProperty.call(actionMap, 'set')) {
|
|
157
|
+
dset(payload, key, actionMap.set)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// to_string is not exclusive and can be paired with other actions. Final action.
|
|
161
|
+
if (actionMap.to_string) {
|
|
162
|
+
const valueToString = get(payload, key)
|
|
163
|
+
|
|
164
|
+
// Do not string arrays and objects. Do not double-encode strings.
|
|
165
|
+
if (
|
|
166
|
+
typeof valueToString === 'string' ||
|
|
167
|
+
(typeof valueToString === 'object' && valueToString !== null)
|
|
168
|
+
) {
|
|
169
|
+
continue
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// TODO: Check stringifier in Golang for parity.
|
|
173
|
+
if (valueToString !== undefined) {
|
|
174
|
+
dset(payload, key, JSON.stringify(valueToString))
|
|
175
|
+
} else {
|
|
176
|
+
// TODO: Check this behavior.
|
|
177
|
+
dset(payload, key, 'undefined')
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function sampleEvent(payload: any, config: TransformerConfig): boolean {
|
|
184
|
+
if (config.sample!.percent <= 0) {
|
|
185
|
+
return false
|
|
186
|
+
} else if (config.sample!.percent >= 1) {
|
|
187
|
+
return true
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// If we're not filtering deterministically, just use raw percentage.
|
|
191
|
+
if (!config.sample!.path) {
|
|
192
|
+
return samplePercent(config.sample!.percent)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Otherwise, use a deterministic hash.
|
|
196
|
+
return sampleConsistentPercent(payload, config)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function samplePercent(percent: number): boolean {
|
|
200
|
+
// Math.random returns [0, 1) => 0.0<>0.9999...
|
|
201
|
+
return Math.random() <= percent
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// sampleConsistentPercent converts an input string of bytes into a consistent uniform
|
|
205
|
+
// continuous distribution of [0.0, 1.0]. This is based on
|
|
206
|
+
// http://mumble.net/~campbell/tmp/random_real.c, but using the digest
|
|
207
|
+
// result of the input value as the random information.
|
|
208
|
+
|
|
209
|
+
// IMPORTANT - This function needs to === the Golang implementation to ensure that the two return the same vals!
|
|
210
|
+
// See: https://github.com/segmentio/sampler/blob/65cb04132305a04fcd4bcaef67d57fbe40c30241/sampler.go#L13-L38
|
|
211
|
+
|
|
212
|
+
// Since AJS supports IE9+ (typed arrays were introduced in IE10) we're doing some manual array math.
|
|
213
|
+
// This could be done directly with strings, but arrays are easier to reason about/have better function support.
|
|
214
|
+
function sampleConsistentPercent(
|
|
215
|
+
payload: any,
|
|
216
|
+
config: TransformerConfig
|
|
217
|
+
): boolean {
|
|
218
|
+
const field = get(payload, config.sample!.path)
|
|
219
|
+
|
|
220
|
+
const hash = MD5.hash(JSON.stringify(field))
|
|
221
|
+
// convert hash to byte array
|
|
222
|
+
const digest = hash.match(/.{2}/g)!.map((byte) => parseInt(byte, 16))
|
|
223
|
+
|
|
224
|
+
let exponent = -64
|
|
225
|
+
|
|
226
|
+
// Manually maintain 64-bit int as an array.
|
|
227
|
+
let significand: number[] = []
|
|
228
|
+
|
|
229
|
+
// Left-shift and OR for first 8 bytes of digest. (8 bytes * 8 = 64 bits)
|
|
230
|
+
consumeDigest(digest.slice(0, 8), significand)
|
|
231
|
+
|
|
232
|
+
let leadingZeros = 0
|
|
233
|
+
for (let i = 0; i < 64; i++) {
|
|
234
|
+
if (significand[i] === 1) {
|
|
235
|
+
break
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
leadingZeros++
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (leadingZeros !== 0) {
|
|
242
|
+
// Use the last 8 bytes of the digest, same as before.
|
|
243
|
+
const val: number[] = []
|
|
244
|
+
consumeDigest(digest.slice(9, 16), val)
|
|
245
|
+
|
|
246
|
+
exponent -= leadingZeros
|
|
247
|
+
// Left-shift away leading zeros in significand.
|
|
248
|
+
significand.splice(0, leadingZeros)
|
|
249
|
+
|
|
250
|
+
// Right-shift val by 64 minus leading zeros and push into significand.
|
|
251
|
+
val.splice(64 - leadingZeros)
|
|
252
|
+
significand = significand.concat(val)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Flip 64th bit
|
|
256
|
+
significand[63] = significand[63] === 0 ? 1 : 0
|
|
257
|
+
|
|
258
|
+
// Convert our manual binary into a JS num (binary arr => binary string => psuedo-int) and run the ldexp!
|
|
259
|
+
return (
|
|
260
|
+
ldexp(parseInt(significand.join(''), 2), exponent) < config.sample!.percent
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Array byte filler helper
|
|
265
|
+
function consumeDigest(digest: number[], arr: number[]) {
|
|
266
|
+
for (let i = 0; i < 8; i++) {
|
|
267
|
+
let remainder = digest[i]
|
|
268
|
+
for (let binary = 128; binary >= 1; binary /= 2) {
|
|
269
|
+
if (remainder - binary >= 0) {
|
|
270
|
+
remainder -= binary
|
|
271
|
+
arr.push(1)
|
|
272
|
+
} else {
|
|
273
|
+
arr.push(0)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Simplified implementation of https://github.com/stdlib-js/math-base-special-ldexp
|
|
280
|
+
function ldexp(x: number, exp: number) {
|
|
281
|
+
return x * Math.pow(2, exp)
|
|
282
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import get from 'dlv'
|
|
2
|
+
|
|
3
|
+
export function unset(obj: any, prop: any) {
|
|
4
|
+
if (get(obj, prop)) {
|
|
5
|
+
const segs = prop.split('.')
|
|
6
|
+
let last = segs.pop()
|
|
7
|
+
while (segs.length && segs[segs.length - 1].slice(-1) === '\\') {
|
|
8
|
+
last = segs.pop().slice(0, -1) + '.' + last
|
|
9
|
+
}
|
|
10
|
+
while (segs.length) obj = obj[(prop = segs.shift())]
|
|
11
|
+
return delete obj[last]
|
|
12
|
+
}
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import * as tsub from '
|
|
2
|
-
import { Matcher, Rule } from '@segment/tsub/dist/store'
|
|
1
|
+
import * as tsub from '../../lib/tsub'
|
|
3
2
|
import { DestinationMiddlewareFunction } from '../middleware'
|
|
4
3
|
|
|
5
4
|
// TODO: update tsub definition
|
|
6
|
-
type RoutingRuleMatcher = Matcher & {
|
|
5
|
+
type RoutingRuleMatcher = tsub.Matcher & {
|
|
7
6
|
config?: {
|
|
8
7
|
expr: string
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export type RoutingRule = Rule & {
|
|
11
|
+
export type RoutingRule = tsub.Rule & {
|
|
13
12
|
matchers: RoutingRuleMatcher[]
|
|
14
13
|
}
|
|
15
14
|
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_ht_sdks_events_sdk_js_browser=self.webpackChunk_ht_sdks_events_sdk_js_browser||[]).push([[870],{2870:function(t,r,e){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.Store=r.matches=r.transform=void 0;var o=e(4303);Object.defineProperty(r,"transform",{enumerable:!0,get:function(){return n(o).default}});var i=e(2370);Object.defineProperty(r,"matches",{enumerable:!0,get:function(){return n(i).default}});var u=e(1444);Object.defineProperty(r,"Store",{enumerable:!0,get:function(){return n(u).default}})},2370:function(t,r,e){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});var o=n(e(7843));function i(t,r){if(!Array.isArray(t))return!0===u(t,r);var e=t[0];switch(e){case"!":return!i(t[1],r);case"or":for(var n=1;n<t.length;n++)if(i(t[n],r))return!0;return!1;case"and":for(n=1;n<t.length;n++)if(!i(t[n],r))return!1;return!0;case"=":case"!=":return function(t,r,e,n){s(t)&&(t=i(t,n));s(r)&&(r=i(r,n));"object"==typeof t&&"object"==typeof r&&(t=JSON.stringify(t),r=JSON.stringify(r));switch(e){case"=":return t===r;case"!=":return t!==r;default:throw new Error("Invalid operator in compareItems: ".concat(e))}}(u(t[1],r),u(t[2],r),e,r);case"<=":case"<":case">":case">=":return function(t,r,e,n){s(t)&&(t=i(t,n));s(r)&&(r=i(r,n));if("number"!=typeof t||"number"!=typeof r)return!1;switch(e){case"<=":return t<=r;case">=":return t>=r;case"<":return t<r;case">":return t>r;default:throw new Error("Invalid operator in compareNumbers: ".concat(e))}}(u(t[1],r),u(t[2],r),e,r);case"in":return function(t,r,e){return void 0!==r.find((function(r){return u(r,e)===t}))}(u(t[1],r),u(t[2],r),r);case"contains":return function(t,r){if("string"!=typeof t||"string"!=typeof r)return!1;return-1!==t.indexOf(r)}(u(t[1],r),u(t[2],r));case"match":return function(t,r){if("string"!=typeof t||"string"!=typeof r)return!1;return function(t,r){var e,n;t:for(;t.length>0;){var o=void 0,i=void 0;if(o=(e=c(t)).star,i=e.chunk,t=e.pattern,o&&""===i)return!0;var u=f(i,r),s=u.t,a=u.ok,p=u.err;if(p)return!1;if(!a||!(0===s.length||t.length>0)){if(o)for(var l=0;l<r.length;l++){if(s=(n=f(i,r.slice(l+1))).t,a=n.ok,p=n.err,a){if(0===t.length&&s.length>0)continue;r=s;continue t}if(p)return!1}return!1}r=s}return 0===r.length}(r,t)}(u(t[1],r),u(t[2],r));case"lowercase":var o=u(t[1],r);return"string"!=typeof o?null:o.toLowerCase();case"typeof":return typeof u(t[1],r);case"length":return function(t){if(null===t)return 0;if(!Array.isArray(t)&&"string"!=typeof t)return NaN;return t.length}(u(t[1],r));default:throw new Error("FQL IR could not evaluate for token: ".concat(e))}}function u(t,r){return Array.isArray(t)?t:"object"==typeof t?t.value:(0,o.default)(r,t)}function s(t){return!!Array.isArray(t)&&(("lowercase"===t[0]||"length"===t[0]||"typeof"===t[0])&&2===t.length||("contains"===t[0]||"match"===t[0])&&3===t.length)}function c(t){for(var r={star:!1,chunk:"",pattern:""};t.length>0&&"*"===t[0];)t=t.slice(1),r.star=!0;var e,n=!1;t:for(e=0;e<t.length;e++)switch(t[e]){case"\\":e+1<t.length&&e++;break;case"[":n=!0;break;case"]":n=!1;break;case"*":if(!n)break t}return r.chunk=t.slice(0,e),r.pattern=t.slice(e),r}function f(t,r){for(var e,n,o={t:"",ok:!1,err:!1};t.length>0;){if(0===r.length)return o;switch(t[0]){case"[":var i=r[0];r=r.slice(1);var u=!0;(t=t.slice(1)).length>0&&"^"===t[0]&&(u=!1,t=t.slice(1));for(var s=!1,c=0;;){if(t.length>0&&"]"===t[0]&&c>0){t=t.slice(1);break}var f,p="";if(f=(e=a(t)).char,t=e.newChunk,e.err)return o;if(p=f,"-"===t[0]&&(p=(n=a(t.slice(1))).char,t=n.newChunk,n.err))return o;f<=i&&i<=p&&(s=!0),c++}if(s!==u)return o;break;case"?":r=r.slice(1),t=t.slice(1);break;case"\\":if(0===(t=t.slice(1)).length)return o.err=!0,o;default:if(t[0]!==r[0])return o;r=r.slice(1),t=t.slice(1)}}return o.t=r,o.ok=!0,o.err=!1,o}function a(t){var r={char:"",newChunk:"",err:!1};return 0===t.length||"-"===t[0]||"]"===t[0]||"\\"===t[0]&&0===(t=t.slice(1)).length?(r.err=!0,r):(r.char=t[0],r.newChunk=t.slice(1),0===r.newChunk.length&&(r.err=!0),r)}r.default=function(t,r){if(!r)throw new Error("No matcher supplied!");switch(r.type){case"all":return!0;case"fql":return function(t,r){if(!t)return!1;try{t=JSON.parse(t)}catch(r){throw new Error('Failed to JSON.parse FQL intermediate representation "'.concat(t,'": ').concat(r))}var e=i(t,r);if("boolean"!=typeof e)return!1;return e}(r.ir,t);default:throw new Error("Matcher of type ".concat(r.type," unsupported."))}}},1444:function(t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var e=function(){function t(t){this.rules=[],this.rules=t||[]}return t.prototype.getRulesByDestinationName=function(t){for(var r=[],e=0,n=this.rules;e<n.length;e++){var o=n[e];o.destinationName!==t&&void 0!==o.destinationName||r.push(o)}return r},t}();r.default=e},4303:function(t,r,e){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});var o=n(e(374)),i=n(e(7843)),u=n(e(5500)),s=e(2341),c=e(4966);function f(t,r){p(t,r.drop,(function(t,r){r.forEach((function(r){return delete t[r]}))}))}function a(t,r){p(t,r.allow,(function(t,r){Object.keys(t).forEach((function(e){r.includes(e)||delete t[e]}))}))}function p(t,r,e){Object.entries(r).forEach((function(r){var n=r[0],o=r[1],u=function(t){"object"==typeof t&&null!==t&&e(t,o)},s=""===n?t:(0,i.default)(t,n);Array.isArray(s)?s.forEach(u):u(s)}))}function l(t,r){var e=JSON.parse(JSON.stringify(t));for(var n in r.map)if(r.map.hasOwnProperty(n)){var o=r.map[n],u=n.split("."),f=void 0;if(u.length>1?(u.pop(),f=(0,i.default)(e,u.join("."))):f=t,"object"==typeof f){if(o.copy){var a=(0,i.default)(e,o.copy);void 0!==a&&(0,s.dset)(t,n,a)}else if(o.move){var p=(0,i.default)(e,o.move);void 0!==p&&(0,s.dset)(t,n,p),(0,c.unset)(t,o.move)}else o.hasOwnProperty("set")&&(0,s.dset)(t,n,o.set);if(o.to_string){var l=(0,i.default)(t,n);if("string"==typeof l||"object"==typeof l&&null!==l)continue;void 0!==l?(0,s.dset)(t,n,JSON.stringify(l)):(0,s.dset)(t,n,"undefined")}}}}function v(t,r){return!(r.sample.percent<=0)&&(r.sample.percent>=1||(r.sample.path?function(t,r){var e=(0,i.default)(t,r.sample.path),n=(0,o.default)(JSON.stringify(e)),s=-64,c=[];y(n.slice(0,8),c);for(var f=0,a=0;a<64&&1!==c[a];a++)f++;if(0!==f){var p=[];y(n.slice(9,16),p),s-=f,c.splice(0,f),p.splice(64-f),c=c.concat(p)}return c[63]=0===c[63]?1:0,(0,u.default)(parseInt(c.join(""),2),s)<r.sample.percent}(t,r):(e=r.sample.percent,Math.random()<=e)));var e}function y(t,r){for(var e=0;e<8;e++)for(var n=t[e],o=128;o>=1;o/=2)n-o>=0?(n-=o,r.push(1)):r.push(0)}r.default=function(t,r){for(var e=t,n=0,o=r;n<o.length;n++){var i=o[n];switch(i.type){case"drop":return null;case"drop_properties":f(e,i.config);break;case"allow_properties":a(e,i.config);break;case"sample_event":if(v(e,i.config))break;return null;case"map_properties":l(e,i.config);break;case"hash_properties":break;default:throw new Error('Transformer of type "'.concat(i.type,'" is unsupported.'))}}return e}},4966:function(t,r,e){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.unset=void 0;var o=n(e(7843));r.unset=function(t,r){if((0,o.default)(t,r)){for(var e=r.split("."),n=e.pop();e.length&&"\\"===e[e.length-1].slice(-1);)n=e.pop().slice(0,-1)+"."+n;for(;e.length;)t=t[r=e.shift()];return delete t[n]}return!0}},3304:function(t){"use strict";var r="function"==typeof Float64Array?Float64Array:void 0;t.exports=r},7382:function(t,r,e){"use strict";var n,o=e(5569),i=e(3304),u=e(8482);n=o()?i:u,t.exports=n},8482:function(t){"use strict";t.exports=function(){throw new Error("not implemented")}},6322:function(t,r,e){"use strict";var n,o=e(2508),i=e(5679),u=e(882);n=o()?i:u,t.exports=n},882:function(t){"use strict";t.exports=function(){throw new Error("not implemented")}},5679:function(t){"use strict";var r="function"==typeof Uint16Array?Uint16Array:void 0;t.exports=r},4773:function(t,r,e){"use strict";var n,o=e(9773),i=e(3004),u=e(3078);n=o()?i:u,t.exports=n},3078:function(t){"use strict";t.exports=function(){throw new Error("not implemented")}},3004:function(t){"use strict";var r="function"==typeof Uint32Array?Uint32Array:void 0;t.exports=r},7980:function(t,r,e){"use strict";var n,o=e(8114),i=e(6737),u=e(3357);n=o()?i:u,t.exports=n},3357:function(t){"use strict";t.exports=function(){throw new Error("not implemented")}},6737:function(t){"use strict";var r="function"==typeof Uint8Array?Uint8Array:void 0;t.exports=r},2684:function(t){"use strict";var r="function"==typeof Float64Array?Float64Array:null;t.exports=r},5569:function(t,r,e){"use strict";var n=e(3876);t.exports=n},3876:function(t,r,e){"use strict";var n=e(1448),o=e(2684);t.exports=function(){var t,r;if("function"!=typeof o)return!1;try{r=new o([1,3.14,-3.14,NaN]),t=n(r)&&1===r[0]&&3.14===r[1]&&-3.14===r[2]&&r[3]!=r[3]}catch(r){t=!1}return t}},9048:function(t,r,e){"use strict";var n=e(3763);t.exports=n},3763:function(t){"use strict";var r=Object.prototype.hasOwnProperty;t.exports=function(t,e){return null!=t&&r.call(t,e)}},7009:function(t,r,e){"use strict";var n=e(6784);t.exports=n},6784:function(t){"use strict";t.exports=function(){return"function"==typeof Symbol&&"symbol"==typeof Symbol("foo")}},3123:function(t,r,e){"use strict";var n=e(8481);t.exports=n},8481:function(t,r,e){"use strict";var n=e(7009)();t.exports=function(){return n&&"symbol"==typeof Symbol.toStringTag}},2508:function(t,r,e){"use strict";var n=e(3403);t.exports=n},3403:function(t,r,e){"use strict";var n=e(768),o=e(9668),i=e(187);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=n(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},187:function(t){"use strict";var r="function"==typeof Uint16Array?Uint16Array:null;t.exports=r},9773:function(t,r,e){"use strict";var n=e(2822);t.exports=n},2822:function(t,r,e){"use strict";var n=e(2744),o=e(3899),i=e(746);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=n(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},746:function(t){"use strict";var r="function"==typeof Uint32Array?Uint32Array:null;t.exports=r},8114:function(t,r,e){"use strict";var n=e(8066);t.exports=n},8066:function(t,r,e){"use strict";var n=e(8279),o=e(3443),i=e(2731);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=n(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},2731:function(t){"use strict";var r="function"==typeof Uint8Array?Uint8Array:null;t.exports=r},1448:function(t,r,e){"use strict";var n=e(1453);t.exports=n},1453:function(t,r,e){"use strict";var n=e(6208),o="function"==typeof Float64Array;t.exports=function(t){return o&&t instanceof Float64Array||"[object Float64Array]"===n(t)}},9331:function(t,r,e){"use strict";var n=e(7980),o={uint16:e(6322),uint8:n};t.exports=o},5902:function(t,r,e){"use strict";var n=e(4106);t.exports=n},4106:function(t,r,e){"use strict";var n,o,i=e(9331);(o=new i.uint16(1))[0]=4660,n=52===new i.uint8(o.buffer)[0],t.exports=n},768:function(t,r,e){"use strict";var n=e(3823);t.exports=n},3823:function(t,r,e){"use strict";var n=e(6208),o="function"==typeof Uint16Array;t.exports=function(t){return o&&t instanceof Uint16Array||"[object Uint16Array]"===n(t)}},2744:function(t,r,e){"use strict";var n=e(2326);t.exports=n},2326:function(t,r,e){"use strict";var n=e(6208),o="function"==typeof Uint32Array;t.exports=function(t){return o&&t instanceof Uint32Array||"[object Uint32Array]"===n(t)}},8279:function(t,r,e){"use strict";var n=e(208);t.exports=n},208:function(t,r,e){"use strict";var n=e(6208),o="function"==typeof Uint8Array;t.exports=function(t){return o&&t instanceof Uint8Array||"[object Uint8Array]"===n(t)}},6315:function(t){"use strict";t.exports=1023},3105:function(t){"use strict";t.exports=2146435072},6988:function(t){"use strict";t.exports=-1023},9777:function(t){"use strict";t.exports=1023},3690:function(t){"use strict";t.exports=-1074},2918:function(t,r,e){"use strict";var n=e(4772).NEGATIVE_INFINITY;t.exports=n},4165:function(t){"use strict";var r=Number.POSITIVE_INFINITY;t.exports=r},6488:function(t){"use strict";t.exports=22250738585072014e-324},9668:function(t){"use strict";t.exports=65535},3899:function(t){"use strict";t.exports=4294967295},3443:function(t){"use strict";t.exports=255},7011:function(t,r,e){"use strict";var n=e(812);t.exports=n},812:function(t,r,e){"use strict";var n=e(4165),o=e(2918);t.exports=function(t){return t===n||t===o}},1883:function(t,r,e){"use strict";var n=e(1797);t.exports=n},1797:function(t){"use strict";t.exports=function(t){return t!=t}},513:function(t,r,e){"use strict";var n=e(5760);t.exports=n},5760:function(t){"use strict";t.exports=function(t){return Math.abs(t)}},6871:function(t,r,e){"use strict";var n=e(7838),o=e(1921),i=e(2490),u=[0,0];t.exports=function(t,r){var e,s;return n(u,t),e=u[0],e&=2147483647,s=o(r),i(e|=s&=2147483648,u[1])}},5848:function(t,r,e){"use strict";var n=e(6871);t.exports=n},5500:function(t,r,e){"use strict";var n=e(8397);t.exports=n},8397:function(t,r,e){"use strict";var n=e(4165),o=e(2918),i=e(6315),u=e(9777),s=e(6988),c=e(3690),f=e(1883),a=e(7011),p=e(5848),l=e(4948),v=e(8478),y=e(7838),h=e(2490),d=[0,0],x=[0,0];t.exports=function(t,r){var e,g;return 0===t||f(t)||a(t)?t:(l(d,t),r+=d[1],(r+=v(t=d[0]))<c?p(0,t):r>u?t<0?o:n:(r<=s?(r+=52,g=2220446049250313e-31):g=1,y(x,t),e=x[0],e&=2148532223,g*h(e|=r+i<<20,x[1])))}},4772:function(t,r,e){"use strict";var n=e(7548);t.exports=n},7548:function(t){"use strict";t.exports=Number},8478:function(t,r,e){"use strict";var n=e(4500);t.exports=n},4500:function(t,r,e){"use strict";var n=e(1921),o=e(3105),i=e(6315);t.exports=function(t){var r=n(t);return(r=(r&o)>>>20)-i|0}},2490:function(t,r,e){"use strict";var n=e(9639);t.exports=n},4445:function(t,r,e){"use strict";var n,o,i;!0===e(5902)?(o=1,i=0):(o=0,i=1),n={HIGH:o,LOW:i},t.exports=n},9639:function(t,r,e){"use strict";var n=e(4773),o=e(7382),i=e(4445),u=new o(1),s=new n(u.buffer),c=i.HIGH,f=i.LOW;t.exports=function(t,r){return s[c]=t,s[f]=r,u[0]}},5646:function(t,r,e){"use strict";var n;n=!0===e(5902)?1:0,t.exports=n},1921:function(t,r,e){"use strict";var n=e(6285);t.exports=n},6285:function(t,r,e){"use strict";var n=e(4773),o=e(7382),i=e(5646),u=new o(1),s=new n(u.buffer);t.exports=function(t){return u[0]=t,s[i]}},4948:function(t,r,e){"use strict";var n=e(9422);t.exports=n},9422:function(t,r,e){"use strict";var n=e(8857);t.exports=function(t,r){return 1===arguments.length?n([0,0],t):n(t,r)}},8857:function(t,r,e){"use strict";var n=e(6488),o=e(7011),i=e(1883),u=e(513);t.exports=function(t,r){return i(r)||o(r)?(t[0]=r,t[1]=0,t):0!==r&&u(r)<n?(t[0]=4503599627370496*r,t[1]=-52,t):(t[0]=r,t[1]=0,t)}},7838:function(t,r,e){"use strict";var n=e(4010);t.exports=n},5782:function(t,r,e){"use strict";var n,o,i;!0===e(5902)?(o=1,i=0):(o=0,i=1),n={HIGH:o,LOW:i},t.exports=n},4010:function(t,r,e){"use strict";var n=e(4903);t.exports=function(t,r){return 1===arguments.length?n([0,0],t):n(t,r)}},4903:function(t,r,e){"use strict";var n=e(4773),o=e(7382),i=e(5782),u=new o(1),s=new n(u.buffer),c=i.HIGH,f=i.LOW;t.exports=function(t,r){return u[0]=r,t[0]=s[c],t[1]=s[f],t}},6208:function(t,r,e){"use strict";var n,o=e(3123),i=e(7407),u=e(4210);n=o()?u:i,t.exports=n},7407:function(t,r,e){"use strict";var n=e(173);t.exports=function(t){return n.call(t)}},4210:function(t,r,e){"use strict";var n=e(9048),o=e(1403),i=e(173);t.exports=function(t){var r,e,u;if(null==t)return i.call(t);e=t[o],r=n(t,o);try{t[o]=void 0}catch(r){return i.call(t)}return u=i.call(t),r?t[o]=e:delete t[o],u}},173:function(t){"use strict";var r=Object.prototype.toString;t.exports=r},1403:function(t){"use strict";var r="function"==typeof Symbol?Symbol.toStringTag:"";t.exports=r},7843:function(t){t.exports=function(t,r,e,n,o){for(r=r.split?r.split("."):r,n=0;n<r.length;n++)t=t?t[r[n]]:o;return t===o?e:t}},2341:function(t,r){r.dset=function(t,r,e){r.split&&(r=r.split("."));for(var n,o,i=0,u=r.length,s=t;i<u&&"__proto__"!==(o=r[i++])&&"constructor"!==o&&"prototype"!==o;)s=s[o]=i===u?e:typeof(n=s[o])==typeof r?n:0*r[i]!=0||~(""+r[i]).indexOf(".")?{}:[]}},374:function(t,r,e){"use strict";e.r(r),e.d(r,{default:function(){return i}});for(var n=[],o=0;o<64;)n[o]=0|4294967296*Math.sin(++o%Math.PI);function i(t){var r,e,i,u=[r=1732584193,e=4023233417,~r,~e],s=[],c=unescape(encodeURI(t))+"",f=c.length;for(t=--f/4+2|15,s[--t]=8*f;~f;)s[f>>2]|=c.charCodeAt(f)<<8*f--;for(o=c=0;o<t;o+=16){for(f=u;c<64;f=[i=f[3],r+((i=f[0]+[r&e|~r&i,i&r|~i&e,r^e^i,e^(r|~i)][f=c>>4]+n[c]+~~s[o|15&[c,5*c+1,3*c+5,7*c][f]])<<(f=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*f+c++%4])|i>>>-f),r,e])r=0|f[1],e=f[2];for(c=4;c;)u[--c]+=f[c]}for(t="";c<32;)t+=(u[c>>3]>>4*(1^c++)&15).toString(16);return t}}}]);
|
|
2
|
-
//# sourceMappingURL=870.bundle.6d7307379da86a3bf277.js.map
|