Ejemplo n.º 1
0
    def build(self, options):
        ValidatorsPresent.call(options, 'event')
        context = ContextMerger.call(self.context, options.get('context'))
        context = ContextSanitizer.call(context)
        options.update({'sent_at': timestamp(), 'context': context})

        return Command(method='post', path='track', data=options)
Ejemplo n.º 2
0
    def build(self, options):
        ValidatorsPresent.call(options, 'user_id')
        ValidatorsNotSupported.call(options, 'properties')
        context = ContextMerger.call(self.context, options.get('context'))
        context = ContextSanitizer.call(context)
        options.update({'sent_at': timestamp(), 'context': context})

        return Command(method='post', path='identify', data=options)
Ejemplo n.º 3
0
    def build(self, options):
        ValidatorsPresent.call(options, 'user_id')

        context = ContextMerger.call(self.context, options.get('context'))
        context = ContextSanitizer.call(context)
        ValidatorsPresent.call(context, 'user_agent', 'ip')

        options.update({'sent_at': timestamp(), 'context': context})

        method = ('delete' if options.get('reset', False) else 'post')

        return Command(method=method, path='impersonate', data=options)
Ejemplo n.º 4
0
 def test_it_should_use_iso_format(self, mock_datetime):
     mock_datetime.utcnow.return_value = datetime(
         2018, 1, 2, 3, 4, 5, 678901)
     expected = '2018-01-02T03:04:05.678901'
     self.assertEqual(timestamp(), expected)